From 5be8f5b97e8b473ebb61fef90211786a0a416dfa Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 12 Aug 2015 10:09:22 +0700 Subject: [PATCH 1/8] Fix CTest coverage runs for test_filter_distribcell --- CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bbc353f63..45b626324c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -287,6 +287,22 @@ foreach(test ${TESTS}) WORKING_DIRECTORY ${TEST_PATH} COMMAND $ -p ${TEST_PATH}) + elseif(${test} MATCHES "test_filter_distribcell") + + # Add each case for distribcell tests + add_test(NAME ${TEST_NAME}_case-1 + WORKING_DIRECTORY ${TEST_PATH}/case-1 + COMMAND $ ${TEST_PATH}/case-1) + add_test(NAME ${TEST_NAME}_case-2 + WORKING_DIRECTORY ${TEST_PATH}/case-2 + COMMAND $ ${TEST_PATH}/case-2) + add_test(NAME ${TEST_NAME}_case-3 + WORKING_DIRECTORY ${TEST_PATH}/case-3 + COMMAND $ ${TEST_PATH}/case-3) + add_test(NAME ${TEST_NAME}_case-4 + WORKING_DIRECTORY ${TEST_PATH}/case-4 + COMMAND $ ${TEST_PATH}/case-4) + # If a restart test is encounted, need to run with -r and restart file(s) elseif(${test} MATCHES "restart") From 2eeb002a6dcfed292d771fc3d8263e246cdbeda5 Mon Sep 17 00:00:00 2001 From: walshjon Date: Thu, 13 Aug 2015 12:33:13 -0700 Subject: [PATCH 2/8] compute leakage for fixed source runs --- src/eigenvalue.F90 | 14 +++++++------- src/fixed_source.F90 | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/eigenvalue.F90 b/src/eigenvalue.F90 index 1bbcbe850e..c4b9b9a678 100644 --- a/src/eigenvalue.F90 +++ b/src/eigenvalue.F90 @@ -176,19 +176,19 @@ contains !$omp critical global_tallies(K_TRACKLENGTH) % value = & global_tallies(K_TRACKLENGTH) % value + global_tally_tracklength - global_tallies(K_COLLISION) % value = & + global_tallies(K_COLLISION) % value = & global_tallies(K_COLLISION) % value + global_tally_collision - global_tallies(LEAKAGE) % value = & + global_tallies(LEAKAGE) % value = & global_tallies(LEAKAGE) % value + global_tally_leakage - global_tallies(K_ABSORPTION) % value = & + global_tallies(K_ABSORPTION) % value = & global_tallies(K_ABSORPTION) % value + global_tally_absorption !$omp end critical ! reset private tallies - global_tally_tracklength = 0 - global_tally_collision = 0 - global_tally_leakage = 0 - global_tally_absorption = 0 + global_tally_tracklength = ZERO + global_tally_collision = ZERO + global_tally_leakage = ZERO + global_tally_absorption = ZERO !$omp end parallel #ifdef _OPENMP diff --git a/src/fixed_source.F90 b/src/fixed_source.F90 index 9e2d34600b..9e7059aa80 100644 --- a/src/fixed_source.F90 +++ b/src/fixed_source.F90 @@ -6,7 +6,7 @@ module fixed_source use constants, only: ZERO, MAX_LINE_LEN use global - use output, only: write_message, header + use output, only: write_message, header, print_batch_leakage use particle_header, only: Particle use random_lcg, only: set_particle_seed use source, only: sample_external_source, copy_source_attributes @@ -117,11 +117,24 @@ contains subroutine finalize_batch() +! Update global tallies with the omp private accumulation variables +!$omp parallel +!$omp critical + global_tallies(LEAKAGE) % value = & + global_tallies(LEAKAGE) % value + global_tally_leakage +!$omp end critical + + ! reset private tallies + global_tally_leakage = ZERO +!$omp end parallel + ! Collect and accumulate tallies call time_tallies % start() call synchronize_tallies() call time_tallies % stop() + if (master) call print_batch_leakage() + ! Check_triggers if (master) call check_triggers() #ifdef MPI From 5cbaffbcc2047843bd053089aac5d102a92744a8 Mon Sep 17 00:00:00 2001 From: walshjon Date: Thu, 13 Aug 2015 12:39:28 -0700 Subject: [PATCH 3/8] remove calls to no-existent subroutine --- src/fixed_source.F90 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/fixed_source.F90 b/src/fixed_source.F90 index 9e7059aa80..9dbd57324f 100644 --- a/src/fixed_source.F90 +++ b/src/fixed_source.F90 @@ -6,7 +6,7 @@ module fixed_source use constants, only: ZERO, MAX_LINE_LEN use global - use output, only: write_message, header, print_batch_leakage + use output, only: write_message, header use particle_header, only: Particle use random_lcg, only: set_particle_seed use source, only: sample_external_source, copy_source_attributes @@ -133,8 +133,6 @@ contains call synchronize_tallies() call time_tallies % stop() - if (master) call print_batch_leakage() - ! Check_triggers if (master) call check_triggers() #ifdef MPI From d45b9d87d563610805c6c9ca4f816318520223e6 Mon Sep 17 00:00:00 2001 From: walshjon Date: Thu, 13 Aug 2015 14:09:38 -0700 Subject: [PATCH 4/8] print out mean running leakage at each batch --- src/fixed_source.F90 | 13 ++++--- src/global.F90 | 4 +++ src/output.F90 | 80 ++++++++++++++++++++++++++++---------------- 3 files changed, 65 insertions(+), 32 deletions(-) diff --git a/src/fixed_source.F90 b/src/fixed_source.F90 index 9dbd57324f..76564ee2f3 100644 --- a/src/fixed_source.F90 +++ b/src/fixed_source.F90 @@ -6,7 +6,8 @@ module fixed_source use constants, only: ZERO, MAX_LINE_LEN use global - use output, only: write_message, header + use output, only: write_message, header, print_mean_leak,& + print_columns use particle_header, only: Particle use random_lcg, only: set_particle_seed use source, only: sample_external_source, copy_source_attributes @@ -26,6 +27,7 @@ contains type(Particle) :: p if (master) call header("FIXED SOURCE TRANSPORT SIMULATION", level=1) + if (master) call print_columns() ! Allocate particle and dummy source site !$omp parallel @@ -103,9 +105,6 @@ contains subroutine initialize_batch() - call write_message("Simulating batch " // trim(to_str(current_batch)) & - &// "...", 1) - ! Reset total starting particle weight used for normalizing tallies total_weight = ZERO @@ -133,6 +132,12 @@ contains call synchronize_tallies() call time_tallies % stop() + leak = global_tallies(LEAKAGE) % sum / n_realizations + leak_sem = sqrt(ONE / (n_realizations - ONE) & + * (global_tallies(LEAKAGE) % sum_sq / n_realizations& + - leak * leak)) + if (master) call print_mean_leak() + ! Check_triggers if (master) call check_triggers() #ifdef MPI diff --git a/src/global.F90 b/src/global.F90 index a5ff7453ea..b2a563d9ee 100644 --- a/src/global.F90 +++ b/src/global.F90 @@ -200,6 +200,10 @@ module global real(8) :: k_abs_tra = ZERO ! sum over batches of k_absorption * k_tracklength real(8) :: k_combined(2) ! combined best estimate of k-effective + ! Temorary leakage values + real(8) :: leak ! running mean leakage + real(8) :: leak_sem ! 1sigma SEM of the running mean leakage + ! Shannon entropy logical :: entropy_on = .false. real(8), allocatable :: entropy(:) ! shannon entropy at each generation diff --git a/src/output.F90 b/src/output.F90 index cd08e46110..ea918b4361 100644 --- a/src/output.F90 +++ b/src/output.F90 @@ -7,7 +7,7 @@ module output use endf, only: reaction_name use error, only: fatal_error, warning use geometry_header, only: Cell, Universe, Surface, Lattice, RectLattice, & - &HexLattice, BASE_UNIVERSE + HexLattice, BASE_UNIVERSE use global use math, only: t_percentile use mesh_header, only: StructuredMesh @@ -1346,35 +1346,44 @@ contains subroutine print_columns() - write(UNIT=ou, FMT='(2X,A9,3X)', ADVANCE='NO') "Bat./Gen." - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') " k " - if (entropy_on) write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "Entropy " - write(UNIT=ou, FMT='(A20,3X)', ADVANCE='NO') " Average k " - if (cmfd_run) then - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') " CMFD k " - select case(trim(cmfd_display)) - case('entropy') - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "CMFD Ent" - case('balance') - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "RMS Bal " - case('source') - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "RMS Src " - case('dominance') - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "Dom Rat " - end select - end if - write(UNIT=ou, FMT=*) + select case(run_mode) + case(MODE_EIGENVALUE) + write(UNIT=ou, FMT='(2X,A9,3X)', ADVANCE='NO') "Bat./Gen." + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') " k " + if (entropy_on) write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "Entropy " + write(UNIT=ou, FMT='(A20,3X)', ADVANCE='NO') " Average k " + if (cmfd_run) then + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') " CMFD k " + select case(trim(cmfd_display)) + case('entropy') + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "CMFD Ent" + case('balance') + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "RMS Bal " + case('source') + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "RMS Src " + case('dominance') + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "Dom Rat " + end select + end if + write(UNIT=ou, FMT=*) - write(UNIT=ou, FMT='(2X,A9,3X)', ADVANCE='NO') "=========" - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "========" - if (entropy_on) write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "========" - write(UNIT=ou, FMT='(A20,3X)', ADVANCE='NO') "====================" - if (cmfd_run) then + write(UNIT=ou, FMT='(2X,A9,3X)', ADVANCE='NO') "=========" write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "========" - if (cmfd_display /= '') & - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "========" - end if - write(UNIT=ou, FMT=*) + if (entropy_on) write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "========" + write(UNIT=ou, FMT='(A20,3X)', ADVANCE='NO') "====================" + if (cmfd_run) then + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "========" + if (cmfd_display /= '') & + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "========" + end if + write(UNIT=ou, FMT=*) + case(MODE_FIXEDSOURCE) + write(ou, '(A10)', advance='no') 'Batch' + write(ou, '(A24)', advance='no') 'Mean Leakage' + write(ou, '(A24)') '1sigma SEM' + case default + continue + end select end subroutine print_columns @@ -1454,6 +1463,21 @@ contains end subroutine print_batch_keff +!=============================================================================== +! PRINT_MEAN_LEAK displays the overall mean system leakage and 1sigma SEM at +! each batch +!=============================================================================== + + subroutine print_mean_leak() + + ! write out information batch and option independent output + write(ou, '(A10)', advance='no') trim(to_str(current_batch)) + write(ou, '(ES24.16)', advance='no') leak + if (n_realizations > 1) write(ou, '(ES24.16)', advance='no') leak_sem + write(ou, *) + + end subroutine print_mean_leak + !=============================================================================== ! PRINT_PLOT displays selected options for plotting !=============================================================================== From 6ecc9ae6a124b61d37bd65ba994683508cc3e514 Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Thu, 13 Aug 2015 20:51:27 -0600 Subject: [PATCH 5/8] Fix clean_xml.py indentation --- openmc/clean_xml.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openmc/clean_xml.py b/openmc/clean_xml.py index 619475fa07..2bb3f39f1b 100644 --- a/openmc/clean_xml.py +++ b/openmc/clean_xml.py @@ -82,11 +82,11 @@ def clean_xml_indentation(element, level=0): if not element.tail or not element.tail.strip(): element.tail = i - for element in element: - clean_xml_indentation(element, level+1) + for sub_element in element: + clean_xml_indentation(sub_element, level+1) - if not element.tail or not element.tail.strip(): - element.tail = i + if not sub_element.tail or not sub_element.tail.strip(): + sub_element.tail = i else: if level and (not element.tail or not element.tail.strip()): From fc5fd61b7fe533148cea21df0a9997b2ddf5b68d Mon Sep 17 00:00:00 2001 From: walshjon Date: Thu, 13 Aug 2015 23:01:02 -0700 Subject: [PATCH 6/8] incorporate leakage into fixed source test --- tests/test_fixed_source/results_true.dat | 3 +++ tests/test_fixed_source/test_fixed_source.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/tests/test_fixed_source/results_true.dat b/tests/test_fixed_source/results_true.dat index 2ec2d00b8e..99eb15e10d 100644 --- a/tests/test_fixed_source/results_true.dat +++ b/tests/test_fixed_source/results_true.dat @@ -1,3 +1,6 @@ tally 1: 4.483337E+02 2.017057E+04 +leakage: +9.820000E+00 +9.648000E+00 diff --git a/tests/test_fixed_source/test_fixed_source.py b/tests/test_fixed_source/test_fixed_source.py index 1f4382c08f..e96a3ad8fe 100644 --- a/tests/test_fixed_source/test_fixed_source.py +++ b/tests/test_fixed_source/test_fixed_source.py @@ -28,6 +28,10 @@ class FixedSourceTestHarness(TestHarness): outstr += '\n'.join(results) + '\n' tally_num += 1 + outstr += 'leakage:\n' + outstr += '{0:12.6E}'.format(sp._global_tallies[3][0]) + '\n' + outstr += '{0:12.6E}'.format(sp._global_tallies[3][1]) + '\n' + return outstr From e1868225ddb40ff3cf01bcce8b52232d81c87854 Mon Sep 17 00:00:00 2001 From: walshjon Date: Thu, 13 Aug 2015 23:07:45 -0700 Subject: [PATCH 7/8] simplified hotfix version of PR 440 --- src/fixed_source.F90 | 10 +----- src/global.F90 | 4 --- src/output.F90 | 78 +++++++++++++++----------------------------- 3 files changed, 28 insertions(+), 64 deletions(-) diff --git a/src/fixed_source.F90 b/src/fixed_source.F90 index 76564ee2f3..1c34c8f2af 100644 --- a/src/fixed_source.F90 +++ b/src/fixed_source.F90 @@ -6,8 +6,7 @@ module fixed_source use constants, only: ZERO, MAX_LINE_LEN use global - use output, only: write_message, header, print_mean_leak,& - print_columns + use output, only: write_message, header use particle_header, only: Particle use random_lcg, only: set_particle_seed use source, only: sample_external_source, copy_source_attributes @@ -27,7 +26,6 @@ contains type(Particle) :: p if (master) call header("FIXED SOURCE TRANSPORT SIMULATION", level=1) - if (master) call print_columns() ! Allocate particle and dummy source site !$omp parallel @@ -132,12 +130,6 @@ contains call synchronize_tallies() call time_tallies % stop() - leak = global_tallies(LEAKAGE) % sum / n_realizations - leak_sem = sqrt(ONE / (n_realizations - ONE) & - * (global_tallies(LEAKAGE) % sum_sq / n_realizations& - - leak * leak)) - if (master) call print_mean_leak() - ! Check_triggers if (master) call check_triggers() #ifdef MPI diff --git a/src/global.F90 b/src/global.F90 index b2a563d9ee..a5ff7453ea 100644 --- a/src/global.F90 +++ b/src/global.F90 @@ -200,10 +200,6 @@ module global real(8) :: k_abs_tra = ZERO ! sum over batches of k_absorption * k_tracklength real(8) :: k_combined(2) ! combined best estimate of k-effective - ! Temorary leakage values - real(8) :: leak ! running mean leakage - real(8) :: leak_sem ! 1sigma SEM of the running mean leakage - ! Shannon entropy logical :: entropy_on = .false. real(8), allocatable :: entropy(:) ! shannon entropy at each generation diff --git a/src/output.F90 b/src/output.F90 index ea918b4361..939451c6fb 100644 --- a/src/output.F90 +++ b/src/output.F90 @@ -1346,44 +1346,35 @@ contains subroutine print_columns() - select case(run_mode) - case(MODE_EIGENVALUE) - write(UNIT=ou, FMT='(2X,A9,3X)', ADVANCE='NO') "Bat./Gen." - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') " k " - if (entropy_on) write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "Entropy " - write(UNIT=ou, FMT='(A20,3X)', ADVANCE='NO') " Average k " - if (cmfd_run) then - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') " CMFD k " - select case(trim(cmfd_display)) - case('entropy') - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "CMFD Ent" - case('balance') - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "RMS Bal " - case('source') - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "RMS Src " - case('dominance') - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "Dom Rat " - end select - end if - write(UNIT=ou, FMT=*) + write(UNIT=ou, FMT='(2X,A9,3X)', ADVANCE='NO') "Bat./Gen." + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') " k " + if (entropy_on) write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "Entropy " + write(UNIT=ou, FMT='(A20,3X)', ADVANCE='NO') " Average k " + if (cmfd_run) then + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') " CMFD k " + select case(trim(cmfd_display)) + case('entropy') + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "CMFD Ent" + case('balance') + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "RMS Bal " + case('source') + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "RMS Src " + case('dominance') + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "Dom Rat " + end select + end if + write(UNIT=ou, FMT=*) - write(UNIT=ou, FMT='(2X,A9,3X)', ADVANCE='NO') "=========" + write(UNIT=ou, FMT='(2X,A9,3X)', ADVANCE='NO') "=========" + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "========" + if (entropy_on) write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "========" + write(UNIT=ou, FMT='(A20,3X)', ADVANCE='NO') "====================" + if (cmfd_run) then write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "========" - if (entropy_on) write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "========" - write(UNIT=ou, FMT='(A20,3X)', ADVANCE='NO') "====================" - if (cmfd_run) then - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "========" - if (cmfd_display /= '') & - write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "========" - end if - write(UNIT=ou, FMT=*) - case(MODE_FIXEDSOURCE) - write(ou, '(A10)', advance='no') 'Batch' - write(ou, '(A24)', advance='no') 'Mean Leakage' - write(ou, '(A24)') '1sigma SEM' - case default - continue - end select + if (cmfd_display /= '') & + write(UNIT=ou, FMT='(A8,3X)', ADVANCE='NO') "========" + end if + write(UNIT=ou, FMT=*) end subroutine print_columns @@ -1463,21 +1454,6 @@ contains end subroutine print_batch_keff -!=============================================================================== -! PRINT_MEAN_LEAK displays the overall mean system leakage and 1sigma SEM at -! each batch -!=============================================================================== - - subroutine print_mean_leak() - - ! write out information batch and option independent output - write(ou, '(A10)', advance='no') trim(to_str(current_batch)) - write(ou, '(ES24.16)', advance='no') leak - if (n_realizations > 1) write(ou, '(ES24.16)', advance='no') leak_sem - write(ou, *) - - end subroutine print_mean_leak - !=============================================================================== ! PRINT_PLOT displays selected options for plotting !=============================================================================== From 2c23d0ac212c2d62bf8aa5c8ebfc96591f8f9f91 Mon Sep 17 00:00:00 2001 From: walshjon Date: Thu, 13 Aug 2015 23:12:07 -0700 Subject: [PATCH 8/8] reinclude the batch count printout --- src/fixed_source.F90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fixed_source.F90 b/src/fixed_source.F90 index 1c34c8f2af..9dbd57324f 100644 --- a/src/fixed_source.F90 +++ b/src/fixed_source.F90 @@ -103,6 +103,9 @@ contains subroutine initialize_batch() + call write_message("Simulating batch " // trim(to_str(current_batch)) & + &// "...", 1) + ! Reset total starting particle weight used for normalizing tallies total_weight = ZERO