Small fixes

Changed the '-tr' commandline option to '-k'.  Removed redundant 'write_particle_track' call.  Moved particle_track subroutines to their own module.  Layed (commented out) groundwork for particle_track to use output_interface.
This commit is contained in:
Sterling Harper 2013-06-18 10:46:06 -04:00
parent e9a5d18f0e
commit a164dfa69f
7 changed files with 70 additions and 51 deletions

View file

@ -362,7 +362,7 @@ Particle Track Visualization
OpenMC can dump particle tracks—the position of particles as they are transported through the geometry. There are two ways to make OpenMC output tracks: all particle tracks through a commandline argument or specific particle tracks through settings.xml.
Running OpenMC with the argument "-tr", "-track", or "--track" will cause a track file to be created for every particle transported in the code.
Running OpenMC with the argument "-k", "-track", or "--track" will cause a track file to be created for every particle transported in the code.
The settings.xml file can dictate that specific particle tracks are output. These particles are specified withen a ''track'' element. The ''track'' element should contain triplets of integers specifying the batch, generation, and particle numbers, respectively. For example, to output the tracks for particles 3 and 4 of batch 1 and generation 2 the settings.xml file should contain:

View file

@ -272,6 +272,10 @@ output_interface.o: tally_header.o
particle_header.o: constants.o
particle_track.o: constants.o
particle_track.o: global.o
particle_track.o: string.o
particle_restart.o: bank_header.o
particle_restart.o: constants.o
particle_restart.o: geometry_header.o
@ -302,6 +306,7 @@ physics.o: material_header.o
physics.o: mesh.o
physics.o: output.o
physics.o: particle_header.o
physics.o: particle_track.o
physics.o: particle_restart_write.o
physics.o: random_lcg.o
physics.o: search.o

View file

@ -43,6 +43,7 @@ mpiio_interface.o \
output.o \
output_interface.o \
particle_header.o \
particle_track.o \
particle_restart.o \
particle_restart_write.o \
physics.o \

View file

@ -377,8 +377,9 @@ contains
case ('-eps_tol', '-ksp_gmres_restart')
! Handle options that would be based to PETSC
i = i + 1
case ('-tr', '-track', '--track')
case ('-k', '-track', '--track')
write_all_tracks = .true.
i = i + 1
case default
message = "Unknown command line option: " // argv(i)
call fatal_error()

View file

@ -170,6 +170,7 @@ contains
write(OUTPUT_UNIT,*) ' -r, --restart Restart a previous run from a state point'
write(OUTPUT_UNIT,*) ' or a particle restart file'
write(OUTPUT_UNIT,*) ' -t, --tallies Write tally results from state point'
write(OUTPUT_UNIT,*) ' -k, --tracks Write tracks for all particles'
write(OUTPUT_UNIT,*) ' -v, --version Show version information'
write(OUTPUT_UNIT,*) ' -?, --help Show this message'
end if
@ -1982,45 +1983,4 @@ contains
end function get_label
!===============================================================================
! INITIALIZE_PARTICLE_TRACK opens a particle track output file.
!
! TODO: This subroutine needs to be modified to work with HDF5 files. It
! should also probably write a header that identifies the file as a particle
! track and maybe adds particle identifying information (batch #, etc.).
!===============================================================================
subroutine initialize_particle_track()
character(MAX_FILE_LEN) :: filename
filename = trim(path_output) // 'track_' // trim(to_str(current_batch)) &
// '_' // trim(to_str(current_gen)) // '_' // trim(to_str(p % id)) &
// '.binary'
open(UNIT=UNIT_TRACK, FILE=filename, STATUS='replace', &
ACCESS='stream')
end subroutine initialize_particle_track
!===============================================================================
! WRITE_PARTICLE_TRACK outputs particle position to a binary file.
!
! TODO: This subroutine needs to be modified to work with HDF5 files. Perhaps
! it should also be made somehow more general so that it can output
! information other than just particle position.
!===============================================================================
subroutine write_particle_track()
write(UNIT_TRACK) p % coord0 % xyz
end subroutine write_particle_track
!===============================================================================
! FINALIZE_PARTICLE_TRACK closes the particle track file.
!
! TODO: This subroutine needs to be modified to work with HDF5 files.
!===============================================================================
subroutine finalize_particle_track()
close(UNIT=UNIT_TRACK)
end subroutine finalize_particle_track
end module output

56
src/particle_track.F90 Normal file
View file

@ -0,0 +1,56 @@
module particle_track
use constants
use global
!use output_interface only: file_create, file_close, write_double1Darray
use string, only: to_str
implicit none
contains
!===============================================================================
! INITIALIZE_PARTICLE_TRACK opens a particle track output file.
!
! TODO: This subroutine needs to be modified to work with HDF5 files. It
! should also probably write a header that identifies the file as a particle
! track and maybe adds particle identifying information (batch #, etc.).
!===============================================================================
subroutine initialize_particle_track()
character(MAX_FILE_LEN) :: filename
filename = trim(path_output) // 'track_' // trim(to_str(current_batch)) &
// '_' // trim(to_str(current_gen)) // '_' // trim(to_str(p % id)) &
// '.binary'
open(UNIT=UNIT_TRACK, FILE=filename, STATUS='replace', &
ACCESS='stream')
!file_create(filename, 'serial')
end subroutine initialize_particle_track
!===============================================================================
! WRITE_PARTICLE_TRACK outputs particle position to a binary file.
!
! TODO: This subroutine needs to be modified to work with HDF5 files. Perhaps
! it should also be made somehow more general so that it can output
! information other than just particle position.
!===============================================================================
subroutine write_particle_track()
write(UNIT_TRACK) p % coord0 % xyz
!write_double1Darray(p % coord0 % xyz, 'coordinates', 3)
end subroutine write_particle_track
!===============================================================================
! FINALIZE_PARTICLE_TRACK closes the particle track file.
!
! TODO: This subroutine needs to be modified to work with HDF5 files.
!===============================================================================
subroutine finalize_particle_track()
close(UNIT=UNIT_TRACK)
!file_close('serial')
end subroutine finalize_particle_track
end module particle_track

View file

@ -14,10 +14,11 @@ module physics
use interpolation, only: interpolate_tab1
use material_header, only: Material
use mesh, only: get_mesh_indices
use output, only: write_message, initialize_particle_track, &
use output, only: write_message
use particle_header, only: LocalCoord
use particle_track, only: initialize_particle_track, &
write_particle_track, &
finalize_particle_track
use particle_header, only: LocalCoord
use particle_restart_write, only: write_particle_restart
use random_lcg, only: prn
use search, only: binary_search
@ -114,12 +115,6 @@ contains
coord => coord % next
end do
! Write particle track
if (write_track) then
call write_particle_track()
end if
! Score track-length tallies
if (active_tracklength_tallies % size() > 0) &
call score_tracklength_tally(distance)
@ -196,6 +191,7 @@ contains
! Finish particle track.
if (write_track) then
call write_particle_track()
call finalize_particle_track()
endif