From 26e260114108c3cee6653e9c57e80c98fdd5dbfc Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 20 Feb 2017 10:47:51 -0600 Subject: [PATCH] Update particle restart format and documentation --- docs/source/io_formats/particle_restart.rst | 74 +++++++------------ docs/source/io_formats/statepoint.rst | 2 +- openmc/particle_restart.py | 12 +-- src/particle_restart.F90 | 4 +- src/particle_restart_write.F90 | 52 +++++++------ .../results_true.dat | 2 +- .../results_true.dat | 2 +- tests/testing_harness.py | 4 +- 8 files changed, 63 insertions(+), 89 deletions(-) diff --git a/docs/source/io_formats/particle_restart.rst b/docs/source/io_formats/particle_restart.rst index 3dee8c47db..9f34184955 100644 --- a/docs/source/io_formats/particle_restart.rst +++ b/docs/source/io_formats/particle_restart.rst @@ -4,55 +4,31 @@ Particle Restart File Format ============================ -The current revision of the particle restart file format is 1. +The current version of the particle restart file format is 2.0. -**/filetype** (*char[]*) +**/** - String indicating the type of file. +:Attributes: - **filetype** (*char[]*) -- String indicating the type of file. + - **version** (*int[2]*) -- Major and minor version of the summary + file format. + - **openmc_version** (*int[3]*) -- Major, minor, and release + version number for OpenMC. + - **git_sha1** (*char[40]*) -- Git commit SHA-1 hash. -**/revision** (*int*) - - Revision of the particle restart file format. Any time a change is made in - the format, this integer is incremented. - -**/current_batch** (*int*) - - The number of batches already simulated. - -**/gen_per_batch** (*int*) - - Number of generations per batch. - -**/current_gen** (*int*) - - The number of generations already simulated. - -**/n_particles** (*int8_t*) - - Number of particles used per generation. - -**/run_mode** (*int*) - - Run mode used. A value of 1 indicates a fixed-source run and a value of 2 - indicates an eigenvalue run. - -**/id** (*int8_t*) - - Unique identifier of the particle. - -**/weight** (*double*) - - Weight of the particle. - -**/energy** (*double*) - - Energy of the particle in eV for continuous-energy mode, or the energy - group of the particle for multi-group mode. - -**/xyz** (*double[3]*) - - Position of the particle. - -**/uvw** (*double[3]*) - - Direction of the particle. +:Datasets: - **current_batch** (*int*) -- The number of batches already + simulated. + - **generations_per_batch** (*int*) -- Number of generations per + batch. + - **current_generation** (*int*) -- The number of generations already + simulated. + - **n_particles** (*int8_t*) -- Number of particles used per + generation. + - **run_mode** (*char[]*) -- Run mode used, either 'fixed source', + 'eigenvalue', or 'particle restart'. + - **id** (*int8_t*) -- Unique identifier of the particle. + - **weight** (*double*) -- Weight of the particle. + - **energy** (*double*) -- Energy of the particle in eV for + continuous-energy mode, or the energy group of the particle for + multi-group mode. + - **xyz** (*double[3]*) -- Position of the particle. + - **uvw** (*double[3]*) -- Direction of the particle. diff --git a/docs/source/io_formats/statepoint.rst b/docs/source/io_formats/statepoint.rst index eff590605a..8026c258e6 100644 --- a/docs/source/io_formats/statepoint.rst +++ b/docs/source/io_formats/statepoint.rst @@ -4,7 +4,7 @@ State Point File Format ======================= -The current revision of the statepoint file format is 16.0. +The current version of the statepoint file format is 16.0. **/** diff --git a/openmc/particle_restart.py b/openmc/particle_restart.py index 651855a878..4fab8e5634 100644 --- a/openmc/particle_restart.py +++ b/openmc/particle_restart.py @@ -17,9 +17,9 @@ class Particle(object): ---------- current_batch : int The batch containing the particle - gen_per_batch : int + generations_per_batch : int Number of generations per batch - current_gen : int + current_generation : int The generation containing the particle n_particles : int Number of particles per generation @@ -50,16 +50,16 @@ class Particle(object): return self._f['current_batch'].value @property - def current_gen(self): - return self._f['current_gen'].value + def current_generation(self): + return self._f['current_generation'].value @property def energy(self): return self._f['energy'].value @property - def gen_per_batch(self): - return self._f['gen_per_batch'].value + def generations_per_batch(self): + return self._f['generations_per_batch'].value @property def id(self): diff --git a/src/particle_restart.F90 b/src/particle_restart.F90 index e0174d05f8..430ee4d447 100644 --- a/src/particle_restart.F90 +++ b/src/particle_restart.F90 @@ -81,8 +81,8 @@ contains ! Read data from file call read_dataset(current_batch, file_id, 'current_batch') - call read_dataset(gen_per_batch, file_id, 'gen_per_batch') - call read_dataset(current_gen, file_id, 'current_gen') + call read_dataset(gen_per_batch, file_id, 'generations_per_batch') + call read_dataset(current_gen, file_id, 'current_generation') call read_dataset(n_particles, file_id, 'n_particles') call read_dataset(tempstr, file_id, 'run_mode') select case (tempstr) diff --git a/src/particle_restart_write.F90 b/src/particle_restart_write.F90 index a2e01a7a6d..08e80ea1b0 100644 --- a/src/particle_restart_write.F90 +++ b/src/particle_restart_write.F90 @@ -23,7 +23,6 @@ contains integer(HID_T) :: file_id character(MAX_FILE_LEN) :: filename - type(Bank), pointer :: src ! Dont write another restart file if in particle restart mode if (run_mode == MODE_PARTICLE) return @@ -36,35 +35,34 @@ contains ! Create file file_id = file_create(filename) - ! Get information about source particle - src => source_bank(current_work) - - ! Write filetype and version info - call write_attribute(file_id, 'filetype', 'particle restart') - call write_attribute(file_id, 'version', VERSION_PARTICLE_RESTART) - call write_attribute(file_id, "openmc_version", VERSION) + associate (src => source_bank(current_work)) + ! Write filetype and version info + call write_attribute(file_id, 'filetype', 'particle restart') + call write_attribute(file_id, 'version', VERSION_PARTICLE_RESTART) + call write_attribute(file_id, "openmc_version", VERSION) #ifdef GIT_SHA1 - call write_attribute(file_id, "git_sha1", GIT_SHA1) + call write_attribute(file_id, "git_sha1", GIT_SHA1) #endif - ! Write data to file - call write_dataset(file_id, 'current_batch', current_batch) - call write_dataset(file_id, 'gen_per_batch', gen_per_batch) - call write_dataset(file_id, 'current_gen', current_gen) - call write_dataset(file_id, 'n_particles', n_particles) - select case(run_mode) - case (MODE_FIXEDSOURCE) - call write_dataset(file_id, 'run_mode', 'fixed source') - case (MODE_EIGENVALUE) - call write_dataset(file_id, 'run_mode', 'eigenvalue') - case (MODE_PARTICLE) - call write_dataset(file_id, 'run_mode', 'particle restart') - end select - call write_dataset(file_id, 'id', p%id) - call write_dataset(file_id, 'weight', src%wgt) - call write_dataset(file_id, 'energy', src%E) - call write_dataset(file_id, 'xyz', src%xyz) - call write_dataset(file_id, 'uvw', src%uvw) + ! Write data to file + call write_dataset(file_id, 'current_batch', current_batch) + call write_dataset(file_id, 'generations_per_batch', gen_per_batch) + call write_dataset(file_id, 'current_generation', current_gen) + call write_dataset(file_id, 'n_particles', n_particles) + select case(run_mode) + case (MODE_FIXEDSOURCE) + call write_dataset(file_id, 'run_mode', 'fixed source') + case (MODE_EIGENVALUE) + call write_dataset(file_id, 'run_mode', 'eigenvalue') + case (MODE_PARTICLE) + call write_dataset(file_id, 'run_mode', 'particle restart') + end select + call write_dataset(file_id, 'id', p%id) + call write_dataset(file_id, 'weight', src%wgt) + call write_dataset(file_id, 'energy', src%E) + call write_dataset(file_id, 'xyz', src%xyz) + call write_dataset(file_id, 'uvw', src%uvw) + end associate ! Close file call file_close(file_id) diff --git a/tests/test_particle_restart_eigval/results_true.dat b/tests/test_particle_restart_eigval/results_true.dat index 5b548bca7c..d1f933582e 100644 --- a/tests/test_particle_restart_eigval/results_true.dat +++ b/tests/test_particle_restart_eigval/results_true.dat @@ -1,6 +1,6 @@ current batch: 1.000000E+01 -current gen: +current generation: 1.000000E+00 particle id: 1.030000E+03 diff --git a/tests/test_particle_restart_fixed/results_true.dat b/tests/test_particle_restart_fixed/results_true.dat index 0a5126de83..c4ac94c4d8 100644 --- a/tests/test_particle_restart_fixed/results_true.dat +++ b/tests/test_particle_restart_fixed/results_true.dat @@ -1,6 +1,6 @@ current batch: 7.000000E+00 -current gen: +current generation: 1.000000E+00 particle id: 1.440000E+02 diff --git a/tests/testing_harness.py b/tests/testing_harness.py index fc3b4f9346..352022b260 100644 --- a/tests/testing_harness.py +++ b/tests/testing_harness.py @@ -219,8 +219,8 @@ class ParticleRestartTestHarness(TestHarness): outstr = '' outstr += 'current batch:\n' outstr += "{0:12.6E}\n".format(p.current_batch) - outstr += 'current gen:\n' - outstr += "{0:12.6E}\n".format(p.current_gen) + outstr += 'current generation:\n' + outstr += "{0:12.6E}\n".format(p.current_generation) outstr += 'particle id:\n' outstr += "{0:12.6E}\n".format(p.id) outstr += 'run mode:\n'