setup simulation by reading in setting file, and setup variables to be used.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input_file |
Filename for toml settings to be used |
||
type(tevipc), | intent(out) | :: | tev |
handle for communicating with TEV |
||
type(dect_array), | intent(out), | allocatable | :: | dects(:) |
array of photon detectors |
|
type(sdf), | intent(out), | allocatable | :: | array(:) |
array of SDF objects that create the geometry |
|
type(photon), | intent(out) | :: | packet |
photon that is to be simulated |
||
type(spectrum_t), | intent(out) | :: | spectrum | |||
type(toml_table), | intent(out) | :: | dict |
toml table of meta-data to be written to output files. |
||
real(kind=wp), | intent(out), | allocatable | :: | distances(:) | ||
real(kind=wp), | intent(out), | allocatable | :: | image(:,:,:) | ||
real(kind=wp), | intent(out) | :: | nscatt | |||
real(kind=wp), | intent(out) | :: | start | |||
logical, | intent(in), | optional | :: | display |
flag to display simulation init settings |
subroutine setup(input_file, tev, dects, array, packet, spectrum, dict, distances, image, nscatt, start, display) !! setup simulation by reading in setting file, and setup variables to be used. !shared data use iarray use constants, only : wp !subroutines use detectors, only : dect_array use parse_mod, only : parse_params use photonMod, only : photon use random, only : init_rng use piecewiseMod use sdfs, only : sdf, render use sim_state_mod, only : state use setupMod, only : setup_simulation, directory use utils, only : get_time, print_time, str use vector_class, only : vector ! !external deps use tev_mod, only : tevipc, tev_init use tomlf, only : toml_table, toml_error !> Filename for toml settings to be used character(*), intent(in) :: input_file !> array of SDF objects that create the geometry type(sdf), allocatable, intent(out) :: array(:) !> array of photon detectors type(dect_array), allocatable, intent(out) :: dects(:) !> toml table of meta-data to be written to output files. type(toml_table), intent(out) :: dict !> handle for communicating with TEV type(tevipc), intent(out) :: tev !> photon that is to be simulated type(photon), intent(out) :: packet real(kind=wp), allocatable, intent(out) :: distances(:), image(:,:,:) real(kind=wp), intent(out) :: nscatt, start type(spectrum_t), intent(out) :: spectrum !> flag to display simulation init settings logical, optional, intent(in) :: display ! mpi/mp variables integer :: id real(kind=wp) :: chance, threshold type(toml_error), allocatable :: error logical :: disp if(present(display))then disp = display else disp = .true. end if chance = 1._wp/10._wp threshold = 1e-6_wp call directory() dict = toml_table() call parse_params("res/"//trim(input_file), packet, dects, spectrum, dict, error) if(allocated(error))then print*,error%message stop 1 end if allocate(image(state%grid%nxg,state%grid%nzg,1)) if(disp)call display_settings(state, input_file, packet, "Pathlength") if(state%tev)then !init TEV link tev = tevipc() call tev%close_image(state%experiment) call tev%create_image(state%experiment, state%grid%nxg, state%grid%nzg, ["I", "J", "K"], .true.) end if nscatt = 0._wp call init_rng(spread(state%iseed+0, 1, 8), fwd=.true.) call setup_simulation(array, dict) ! render geometry to voxel format for debugging if(state%render_geom)then print*,"Rendering geometry to file" call render(array, state) end if allocate(distances(size(array))) start = get_time() id = 0 if(id == 0)then print*,'# of photons to run',state%nphotons end if end subroutine setup