From 40b05fe94e16731703ca758a55953d62f353fc7a Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 29 Jun 2016 10:17:31 +0700 Subject: [PATCH 1/4] Ensure source bank is resampled at each generation for fixed source --- docs/source/usersguide/input.rst | 2 +- src/particle_restart.F90 | 7 ++++++- src/simulation.F90 | 10 +++++++++- tests/test_fixed_source/results_true.dat | 8 ++++---- tests/test_particle_restart_fixed/results_true.dat | 10 +++++----- .../test_particle_restart_fixed.py | 2 +- 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/docs/source/usersguide/input.rst b/docs/source/usersguide/input.rst index 4c1f238238..d6802075e5 100644 --- a/docs/source/usersguide/input.rst +++ b/docs/source/usersguide/input.rst @@ -688,7 +688,7 @@ attributes/sub-elements: *Default*: false - :source_write: + :write: If this element is set to "false", source sites are not written to the state point or source point file. This can substantially reduce the size of state points if large numbers of particles per batch are used. diff --git a/src/particle_restart.F90 b/src/particle_restart.F90 index e5cca17bf8..846d37160d 100644 --- a/src/particle_restart.F90 +++ b/src/particle_restart.F90 @@ -97,10 +97,15 @@ contains call read_dataset(p % id, file_id, 'id') call read_dataset(p % wgt, file_id, 'weight') call read_dataset(p % E, file_id, 'energy') - call read_dataset(p % g, file_id, 'energy_group') call read_dataset(p % coord(1) % xyz, file_id, 'xyz') call read_dataset(p % coord(1) % uvw, file_id, 'uvw') + ! Set energy group and average energy in multi-group mode + if (.not. run_CE) then + p % g = int(p % E) + p % E = energy_bin_avg(p % g) + end if + ! Set particle last attributes p % last_wgt = p % wgt p % last_xyz = p % coord(1)%xyz diff --git a/src/simulation.F90 b/src/simulation.F90 index b762979d73..2e15e7c07a 100644 --- a/src/simulation.F90 +++ b/src/simulation.F90 @@ -17,7 +17,7 @@ module simulation print_batch_keff, print_generation use particle_header, only: Particle use random_lcg, only: set_particle_seed - use source, only: initialize_source + use source, only: initialize_source, sample_external_source use state_point, only: write_state_point, write_source_point use string, only: to_str use tally, only: synchronize_tallies, setup_active_usertallies, & @@ -227,6 +227,8 @@ contains subroutine finalize_generation() + integer(8) :: i + ! Update global tallies with the omp private accumulation variables !$omp parallel !$omp critical @@ -271,6 +273,12 @@ contains ! Write generation output if (master .and. current_gen /= gen_per_batch) call print_generation() + elseif (run_mode == MODE_FIXEDSOURCE) then + ! For fixed-source mode, we need to sample the external source + call set_particle_seed(overall_gen*n_particles) + do i = 1, work + call sample_external_source(source_bank(i)) + end do end if end subroutine finalize_generation diff --git a/tests/test_fixed_source/results_true.dat b/tests/test_fixed_source/results_true.dat index c7ddf3c0b5..eece8dc1c2 100644 --- a/tests/test_fixed_source/results_true.dat +++ b/tests/test_fixed_source/results_true.dat @@ -1,6 +1,6 @@ tally 1: -4.518784E+02 -2.056386E+04 +4.460676E+02 +1.993197E+04 leakage: -9.750000E+00 -9.508100E+00 +9.660000E+00 +9.335800E+00 diff --git a/tests/test_particle_restart_fixed/results_true.dat b/tests/test_particle_restart_fixed/results_true.dat index de42a0c68e..9cc800cf67 100644 --- a/tests/test_particle_restart_fixed/results_true.dat +++ b/tests/test_particle_restart_fixed/results_true.dat @@ -1,16 +1,16 @@ current batch: -7.000000E+00 +9.000000E+00 current gen: 1.000000E+00 particle id: -9.280000E+02 +5.900000E+02 run mode: fixed source particle weight: 1.000000E+00 particle energy: -4.412022E+00 +5.284635E+00 particle xyz: -5.572639E+00 -9.139472E+00 -1.974824E+00 +4.995064E+00 7.895146E+00 1.198717E+00 particle uvw: -1.410422E-01 5.330426E-01 -8.342498E-01 +7.594252E-01 3.731736E-01 -5.329305E-01 diff --git a/tests/test_particle_restart_fixed/test_particle_restart_fixed.py b/tests/test_particle_restart_fixed/test_particle_restart_fixed.py index 5af7454894..fcd377f13b 100644 --- a/tests/test_particle_restart_fixed/test_particle_restart_fixed.py +++ b/tests/test_particle_restart_fixed/test_particle_restart_fixed.py @@ -7,5 +7,5 @@ from testing_harness import ParticleRestartTestHarness if __name__ == '__main__': - harness = ParticleRestartTestHarness('particle_7_928.*') + harness = ParticleRestartTestHarness('particle_9_590.h5') harness.main() From 70daa76e0e9d0bd8163e5c9d306788dbd7cf30c6 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 29 Jun 2016 18:33:59 +0700 Subject: [PATCH 2/4] Make sure MT=3 cross section is not used --- src/ace.F90 | 2 +- src/constants.F90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ace.F90 b/src/ace.F90 index cbe14b6ae8..170c885f02 100644 --- a/src/ace.F90 +++ b/src/ace.F90 @@ -913,7 +913,7 @@ contains ! Skip total inelastic level scattering, gas production cross sections ! (MT=200+), etc. - if (rxn % MT == N_LEVEL) cycle + if (rxn % MT == N_LEVEL .or. rxn % MT == N_NONELASTIC) cycle if (rxn % MT > N_5N2P .and. rxn % MT < N_P0) cycle ! Skip level cross sections if total is available diff --git a/src/constants.F90 b/src/constants.F90 index f6e82d9bdc..75c047e8d6 100644 --- a/src/constants.F90 +++ b/src/constants.F90 @@ -207,7 +207,7 @@ module constants N_4N2P = 194, N_4N2A = 195, N_4NPA = 196, N_3P = 197, N_N3P = 198, & N_3N2PA = 199, N_5N2P = 200, N_P0 = 600, N_PC = 649, N_D0 = 650, & N_DC = 699, N_T0 = 700, N_TC = 749, N_3HE0 = 750, N_3HEC = 799, & - N_A0 = 800, N_AC = 849, N_2N0 = 875, N_2NC = 891 + N_A0 = 800, N_AC = 849, N_2N0 = 875, N_2NC = 891, N_NONELASTIC = 3 ! ACE table types integer, parameter :: & From 348eb44b6fb63fd4f1b1bfa9d859aee041459ec2 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 29 Jun 2016 18:51:26 +0700 Subject: [PATCH 3/4] Make sure fixed source resample is reproducible for MPI runs --- src/simulation.F90 | 2 +- tests/test_fixed_source/results_true.dat | 8 ++++---- tests/test_particle_restart_fixed/results_true.dat | 10 +++++----- .../test_particle_restart_fixed.py | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/simulation.F90 b/src/simulation.F90 index 2e15e7c07a..3321dc70fa 100644 --- a/src/simulation.F90 +++ b/src/simulation.F90 @@ -275,8 +275,8 @@ contains if (master .and. current_gen /= gen_per_batch) call print_generation() elseif (run_mode == MODE_FIXEDSOURCE) then ! For fixed-source mode, we need to sample the external source - call set_particle_seed(overall_gen*n_particles) do i = 1, work + call set_particle_seed(overall_gen*n_particles + work_index(rank) + i) call sample_external_source(source_bank(i)) end do end if diff --git a/tests/test_fixed_source/results_true.dat b/tests/test_fixed_source/results_true.dat index eece8dc1c2..6246dfaf62 100644 --- a/tests/test_fixed_source/results_true.dat +++ b/tests/test_fixed_source/results_true.dat @@ -1,6 +1,6 @@ tally 1: -4.460676E+02 -1.993197E+04 +4.448476E+02 +1.984373E+04 leakage: -9.660000E+00 -9.335800E+00 +9.790000E+00 +9.588300E+00 diff --git a/tests/test_particle_restart_fixed/results_true.dat b/tests/test_particle_restart_fixed/results_true.dat index 9cc800cf67..047760a2d5 100644 --- a/tests/test_particle_restart_fixed/results_true.dat +++ b/tests/test_particle_restart_fixed/results_true.dat @@ -1,16 +1,16 @@ current batch: -9.000000E+00 +7.000000E+00 current gen: 1.000000E+00 particle id: -5.900000E+02 +1.440000E+02 run mode: fixed source particle weight: 1.000000E+00 particle energy: -5.284635E+00 +5.749729E+00 particle xyz: -4.995064E+00 7.895146E+00 1.198717E+00 +8.754675E+00 2.551620E+00 4.394350E-01 particle uvw: -7.594252E-01 3.731736E-01 -5.329305E-01 +-5.971721E-01 -4.845709E-01 6.391999E-01 diff --git a/tests/test_particle_restart_fixed/test_particle_restart_fixed.py b/tests/test_particle_restart_fixed/test_particle_restart_fixed.py index fcd377f13b..df0398c6eb 100644 --- a/tests/test_particle_restart_fixed/test_particle_restart_fixed.py +++ b/tests/test_particle_restart_fixed/test_particle_restart_fixed.py @@ -7,5 +7,5 @@ from testing_harness import ParticleRestartTestHarness if __name__ == '__main__': - harness = ParticleRestartTestHarness('particle_9_590.h5') + harness = ParticleRestartTestHarness('particle_7_144.h5') harness.main() From 49889f7128243e7b6a7f093e633078a046727e4b Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 29 Jun 2016 20:48:53 +0700 Subject: [PATCH 4/4] @smharper calling me out on my laziness --- src/constants.F90 | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/constants.F90 b/src/constants.F90 index 75c047e8d6..b3e5ed89b1 100644 --- a/src/constants.F90 +++ b/src/constants.F90 @@ -186,28 +186,28 @@ module constants ! Reaction types integer, parameter :: & - TOTAL_XS = 1, ELASTIC = 2, N_LEVEL = 4, MISC = 5, N_2ND = 11, & - N_2N = 16, N_3N = 17, N_FISSION = 18, N_F = 19, N_NF = 20, & - N_2NF = 21, N_NA = 22, N_N3A = 23, N_2NA = 24, N_3NA = 25, & - N_NP = 28, N_N2A = 29, N_2N2A = 30, N_ND = 32, N_NT = 33, & - N_N3HE = 34, N_ND2A = 35, N_NT2A = 36, N_4N = 37, N_3NF = 38, & - N_2NP = 41, N_3NP = 42, N_N2P = 44, N_NPA = 45, N_N1 = 51, & - N_N40 = 90, N_NC = 91, N_DISAPPEAR = 101, N_GAMMA = 102, N_P = 103, & - N_D = 104, N_T = 105, N_3HE = 106, N_A = 107, N_2A = 108, & - N_3A = 109, N_2P = 111, N_PA = 112, N_T2A = 113, N_D2A = 114, & - N_PD = 115, N_PT = 116, N_DA = 117, N_5N = 152, N_6N = 153, & - N_2NT = 154, N_TA = 155, N_4NP = 156, N_3ND = 157, N_NDA = 158, & - N_2NPA = 159, N_7N = 160, N_8N = 161, N_5NP = 162, N_6NP = 163, & - N_7NP = 164, N_4NA = 165, N_5NA = 166, N_6NA = 167, N_7NA = 168, & - N_4ND = 169, N_5ND = 170, N_6ND = 171, N_3NT = 172, N_4NT = 173, & - N_5NT = 174, N_6NT = 175, N_2N3HE = 176, N_3N3HE = 177, N_4N3HE = 178, & - N_3N2P = 179, N_3N3A = 180, N_3NPA = 181, N_DT = 182, N_NPD = 183, & - N_NPT = 184, N_NDT = 185, N_NP3HE = 186, N_ND3HE = 187, N_NT3HE = 188, & - N_NTA = 189, N_2N2P = 190, N_P3HE = 191, N_D3HE = 192, N_3HEA = 193, & - N_4N2P = 194, N_4N2A = 195, N_4NPA = 196, N_3P = 197, N_N3P = 198, & - N_3N2PA = 199, N_5N2P = 200, N_P0 = 600, N_PC = 649, N_D0 = 650, & - N_DC = 699, N_T0 = 700, N_TC = 749, N_3HE0 = 750, N_3HEC = 799, & - N_A0 = 800, N_AC = 849, N_2N0 = 875, N_2NC = 891, N_NONELASTIC = 3 + TOTAL_XS = 1, ELASTIC = 2, N_NONELASTIC = 3, N_LEVEL = 4, MISC = 5, & + N_2ND = 11, N_2N = 16, N_3N = 17, N_FISSION = 18, N_F = 19, & + N_NF = 20, N_2NF = 21, N_NA = 22, N_N3A = 23, N_2NA = 24, & + N_3NA = 25, N_NP = 28, N_N2A = 29, N_2N2A = 30, N_ND = 32, & + N_NT = 33, N_N3HE = 34, N_ND2A = 35, N_NT2A = 36, N_4N = 37, & + N_3NF = 38, N_2NP = 41, N_3NP = 42, N_N2P = 44, N_NPA = 45, & + N_N1 = 51, N_N40 = 90, N_NC = 91, N_DISAPPEAR = 101, N_GAMMA = 102, & + N_P = 103, N_D = 104, N_T = 105, N_3HE = 106, N_A = 107, & + N_2A = 108, N_3A = 109, N_2P = 111, N_PA = 112, N_T2A = 113, & + N_D2A = 114, N_PD = 115, N_PT = 116, N_DA = 117, N_5N = 152, & + N_6N = 153, N_2NT = 154, N_TA = 155, N_4NP = 156, N_3ND = 157, & + N_NDA = 158, N_2NPA = 159, N_7N = 160, N_8N = 161, N_5NP = 162, & + N_6NP = 163, N_7NP = 164, N_4NA = 165, N_5NA = 166, N_6NA = 167, & + N_7NA = 168, N_4ND = 169, N_5ND = 170, N_6ND = 171, N_3NT = 172, & + N_4NT = 173, N_5NT = 174, N_6NT = 175, N_2N3HE = 176, N_3N3HE = 177, & + N_4N3HE = 178, N_3N2P = 179, N_3N3A = 180, N_3NPA = 181, N_DT = 182, & + N_NPD = 183, N_NPT = 184, N_NDT = 185, N_NP3HE = 186, N_ND3HE = 187, & + N_NT3HE = 188, N_NTA = 189, N_2N2P = 190, N_P3HE = 191, N_D3HE = 192, & + N_3HEA = 193, N_4N2P = 194, N_4N2A = 195, N_4NPA = 196, N_3P = 197, & + N_N3P = 198, N_3N2PA = 199, N_5N2P = 200, N_P0 = 600, N_PC = 649, & + N_D0 = 650, N_DC = 699, N_T0 = 700, N_TC = 749, N_3HE0 = 750, & + N_3HEC = 799, N_A0 = 800, N_AC = 849, N_2N0 = 875, N_2NC = 891 ! ACE table types integer, parameter :: &