diff --git a/docs/source/usersguide/processing.rst b/docs/source/usersguide/processing.rst index 8d6fea037..f51f87685 100644 --- a/docs/source/usersguide/processing.rst +++ b/docs/source/usersguide/processing.rst @@ -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: diff --git a/src/DEPENDENCIES b/src/DEPENDENCIES index e8cc541f4..48ef958f4 100644 --- a/src/DEPENDENCIES +++ b/src/DEPENDENCIES @@ -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 diff --git a/src/OBJECTS b/src/OBJECTS index b07990675..6ba5516d5 100644 --- a/src/OBJECTS +++ b/src/OBJECTS @@ -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 \ diff --git a/src/initialize.F90 b/src/initialize.F90 index 7038544da..3d54173be 100644 --- a/src/initialize.F90 +++ b/src/initialize.F90 @@ -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() diff --git a/src/output.F90 b/src/output.F90 index c10891f26..77b323ce6 100644 --- a/src/output.F90 +++ b/src/output.F90 @@ -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 diff --git a/src/particle_track.F90 b/src/particle_track.F90 new file mode 100644 index 000000000..c4c218520 --- /dev/null +++ b/src/particle_track.F90 @@ -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 diff --git a/src/physics.F90 b/src/physics.F90 index 8b6764200..35ecb3aa6 100644 --- a/src/physics.F90 +++ b/src/physics.F90 @@ -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