Able to read BC from file
This commit is contained in:
parent
eebadc8e05
commit
422b9e84e2
7 changed files with 484 additions and 327 deletions
233
moduleOutput.f90
Normal file
233
moduleOutput.f90
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
module output
|
||||
use constantParameters, only: dp
|
||||
implicit none
|
||||
|
||||
public
|
||||
private:: dataRef_id, dataBC_id, dataF_id, dataPhi_id, dataCum_id
|
||||
private:: formatFloat, formatSep, formatTime
|
||||
|
||||
integer:: everyOutput, everyWrite
|
||||
character(:), allocatable:: pathOutput
|
||||
integer, parameter:: dataRef_id = 10
|
||||
integer, parameter:: dataBC_id = 20
|
||||
integer, parameter:: dataF_id = 30
|
||||
integer, parameter:: dataPhi_id = 40
|
||||
integer, parameter:: dataCum_id = 50
|
||||
character(len=7), parameter:: formatFloat = 'ES0.6e3'
|
||||
character(len=3), parameter:: formatSep = '","'
|
||||
character(len=7):: formatTime
|
||||
|
||||
contains
|
||||
subroutine setTimeFormat(nt)
|
||||
integer, intent(in):: nt
|
||||
integer:: l
|
||||
|
||||
l=max(1,ceiling(log10(real(nt))))
|
||||
write(formatTime, '(A2,I0,".",I0,A1)') '(I',l,l,')'
|
||||
|
||||
end subroutine setTimeFormat
|
||||
|
||||
subroutine createPath()
|
||||
character(8) :: date_now
|
||||
character(10) :: time_now
|
||||
|
||||
call date_and_time(date_now, time_now)
|
||||
|
||||
!Compose the folder name
|
||||
pathOutput = date_now(1:4) // '-' // date_now(5:6) // '-' // date_now(7:8) // '_' // &
|
||||
time_now(1:2) // '.' // time_now(3:4) // '.' // time_now(5:6) // '/'
|
||||
|
||||
call system('mkdir ' // pathOutput)
|
||||
|
||||
end subroutine createPath
|
||||
|
||||
subroutine writeOutputF(t, dt, nr, r, nv, v, f)
|
||||
use referenceValues, only: L_ref, n_ref, u_ref, t_ref
|
||||
|
||||
integer, intent(in):: t
|
||||
integer, intent(in):: nr, nv
|
||||
real(dp), intent(in):: dt
|
||||
real(dp), intent(in):: r(1:nr)
|
||||
real(dp), intent(in):: v(1:nv)
|
||||
real(dp), intent(in):: f(1:nr,1:nv)
|
||||
character(len=30) :: myfmt
|
||||
character(:), allocatable:: filename
|
||||
integer:: i
|
||||
character(len=10):: timeString
|
||||
|
||||
write (timeString, formatTime) t
|
||||
filename = 'time_' // trim(timeString) // '_f_i.csv'
|
||||
write (*, '(A, A)') 'Writing: ', filename
|
||||
|
||||
open(unit=dataF_id, file=pathOutput // filename)
|
||||
write(dataF_id, '(A)') "t (s)"
|
||||
write(dataF_id, '('//formatFloat//')') t*dt*t_ref
|
||||
write(myfmt, "(I0)") nr
|
||||
myfmt = '(A,' // trim(myfmt) // '(' // formatSep // ',' // formatFloat // '))'
|
||||
write(dataF_id, myfmt) "v (m/s) / r (m)", r*L_ref
|
||||
write(myfmt, "(I0)") nr
|
||||
myfmt = '(' // formatFloat // ',' // trim(myfmt) // '(' // formatSep // ',' // formatFloat // '))'
|
||||
do i = 1, nv
|
||||
write(dataF_id, myfmt) v(i)*u_ref, f(:,i)*n_ref/u_ref
|
||||
|
||||
end do
|
||||
|
||||
close(unit=dataF_id)
|
||||
|
||||
end subroutine writeOutputF
|
||||
|
||||
subroutine writeOutputPhi(t, dt, nr, r, phi, E, n_e)
|
||||
use constantParameters, only: eV_to_K
|
||||
use referenceValues, only: L_ref, phi_ref, t_ref, n_ref
|
||||
|
||||
integer, intent(in):: t
|
||||
integer, intent(in):: nr
|
||||
real(dp), intent(in):: dt
|
||||
real(dp), intent(in):: r(1:nr)
|
||||
real(dp), intent(in):: phi(1:nr)
|
||||
real(dp), intent(in):: E(1:nr)
|
||||
real(dp), intent(in):: n_e(1:nr)
|
||||
character(:), allocatable:: filename
|
||||
integer:: i
|
||||
character(len=10):: timeString
|
||||
|
||||
write (timeString, formatTime) t
|
||||
filename = 'time_' // trim(timeString)//'_phi.csv'
|
||||
write (*, '(A, A)') 'Writing: ', filename
|
||||
|
||||
open(unit=dataPhi_id, file=pathOutput//filename)
|
||||
write(dataPhi_id, '(A)') "t (s)"
|
||||
write(dataPhi_id, '('//formatFloat//')') t*dt*t_ref
|
||||
write(dataPhi_id, '(A,3('//formatSep//',A))') "r (m)","phi (V)","E (V m^-1)","n_e (m^-3)"
|
||||
do i = 1, nr
|
||||
write(dataPhi_id, '('//formatFloat//',3('//formatSep //','//formatFloat//'))') &
|
||||
r(i)*L_ref, &
|
||||
phi(i)*phi_ref, &
|
||||
E(i)*phi_ref/L_ref, &
|
||||
n_e(i)*n_ref
|
||||
|
||||
end do
|
||||
|
||||
close(unit=dataPhi_id)
|
||||
|
||||
end subroutine writeOutputPhi
|
||||
|
||||
subroutine writeOutputMom(t, dt, nr, r, n_i, u_i, T_i, Z)
|
||||
use constantParameters, only: eV_to_K
|
||||
use referenceValues, only: L_ref, t_ref, n_ref, u_ref, Temp_ref
|
||||
|
||||
integer, intent(in):: t
|
||||
integer, intent(in):: nr
|
||||
real(dp), intent(in):: dt
|
||||
real(dp), intent(in):: r(1:nr)
|
||||
real(dp), intent(in):: n_i(1:nr)
|
||||
real(dp), intent(in):: u_i(1:nr)
|
||||
real(dp), intent(in):: T_i(1:nr)
|
||||
real(dp), intent(in):: Z(1:nr)
|
||||
character(:), allocatable:: filename
|
||||
integer:: i
|
||||
character(len=10):: timeString
|
||||
|
||||
write (timeString, formatTime) t
|
||||
filename = 'time_' // trim(timeString)//'_mom_i.csv'
|
||||
write (*, '(A, A)') 'Writing: ', filename
|
||||
|
||||
open(unit=dataPhi_id, file=pathOutput//filename)
|
||||
write(dataPhi_id, '(A)') "t (s)"
|
||||
write(dataPhi_id, '('//formatFloat//')') t*dt*t_ref
|
||||
write(dataPhi_id, '(A,4('//formatSep//',A))') "r (m)","n_i (m^-3)","u_i (m s^-1)", "T_i (eV)","Zave"
|
||||
do i = 1, nr
|
||||
write(dataPhi_id, '('//formatFloat//',4('//formatSep //','//formatFloat//'))') &
|
||||
r(i)*L_ref, &
|
||||
n_i(i)*n_ref, &
|
||||
u_i(i)*u_ref, &
|
||||
T_i(i)*Temp_ref/ev_to_K, &
|
||||
Z(i)
|
||||
|
||||
end do
|
||||
|
||||
close(unit=dataPhi_id)
|
||||
|
||||
end subroutine writeOutputMom
|
||||
|
||||
subroutine writeOutputBoundary(t, dt, n, u, Temp, Z)
|
||||
use constantParameters, only: eV_to_K
|
||||
use referenceValues, only: t_ref, n_ref, u_ref, Temp_ref
|
||||
|
||||
integer, intent(in):: t
|
||||
real(dp), intent(in):: dt
|
||||
real(dp), intent(in):: n, u, Temp, Z
|
||||
character(len=6), parameter:: filename = 'bc.csv'
|
||||
logical:: res
|
||||
|
||||
inquire(file=pathOutput // filename, exist=res)
|
||||
if (.not. res) then
|
||||
write (*, '(A, A)') 'Writing: ', filename
|
||||
open(unit=dataBC_id, file=pathOutput // filename, action='write', position='append')
|
||||
write(dataBC_id, '(A,4(' // formatSep // ',A))') 't (s)', 'n (m^-3)', 'u (m s^-1)', 'T (eV)', 'Z'
|
||||
close(dataBC_id)
|
||||
|
||||
end if
|
||||
|
||||
open(unit=dataBC_id, file=pathOutput // filename, action='write', position='append')
|
||||
write(dataBC_id, '(' // formatFloat // ',4('// formatSep // ',' // formatFloat // '))') &
|
||||
t*dt*t_ref, n*n_ref, u*u_ref, Temp*Temp_ref/eV_to_K, Z
|
||||
|
||||
close(dataBC_id)
|
||||
|
||||
end subroutine writeOutputBoundary
|
||||
|
||||
subroutine writeOutputRef()
|
||||
use referenceValues, only: t_ref, L_ref, n_ref, u_ref, Temp_ref, phi_ref
|
||||
|
||||
character(len=7), parameter:: filename = 'ref.csv'
|
||||
|
||||
write (*, '(A, A)') 'Writing: ', filename
|
||||
open(unit=dataRef_id, file=pathOutput // filename)
|
||||
write(dataRef_id, '(A,5(' // formatSep // ',A))') 't_ref (s)', 'L_ref (m)', 'n_ref (m^-3)', &
|
||||
'u_ref (m s^-1)', 'T_ref (K)', 'phi_ref (V)'
|
||||
write(dataRef_id, '(' // formatFloat // ',5('// formatSep // ',' // formatFloat // '))') &
|
||||
t_ref, L_ref, n_ref, &
|
||||
u_ref, Temp_ref, phi_ref
|
||||
|
||||
close(dataRef_id)
|
||||
|
||||
end subroutine writeOutputRef
|
||||
|
||||
subroutine writeOutputFCum(t, dt, r, nv, v, f)
|
||||
use referenceValues, only: L_ref, n_ref, u_ref, t_ref
|
||||
|
||||
integer, intent(in):: t
|
||||
real(dp), intent(in):: dt
|
||||
integer, intent(in):: nv
|
||||
real(dp), intent(in):: r
|
||||
real(dp), intent(in):: v(1:nv)
|
||||
real(dp), intent(in):: f(1:nv)
|
||||
character(len=30) :: myfmt
|
||||
character(:), allocatable:: filename
|
||||
integer:: i
|
||||
character(len=10):: timeString
|
||||
|
||||
write (timeString, formatTime) t
|
||||
filename = 'time_' // trim(timeString) // '_fCum_i.csv'
|
||||
write (*, '(A, A)') 'Writing: ', filename
|
||||
|
||||
open(unit=dataCum_id, file=pathOutput // filename)
|
||||
write(dataCum_id, '(A)') "t (s)"
|
||||
write(dataCum_id, '('//formatFloat//')') t*dt*t_ref
|
||||
write(myfmt, "(I0)") 1
|
||||
myfmt = '(A,' // trim(myfmt) // '(' // formatSep // ',' // formatFloat // '))'
|
||||
write(dataCum_id, myfmt) "v (m/s) / r (m)", r*L_ref
|
||||
write(myfmt, "(I0)") 1
|
||||
myfmt = '(' // formatFloat // ',' // trim(myfmt) // '(' // formatSep // ',' // formatFloat // '))'
|
||||
do i = 1, nv
|
||||
write(dataCum_id, myfmt) v(i)*u_ref, f(i)*n_ref/u_ref
|
||||
|
||||
end do
|
||||
|
||||
close(unit=dataCum_id)
|
||||
|
||||
end subroutine writeOutputFCum
|
||||
|
||||
end module output
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue