Cleaned up implimentation of track output

This commit is contained in:
Sterling 2013-06-10 12:35:59 -04:00
parent 8df7694b82
commit 18ea0af331
5 changed files with 32 additions and 10 deletions

View file

@ -294,6 +294,7 @@ physics.o: material_header.o
physics.o: mesh.o
physics.o: output.o
physics.o: particle_header.o
physics.o: particle_restart.o
physics.o: particle_restart_write.o
physics.o: random_lcg.o
physics.o: search.o

View file

@ -283,6 +283,9 @@ module global
! Particle restart run
logical :: particle_restart_run = .false.
! Particle track output
logical :: write_track = .false.
! ============================================================================
! CMFD VARIABLES

View file

@ -311,6 +311,8 @@ contains
i = i + 1
path_particle_restart = argv(i)
particle_restart_run = .true.
case ('-tr', '-track', '--track')
write_track = .true.
case default
message = "Unknown command line option: " // argv(i)
call fatal_error()

View file

@ -11,6 +11,7 @@ module particle_restart
use physics, only: transport
use random_lcg, only: set_particle_seed
use source, only: initialize_particle
use string, only: to_str
#ifdef HDF5
use hdf5_interface
@ -19,6 +20,7 @@ module particle_restart
implicit none
private
public :: run_particle_restart
public :: write_particle_track
#ifdef HDF5
integer(HID_T) :: hdf5_particle_file
@ -118,6 +120,7 @@ contains
subroutine run_particle_restart()
integer(8) :: particle_seed
character(MAX_FILE_LEN) :: filename
! initialize the particle to be tracked
allocate(p)
@ -138,9 +141,22 @@ contains
current_gen - 1)*n_particles + p % id
call set_particle_seed(particle_seed)
! Open particle track output file.
if (write_track) then
filename = trim(path_output) // 'track_' // trim(to_str(current_batch)) &
// '_' // trim(to_str(current_work)) // '.binary'
open(UNIT=UNIT_TRACK, FILE=filename, STATUS='replace', &
ACCESS='stream')
end if
! transport neutron
call transport()
! Close particle track output file.
if (write_track) then
close(UNIT=UNIT_TRACK)
endif
! write output if particle made it
write(ou,*) 'Particle Successfully Transport:'
write(ou,*) 'WEIGHT:', p % wgt
@ -150,4 +166,8 @@ contains
end subroutine run_particle_restart
subroutine write_particle_track()
write(UNIT_TRACK) p % coord0 % xyz
end subroutine write_particle_track
end module particle_restart

View file

@ -15,6 +15,7 @@ module physics
use mesh, only: get_mesh_indices
use output, only: write_message
use particle_header, only: LocalCoord
use particle_restart, only: write_particle_track
use particle_restart_write, only: write_particle_restart
use random_lcg, only: prn
use search, only: binary_search
@ -73,14 +74,13 @@ contains
! Force calculation of cross-sections by setting last energy to zero
micro_xs % last_E = ZERO
if (run_mode == MODE_PARTICLE) then
open(UNIT=UNIT_TRACK, FILE='test', STATUS='replace', &
ACCESS='stream')
write(UNIT_TRACK) p % coord0 % xyz
end if
do while (p % alive)
! Write particle track.
if (write_track) then
call write_particle_track()
endif
! Calculate microscopic and macroscopic cross sections -- note: if the
! material is the same as the last material and the energy of the
! particle hasn't changed, we don't need to lookup cross sections again.
@ -185,10 +185,6 @@ contains
end do
if (run_mode == MODE_PARTICLE) then
close(UNIT=UNIT_TRACK)
end if
end subroutine transport
!===============================================================================