New input options and fCUm now calculates the number of ions passing by (to plot dN/dE easily
This commit is contained in:
parent
6e07067faa
commit
f25abb3213
15 changed files with 169 additions and 27 deletions
|
|
@ -21,6 +21,24 @@ module input
|
|||
|
||||
end subroutine openInputFile
|
||||
|
||||
subroutine checkIO(subroutineName)
|
||||
|
||||
character(len=*), intent(in):: subroutineName
|
||||
|
||||
if (inputFile_io < 0) then
|
||||
write (*, '("End-of-file found when reading in subroutine: ",a)') subroutineName
|
||||
error stop
|
||||
|
||||
elseif (inputFile_io > 0) then
|
||||
write (*, '("Error condition ", i3," found when reading in subroutine: ",a)') inputFile_io, subroutineName
|
||||
error stop
|
||||
|
||||
end if
|
||||
|
||||
inputFile_io = 0
|
||||
|
||||
end subroutine checkIO
|
||||
|
||||
subroutine readReference()
|
||||
use constantParameters, only: dp, kb, qe, eps_0, ev_to_K, cm3_to_m3, PI
|
||||
use referenceValues
|
||||
|
|
@ -28,6 +46,7 @@ module input
|
|||
namelist /reference/ m_ref, Temp_ref, n_ref
|
||||
|
||||
read(nml=reference, unit=inputFile_id, iostat=inputFile_io)
|
||||
rewind(unit=inputFile_id)
|
||||
|
||||
! Set reference numbers (in SI units)
|
||||
Temp_ref = Temp_ref * eV_to_K
|
||||
|
|
@ -37,6 +56,8 @@ module input
|
|||
L_ref = u_ref * t_ref
|
||||
phi_ref = kb * Temp_ref / qe
|
||||
|
||||
call checkIO('readReference')
|
||||
|
||||
end subroutine readReference
|
||||
|
||||
subroutine readGrid(r0, rf, dr, v0, vf, nv)
|
||||
|
|
@ -48,6 +69,9 @@ module input
|
|||
namelist /grid/ r0, rf, dr, v0, vf, nv
|
||||
|
||||
read(nml=grid, unit=inputFile_id, iostat=inputFile_io)
|
||||
rewind(unit=inputFile_id)
|
||||
|
||||
call checkIO('readGrid')
|
||||
|
||||
r0 = r0/L_ref
|
||||
rf = rf/L_ref
|
||||
|
|
@ -58,6 +82,22 @@ module input
|
|||
|
||||
end subroutine readGrid
|
||||
|
||||
subroutine readOutput(folder_alloc, outputStep)
|
||||
|
||||
character(:), allocatable, intent(out):: folder_alloc
|
||||
real(dp), intent(out):: outputStep
|
||||
character(len=128):: folder
|
||||
namelist /output/ folder, outputStep
|
||||
|
||||
read(nml=output, unit=inputFile_id, iostat=inputFile_io)
|
||||
rewind(unit=inputFile_id)
|
||||
|
||||
call checkIO('readOutput')
|
||||
|
||||
folder_alloc = trim(folder)
|
||||
|
||||
end subroutine readOutput
|
||||
|
||||
subroutine readTime(t0, tf, CFL)
|
||||
use referenceValues, only: t_ref
|
||||
|
||||
|
|
@ -66,6 +106,9 @@ module input
|
|||
namelist /time/ t0, tf, CFL
|
||||
|
||||
read(nml=time, unit=inputFile_id, iostat=inputFile_io)
|
||||
rewind(unit=inputFile_id)
|
||||
|
||||
call checkIO('readTime')
|
||||
|
||||
t0 = t0/t_ref
|
||||
tf = tf/t_ref
|
||||
|
|
@ -79,6 +122,9 @@ module input
|
|||
namelist /detector/ rCum
|
||||
|
||||
read(nml=detector, unit=inputFile_id, iostat=inputFile_io)
|
||||
rewind(unit=inputFile_id)
|
||||
|
||||
call checkIO('readDetector')
|
||||
|
||||
! Set position to calculate cumulative sum of f (non-dimensional units)
|
||||
rCum = rCum/L_ref
|
||||
|
|
@ -94,12 +140,16 @@ module input
|
|||
namelist /boundary/ filename
|
||||
|
||||
read(nml=boundary, unit=inputFile_id, iostat=inputFile_io)
|
||||
rewind(unit=inputFile_id)
|
||||
|
||||
call checkIO('readBoundary')
|
||||
|
||||
filename_dynamic = trim(filename)
|
||||
|
||||
call bc%init(filename_dynamic)
|
||||
|
||||
end subroutine readBoundary
|
||||
|
||||
subroutine readZ(Zlist, nz, Tene_to_Z)
|
||||
use tableTNZ
|
||||
|
||||
|
|
@ -117,6 +167,9 @@ module input
|
|||
|
||||
! Read namelist
|
||||
read(nml=Zbins, unit=inputFile_id, iostat=inputFile_io)
|
||||
rewind(unit=inputFile_id)
|
||||
|
||||
call checkIO('readZ')
|
||||
|
||||
! Get the real Z bins
|
||||
nz = count(ZList > 0.0_dp)
|
||||
|
|
@ -133,6 +186,18 @@ module input
|
|||
|
||||
end subroutine readZ
|
||||
|
||||
subroutine readParallel(nThreads)
|
||||
|
||||
integer, intent(out):: nThreads
|
||||
namelist /parallel/ nThreads
|
||||
|
||||
read(nml=parallel, unit=inputFile_id, iostat=inputFile_io)
|
||||
rewind(unit=inputFile_id)
|
||||
|
||||
call checkIO('readParallel')
|
||||
|
||||
end subroutine readParallel
|
||||
|
||||
subroutine closeInputFile()
|
||||
|
||||
close(inputFile_id)
|
||||
|
|
|
|||
|
|
@ -37,15 +37,17 @@ module output
|
|||
|
||||
end function setZFormat
|
||||
|
||||
subroutine createPath()
|
||||
character(8) :: date_now
|
||||
character(10) :: time_now
|
||||
subroutine createPath(folder)
|
||||
character(8) :: date_now
|
||||
character(10):: time_now
|
||||
character(:), allocatable:: folder
|
||||
|
||||
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) // '/'
|
||||
time_now(1:2) // '.' // time_now(3:4) // '.' // time_now(5:6) // '_' // &
|
||||
folder // '/'
|
||||
|
||||
call system('mkdir ' // pathOutput)
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,13 @@ module tableTNZ
|
|||
integer:: id = 20
|
||||
num_ne = 0
|
||||
|
||||
inquire(file=tableFile, iostat=stat)
|
||||
if (stat /= 0) then
|
||||
write (*, '("Error: TNZ table file ", a, " does not exist")') tableFile
|
||||
return
|
||||
|
||||
end if
|
||||
|
||||
open(id, file = tableFile)
|
||||
amount = -1 ! Remove header
|
||||
do
|
||||
|
|
|
|||
|
|
@ -62,8 +62,10 @@ program VlaPlEx
|
|||
real(dp), allocatable, dimension(:,:):: fCum_i
|
||||
real(dp):: rCum
|
||||
integer:: rCum_index
|
||||
real(dp):: outputStep
|
||||
character(:), allocatable:: folder
|
||||
|
||||
character(len=128) arg
|
||||
character(len=128):: arg
|
||||
|
||||
CALL get_command_argument(1, arg)
|
||||
if (arg == '') then
|
||||
|
|
@ -74,11 +76,12 @@ program VlaPlEx
|
|||
inputFile = trim(arg)
|
||||
call openInputFile()
|
||||
call readReference()
|
||||
call readParallel(nThreads)
|
||||
call readGrid(r0, rf, dr, v0, vf, nv)
|
||||
call readOutput(folder, outputStep)
|
||||
call readTime(t0, tf, CFL)
|
||||
call readDetector(rCum)
|
||||
call readBoundary(boundaryConditions)
|
||||
nThreads = 16
|
||||
call readZ(Zlist, nz, Tene_to_Z)
|
||||
call closeInputFile()
|
||||
|
||||
|
|
@ -113,7 +116,7 @@ program VlaPlEx
|
|||
nt = nint((tf - t0) / dt)
|
||||
dt = (tf - t0) / float(nt)
|
||||
|
||||
everyOutput = nint(1.0e-9_dp/t_ref/dt)
|
||||
everyOutput = nint(outputStep/t_ref/dt)
|
||||
if (everyOutput == 0) then
|
||||
everyOutput = 1
|
||||
|
||||
|
|
@ -192,7 +195,7 @@ program VlaPlEx
|
|||
f0 = 0.0_dp
|
||||
|
||||
! Output initial values
|
||||
call createPath()
|
||||
call createPath(folder)
|
||||
call setTimeFormat(nt)
|
||||
t = 0
|
||||
call writeOutputRef()
|
||||
|
|
@ -386,7 +389,7 @@ program VlaPlEx
|
|||
if (all(n_i(iz,:) < n_epsilon) .and. iz .ne. z_inj) then
|
||||
cycle
|
||||
end if
|
||||
fCum_i(iz,:) = fCum_i(iz,:) + f_i_old(iz,rCum_index,:)
|
||||
fCum_i(iz,:) = fCum_i(iz,:) + f_i_old(iz,rCum_index,:)*dt*(v+dv/2.0)*dv
|
||||
end do
|
||||
! Write output
|
||||
if (mod(t,everyOutput) == 0 .or. t == nt) then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue