From 75bc67c2e4179a45579871f7f6b7b3676fcf2036 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Tue, 25 Nov 2014 21:37:02 -0500 Subject: [PATCH] Updated all tests to use new statepoint format --- src/hdf5_summary.F90 | 4 +- src/state_point.F90 | 572 +++++++---- src/utils/openmc/__init__.py | 4 +- src/utils/openmc/nuclide.py | 15 +- src/utils/openmc/opencg_compatible.py | 12 +- src/utils/openmc/statepoint.py | 955 ++++++++++-------- src/utils/openmc/summary.py | 495 +++++++++ src/utils/openmc/surface.py | 2 +- src/utils/openmc/universe.py | 4 +- tests/test_cmfd_feed/results.py | 57 +- tests/test_cmfd_jfnk/results.py | 57 +- tests/test_cmfd_nofeed/results.py | 57 +- tests/test_confidence_intervals/results.py | 13 +- tests/test_density_atombcm/results.py | 5 +- tests/test_density_atomcm3/results.py | 5 +- tests/test_density_kgm3/results.py | 5 +- tests/test_density_sum/results.py | 5 +- tests/test_eigenvalue_genperbatch/results.py | 5 +- tests/test_eigenvalue_no_inactive/results.py | 5 +- tests/test_energy_grid/results.py | 5 +- tests/test_entropy/results.py | 7 +- tests/test_filter_cell/results.py | 13 +- tests/test_filter_cellborn/results.py | 13 +- tests/test_filter_energy/results.py | 13 +- tests/test_filter_energyout/results.py | 12 +- tests/test_filter_group_transfer/results.py | 12 +- tests/test_filter_material/results.py | 13 +- tests/test_filter_mesh_2d/results.py | 13 +- tests/test_filter_mesh_3d/results.py | 13 +- tests/test_filter_universe/results.py | 13 +- tests/test_fixed_source/results.py | 11 +- tests/test_infinite_cell/results.py | 4 +- tests/test_lattice/results.py | 5 +- tests/test_lattice_multiple/results.py | 5 +- tests/test_natural_element/results.py | 5 +- tests/test_output/results.py | 5 +- tests/test_particle_restart_eigval/results.py | 8 +- tests/test_particle_restart_fixed/results.py | 2 +- tests/test_ptables_off/results.py | 5 +- tests/test_reflective_cone/results.py | 5 +- tests/test_reflective_cylinder/results.py | 8 +- tests/test_reflective_plane/results.py | 10 +- tests/test_reflective_sphere/results.py | 10 +- tests/test_resonance_scattering/results.py | 2 +- tests/test_rotation/results.py | 10 +- tests/test_salphabeta/results.py | 10 +- tests/test_salphabeta_multiple/results.py | 5 +- tests/test_score_MT/results.py | 13 +- tests/test_score_absorption/results.py | 23 +- tests/test_score_current/results.py | 22 +- tests/test_score_events/results.py | 22 +- tests/test_score_fission/results.py | 22 +- tests/test_score_flux/results.py | 13 +- tests/test_score_flux_yn/results.py | 22 +- tests/test_score_kappafission/results.py | 13 +- tests/test_score_nufission/results.py | 13 +- tests/test_score_nuscatter/results.py | 13 +- tests/test_score_nuscatter_n/results.py | 13 +- tests/test_score_nuscatter_pn/results.py | 22 +- tests/test_score_nuscatter_yn/results.py | 22 +- tests/test_score_scatter/results.py | 13 +- tests/test_score_scatter_n/results.py | 13 +- tests/test_score_scatter_pn/results.py | 22 +- tests/test_score_scatter_yn/results.py | 22 +- tests/test_score_total/results.py | 12 +- tests/test_score_total_yn/results.py | 21 +- tests/test_seed/results.py | 5 +- tests/test_source_angle_mono/results.py | 5 +- tests/test_source_energy_maxwell/results.py | 5 +- tests/test_source_energy_mono/results.py | 5 +- tests/test_source_file/results.py | 5 +- tests/test_source_point/results.py | 5 +- tests/test_sourcepoint_batch/results.py | 7 +- tests/test_sourcepoint_interval/results.py | 7 +- tests/test_sourcepoint_latest/results.py | 5 +- tests/test_sourcepoint_restart/results.py | 26 +- tests/test_statepoint_batch/results.py | 5 +- tests/test_statepoint_interval/results.py | 5 +- tests/test_statepoint_restart/results.py | 26 +- tests/test_statepoint_restart/settings.xml | 2 +- tests/test_statepoint_sourcesep/results.py | 5 +- tests/test_survival_biasing/results.py | 5 +- tests/test_tally_assumesep/results.py | 31 +- tests/test_tally_nuclides/results.py | 19 +- tests/test_trace/results.py | 5 +- tests/test_translation/results.py | 5 +- tests/test_uniform_fs/results.py | 5 +- tests/test_universe/results.py | 5 +- tests/test_void/results.py | 5 +- 89 files changed, 1934 insertions(+), 1114 deletions(-) create mode 100644 src/utils/openmc/summary.py diff --git a/src/hdf5_summary.F90 b/src/hdf5_summary.F90 index 09761c87a1..7ddb6c3d6a 100644 --- a/src/hdf5_summary.F90 +++ b/src/hdf5_summary.F90 @@ -148,8 +148,8 @@ contains case (CELL_FILL) call su % write_data("universe", "fill_type", & group="geometry/cells/cell " // trim(to_str(c % id))) - call su % write_data(universes(c % fill) % id, "universe", & - group="geometry/cells/cell " // trim(to_str(c % id))) + call su % write_data(universes(c % fill) % id, "fill", & + group="geometry/cells/cell " // trim(to_str(c % id))) if (allocated(c % translation)) then call su % write_data(1, "translated", & diff --git a/src/state_point.F90 b/src/state_point.F90 index b39bda74de..658941fee7 100644 --- a/src/state_point.F90 +++ b/src/state_point.F90 @@ -19,6 +19,8 @@ module state_point use string, only: to_str, zero_padded, count_digits use output_interface use tally_header, only: TallyObject + use mesh_header, only: StructuredMesh + use dict_header, only: ElemKeyValueII, ElemKeyValueCI #ifdef MPI use mpi @@ -36,12 +38,18 @@ contains subroutine write_state_point() - character(MAX_FILE_LEN) :: filename - integer :: i - integer :: j - integer, allocatable :: temp_array(:) - type(TallyObject), pointer :: t => null() - + character(MAX_FILE_LEN) :: filename + integer :: i, j, k, m + integer :: n_x, n_y, n_z + character(11), allocatable :: name_array(:) + integer, allocatable :: id_array(:) + integer, allocatable :: key_array(:) + type(StructuredMesh), pointer :: mesh => null() + type(TallyObject), pointer :: tally => null() + type(ElemKeyValueII), pointer :: current => null() + type(ElemKeyValueII), pointer :: next => null() + type(ElemKeyValueCI), pointer :: cur_nuclide => null() + type(ElemKeyValueCI), pointer :: next_nuclide => null() ! Set filename for state point filename = trim(path_output) // 'statepoint.' // & & zero_padded(current_batch, count_digits(n_batches)) @@ -83,17 +91,26 @@ contains ! Write run information call sp % write_data(run_mode, "run_mode") call sp % write_data(n_particles, "n_particles") + call sp % write_data(n_batches, "n_batches") ! Write out current batch number call sp % write_data(current_batch, "current_batch") + ! Indicate whether source bank is stored in statepoint + if (source_separate) then + call sp % write_data(0, "source_present") + else + call sp % write_data(1, "source_present") + end if + ! Write out information for eigenvalue run if (run_mode == MODE_EIGENVALUE) then call sp % write_data(n_inactive, "n_inactive") call sp % write_data(gen_per_batch, "gen_per_batch") call sp % write_data(k_generation, "k_generation", & length=current_batch*gen_per_batch) - call sp % write_data(entropy, "entropy", length=current_batch*gen_per_batch) + call sp % write_data(entropy, "entropy", & + length=current_batch*gen_per_batch) call sp % write_data(k_col_abs, "k_col_abs") call sp % write_data(k_col_tra, "k_col_tra") call sp % write_data(k_abs_tra, "k_abs_tra") @@ -101,6 +118,10 @@ contains ! Write out CMFD info if (cmfd_on) then +#ifdef HDF5 + call sp % open_group("cmfd") + call sp % close_group() +#endif call sp % write_data(1, "cmfd_on") call sp % write_data(cmfd % indices, "indices", length=4, group="cmfd") call sp % write_data(cmfd % k_cmfd, "k_cmfd", length=current_batch, & @@ -110,7 +131,7 @@ contains cmfd % indices(2), cmfd % indices(3)/), & group="cmfd") call sp % write_data(cmfd % entropy, "cmfd_entropy", & - length=current_batch, group="cmfd") + length=current_batch, group="cmfd") call sp % write_data(cmfd % balance, "cmfd_balance", & length=current_batch, group="cmfd") call sp % write_data(cmfd % dom, "cmfd_dominance", & @@ -122,119 +143,162 @@ contains end if end if - ! Write number of meshes - call sp % write_data(n_meshes, "n_meshes", group="tallies") +#ifdef HDF5 + call sp % open_group("tallies") + call sp % close_group() +#endif - ! Write information for meshes - MESH_LOOP: do i = 1, n_meshes - call sp % write_data(meshes(i) % id, "id", & - group="tallies/mesh" // to_str(i)) - call sp % write_data(meshes(i) % type, "type", & - group="tallies/mesh" // to_str(i)) - call sp % write_data(meshes(i) % n_dimension, "n_dimension", & - group="tallies/mesh" // to_str(i)) - call sp % write_data(meshes(i) % dimension, "dimension", & - group="tallies/mesh" // to_str(i), & - length=meshes(i) % n_dimension) - call sp % write_data(meshes(i) % lower_left, "lower_left", & - group="tallies/mesh" // to_str(i), & - length=meshes(i) % n_dimension) - call sp % write_data(meshes(i) % upper_right, "upper_right", & - group="tallies/mesh" // to_str(i), & - length=meshes(i) % n_dimension) - call sp % write_data(meshes(i) % width, "width", & - group="tallies/mesh" // to_str(i), & - length=meshes(i) % n_dimension) - end do MESH_LOOP + ! Write number of meshes + call sp % write_data(n_meshes, "n_meshes", group="tallies/meshes") + + if (n_meshes > 0) then + + ! Print list of mesh IDs + current => mesh_dict % keys() + + allocate(id_array(n_meshes)) + allocate(key_array(n_meshes)) + i = 1 + + do while (associated(current)) + key_array(i) = current % key + id_array(i) = current % value + + ! Move to next mesh + next => current % next + deallocate(current) + current => next + i = i + 1 + end do + + call sp % write_data(id_array, "ids", & + group="tallies/meshes", length=n_meshes) + call sp % write_data(key_array, "keys", & + group="tallies/meshes", length=n_meshes) + + deallocate(key_array) + + ! Write information for meshes + MESH_LOOP: do i = 1, n_meshes + + mesh => meshes(id_array(i)) + + call sp % write_data(mesh % id, "id", & + group="tallies/meshes/mesh " // trim(to_str(mesh % id))) + call sp % write_data(mesh % type, "type", & + group="tallies/meshes/mesh " // trim(to_str(mesh % id))) + call sp % write_data(mesh % n_dimension, "n_dimension", & + group="tallies/meshes/mesh " // trim(to_str(mesh % id))) + call sp % write_data(mesh % dimension, "dimension", & + group="tallies/meshes/mesh " // trim(to_str(mesh % id)), & + length=mesh % n_dimension) + call sp % write_data(mesh % lower_left, "lower_left", & + group="tallies/meshes/mesh " // trim(to_str(mesh % id)), & + length=mesh % n_dimension) + call sp % write_data(mesh % upper_right, "upper_right", & + group="tallies/meshes/mesh " // trim(to_str(mesh % id)), & + length=mesh % n_dimension) + call sp % write_data(mesh % width, "width", & + group="tallies/meshes/mesh " // trim(to_str(mesh % id)), & + length=mesh % n_dimension) + end do MESH_LOOP + + deallocate(id_array) + + end if ! Write number of tallies call sp % write_data(n_tallies, "n_tallies", group="tallies") - ! Write all tally information except results - TALLY_METADATA: do i = 1, n_tallies - !Get pointer to tally - t => tallies(i) + if (n_tallies > 0) then - ! Write id - call sp % write_data(t % id, "id", group="tallies/tally" // to_str(i)) + ! Print list of tally IDs + allocate(id_array(n_tallies)) + allocate(key_array(n_tallies)) - ! Write number of realizations - call sp % write_data(t % n_realizations, "n_realizations", & - group="tallies/tally" // to_str(i)) + ! Write all tally information except results + do i = 1, n_tallies + tally => tallies(i) + key_array(i) = tally % id + id_array(i) = i + end do - ! Write size of each tally - call sp % write_data(t % total_score_bins, "total_score_bins", & - group="tallies/tally" // to_str(i)) - call sp % write_data(t % total_filter_bins, "total_filter_bins", & - group="tallies/tally" // to_str(i)) + call sp % write_data(id_array, "ids", & + group="tallies", length=n_tallies) + call sp % write_data(key_array, "keys", & + group="tallies", length=n_tallies) - ! Write number of filters - call sp % write_data(t % n_filters, "n_filters", & - group="tallies/tally" // to_str(i)) + deallocate(key_array) - ! Write filter information - FILTER_LOOP: do j = 1, t % n_filters + ! Write all tally information except results + TALLY_METADATA: do i = 1, n_tallies - ! Write type of filter - call sp % write_data(t % filters(j) % type, "type", & - group="tallies/tally" // trim(to_str(i)) // "/filter" // to_str(j)) + ! Get pointer to tally + tally => tallies(i) - ! Write number of bins for this filter - call sp % write_data(t % filters(j) % n_bins, "n_bins", & - group="tallies/tally" // trim(to_str(i)) // "/filter" // to_str(j)) + call sp % write_data(len(tally % label), "label_size", & + group="tallies/tally " // trim(to_str(tally % id))) + if (len(tally % label) > 0) then + call sp % write_data(tally % label, "label", & + group="tallies/tally " // trim(to_str(tally % id))) + endif - ! Write bins - if (t % filters(j) % type == FILTER_ENERGYIN .or. & - t % filters(j) % type == FILTER_ENERGYOUT) then - call sp % write_data(t % filters(j) % real_bins, "bins", & - group="tallies/tally" // trim(to_str(i)) // "/filter" // to_str(j), & - length=size(t % filters(j) % real_bins)) - else - call sp % write_data(t % filters(j) % int_bins, "bins", & - group="tallies/tally" // trim(to_str(i)) // "/filter" // to_str(j), & - length=size(t % filters(j) % int_bins)) - end if + call sp % write_data(tally % estimator, "estimator", & + group="tallies/tally " // trim(to_str(tally % id))) + call sp % write_data(tally % n_realizations, "n_realizations", & + group="tallies/tally " // trim(to_str(tally % id))) + call sp % write_data(tally % n_filters, "n_filters", & + group="tallies/tally " // trim(to_str(tally % id))) - end do FILTER_LOOP + ! Write filter information + FILTER_LOOP: do j = 1, tally % n_filters - ! Write number of nuclide bins - call sp % write_data(t % n_nuclide_bins, "n_nuclide_bins", & - group="tallies/tally" // to_str(i)) + call sp % write_data(tally % filters(j) % type, "type", & + group="tallies/tally " // trim(to_str(tally % id)) // & + "/filter " // to_str(j)) + call sp % write_data(tally % filters(j) % n_bins, "n_bins", & + group="tallies/tally " // trim(to_str(tally % id)) // & + "/filter " // to_str(j)) + if (tally % filters(j) % type == FILTER_ENERGYIN .or. & + tally % filters(j) % type == FILTER_ENERGYOUT) then + call sp % write_data(tally % filters(j) % real_bins, "bins", & + group="tallies/tally " // trim(to_str(tally % id)) // & + "/filter " // to_str(j), & + length=size(tally % filters(j) % real_bins)) + else + call sp % write_data(tally % filters(j) % int_bins, "bins", & + group="tallies/tally " // trim(to_str(tally % id)) // & + "/filter " // to_str(j), & + length=size(tally % filters(j) % int_bins)) + end if - ! Set up nuclide bin array and then write - allocate(temp_array(t % n_nuclide_bins)) - NUCLIDE_LOOP: do j = 1, t % n_nuclide_bins - if (t % nuclide_bins(j) > 0) then - temp_array(j) = nuclides(t % nuclide_bins(j)) % zaid - else - temp_array(j) = t % nuclide_bins(j) - end if - end do NUCLIDE_LOOP - call sp % write_data(temp_array, "nuclide_bins", & - group="tallies/tally" // to_str(i), length=t % n_nuclide_bins) - deallocate(temp_array) + end do FILTER_LOOP - ! Write number of score bins, score bins, and moment order - call sp % write_data(t % n_score_bins, "n_score_bins", & - group="tallies/tally" // to_str(i)) - call sp % write_data(t % score_bins, "score_bins", & - group="tallies/tally" // to_str(i), length=t % n_score_bins) - call sp % write_data(t % moment_order, "moment_order", & - group="tallies/tally" // to_str(i), length=t % n_score_bins) + call sp % write_data(tally % n_nuclide_bins, "n_nuclides", & + group="tallies/tally " // trim(to_str(tally % id))) - ! Write number of user score bins - call sp % write_data(t % n_user_score_bins, "n_user_score_bins", & - group="tallies/tally" // to_str(i)) + ! Set up nuclide bin array and then write + allocate(key_array(tally % n_nuclide_bins)) + NUCLIDE_LOOP: do j = 1, tally % n_nuclide_bins + key_array(j) = tally % nuclide_bins(j) + end do NUCLIDE_LOOP + call sp % write_data(key_array, "nuclides", & + group="tallies/tally " // trim(to_str(tally % id)), & + length=tally % n_nuclide_bins) + deallocate(key_array) - end do TALLY_METADATA + call sp % write_data(tally % n_score_bins, "n_score_bins", & + group="tallies/tally " // trim(to_str(tally % id))) + call sp % write_data(tally % score_bins, "score_bins", & + group="tallies/tally " // trim(to_str(tally % id)), & + length=tally % n_score_bins) + call sp % write_data(tally % moment_order, "moment_order", & + group="tallies/tally " // trim(to_str(tally % id)), & + length=tally % n_score_bins) + + end do TALLY_METADATA - ! Indicate where source bank is stored in statepoint - if (source_separate) then - call sp % write_data(0, "source_present") - else - call sp % write_data(1, "source_present") end if - end if ! Check for the no-tally-reduction method @@ -264,12 +328,12 @@ contains TALLY_RESULTS: do i = 1, n_tallies ! Set point to current tally - t => tallies(i) + tally => tallies(i) ! Write sum and sum_sq for each bin - call sp % write_tally_result(t % results, "results", & - group="tallies/tally" // to_str(i), & - n1=size(t % results, 1), n2=size(t % results, 2)) + call sp % write_tally_result(tally % results, "results", & + group="tallies/tally " // trim(to_str(tally % id)), & + n1=size(tally % results, 1), n2=size(tally % results, 2)) end do TALLY_RESULTS @@ -285,6 +349,10 @@ contains end if + if (master .and. n_tallies > 0) then + deallocate(id_array) + end if + end subroutine write_state_point !=============================================================================== @@ -391,7 +459,10 @@ contains #ifdef MPI real(8) :: dummy ! temporary receive buffer for non-root reduces #endif - type(TallyObject), pointer :: t => null() + integer, allocatable :: id_array(:) + type(ElemKeyValueII), pointer :: current => null() + type(ElemKeyValueII), pointer :: next => null() + type(TallyObject), pointer :: tally => null() type(TallyResult), allocatable :: tallyresult_temp(:,:) ! ========================================================================== @@ -448,22 +519,38 @@ contains ! Indicate that tallies are on if (master) then call sp % write_data(1, "tallies_present", group="tallies") + + ! Build list of tally IDs + current => tally_dict % keys() + allocate(id_array(n_tallies)) + i = 1 + + do while (associated(current)) + id_array(i) = current % value + ! Move to next tally + next => current % next + deallocate(current) + current => next + i = i + 1 + end do + end if ! Write all tally results TALLY_RESULTS: do i = 1, n_tallies - t => tallies(i) + + tally => tallies(i) ! Determine size of tally results array - m = size(t % results, 1) - n = size(t % results, 2) + m = size(tally % results, 1) + n = size(tally % results, 2) n_bins = m*n*2 ! Allocate array for storing sums and sums of squares, but ! contiguously in memory for each allocate(tally_temp(2,m,n)) - tally_temp(1,:,:) = t % results(:,:) % sum - tally_temp(2,:,:) = t % results(:,:) % sum_sq + tally_temp(1,:,:) = tally % results(:,:) % sum + tally_temp(2,:,:) = tally % results(:,:) % sum_sq if (master) then ! The MPI_IN_PLACE specifier allows the master to copy values into @@ -472,11 +559,12 @@ contains call MPI_REDUCE(MPI_IN_PLACE, tally_temp, n_bins, MPI_REAL8, & MPI_SUM, 0, MPI_COMM_WORLD, mpi_err) #endif + ! At the end of the simulation, store the results back in the ! regular TallyResults array if (current_batch == n_batches) then - t % results(:,:) % sum = tally_temp(1,:,:) - t % results(:,:) % sum_sq = tally_temp(2,:,:) + tally % results(:,:) % sum = tally_temp(1,:,:) + tally % results(:,:) % sum_sq = tally_temp(2,:,:) end if ! Put in temporary tally result @@ -485,8 +573,8 @@ contains tallyresult_temp(:,:) % sum_sq = tally_temp(2,:,:) ! Write reduced tally results to file - call sp % write_tally_result(t % results, "results", & - group="tallies/tally" // to_str(i), n1=m, n2=n) + call sp % write_tally_result(tally % results, "results", & + group="tallies/tally " // trim(to_str(tally % id)), n1=m, n2=n) ! Deallocate temporary tally result deallocate(tallyresult_temp) @@ -501,6 +589,9 @@ contains ! Deallocate temporary copy of tally results deallocate(tally_temp) end do TALLY_RESULTS + + deallocate(id_array) + else if (master) then ! Indicate that tallies are off @@ -516,16 +607,24 @@ contains subroutine load_state_point() - character(MAX_FILE_LEN) :: path_temp - character(19) :: current_time - integer :: i - integer :: j - integer :: length(4) - integer :: int_array(3) - integer, allocatable :: temp_array(:) - logical :: source_present - real(8) :: real_array(3) - type(TallyObject), pointer :: t => null() + character(MAX_FILE_LEN) :: path_temp + character(19) :: current_time + character(52) :: label + integer :: i, j, k + integer :: length(4) + integer :: int_array(3) + integer, allocatable :: id_array(:) + integer, allocatable :: key_array(:) + integer :: curr_key + integer, allocatable :: temp_array(:) + integer, allocatable :: temp_array3D(:,:,:) + integer, allocatable :: temp_array4D(:,:,:,:) + logical :: source_present + real(8) :: l + real(8) :: real_array(3) + real(8), allocatable :: temp_real_array(:) + type(StructuredMesh), pointer :: mesh => null() + type(TallyObject), pointer :: tally => null() ! Write message call write_message("Loading state point " // trim(path_state_point) & @@ -567,10 +666,22 @@ contains ! Read and overwrite run information except number of batches call sp % read_data(run_mode, "run_mode") call sp % read_data(n_particles, "n_particles") + call sp % read_data(int_array(1), "n_batches") + + ! Take maximum of statepoint n_batches and input n_batches + n_batches = max(n_batches, int_array(1)) ! Read batch number to restart at call sp % read_data(restart_batch, "current_batch") + ! Check for source in statepoint if needed + call sp % read_data(int_array(1), "source_present") + if (int_array(1) == 1) then + source_present = .true. + else + source_present = .false. + end if + if (restart_batch > n_batches) then call fatal_error("The number batches specified in settings.xml is fewer & & than the number of batches in the given statepoint file.") @@ -594,7 +705,7 @@ contains ! Read in to see if CMFD was on call sp % read_data(int_array(1), "cmfd_on") - ! Write out CMFD info + ! Read in CMFD info if (int_array(1) == 1) then call sp % read_data(cmfd % indices, "indices", length=4, group="cmfd") call sp % read_data(cmfd % k_cmfd, "k_cmfd", length=restart_batch, & @@ -603,7 +714,7 @@ contains call sp % read_data(cmfd % cmfd_src, "cmfd_src", & length=length, group="cmfd") call sp % read_data(cmfd % entropy, "cmfd_entropy", & - length=restart_batch, group="cmfd") + length=restart_batch, group="cmfd") call sp % read_data(cmfd % balance, "cmfd_balance", & length=restart_batch, group="cmfd") call sp % read_data(cmfd % dom, "cmfd_dominance", & @@ -614,127 +725,134 @@ contains end if ! Read number of meshes - call sp % read_data(n_meshes, "n_meshes", group="tallies") + call sp % read_data(n_meshes, "n_meshes", group="tallies/meshes") - ! Read and overwrite mesh information - MESH_LOOP: do i = 1, n_meshes - call sp % read_data(meshes(i) % id, "id", & - group="tallies/mesh" // to_str(i)) - call sp % read_data(meshes(i) % type, "type", & - group="tallies/mesh" // to_str(i)) - call sp % read_data(meshes(i) % n_dimension, "n_dimension", & - group="tallies/mesh" // to_str(i)) - call sp % read_data(meshes(i) % dimension, "dimension", & - group="tallies/mesh" // to_str(i), & - length=meshes(i) % n_dimension) - call sp % read_data(meshes(i) % lower_left, "lower_left", & - group="tallies/mesh" // to_str(i), & - length=meshes(i) % n_dimension) - call sp % read_data(meshes(i) % upper_right, "upper_right", & - group="tallies/mesh" // to_str(i), & - length=meshes(i) % n_dimension) - call sp % read_data(meshes(i) % width, "width", & - group="tallies/mesh" // to_str(i), & - length=meshes(i) % n_dimension) - end do MESH_LOOP + if (n_meshes > 0) then + + ! Read list of mesh keys-> IDs + allocate(id_array(n_meshes)) + allocate(key_array(n_meshes)) + + call sp % read_data(id_array, "ids", & + group="tallies/meshes", length=n_meshes) + call sp % read_data(key_array, "keys", & + group="tallies/meshes", length=n_meshes) + + ! Read and overwrite mesh information + MESH_LOOP: do i = 1, n_meshes + + mesh => meshes(id_array(i)) + curr_key = key_array(id_array(i)) + + call sp % read_data(mesh % id, "id", & + group="tallies/meshes/mesh " // trim(to_str(curr_key))) + call sp % read_data(mesh % type, "type", & + group="tallies/meshes/mesh " // trim(to_str(curr_key))) + call sp % read_data(mesh % n_dimension, "n_dimension", & + group="tallies/meshes/mesh " // trim(to_str(meshes(i) % id))) + call sp % read_data(mesh % dimension, "dimension", & + group="tallies/meshes/mesh " // trim(to_str(curr_key)), & + length=mesh % n_dimension) + call sp % read_data(mesh % lower_left, "lower_left", & + group="tallies/meshes/mesh " // trim(to_str(curr_key)), & + length=mesh % n_dimension) + call sp % read_data(mesh % upper_right, "upper_right", & + group="tallies/meshes/mesh " // trim(to_str(curr_key)), & + length=mesh % n_dimension) + call sp % read_data(mesh % width, "width", & + group="tallies/meshes/mesh " // trim(to_str(curr_key)), & + length=meshes(i) % n_dimension) + + end do MESH_LOOP + + deallocate(id_array) + deallocate(key_array) + + end if ! Read and overwrite number of tallies call sp % read_data(n_tallies, "n_tallies", group="tallies") + ! Read list of tally keys-> IDs + allocate(id_array(n_tallies)) + allocate(key_array(n_tallies)) + + call sp % read_data(id_array, "ids", group="tallies", length=n_tallies) + call sp % read_data(key_array, "keys", group="tallies", length=n_tallies) + ! Read in tally metadata TALLY_METADATA: do i = 1, n_tallies ! Get pointer to tally - t => tallies(i) + tally => tallies(i) + curr_key = key_array(id_array(i)) - ! Read tally id - call sp % read_data(t % id, "id", group="tallies/tally" // to_str(i)) - - ! Read number of realizations - call sp % read_data(t % n_realizations, "n_realizations", & - group="tallies/tally" // to_str(i)) - - ! Read size of tally results - call sp % read_data(int_array(1), "total_score_bins", & - group="tallies/tally" // to_str(i)) - call sp % read_data(int_array(2), "total_filter_bins", & - group="tallies/tally" // to_str(i)) - - ! Check size of tally results array - if (int_array(1) /= t % total_score_bins .and. & - int_array(2) /= t % total_filter_bins) then - call fatal_error("Input file tally structure is different from & - &restart.") + call sp % read_data(j, "label_size", group="tallies/tally " // & + trim(to_str(curr_key))) + if (j > 0) then + call sp % read_data(label, "label", group="tallies/tally " // & + trim(to_str(curr_key))) end if - ! Read number of filters - call sp % read_data(t % n_filters, "n_filters", & - group="tallies/tally" // to_str(i)) + call sp % read_data(tally % estimator, "estimator", & + group="tallies/tally " // trim(to_str(curr_key))) + call sp % read_data(tally % n_realizations, "n_realizations", & + group="tallies/tally " // trim(to_str(curr_key))) + call sp % read_data(tally % n_filters, "n_filters", & + group="tallies/tally " // trim(to_str(curr_key))) - ! Read filter information - FILTER_LOOP: do j = 1, t % n_filters - - ! Read type of filter - call sp % read_data(t % filters(j) % type, "type", & - group="tallies/tally" // trim(to_str(i)) // "/filter" // to_str(j)) - - ! Read number of bins for this filter - call sp % read_data(t % filters(j) % n_bins, "n_bins", & - group="tallies/tally" // trim(to_str(i)) // "/filter" // to_str(j)) - - ! Read bins - if (t % filters(j) % type == FILTER_ENERGYIN .or. & - t % filters(j) % type == FILTER_ENERGYOUT) then - call sp % read_data(t % filters(j) % real_bins, "bins", & - group="tallies/tally" // trim(to_str(i)) // "/filter" // to_str(j), & - length=size(t % filters(j) % real_bins)) + FILTER_LOOP: do j = 1, tally % n_filters + call sp % read_data(tally % filters(j) % type, "type", & + group="tallies/tally " // trim(to_str(curr_key)) // & + "/filter " // to_str(j)) + call sp % read_data(tally % filters(j) % n_bins, "n_bins", & + group="tallies/tally " // trim(to_str(curr_key)) // & + "/filter " // to_str(j)) + if (tally % filters(j) % type == FILTER_ENERGYIN .or. & + tally % filters(j) % type == FILTER_ENERGYOUT) then + call sp % read_data(tally % filters(j) % real_bins, "bins", & + group="tallies/tally " // trim(to_str(curr_key)) // & + "/filter " // to_str(j), & + length=size(tally % filters(j) % real_bins)) else - call sp % read_data(t % filters(j) % int_bins, "bins", & - group="tallies/tally" // trim(to_str(i)) // "/filter" // to_str(j), & - length=size(t % filters(j) % int_bins)) + call sp % read_data(tally % filters(j) % int_bins, "bins", & + group="tallies/tally " // trim(to_str(curr_key)) // & + "/filter " // to_str(j), & + length=size(tally % filters(j) % int_bins)) end if end do FILTER_LOOP - ! Read number of nuclide bins - call sp % read_data(t % n_nuclide_bins, "n_nuclide_bins", & - group="tallies/tally" // to_str(i)) + call sp % read_data(tally % n_nuclide_bins, "n_nuclides", & + group="tallies/tally " // trim(to_str(curr_key))) - ! Set up nuclide bin array and then write - allocate(temp_array(t % n_nuclide_bins)) - call sp % read_data(temp_array, "nuclide_bins", & - group="tallies/tally" // to_str(i), length=t % n_nuclide_bins) - NUCLIDE_LOOP: do j = 1, t % n_nuclide_bins + ! Set up nuclide bin array and then read + allocate(temp_array(tally % n_nuclide_bins)) + call sp % read_data(temp_array, "nuclides", & + group="tallies/tally " // trim(to_str(curr_key)), & + length=tally % n_nuclide_bins) + + NUCLIDE_LOOP: do j = 1, tally % n_nuclide_bins if (temp_array(j) > 0) then - nuclides(t % nuclide_bins(j)) % zaid = temp_array(j) + tally % nuclide_bins(j) = temp_array(j) else - t % nuclide_bins(j) = temp_array(j) + tally % nuclide_bins(j) = temp_array(j) end if end do NUCLIDE_LOOP + deallocate(temp_array) - ! Write number of score bins, score bins, and scatt order - call sp % read_data(t % n_score_bins, "n_score_bins", & - group="tallies/tally" // to_str(i)) - call sp % read_data(t % score_bins, "score_bins", & - group="tallies/tally" // to_str(i), length=t % n_score_bins) - call sp % read_data(t % moment_order, "moment_order", & - group="tallies/tally" // to_str(i), length=t % n_score_bins) - - ! Write number of user score bins - call sp % read_data(t % n_user_score_bins, "n_user_score_bins", & - group="tallies/tally" // to_str(i)) + call sp % read_data(tally % n_score_bins, "n_score_bins", & + group="tallies/tally " // trim(to_str(curr_key))) + call sp % read_data(tally % score_bins, "score_bins", & + group="tallies/tally " // trim(to_str(curr_key)), & + length=tally % n_score_bins) + call sp % read_data(tally % moment_order, "moment_order", & + group="tallies/tally " // trim(to_str(curr_key)), & + length=tally % n_score_bins) end do TALLY_METADATA - ! Check for source in statepoint if needed - call sp % read_data(int_array(1), "source_present") - if (int_array(1) == 1) then - source_present = .true. - else - source_present = .false. - end if - ! Check to make sure source bank is present if (path_source_point == path_state_point .and. .not. source_present) then call fatal_error("Source bank must be contained in statepoint restart & @@ -759,24 +877,30 @@ contains n1=N_GLOBAL_TALLIES, n2=1) ! Check if tally results are present - call sp % read_data(int_array(1), "tallies_present", group="tallies", collect=.false.) + call sp % read_data(int_array(1), "tallies_present", & + group="tallies", collect=.false.) ! Read in sum and sum squared if (int_array(1) == 1) then TALLY_RESULTS: do i = 1, n_tallies ! Set pointer to tally - t => tallies(i) + tally => tallies(i) + curr_key = key_array(id_array(i)) ! Read sum and sum_sq for each bin - call sp % read_tally_result(t % results, "results", & - group="tallies/tally" // to_str(i), & - n1=size(t % results, 1), n2=size(t % results, 2)) + call sp % read_tally_result(tally % results, "results", & + group="tallies/tally " // trim(to_str(curr_key)), & + n1=size(tally % results, 1), n2=size(tally % results, 2)) end do TALLY_RESULTS + end if end if + deallocate(id_array) + deallocate(key_array) + ! Read source if in eigenvalue mode if (run_mode == MODE_EIGENVALUE) then diff --git a/src/utils/openmc/__init__.py b/src/utils/openmc/__init__.py index 5e5ec08b99..2f3a9b6de4 100644 --- a/src/utils/openmc/__init__.py +++ b/src/utils/openmc/__init__.py @@ -14,6 +14,6 @@ from openmc.executor import * #from statepoint import * try: - from openmc.opencg_compatible import * + from openmc.opencg_compatible import * except ImportError: - pass + pass diff --git a/src/utils/openmc/nuclide.py b/src/utils/openmc/nuclide.py index c35a22fc6e..8603c833b8 100644 --- a/src/utils/openmc/nuclide.py +++ b/src/utils/openmc/nuclide.py @@ -10,6 +10,7 @@ class Nuclide(object): # Initialize class attributes self._name = '' self._xs = None + self._zaid = None # Set the Material class attributes self.set_name(name) @@ -63,8 +64,20 @@ class Nuclide(object): self._xs = xs + def set_zaid(self, zaid): + + if not is_integer(zaid): + msg = 'Unable to set zaid for Nuclide ' \ + 'with a non-integer {0}'.format(zaid) + raise ValueError(msg) + + self._zaid = zaid + + def __repr__(self): string = 'Nuclide - {0}\n'.format(self._name) string += '{0: <16}{1}{2}\n'.format('\tXS', '=\t', self._xs) - return string + if self._zaid is not None: + string += '{0: <16}{1}{2}\n'.format('\tZAID', '=\t', self._zaid) + return string \ No newline at end of file diff --git a/src/utils/openmc/opencg_compatible.py b/src/utils/openmc/opencg_compatible.py index 6fab1681b3..d14bfadc06 100644 --- a/src/utils/openmc/opencg_compatible.py +++ b/src/utils/openmc/opencg_compatible.py @@ -370,10 +370,10 @@ def get_opencg_cell(openmc_cell): else: opencg_cell.setFill(get_opencg_lattice(fill)) - if openmc_cell._rotation: + if openmc_cell._rotation is not None: opencg_cell.setRotation(openmc_cell._rotation) - if openmc_cell._translation: + if openmc_cell._translation is not None: opencg_cell.setTranslation(openmc_cell._translation) surfaces = openmc_cell._surfaces @@ -573,7 +573,7 @@ def get_openmc_cell(opencg_cell): openmc_cell.set_rotation(rotation) if opencg_cell._translation: - translation = np.asarray(opencg_cell._translation, dtype=np.int) + translation = np.asarray(opencg_cell._translation, dtype=np.float64) openmc_cell.setTranslation(translation) surfaces = opencg_cell._surfaces @@ -702,12 +702,6 @@ def get_opencg_lattice(openmc_lattice): universe_id = universes[x][y][z]._id universe_array[z][y][x] = unique_universes[universe_id] - # Transpose, reverse y-dimension in array for appropriate ordering in OpenCG - shape = universe_array.shape - universe_array = np.transpose(universe_array) - universe_array.shape = shape - universe_array = universe_array[:,::-1,:] - opencg_lattice = opencg.Lattice(lattice_id, name) opencg_lattice.setDimension(dimension) opencg_lattice.setWidth(width) diff --git a/src/utils/openmc/statepoint.py b/src/utils/openmc/statepoint.py index b51b69c3fa..627a09c0b5 100644 --- a/src/utils/openmc/statepoint.py +++ b/src/utils/openmc/statepoint.py @@ -1,137 +1,38 @@ -#!/usr/bin/env python2 - -import struct -from collections import OrderedDict +#!/usr/bin/env python +import struct, copy import numpy as np import scipy.stats +import openmc +from openmc.constants import * -REVISION_STATEPOINT = 13 - -filter_types = {1: 'universe', 2: 'material', 3: 'cell', 4: 'cellborn', - 5: 'surface', 6: 'mesh', 7: 'energyin', 8: 'energyout'} - -score_types = {-1: 'flux', - -2: 'total', - -3: 'scatter', - -4: 'nu-scatter', - -5: 'scatter-n', - -6: 'scatter-pn', - -7: 'nu-scatter-n', - -8: 'nu-scatter-pn', - -9: 'transport', - -10: 'n1n', - -11: 'absorption', - -12: 'fission', - -13: 'nu-fission', - -14: 'kappa-fission', - -15: 'current', - -16: 'flux-yn', - -17: 'total-yn', - -18: 'scatter-yn', - -19: 'nu-scatter-yn', - -20: 'events', - 1: '(n,total)', - 2: '(n,elastic)', - 4: '(n,level)', - 11: '(n,2nd)', - 16: '(n,2n)', - 17: '(n,3n)', - 18: '(n,fission)', - 19: '(n,f)', - 20: '(n,nf)', - 21: '(n,2nf)', - 22: '(n,na)', - 23: '(n,n3a)', - 24: '(n,2na)', - 25: '(n,3na)', - 28: '(n,np)', - 29: '(n,n2a)', - 30: '(n,2n2a)', - 32: '(n,nd)', - 33: '(n,nt)', - 34: '(n,nHe-3)', - 35: '(n,nd2a)', - 36: '(n,nt2a)', - 37: '(n,4n)', - 38: '(n,3nf)', - 41: '(n,2np)', - 42: '(n,3np)', - 44: '(n,n2p)', - 45: '(n,npa)', - 91: '(n,nc)', - 101: '(n,disappear)', - 102: '(n,gamma)', - 103: '(n,p)', - 104: '(n,d)', - 105: '(n,t)', - 106: '(n,3He)', - 107: '(n,a)', - 108: '(n,2a)', - 109: '(n,3a)', - 111: '(n,2p)', - 112: '(n,pa)', - 113: '(n,t2a)', - 114: '(n,d2a)', - 115: '(n,pd)', - 116: '(n,pt)', - 117: '(n,da)', - 201: '(n,Xn)', - 202: '(n,Xgamma)', - 203: '(n,Xp)', - 204: '(n,Xd)', - 205: '(n,Xt)', - 206: '(n,X3He)', - 207: '(n,Xa)', - 444: '(damage)', - 649: '(n,pc)', - 699: '(n,dc)', - 749: '(n,tc)', - 799: '(n,3Hec)', - 849: '(n,tc)'} -score_types.update({MT: '(n,n' + str(MT-50) + ')' for MT in range(51,91)}) -score_types.update({MT: '(n,p' + str(MT-600) + ')' for MT in range(600,649)}) -score_types.update({MT: '(n,d' + str(MT-650) + ')' for MT in range(650,699)}) -score_types.update({MT: '(n,t' + str(MT-700) + ')' for MT in range(700,749)}) -score_types.update({MT: '(n,3He' + str(MT-750) + ')' for MT in range(750,649)}) -score_types.update({MT: '(n,a' + str(MT-800) + ')' for MT in range(800,849)}) - -class Mesh(object): - def __init__(self): - pass - - def __repr__(self): - if hasattr(self, "dimension"): - return "".format(tuple(self.dimension)) - else: - return "" - -class Filter(object): - def __init__(self): - self.type = 0 - self.bins = [] - - def __repr__(self): - return "".format(self.type) - -class Tally(object): - def __init__(self): - self.filters = OrderedDict() class SourceSite(object): + def __init__(self): - self.weight = None - self.xyz = None - self.uvw = None - self.E = None + + self._weight = None + self._xyz = None + self._uvw = None + self._E = None + def __repr__(self): - return "".format(self.xyz, self.E) + + string = 'SourceSite\n' + string += '{0: <16}{1}{2}\n'.format('\tweight', '=\t', self._weight) + string += '{0: <16}{1}{2}\n'.format('\tE', '=\t', self._E) + string += '{0: <16}{1}{2}\n'.format('\t(x,y,z)', '=\t', self._xyz) + string += '{0: <16}{1}{2}\n'.format('\t(u,v,w)', '=\t', self._uvw) + return string + class StatePoint(object): + def __init__(self, filename): + if filename.endswith('.h5'): import h5py self._f = h5py.File(filename, 'r') @@ -140,460 +41,640 @@ class StatePoint(object): self._f = open(filename, 'rb') self._hdf5 = False - # Set flags for what data was read - self._metadata = False + # Set flags for what data has been read self._results = False self._source = False - - # Initialize arrays for meshes and tallies - self.meshes = [] - self.tallies = [] - self.source = [] + self._with_summary = False # Read all metadata self._read_metadata() + # Read information about tally meshes + self._read_meshes() + + # Read tally metadata + self._read_tallies() + + + @property + def k_combined(self): + return self._k_combined + + @property + def n_particles(self): + return self._n_particles + + @property + def n_batches(self): + return self._n_batches + + @property + def current_batch(self): + return self._current_batch + + @property + def results(self): + return self._results + + @property + def source(self): + return self._source + + @property + def with_summary(self): + return self._with_summary + + @property + def tallies(self): + return self._tallies + + def _read_metadata(self): + # Read filetype - self.filetype = self._get_int(path='filetype')[0] + self._filetype = self._get_int(path='filetype')[0] # Read statepoint revision - self.revision = self._get_int(path='revision')[0] - if self.revision != REVISION_STATEPOINT: - raise Exception('Statepoint Revision is not consistent.') + self._revision = self._get_int(path='revision')[0] + if self._revision != 13: + raise Exception('Statepoint Revision is not consistent.') # Read OpenMC version if self._hdf5: - self.version = [self._get_int(path='version_major')[0], - self._get_int(path='version_minor')[0], - self._get_int(path='version_release')[0]] + self._version = [self._get_int(path='version_major')[0], + self._get_int(path='version_minor')[0], + self._get_int(path='version_release')[0]] else: - self.version = self._get_int(3) + self._version = self._get_int(3) # Read date and time - self.date_and_time = self._get_string(19, path='date_and_time') + self._date_and_time = self._get_string(19, path='date_and_time') # Read path - self.path = self._get_string(255, path='path').strip() + self._path = self._get_string(255, path='path').strip() # Read random number seed - self.seed = self._get_long(path='seed')[0] + self._seed = self._get_long(path='seed')[0] # Read run information - self.run_mode = self._get_int(path='run_mode')[0] - self.n_particles = self._get_long(path='n_particles')[0] + self._run_mode = self._get_int(path='run_mode')[0] + self._n_particles = self._get_long(path='n_particles')[0] + self._n_batches = self._get_int(path='n_batches')[0] # Read current batch - self.current_batch = self._get_int(path='current_batch')[0] + self._current_batch = self._get_int(path='current_batch')[0] + + # Read whether or not the source site distribution is present + self._source_present = self._get_int(path='source_present')[0] # Read criticality information - if self.run_mode == 2: - self.n_inactive = self._get_int(path='n_inactive')[0] - self.gen_per_batch = self._get_int(path='gen_per_batch')[0] - self.k_batch = self._get_double( - self.current_batch*self.gen_per_batch, path='k_generation') - self.entropy = self._get_double( - self.current_batch*self.gen_per_batch, path='entropy') - self.k_col_abs = self._get_double(path='k_col_abs')[0] - self.k_col_tra = self._get_double(path='k_col_tra')[0] - self.k_abs_tra = self._get_double(path='k_abs_tra')[0] - self.k_combined = self._get_double(2, path='k_combined') + if self._run_mode == 2: + self._read_criticality() - # Read CMFD information - cmfd_present = self._get_int(path='cmfd_on')[0] - if cmfd_present == 1: - self.cmfd_indices = self._get_int(4, path='cmfd/indices') - self.k_cmfd = self._get_double(self.current_batch, - path='cmfd/k_cmfd') - self.cmfd_src = self._get_double_array(np.product(self.cmfd_indices), - path='cmfd/cmfd_src') - self.cmfd_src = np.reshape(self.cmfd_src, - tuple(self.cmfd_indices), order='F') - self.cmfd_entropy = self._get_double(self.current_batch, - path='cmfd/cmfd_entropy') - self.cmfd_balance = self._get_double(self.current_batch, - path='cmfd/cmfd_balance') - self.cmfd_dominance = self._get_double(self.current_batch, - path='cmfd/cmfd_dominance') - self.cmfd_srccmp = self._get_double(self.current_batch, - path='cmfd/cmfd_srccmp') - # Read number of meshes - n_meshes = self._get_int(path='tallies/n_meshes')[0] + def _read_criticality(self): - # Read meshes - for i in range(n_meshes): - m = Mesh() - self.meshes.append(m) + # Read criticality information + if self._run_mode == 2: - base = 'tallies/mesh' + str(i+1) + '/' + self._n_inactive = self._get_int(path='n_inactive')[0] + self._gen_per_batch = self._get_int(path='gen_per_batch')[0] + self._k_batch = self._get_double( + self._current_batch*self._gen_per_batch, + path='k_generation') + self._entropy = self._get_double( + self._current_batch*self._gen_per_batch, path='entropy') - # Read id, mesh type, and number of dimensions - m.id = self._get_int(path=base+'id')[0] - m.type = self._get_int(path=base+'type')[0] - n = self._get_int(path=base+'n_dimension')[0] + self._k_col_abs = self._get_double(path='k_col_abs')[0] + self._k_col_tra = self._get_double(path='k_col_tra')[0] + self._k_abs_tra = self._get_double(path='k_abs_tra')[0] + self._k_combined = self._get_double(2, path='k_combined') - # Read mesh size, lower-left coordinates, upper-right coordinates, - # and width of each mesh cell - m.dimension = self._get_int(n, path=base+'dimension') - m.lower_left = self._get_double(n, path=base+'lower_left') - m.upper_right = self._get_double(n, path=base+'upper_right') - m.width = self._get_double(n, path=base+'width') + # Read CMFD information (if used) + self._read_cmfd() - # Read number of tallies - n_tallies = self._get_int(path='tallies/n_tallies')[0] - for i in range(n_tallies): - # Create Tally object and add to list of tallies - t = Tally() - self.tallies.append(t) + def _read_cmfd(self): - base = 'tallies/tally' + str(i+1) + '/' + base = 'cmfd' - # Read id and number of realizations - t.id = self._get_int(path=base+'id')[0] - t.n_realizations = self._get_int(path=base+'n_realizations')[0] + # Read CMFD information + self._cmfd_on = self._get_int(path='cmfd_on')[0] - # Read sizes of tallies - t.total_score_bins = self._get_int(path=base+'total_score_bins')[0] - t.total_filter_bins = self._get_int(path=base+'total_filter_bins')[0] + if self._cmfd_on == 1: - # Read number of filters - n_filters = self._get_int(path=base+'n_filters')[0] + self._cmfd_indices = self._get_int(4, path='{0}/indices'.format(base)) + self._k_cmfd = self._get_double(self._current_batch, + path='{0}/k_cmfd'.format(base)) + self._cmfd_src = self._get_double_array(np.product(self._cmfd_indices), + path='{0}/cmfd_src'.format(base)) + self._cmfd_src = np.reshape(self._cmfd_src, tuple(self._cmfd_indices), + order='F') + self._cmfd_entropy = self._get_double(self._current_batch, + path='{0}/cmfd_entropy'.format(base)) + self._cmfd_balance = self._get_double(self._current_batch, + path='{0}/cmfd_balance'.format(base)) + self._cmfd_dominance = self._get_double(self._current_batch, + path='{0}/cmfd_dominance'.format(base)) + self._cmfd_srccmp = self._get_double(self._current_batch, + path='{0}/cmfd_srccmp'.format(base)) - for j in range(n_filters): - # Create Filter object - f = Filter() - base = 'tallies/tally{0}/filter{1}/'.format(i+1, j+1) + def _read_meshes(self): - # Get type of filter - f.type = filter_types[self._get_int(path=base+'type')[0]] + # Initialize dictionaries for the Meshes + # Keys - Mesh IDs + # Values - Mesh objects + self._meshes = dict() - # Add to filter dictionary - t.filters[f.type] = f + # Read the number of Meshes + self._n_meshes = self._get_int(path='tallies/meshes/n_meshes')[0] - # Determine how many bins are in this filter - f.length = self._get_int(path=base+'n_bins')[0] - assert f.length > 0 - if f.type == 'energyin' or f.type == 'energyout': - f.bins = self._get_double(f.length + 1, path=base+'bins') - elif f.type == 'mesh': - f.bins = self._get_int(path=base+'bins') - else: - f.bins = self._get_int(f.length, path=base+'bins') + # Read a list of the IDs for each Mesh + if self._n_meshes > 0: - base = 'tallies/tally' + str(i+1) + '/' + # OpenMC Mesh IDs (redefined internally from user definitions) + self._mesh_ids = self._get_int(self._n_meshes, + path='tallies/meshes/ids') - # Read nuclide bins - n_nuclides = self._get_int(path=base+'n_nuclide_bins')[0] - t.n_nuclides = n_nuclides - t.nuclides = self._get_int(n_nuclides, path=base+'nuclide_bins') + # User-defined Mesh IDs + self._mesh_keys = self._get_int(self._n_meshes, + path='tallies/meshes/keys') - # Read score bins and scattering order - t.n_scores = self._get_int(path=base+'n_score_bins')[0] - t.scores = [score_types[j] for j in self._get_int( - t.n_scores, path=base+'score_bins')] - t.moment_order = self._get_int(t.n_scores, path=base+'moment_order') - - # Read number of user score bins - t.n_user_scores = self._get_int(path=base+'n_user_score_bins')[0] - - # Set up stride - stride = 1 - for f in list(t.filters.values())[::-1]: - f.stride = stride - stride *= f.length - - # Source bank present - source_present = self._get_int(path='source_present')[0] - if source_present == 1: - self.source_present = True else: - self.source_present = False + self._mesh_keys = list() + self._mesh_ids = list() + + # Build dictionary of Meshes + base = 'tallies/meshes/mesh ' + + # Iterate over all Meshes + for mesh_key in self._mesh_keys: + + # Read the user-specified Mesh ID and type + mesh_id = self._get_int(path='{0}{1}/id'.format(base, mesh_key))[0] + mesh_type = self._get_int(path='{0}{1}/type'.format(base, mesh_key))[0] + + # Get the Mesh dimension + n_dimension = self._get_int( + path='{0}{1}/n_dimension'.format(base, mesh_key))[0] + + # Read the mesh dimensions, lower-left coordinates, + # upper-right coordinates, and width of each mesh cell + dimension = self._get_int( + n_dimension, path='{0}{1}/dimension'.format(base, mesh_key)) + lower_left = self._get_double( + n_dimension, path='{0}{1}/lower_left'.format(base, mesh_key)) + upper_right = self._get_double( + n_dimension, path='{0}{1}/upper_right'.format(base, mesh_key)) + width = self._get_double( + n_dimension, path='{0}{1}/width'.format(base, mesh_key)) + + # Create the Mesh and assign properties to it + mesh = openmc.Mesh(mesh_id) + + mesh.set_dimension(dimension) + mesh.set_width(width) + mesh.set_lower_left(lower_left) + mesh.set_upper_right(upper_right) + + #FIXME: Set the mesh type to 'rectangular' by default + mesh.set_type('rectangular') + + # Add mesh to the global dictionary of all Meshes + self._meshes[mesh_id] = mesh + + + def _read_tallies(self): + + # Initialize dictionaries for the Tallies + # Keys - Tally IDs + # Values - Tally objects + self._tallies = dict() + + # Read the number of tallies + self._n_tallies = self._get_int(path='/tallies/n_tallies')[0] + + # Read a list of the IDs for each Tally + if self._n_tallies > 0: + + # OpenMC Tally IDs (redefined internally from user definitions) + self._tally_ids = self._get_int( + self._n_tallies, path='tallies/ids') + + # User-defined Tally IDs + self._tally_keys = self._get_int( + self._n_tallies, path='tallies/keys') + + else: + self._tally_keys = list() + self._tally_ids = list() + + base = 'tallies/tally ' + + # Iterate over all Tallies + for tally_key in self._tally_keys: + + # Read user-specified Tally label (if specified) + label_size = self._get_int( + path='{0}{1}/label_size'.format(base, tally_key))[0] + + if label_size > 0: + label = self._get_string( + label_size, path='{0}{1}/label'.format(base, tally_key)) + + # Remove leading and trailing characters from string label + label = label.lstrip('[\'') + label = label.rstrip('\']') + + # Read integer Tally estimator type code (analog or tracklength) + estimator_type = self._get_int( + path='{0}{1}/estimator'.format(base, tally_key))[0] + + # Read the Tally size specifications + n_realizations = self._get_int( + path='{0}{1}/n_realizations'.format(base, tally_key))[0] + + # Create Tally object and assign basic properties + tally = openmc.Tally(tally_key, label) + tally.set_estimator(ESTIMATOR_TYPES[estimator_type]) + tally.set_num_realizations(n_realizations) + + # Read the number of Filters + n_filters = self._get_int( + path='{0}{1}/n_filters'.format(base, tally_key))[0] + + subbase = '{0}{1}/filter '.format(base, tally_key) + + # Initialize the stride + stride = 1 + + # Initialize all Filters + for j in range(1, n_filters+1): + + # Read the integer Filter type code + filter_type = self._get_int( + path='{0}{1}/type'.format(subbase, j))[0] + + n_bins = self._get_int( + path='{0}{1}/n_bins'.format(subbase, j))[0] + + if n_bins <= 0: + msg = 'Unable to create Filter {0} for Tally ID={2} ' \ + 'since no bins were specified'.format(j, tally_key) + raise ValueError(msg) + + # Read the bin values + if FILTER_TYPES[filter_type] in ['energy', 'energyout']: + bins = self._get_double( + n_bins+1, path='{0}{1}/bins'.format(subbase, j)) + + # FIXME + elif FILTER_TYPES[filter_type] in ['mesh', 'distribcell']: + bins = self._get_int( + path='{0}{1}/bins'.format(subbase, j))[0] + + else: + bins = self._get_int( + n_bins, path='{0}{1}/bins'.format(subbase, j)) + + # Create Filter object + filter = openmc.Filter(FILTER_TYPES[filter_type], bins) + filter.set_stride(stride) + filter.set_num_bins(n_bins) + + if FILTER_TYPES[filter_type] == 'mesh': + filter.set_mesh(self._meshes[bins]) + + # Add Filter to the Tally + tally.add_filter(filter) + + # Update the stride for the next Filter + stride *= n_bins + + # Read Nuclide bins + n_nuclides = self._get_int( + path='{0}{1}/n_nuclides'.format(base, tally_key))[0] + + nuclide_zaids = self._get_int( + n_nuclides, path='{0}{1}/nuclides'.format(base, tally_key)) + + # Add all Nuclides to the Tally + for nuclide_zaid in nuclide_zaids: + tally.add_nuclide(nuclide_zaid) + + # Read score bins + n_score_bins = self._get_int( + path='{0}{1}/n_score_bins'.format(base, tally_key))[0] + + tally.set_num_score_bins(n_score_bins) + + scores = [SCORE_TYPES[j] for j in self._get_int( + n_score_bins, path='{0}{1}/score_bins'.format(base, tally_key))] + + # Read the scattering moment order for all scores + scatt_order = self._get_int( + n_score_bins, path='{0}{1}/moment_order'.format(base, tally_key)) + + # Add the scores to the Tally + for j, score in enumerate(scores): + + # If this is a scattering moment, insert the scattering order + if 'scatter-n' in score or 'scatter-yn' in score or 'scatter-pn' in score: + score = score.replace('n', str(scatt_order[j])) + + tally.add_score(score) + + # Add Tally to the global dictionary of all Tallies + self._tallies[tally_key] = tally - # Set flag indicating metadata has already been read - self._metadata = True def read_results(self): - # Check whether metadata has been read - if not self._metadata: - self._read_metadata() - # Number of realizations for global tallies - self.n_realizations = self._get_int(path='n_realizations')[0] + # Number of realizations for global Tallies + self._n_realizations = self._get_int(path='n_realizations')[0] - # Read global tallies + # Read global Tallies n_global_tallies = self._get_int(path='n_global_tallies')[0] + if self._hdf5: data = self._f['global_tallies'].value - self.global_tallies = np.column_stack((data['sum'], data['sum_sq'])) + self._global_tallies = np.column_stack((data['sum'], data['sum_sq'])) + else: - self.global_tallies = np.array(self._get_double(2*n_global_tallies)) - self.global_tallies.shape = (n_global_tallies, 2) + self._global_tallies = np.array(self._get_double(2*n_global_tallies)) + self._global_tallies.shape = (n_global_tallies, 2) - # Flag indicating if tallies are present - tallies_present = self._get_int(path='tallies/tallies_present')[0] + # Flag indicating if Tallies are present + self._tallies_present = self._get_int(path='tallies/tallies_present')[0] - # Read tally results - if tallies_present: - for i, t in enumerate(self.tallies): - n = t.total_score_bins * t.total_filter_bins + base = 'tallies/tally ' + + # Read Tally results + if self._tallies_present: + + # Iterate over and extract the results for all Tallies + for tally_key in self._tally_keys: + + # Get this Tally + tally = self._tallies[tally_key] + + # Compute the total number of bins for this Tally + num_tot_bins = tally.get_num_bins() + + # Extract Tally data from the file if self._hdf5: - path = 'tallies/tally{0}/results'.format(i+1) - data = self._f[path].value - t.results = np.column_stack((data['sum'], data['sum_sq'])) - t.results.shape = (t.total_filter_bins, t.total_score_bins, 2) - else: - t.results = np.array(self._get_double(2*n)) - t.results.shape = (t.total_filter_bins, t.total_score_bins, 2) + data = self._f['{0}{1}/results'.format(base, tally_key)].value + sum = data['sum'] + sum_sq = data['sum_sq'] - # Indicate that tally results have been read + else: + results = np.array(self._get_double(2*num_tot_bins)) + sum = results[0::2] + sum_sq = results[1::2] + + # Define a routine to convert 0 to 1 + nonzero = lambda val: 1 if not val else val + + # Reshape the results arrays + new_shape = (nonzero(tally.get_num_filter_bins()), + nonzero(tally.get_num_nuclides()), + nonzero(tally.get_num_score_bins())) + + sum = np.reshape(sum, new_shape) + sum_sq = np.reshape(sum_sq, new_shape) + + # Set the data for this Tally + tally.set_results(sum=sum, sum_sq=sum_sq) + + # Indicate that Tally results have been read self._results = True + def read_source(self): - # Check whether tally results have been read + + # Check whether Tally results have been read if not self._results: self.read_results() # Check if source bank is in statepoint - if not self.source_present: - print('Source not in statepoint file.') + if not self._source_present: + print('Unable to read source since it is not in statepoint file') return + # Initialize a NumPy array for the source sites + self._source = np.empty(self._n_particles, dtype=SourceSite) + # For HDF5 state points, copy entire bank if self._hdf5: source_sites = self._f['source_bank'].value - for i in range(self.n_particles): - s = SourceSite() - self.source.append(s) + # Initialize SourceSite object for each particle + for i in range(self._n_particles): + + # Initialize new source site + site = SourceSite() # Read position, angle, and energy if self._hdf5: - s.weight, s.xyz, s.uvw, s.E = source_sites[i] + site._weight, site._xyz, site._uvw, site._E = source_sites[i] else: - s.weight = self._get_double()[0] - s.xyz = self._get_double(3) - s.uvw = self._get_double(3) - s.E = self._get_double()[0] + site._weight = self._get_double()[0] + site._xyz = self._get_double(3) + site._uvw = self._get_double(3) + site._E = self._get_double()[0] - def generate_ci(self, confidence=0.95): - """Calculates confidence intervals for each tally bin.""" + # Store the source site in the NumPy array + self._source[i] = site - # Determine number of realizations - n = self.n_realizations + + def compute_ci(self, confidence=0.95): + """Computes confidence intervals for each Tally bin.""" # Determine significance level and percentile for two-sided CI alpha = 1 - confidence percentile = 1 - alpha/2 # Calculate t-value - t_value = scipy.stats.t.ppf(percentile, n - 1) - self.generate_stdev(t_value) + t_value = scipy.stats.t.ppf(percentile, self._n_realizations - 1) + self.compute_stdev(t_value) - def generate_stdev(self, t_value=1.0): + + def compute_stdev(self, t_value=1.0): """ - Calculates the sample mean and standard deviation of the mean for each - tally bin. + Computes the sample mean and the standard deviation of the mean + for each Tally bin. """ # Determine number of realizations - n = self.n_realizations + n = self._n_realizations + + # Calculate the standard deviation for each global tally + for i in range(len(self._global_tallies)): - # Global tallies - for i in range(len(self.global_tallies)): # Get sum and sum of squares - s, s2 = self.global_tallies[i] + s, s2 = self._global_tallies[i] # Calculate sample mean and replace value s /= n - self.global_tallies[i,0] = s + self._global_tallies[i, 0] = s # Calculate standard deviation if s != 0.0: - self.global_tallies[i,1] = t_value*np.sqrt((s2/n - s*s)/(n-1)) + self._global_tallies[i, 1] = t_value * np.sqrt((s2 / n - s**2) / (n-1)) - # Regular tallies - for t in self.tallies: - for i in range(t.results.shape[0]): - for j in range(t.results.shape[1]): - # Get sum and sum of squares - s, s2 = t.results[i,j] - # Calculate sample mean and replace value - s /= n - t.results[i,j,0] = s + # Calculate sample mean and standard deviation for user-defined Tallies + for tally_id, tally in self._tallies.items(): + tally.compute_std_dev(t_value) - # Calculate standard deviation - if s != 0.0: - t.results[i,j,1] = t_value*np.sqrt((s2/n - s*s)/(n-1)) - def get_value(self, tally_index, spec_list, score_index): - """Returns a tally score given a list of filters to satisfy. + def get_tally(self, score, filters, nuclides, + label='', estimator='tracklength'): + """Finds and returns a Tally object with certain properties. Parameters ---------- - tally_index : int - Index for tally in StatePoint.tallies list + score : str + The score string - spec_list : list - A list of tuples where the first value in each tuple is the filter - type, e.g. 'cell', and the second value is the desired index. If the - first value in the tuple is 'mesh', the second value should be a - tuple with three integers specifying the mesh indices. + filters : list + A list of Filter objects - Example: [('cell', 1), ('mesh', (14,17,20)), ('energyin', 2)] + nuclides : list + A list of Nuclide objects - score_index : int - Index corresponding to score for tally, i.e. the second index in - Tally.results[:,:,:]. + label : str + The label specified for the Tally (default is '') + estimator: str + The type of estimator ('tracklength' (default) or 'analog') """ - # Get Tally object given the index - t = self.tallies[tally_index] + # Loop over the domain-to-tallies mapping to find the Tally + tally = None - # Initialize index for filter in Tally.results[:,:,:] - filter_index = 0 + # Iterate over all tallies to find the appropriate one + for tally_id, test_tally in self._tallies.items(): - # Loop over specified filters in spec_list - for f_type, f_index in spec_list: + # Determine if the queried Tally label is the same as this Tally + if not label == test_tally._label: + continue - # Treat mesh filter separately - if f_type == 'mesh': - # Get index in StatePoint.meshes - mesh_index = t.filters['mesh'].bins[0] - 1 + # Determine if the queried Tally estimator is the same as this Tally + if not estimator == test_tally._estimator: + continue - # Get dimensions of corresponding mesh - nx, ny, nz = self.meshes[mesh_index].dimension + # Determine if the queried Tally scores are the same as this Tally + if not score in test_tally._scores: + continue - # Convert (x,y,z) to a single bin -- this is similar to - # subroutine mesh_indices_to_bin in openmc/src/mesh.F90. - value = ((f_index[0] - 1)*ny*nz + - (f_index[1] - 1)*nz + - (f_index[2] - 1)) - filter_index += value*t.filters[f_type].stride - else: - filter_index += f_index*t.filters[f_type].stride + # Determine if queried Tally filters is the same length as this Tally + if len(filters) != len(test_tally._filters): + continue - # Return the desired result from Tally.results. This could be the sum and - # sum of squares, or it could be mean and stdev if self.generate_stdev() - # has been called already. - return t.results[filter_index, score_index] + # Determine if the queried Tally filters are the same as this Tally + contains_filters = True - def extract_results(self, tally_id, score_str): - """Returns a tally results dictionary given a tally_id and score string. + # Iterate over the filters requested by the user + for filter in filters: + if not filter in test_tally._filters: + contains_filters = False + break - Parameters - ---------- - tally_id : int - Index for the tally in StatePoint.tallies list + # Determine if the queried Nuclide is in this Tally + contains_nuclides = True - score_str : string - Corresponds to the string entered for a score in tallies.xml. - For a flux score extraction it would be 'score' + # Iterate over the Nuclides requested by the user + for nuclide in nuclides: + if not nuclide in test_tally._nuclides: + contains_nuclides = False + break + # If the Tally contained all Filters and Nuclides, return the Tally + if contains_filters and contains_nuclides: + tally = test_tally + break + + # If we did not find the Tally, return an error message + if tally is None: + raise LookupError('Unable to get Tally') + + return tally + + + def get_tally_id(self, score, filters, label='', estimator='tracklength'): + """Retrieve the Tally ID for a given list of filters and score(s). + + Parameters + ---------- + score : str + The score string + + filters : list + A list of Filter objects + + label : str + The label specified for the Tally (default is '') + + estimator: str + The type of estimator ('tracklength' (default) or 'analog') """ - # get tally - try: - tally = self.tallies[tally_id-1] - except: - print('Tally does not exist') - return + tally = self.get_tally(score, filters, label, estimator) + return tally._id - # get the score index if it is present - try: - idx = tally.scores.index(score_str) - except ValueError: - print('Score does not exist') - print(tally.scores) - return - # create numpy array for mean and 95% CI - n_bins = len(tally.results) - n_filters = len(tally.filters) - n_scores = len(tally.scores) - meanv = np.zeros(n_bins) - unctv = np.zeros(n_bins) - filters = np.zeros((n_bins,n_filters)) - filtmax = np.zeros(n_filters+1) - meshmax = np.zeros(4) - filtmax[0] = 1 - meshmax[0] = 1 + def link_with_summary(self, summary): - # get number of realizations - n = tally.n_realizations + if not isinstance(summary, openmc.summary.Summary): + msg = 'Unable to link statepoint with {0} which ' \ + 'is not a Summary object'.format(summary) + raise ValueError(msg) - # get t-value - t_value = scipy.stats.t.ppf(0.975, n - 1) + for tally_id, tally in self._tallies.items(): - # calculate mean - meanv = tally.results[:,idx,0] - meanv = meanv / n + nuclides = copy.deepcopy(tally._nuclides) - # calculate 95% two-sided CI - unctv = tally.results[:,idx,1] - unctv = t_value*np.sqrt((unctv/n - meanv*meanv)/(n-1))/meanv + for nuclide_index in nuclides: + tally.remove_nuclide(nuclide_index) + if nuclide_index == -1: + tally.add_nuclide(openmc.Nuclide('total')) + else: + tally.add_nuclide(summary.nuclides[nuclide_index]) - # create output dictionary - data = {'mean':meanv,'CI95':unctv} + for filter in tally._filters: - # get bounds of filter bins - for akey in tally.filters.keys(): - idx = list(tally.filters.keys()).index(akey) - filtmax[n_filters - idx] = tally.filters[akey].length + if filter._type == 'surface': + surface_ids = list() + for bin in filter._bins: + surface_ids.append(summary.surfaces[bin]._id) + filter.set_bin_edges(surface_ids) - # compute bin info - for i in range(n_filters): + if filter._type in ['cell', 'distribcell']: + distribcell_ids = list() + for bin in filter._bins: + distribcell_ids.append(summary.cells[bin]._id) + filter.set_bin_edges(distribcell_ids) - # compute indices for filter combination - filters[:,n_filters - i - 1] = np.floor((np.arange(n_bins) % - np.prod(filtmax[0:i+2]))/(np.prod(filtmax[0:i+1]))) + 1 + if filter._type == 'universe': + universe_ids = list() + for bin in filter._bins: + universe_ids.append(summary.universes[bin]._id) + filter.set_bin_edges(universe_ids) - # append in dictionary bin with filter - data.update({list(tally.filters.keys())[n_filters - i - 1]: - filters[:,n_filters - i - 1]}) + if filter._type == 'material': + material_ids = list() + for bin in filter._bins: + material_ids.append(summary.materials[bin]._id) + filter.set_bin_edges(material_ids) - # check for mesh - if list(tally.filters.keys())[n_filters - i - 1] == 'mesh': - dims = list(self.meshes[tally.filters['mesh'].bins[0] - 1].dimension) - dims.reverse() - dims = np.asarray(dims) - if score_str == 'current': - dims += 1 - meshmax[1:4] = dims - mesh_bins = np.zeros((n_bins,3)) - mesh_bins[:,2] = np.floor(((filters[:,n_filters - i - 1] - 1) % - np.prod(meshmax[0:2]))/(np.prod(meshmax[0:1]))) + 1 - mesh_bins[:,1] = np.floor(((filters[:,n_filters - i - 1] - 1) % - np.prod(meshmax[0:3]))/(np.prod(meshmax[0:2]))) + 1 - mesh_bins[:,0] = np.floor(((filters[:,n_filters - i - 1] - 1) % - np.prod(meshmax[0:4]))/(np.prod(meshmax[0:3]))) + 1 - data.update({'mesh': list(zip(mesh_bins[:,0], mesh_bins[:,1], - mesh_bins[:,2]))}) - i += 1 + self._with_summary = True - # add in maximum bin filters and order - b = list(tally.filters.keys()) - b.reverse() - filtmax = list(filtmax[1:]) - try: - idx = b.index('mesh') - filtmax[idx] = np.max(mesh_bins[:,2]) - filtmax.insert(idx,np.max(mesh_bins[:,1])) - filtmax.insert(idx,np.max(mesh_bins[:,0])) - - except ValueError: - pass - data.update({'bin_order':b,'bin_max':filtmax}) - - return data def _get_data(self, n, typeCode, size): return list(struct.unpack('={0}{1}'.format(n,typeCode), - self._f.read(n*size))) + self._f.read(n*size))) def _get_int(self, n=1, path=None): if self._hdf5: @@ -603,9 +684,9 @@ class StatePoint(object): def _get_long(self, n=1, path=None): if self._hdf5: - return [int(v) for v in self._f[path].value] + return [long(v) for v in self._f[path].value] else: - return [int(v) for v in self._get_data(n, 'q', 8)] + return [long(v) for v in self._get_data(n, 'q', 8)] def _get_float(self, n=1, path=None): if self._hdf5: diff --git a/src/utils/openmc/summary.py b/src/utils/openmc/summary.py new file mode 100644 index 0000000000..ca0905671c --- /dev/null +++ b/src/utils/openmc/summary.py @@ -0,0 +1,495 @@ +#!/usr/bin/env python + +import openmc +from openmc.opencg_compatible import get_opencg_geometry +import numpy as np + +try: + import h5py +except ImportError: + msg = 'Unable to import h5py which is necessary for openmc.summary' + raise ImportError(msg) + + +class Summary(object): + + def __init__(self, filename): + + openmc.reset_auto_ids() + + if not filename.endswith(('.h5', '.hdf5')): + msg = 'Unable to open "{0}" which is not an HDF5 summary file' + raise ValueError(msg) + + self._f = h5py.File(filename, 'r') + self.openmc_geometry = None + self.opencg_geometry = None + + self._read_metadata() + self._read_geometry() + + + def _read_metadata(self): + + # Read OpenMC version + self.version = [self._f['version_major'][0], + self._f['version_minor'][0], + self._f['version_release'][0]] + # Read date and time + self.date_and_time = self._f['date_and_time'][...] + + self.n_batches = self._f['n_batches'][0] + self.n_particles = self._f['n_particles'][0] + self.n_active = self._f['n_active'][0] + self.n_inactive = self._f['n_inactive'][0] + self.gen_per_batch = self._f['gen_per_batch'][0] + self.n_procs = self._f['n_procs'][0] + + + def _read_geometry(self): + + # Read in and initialize the Materials and Geometry + self._read_nuclides() + self._read_materials() + self._read_surfaces() + self._read_cells() + self._read_universes() + self._read_lattices() + self._finalize_geometry() + + + def _read_nuclides(self): + + self.n_nuclides = self._f['nuclides/n_nuclides'][0] + + # Initialize dictionary for each Nuclide + # Keys - Nuclide ZAIDs + # Values - Nuclide objects + self.nuclides = dict() + + for key in self._f['nuclides'].keys(): + + if key == 'n_nuclides': + continue + + index = self._f['nuclides'][key]['index'][0] + alias = self._f['nuclides'][key]['alias'][0] + zaid = self._f['nuclides'][key]['zaid'][0] + + # Read the Nuclide's name (e.g., 'H-1' or 'U-235') + name = alias.split('.')[0] + + # Read the Nuclide's cross-section identifier (e.g., '70c') + xs = alias.split('.')[1] + + # Initialize this Nuclide and add it to the global dictionary of Nuclides + if 'nat' in name: + self.nuclides[index] = openmc.Element(name=name, xs=xs) + else: + self.nuclides[index] = openmc.Nuclide(name=name, xs=xs) + self.nuclides[index].set_zaid(zaid) + + + def _read_materials(self): + + self.n_materials = self._f['materials/n_materials'][0] + + # Initialize dictionary for each Material + # Keys - Material keys + # Values - Material objects + self.materials = dict() + + for key in self._f['materials'].keys(): + + if key == 'n_materials': + continue + + material_id = int(key.lstrip('material ')) + index = self._f['materials'][key]['index'][0] + density = self._f['materials'][key]['atom_density'][0] + nuc_densities = self._f['materials'][key]['nuclide_densities'][...] + nuclides = self._f['materials'][key]['nuclides'][...] + n_sab = self._f['materials'][key]['n_sab'][0] + + sab_names = list() + sab_xs = list() + + # Read the names of the S(a,b) tables for this Material + for i in range(1, n_sab+1): + + sab_table = self._f['materials'][key]['sab_tables'][str(i)][0] + + # Read the cross-section identifiers for each S(a,b) table + sab_names.append(sab_table.split('.')[0]) + sab_xs.append(sab_table.split('.')[1]) + + # Create the Material + material = openmc.Material(material_id=material_id) + + # Set the Material's density to g/cm3 - this is what is used in OpenMC + material.set_density(density=density, units='g/cm3') + + # Add all Nuclides to the Material + for i, zaid in enumerate(nuclides): + nuclide = self.get_nuclide_by_zaid(zaid) + density = nuc_densities[i] + + if isinstance(nuclide, openmc.Nuclide): + material.add_nuclide(nuclide, percent=density, percent_type='ao') + elif isinstance(nuclide, openmc.Element): + material.add_element(nuclide, percent=density, percent_type='ao') + + # Add S(a,b) table(s?) to the Material + for i in range(n_sab): + name = sab_names[i] + xs = sab_xs[i] + material.add_s_alpha_beta(name, xs) + + # Add the Material to the global dictionary of all Materials + self.materials[index] = material + + + def _read_surfaces(self): + + self.n_surfaces = self._f['geometry/n_surfaces'][0] + + # Initialize dictionary for each Surface + # Keys - Surface keys + # Values - Surfacee objects + self.surfaces = dict() + + for key in self._f['geometry/surfaces'].keys(): + + if key == 'n_surfaces': + continue + + surface_id = int(key.lstrip('surface ')) + index = self._f['geometry/surfaces'][key]['index'][0] + surf_type = self._f['geometry/surfaces'][key]['type'][...][0] + bc = self._f['geometry/surfaces'][key]['boundary_condition'][...][0] + coeffs = self._f['geometry/surfaces'][key]['coefficients'][...] + + # Create the Surface based on its type + + if surf_type == 'X Plane': + x0 = coeffs[0] + surface = openmc.XPlane(surface_id, bc, x0) + + elif surf_type == 'Y Plane': + y0 = coeffs[0] + surface = openmc.YPlane(surface_id, bc, y0) + + elif surf_type == 'Z Plane': + z0 = coeffs[0] + surface = openmc.ZPlane(surface_id, bc, z0) + + elif surf_type == 'Plane': + A = coeffs[0] + B = coeffs[1] + C = coeffs[2] + D = coeffs[3] + surface = openmc.Plane(surface_id, bc, A, B, C, D) + + elif surf_type == 'X Cylinder': + y0 = coeffs[0] + z0 = coeffs[1] + R = coeffs[2] + surface = openmc.XCylinder(surface_id, bc, y0, z0, R) + + elif surf_type == 'Y Cylinder': + x0 = coeffs[0] + z0 = coeffs[1] + R = coeffs[2] + surface = openmc.YCylinder(surface_id, bc, x0, z0, R) + + elif surf_type == 'Z Cylinder': + x0 = coeffs[0] + y0 = coeffs[1] + R = coeffs[2] + surface = openmc.ZCylinder(surface_id, bc, x0, y0, R) + + elif surf_type == 'Sphere': + x0 = coeffs[0] + y0 = coeffs[1] + z0 = coeffs[2] + R = coeffs[3] + surface = openmc.Sphere(surface_id, bc, x0, y0, z0, R) + + elif surf_type in ['X Cone', 'Y Cone', 'Z Cone']: + x0 = coeffs[0] + y0 = coeffs[1] + z0 = coeffs[2] + R2 = coeffs[3] + + if surf_type == 'X Cone': + surface = openmc.XCone(surface_id, bc, x0, y0, z0, R2) + if surf_type == 'Y Cone': + surface = openmc.YCone(surface_id, bc, x0, y0, z0, R2) + if surf_type == 'Z Cone': + surface = openmc.ZCone(surface_id, bc, x0, y0, z0, R2) + + # Add Surface to global dictionary of all Surfaces + self.surfaces[index] = surface + + + def _read_cells(self): + + self.n_cells = self._f['geometry/n_cells'][0] + + # Initialize dictionary for each Cell + # Keys - Cell keys + # Values - Cell objects + self.cells = dict() + + # Initialize dictionary for each Cell's fill + # (e.g., Material, Universe or Lattice ID) + # This dictionary is used later to link the fills with + # the corresponding objects + # Keys - Cell keys + # Values - Filling Material, Universe or Lattice ID + self._cell_fills = dict() + + for key in self._f['geometry/cells'].keys(): + + if key == 'n_cells': + continue + + cell_id = int(key.lstrip('cell ')) + index = self._f['geometry/cells'][key]['index'][0] + fill_type = self._f['geometry/cells'][key]['fill_type'][...][0] + + if fill_type == 'normal': + fill = self._f['geometry/cells'][key]['material'][0] + elif fill_type == 'fill': + fill = self._f['geometry/cells'][key]['universe'][0] + else: + fill = self._f['geometry/cells'][key]['lattice'][0] + + if 'surfaces' in self._f['geometry/cells'][key].keys(): + surfaces = self._f['geometry/cells'][key]['surfaces'][...] + else: + surfaces = list() + + # Create this Cell + cell = openmc.Cell(cell_id=cell_id) + + if fill_type == 'universe': + maps = self._f['geometry/cells'][key]['maps'][0] + + if maps > 0: + offset = self._f['geometry/cells'][key]['offset'][...] + cell.set_offset(offset) + + translated = self._f['geometry/cells'][key]['translated'][0] + if translated: + translation = \ + self._f['geometry/cells'][key]['translation'][...] + translation = np.asarray(translation, dtype=np.float64) + cell.set_translation(translation) + + rotated = self._f['geometry/cells'][key]['rotated'][0] + if rotated: + rotation = \ + self._f['geometry/cells'][key]['rotation'][...] + rotation = np.asarray(rotation, dtype=np.int) + cell.set_rotation(rotation) + + # Store Cell fill information for after Universe/Lattice creation + self._cell_fills[index] = (fill_type, fill) + + # Iterate over all Surfaces and add them to the Cell + for surface_halfspace in surfaces: + + halfspace = np.sign(surface_halfspace) + surface_id = np.abs(surface_halfspace) + surface = self.surfaces[surface_id] + cell.add_surface(surface, halfspace) + + # Add the Cell to the global dictionary of all Cells + self.cells[index] = cell + + + def _read_universes(self): + + self.n_universes = self._f['geometry/n_universes'][0] + + # Initialize dictionary for each Universe + # Keys - Universe keys + # Values - Universe objects + self.universes = dict() + + for key in self._f['geometry/universes'].keys(): + + if key == 'n_universes': + continue + + universe_id = int(key.lstrip('universe ')) + index = self._f['geometry/universes'][key]['index'][0] + cells = self._f['geometry/universes'][key]['cells'][...] + + # Create this Universe + universe = openmc.Universe(universe_id=universe_id) + + # Add each Cell to the Universe + for cell_id in cells: + cell = self.cells[cell_id] + universe.add_cell(cell) + + # Add the Universe to the global list of Universes + self.universes[index] = universe + + + def _read_lattices(self): + + self.n_lattices = self._f['geometry/n_lattices'][0] + + # Initialize lattices for each Lattice + # Keys - Lattice keys + # Values - Lattice objects + self.lattices = dict() + + for key in self._f['geometry/lattices'].keys(): + + if key == 'n_lattices': + continue + + lattice_id = int(key.lstrip('lattice ')) + index = self._f['geometry/lattices'][key]['index'][0] + type = self._f['geometry/lattices'][key]['type'][...][0] + width = self._f['geometry/lattices'][key]['width'][...] + dimension = self._f['geometry/lattices'][key]['dimension'][...] + lower_left = self._f['geometry/lattices'][key]['lower_left'][...] + outside = self._f['geometry/lattices'][key]['outside'][0] + maps = self._f['geometry/lattices'][key]['maps'][0] + offset_size = self._f['geometry/lattices'][key]['offset_size'][0] + + if offset_size > 0: + offsets = self._f['geometry/lattices'][key]['offsets'][...] + offsets = np.swapaxes(offsets, 0, 1) + offsets = np.swapaxes(offsets, 1, 2) + + universe_ids = self._f['geometry/lattices'][key]['universes'][...] + universe_ids = np.swapaxes(universe_ids, 0, 1) + universe_ids = np.swapaxes(universe_ids, 1, 2) + + # Create the Lattice + lattice = openmc.Lattice(lattice_id=lattice_id, type=type) + lattice.set_dimension(tuple(dimension)) + lattice.set_lower_left(lower_left) + lattice.set_width(width) + + # Build array of Universe pointers for the Lattice + universes = np.ndarray(tuple(universe_ids.shape), dtype=openmc.Universe) + + for x in range(universe_ids.shape[0]): + for y in range(universe_ids.shape[1]): + for z in range(universe_ids.shape[2]): + universes[x,y,z] = \ + self.get_universe_by_id(universe_ids[x,y,z]) + + # Transpose, reverse y-dimension in array for appropriate ordering + shape = universes.shape + universes = np.transpose(universes, (1,0,2)) + universes.shape = shape + universes = universes[:,::-1,:] + lattice.set_universes(universes) + + # If the Material specified outside the Lattice is not void (-1) + if outside != -1: + lattice.set_outside(self.materials[outside]) + + if offset_size > 0: + lattice.set_offsets(offsets) + + # Add the Lattice to the global dictionary of all Lattices + self.lattices[index] = lattice + + + def _finalize_geometry(self): + + # Initialize Geometry object + self.openmc_geometry = openmc.Geometry() + + # Iterate over all Cells and add fill Materials, Universes and Lattices + for cell_key in self._cell_fills.keys(): + + # Determine the fill type ('normal', 'universe', or 'lattice') and ID + fill_type = self._cell_fills[cell_key][0] + fill_id = self._cell_fills[cell_key][1] + + # Retrieve the object corresponding to the fill type and ID + if fill_type == 'normal': + if fill_id > 0: + fill = self.get_material_by_id(fill_id) + else: + fill = 'void' + elif fill_type == 'universe': + fill = self.get_universe_by_id(fill_id) + else: + fill = self.get_lattice_by_id(fill_id) + + # Set the fill for the Cell + self.cells[cell_key].set_fill(fill) + + # Set the root universe for the Geometry + root_universe = self.get_universe_by_id(0) + self.openmc_geometry.set_root_universe(root_universe) + + + def make_opencg_geometry(self): + if self.opencg_geometry is None: + self.opencg_geometry = get_opencg_geometry(self.openmc_geometry) + + + def get_nuclide_by_zaid(self, zaid): + + for index, nuclide in self.nuclides.items(): + if nuclide._zaid == zaid: + return nuclide + + return None + + + def get_material_by_id(self, material_id): + + for index, material in self.materials.items(): + if material._id == material_id: + return material + + return None + + + def get_surface_by_id(self, surface_id): + + for index, surface in self.surfaces.items(): + if surface._id == surface_id: + return surface + + return None + + + def get_cell_by_id(self, cell_id): + + for index, cell in self.cells.items(): + if cell._id == cell_id: + return cell + + return None + + + def get_universe_by_id(self, universe_id): + + for index, universe in self.universes.items(): + if universe._id == universe_id: + return universe + + return None + + + def get_lattice_by_id(self, lattice_id): + + for index, lattice in self.lattices.items(): + if lattice._id == lattice_id: + return lattice + + return None \ No newline at end of file diff --git a/src/utils/openmc/surface.py b/src/utils/openmc/surface.py index 45c05ab4a3..269bfd1c70 100644 --- a/src/utils/openmc/surface.py +++ b/src/utils/openmc/surface.py @@ -91,7 +91,7 @@ class Surface(object): def __repr__(self): string = 'Surface\n' - string += '{0: <16}{1}{2}\n'.format('\tID', '=\t{0}', self._id) + string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id) string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name) string += '{0: <16}{1}{2}\n'.format('\tType', '=\t', self._type) string += '{0: <16}{1}{2}\n'.format('\tBoundary', '=\t', self._bc_type) diff --git a/src/utils/openmc/universe.py b/src/utils/openmc/universe.py index 36727e927d..ef20907f19 100644 --- a/src/utils/openmc/universe.py +++ b/src/utils/openmc/universe.py @@ -101,8 +101,8 @@ class Cell(object): if not isinstance(fill, (openmc.Material, Universe, Lattice)) \ and fill != 'void': - msg = 'Unable to set Cell ID={0} to use a a non-Material or ' \ - 'Universe fill {1}'.format(self._id, fill) + msg = 'Unable to set Cell ID={0} to use a non-Material or ' \ + 'Universe fill {1}'.format(self._id, fill) raise ValueError(msg) self._fill = fill diff --git a/tests/test_cmfd_feed/results.py b/tests/test_cmfd_feed/results.py index fb5483d2a7..33a37af15b 100644 --- a/tests/test_cmfd_feed/results.py +++ b/tests/test_cmfd_feed/results.py @@ -11,32 +11,41 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.20.binary') + sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) -results3 = sp.tallies[2].results -shape3 = results3.shape -size3 = (np.product(shape3)) -results3 = np.reshape(results3, size3) -results4 = sp.tallies[3].results -shape4 = results4.shape -size4 = (np.product(shape4)) -results4 = np.reshape(results4, size4) +tally1 = sp._tallies[1] +results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) +results1[0::2] = tally1._sum.ravel() +results1[1::2] = tally1._sum_sq.ravel() + +for tally_id in sp._tallies: + if 'CMFD flux, total, scatter-1' in sp._tallies[tally_id]._label: + tally2 = sp._tallies[tally_id] + elif 'CMFD neutron production' in sp._tallies[tally_id]._label: + tally3 = sp._tallies[tally_id] + elif 'CMFD surface currents' in sp._tallies[tally_id]._label: + tally4 = sp._tallies[tally_id] + +results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) +results2[0::2] = tally2._sum.ravel() +results2[1::2] = tally2._sum_sq.ravel() + +results3 = np.zeros((tally3._sum.size + tally3._sum.size, )) +results3[0::2] = tally3._sum.ravel() +results3[1::2] = tally3._sum_sq.ravel() + +results4 = np.zeros((tally4._sum.size + tally4._sum.size, )) +results4[0::2] = tally4._sum.ravel() +results4[1::2] = tally4._sum_sq.ravel() # set up output string outstr = '' # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' @@ -54,25 +63,25 @@ for item in results4: # write out cmfd answers outstr += 'cmfd indices\n' -for item in sp.cmfd_indices: +for item in sp._cmfd_indices: outstr += "{0:12.6E}\n".format(item) outstr += 'k cmfd\n' -for item in sp.k_cmfd: +for item in sp._k_cmfd: outstr += "{0:12.6E}\n".format(item) outstr += 'cmfd entropy\n' -for item in sp.cmfd_entropy: +for item in sp._cmfd_entropy: outstr += "{0:12.6E}\n".format(item) outstr += 'cmfd balance\n' -for item in sp.cmfd_balance: +for item in sp._cmfd_balance: outstr += "{0:12.6E}\n".format(item) outstr += 'cmfd dominance ratio\n' -for item in sp.cmfd_dominance: +for item in sp._cmfd_dominance: outstr += "{0:10.3E}\n".format(item) outstr += 'cmfd openmc source comparison\n' -for item in sp.cmfd_srccmp: +for item in sp._cmfd_srccmp: outstr += "{0:12.6E}\n".format(item) outstr += 'cmfd source\n' -cmfdsrc = np.reshape(sp.cmfd_src, np.product(sp.cmfd_indices), order='F') +cmfdsrc = np.reshape(sp._cmfd_src, np.product(sp._cmfd_indices), order='F') for item in cmfdsrc: outstr += "{0:12.6E}\n".format(item) diff --git a/tests/test_cmfd_jfnk/results.py b/tests/test_cmfd_jfnk/results.py index fb5483d2a7..33a37af15b 100644 --- a/tests/test_cmfd_jfnk/results.py +++ b/tests/test_cmfd_jfnk/results.py @@ -11,32 +11,41 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.20.binary') + sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) -results3 = sp.tallies[2].results -shape3 = results3.shape -size3 = (np.product(shape3)) -results3 = np.reshape(results3, size3) -results4 = sp.tallies[3].results -shape4 = results4.shape -size4 = (np.product(shape4)) -results4 = np.reshape(results4, size4) +tally1 = sp._tallies[1] +results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) +results1[0::2] = tally1._sum.ravel() +results1[1::2] = tally1._sum_sq.ravel() + +for tally_id in sp._tallies: + if 'CMFD flux, total, scatter-1' in sp._tallies[tally_id]._label: + tally2 = sp._tallies[tally_id] + elif 'CMFD neutron production' in sp._tallies[tally_id]._label: + tally3 = sp._tallies[tally_id] + elif 'CMFD surface currents' in sp._tallies[tally_id]._label: + tally4 = sp._tallies[tally_id] + +results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) +results2[0::2] = tally2._sum.ravel() +results2[1::2] = tally2._sum_sq.ravel() + +results3 = np.zeros((tally3._sum.size + tally3._sum.size, )) +results3[0::2] = tally3._sum.ravel() +results3[1::2] = tally3._sum_sq.ravel() + +results4 = np.zeros((tally4._sum.size + tally4._sum.size, )) +results4[0::2] = tally4._sum.ravel() +results4[1::2] = tally4._sum_sq.ravel() # set up output string outstr = '' # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' @@ -54,25 +63,25 @@ for item in results4: # write out cmfd answers outstr += 'cmfd indices\n' -for item in sp.cmfd_indices: +for item in sp._cmfd_indices: outstr += "{0:12.6E}\n".format(item) outstr += 'k cmfd\n' -for item in sp.k_cmfd: +for item in sp._k_cmfd: outstr += "{0:12.6E}\n".format(item) outstr += 'cmfd entropy\n' -for item in sp.cmfd_entropy: +for item in sp._cmfd_entropy: outstr += "{0:12.6E}\n".format(item) outstr += 'cmfd balance\n' -for item in sp.cmfd_balance: +for item in sp._cmfd_balance: outstr += "{0:12.6E}\n".format(item) outstr += 'cmfd dominance ratio\n' -for item in sp.cmfd_dominance: +for item in sp._cmfd_dominance: outstr += "{0:10.3E}\n".format(item) outstr += 'cmfd openmc source comparison\n' -for item in sp.cmfd_srccmp: +for item in sp._cmfd_srccmp: outstr += "{0:12.6E}\n".format(item) outstr += 'cmfd source\n' -cmfdsrc = np.reshape(sp.cmfd_src, np.product(sp.cmfd_indices), order='F') +cmfdsrc = np.reshape(sp._cmfd_src, np.product(sp._cmfd_indices), order='F') for item in cmfdsrc: outstr += "{0:12.6E}\n".format(item) diff --git a/tests/test_cmfd_nofeed/results.py b/tests/test_cmfd_nofeed/results.py index fb5483d2a7..33a37af15b 100644 --- a/tests/test_cmfd_nofeed/results.py +++ b/tests/test_cmfd_nofeed/results.py @@ -11,32 +11,41 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.20.binary') + sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) -results3 = sp.tallies[2].results -shape3 = results3.shape -size3 = (np.product(shape3)) -results3 = np.reshape(results3, size3) -results4 = sp.tallies[3].results -shape4 = results4.shape -size4 = (np.product(shape4)) -results4 = np.reshape(results4, size4) +tally1 = sp._tallies[1] +results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) +results1[0::2] = tally1._sum.ravel() +results1[1::2] = tally1._sum_sq.ravel() + +for tally_id in sp._tallies: + if 'CMFD flux, total, scatter-1' in sp._tallies[tally_id]._label: + tally2 = sp._tallies[tally_id] + elif 'CMFD neutron production' in sp._tallies[tally_id]._label: + tally3 = sp._tallies[tally_id] + elif 'CMFD surface currents' in sp._tallies[tally_id]._label: + tally4 = sp._tallies[tally_id] + +results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) +results2[0::2] = tally2._sum.ravel() +results2[1::2] = tally2._sum_sq.ravel() + +results3 = np.zeros((tally3._sum.size + tally3._sum.size, )) +results3[0::2] = tally3._sum.ravel() +results3[1::2] = tally3._sum_sq.ravel() + +results4 = np.zeros((tally4._sum.size + tally4._sum.size, )) +results4[0::2] = tally4._sum.ravel() +results4[1::2] = tally4._sum_sq.ravel() # set up output string outstr = '' # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' @@ -54,25 +63,25 @@ for item in results4: # write out cmfd answers outstr += 'cmfd indices\n' -for item in sp.cmfd_indices: +for item in sp._cmfd_indices: outstr += "{0:12.6E}\n".format(item) outstr += 'k cmfd\n' -for item in sp.k_cmfd: +for item in sp._k_cmfd: outstr += "{0:12.6E}\n".format(item) outstr += 'cmfd entropy\n' -for item in sp.cmfd_entropy: +for item in sp._cmfd_entropy: outstr += "{0:12.6E}\n".format(item) outstr += 'cmfd balance\n' -for item in sp.cmfd_balance: +for item in sp._cmfd_balance: outstr += "{0:12.6E}\n".format(item) outstr += 'cmfd dominance ratio\n' -for item in sp.cmfd_dominance: +for item in sp._cmfd_dominance: outstr += "{0:10.3E}\n".format(item) outstr += 'cmfd openmc source comparison\n' -for item in sp.cmfd_srccmp: +for item in sp._cmfd_srccmp: outstr += "{0:12.6E}\n".format(item) outstr += 'cmfd source\n' -cmfdsrc = np.reshape(sp.cmfd_src, np.product(sp.cmfd_indices), order='F') +cmfdsrc = np.reshape(sp._cmfd_src, np.product(sp._cmfd_indices), order='F') for item in cmfdsrc: outstr += "{0:12.6E}\n".format(item) diff --git a/tests/test_confidence_intervals/results.py b/tests/test_confidence_intervals/results.py index 51cc325fa7..3eb6c65279 100644 --- a/tests/test_confidence_intervals/results.py +++ b/tests/test_confidence_intervals/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_density_atombcm/results.py b/tests/test_density_atombcm/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_density_atombcm/results.py +++ b/tests/test_density_atombcm/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_density_atomcm3/results.py b/tests/test_density_atomcm3/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_density_atomcm3/results.py +++ b/tests/test_density_atomcm3/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_density_kgm3/results.py b/tests/test_density_kgm3/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_density_kgm3/results.py +++ b/tests/test_density_kgm3/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_density_sum/results.py b/tests/test_density_sum/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_density_sum/results.py +++ b/tests/test_density_sum/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_eigenvalue_genperbatch/results.py b/tests/test_eigenvalue_genperbatch/results.py index 1df9f9ccda..05bc35c571 100644 --- a/tests/test_eigenvalue_genperbatch/results.py +++ b/tests/test_eigenvalue_genperbatch/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.7.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_eigenvalue_no_inactive/results.py b/tests/test_eigenvalue_no_inactive/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_eigenvalue_no_inactive/results.py +++ b/tests/test_eigenvalue_no_inactive/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_energy_grid/results.py b/tests/test_energy_grid/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_energy_grid/results.py +++ b/tests/test_energy_grid/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_entropy/results.py b/tests/test_entropy/results.py index bab7609068..ca43a74a9a 100644 --- a/tests/test_entropy/results.py +++ b/tests/test_entropy/results.py @@ -11,18 +11,19 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'entropy:\n' -for item in sp.entropy: +for item in sp._entropy: outstr += "{0:12.6E}\n".format(item) # write results to file diff --git a/tests/test_filter_cell/results.py b/tests/test_filter_cell/results.py index 51cc325fa7..dabd14975c 100644 --- a/tests/test_filter_cell/results.py +++ b/tests/test_filter_cell/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.empty((tally._sum.size + tally._sum.size, ), dtype=np.float64) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_filter_cellborn/results.py b/tests/test_filter_cellborn/results.py index 51cc325fa7..dabd14975c 100644 --- a/tests/test_filter_cellborn/results.py +++ b/tests/test_filter_cellborn/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.empty((tally._sum.size + tally._sum.size, ), dtype=np.float64) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_filter_energy/results.py b/tests/test_filter_energy/results.py index 51cc325fa7..3eb6c65279 100644 --- a/tests/test_filter_energy/results.py +++ b/tests/test_filter_energy/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_filter_energyout/results.py b/tests/test_filter_energyout/results.py index 51cc325fa7..fe20549c9f 100644 --- a/tests/test_filter_energyout/results.py +++ b/tests/test_filter_energyout/results.py @@ -14,17 +14,17 @@ else: sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_filter_group_transfer/results.py b/tests/test_filter_group_transfer/results.py index 51cc325fa7..fe20549c9f 100644 --- a/tests/test_filter_group_transfer/results.py +++ b/tests/test_filter_group_transfer/results.py @@ -14,17 +14,17 @@ else: sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_filter_material/results.py b/tests/test_filter_material/results.py index 51cc325fa7..3eb6c65279 100644 --- a/tests/test_filter_material/results.py +++ b/tests/test_filter_material/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_filter_mesh_2d/results.py b/tests/test_filter_mesh_2d/results.py index 51cc325fa7..3eb6c65279 100644 --- a/tests/test_filter_mesh_2d/results.py +++ b/tests/test_filter_mesh_2d/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_filter_mesh_3d/results.py b/tests/test_filter_mesh_3d/results.py index 51cc325fa7..3eb6c65279 100644 --- a/tests/test_filter_mesh_3d/results.py +++ b/tests/test_filter_mesh_3d/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_filter_universe/results.py b/tests/test_filter_universe/results.py index 51cc325fa7..3eb6c65279 100644 --- a/tests/test_filter_universe/results.py +++ b/tests/test_filter_universe/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_fixed_source/results.py b/tests/test_fixed_source/results.py index b0d2ef8e17..2a917885c5 100644 --- a/tests/test_fixed_source/results.py +++ b/tests/test_fixed_source/results.py @@ -11,17 +11,18 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out tally results outstr += 'tallies:\n' for item in results: diff --git a/tests/test_infinite_cell/results.py b/tests/test_infinite_cell/results.py index e1c7836111..739fb63511 100644 --- a/tests/test_infinite_cell/results.py +++ b/tests/test_infinite_cell/results.py @@ -14,10 +14,10 @@ sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_lattice/results.py b/tests/test_lattice/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_lattice/results.py +++ b/tests/test_lattice/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_lattice_multiple/results.py b/tests/test_lattice_multiple/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_lattice_multiple/results.py +++ b/tests/test_lattice_multiple/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_natural_element/results.py b/tests/test_natural_element/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_natural_element/results.py +++ b/tests/test_natural_element/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_output/results.py b/tests/test_output/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_output/results.py +++ b/tests/test_output/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_particle_restart_eigval/results.py b/tests/test_particle_restart_eigval/results.py index 23670872be..02b45f9a8a 100644 --- a/tests/test_particle_restart_eigval/results.py +++ b/tests/test_particle_restart_eigval/results.py @@ -2,8 +2,8 @@ import sys -# import particle restart -sys.path.append('../../src/utils') +# import particle restart +sys.path.insert(0, '../../src/utils') import particle_restart as pr # read in particle restart file @@ -14,8 +14,8 @@ else: # set up output string outstr = '' - -# write out properties + +# write out properties outstr += 'current batch:\n' outstr += "{0:12.6E}\n".format(p.current_batch) outstr += 'current gen:\n' diff --git a/tests/test_particle_restart_fixed/results.py b/tests/test_particle_restart_fixed/results.py index e84cb88cff..84956f1d0b 100644 --- a/tests/test_particle_restart_fixed/results.py +++ b/tests/test_particle_restart_fixed/results.py @@ -3,7 +3,7 @@ import sys # import particle restart -sys.path.append('../../src/utils') +sys.path.insert(0, '../../src/utils') import particle_restart as pr # read in particle restart file diff --git a/tests/test_ptables_off/results.py b/tests/test_ptables_off/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_ptables_off/results.py +++ b/tests/test_ptables_off/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_reflective_cone/results.py b/tests/test_reflective_cone/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_reflective_cone/results.py +++ b/tests/test_reflective_cone/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_reflective_cylinder/results.py b/tests/test_reflective_cylinder/results.py index 38aeb0c484..37b1af8048 100644 --- a/tests/test_reflective_cylinder/results.py +++ b/tests/test_reflective_cylinder/results.py @@ -3,13 +3,13 @@ import sys # import statepoint -from openmc.statepoint import StatePoint +import openmc.statepoint as statepoint # read in statepoint file if len(sys.argv) > 1: - sp = StatePoint(sys.argv[1]) + sp = statepoint.StatePoint(sys.argv[1]) else: - sp = StatePoint('statepoint.10.binary') + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string @@ -17,7 +17,7 @@ outstr = '' # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_reflective_plane/results.py b/tests/test_reflective_plane/results.py index e1c7836111..37b1af8048 100644 --- a/tests/test_reflective_plane/results.py +++ b/tests/test_reflective_plane/results.py @@ -3,21 +3,21 @@ import sys # import statepoint -from openmc.statepoint import StatePoint +import openmc.statepoint as statepoint # read in statepoint file if len(sys.argv) > 1: - sp = StatePoint(sys.argv[1]) + sp = statepoint.StatePoint(sys.argv[1]) else: - sp = StatePoint('statepoint.10.binary') + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_reflective_sphere/results.py b/tests/test_reflective_sphere/results.py index e1c7836111..37b1af8048 100644 --- a/tests/test_reflective_sphere/results.py +++ b/tests/test_reflective_sphere/results.py @@ -3,21 +3,21 @@ import sys # import statepoint -from openmc.statepoint import StatePoint +import openmc.statepoint as statepoint # read in statepoint file if len(sys.argv) > 1: - sp = StatePoint(sys.argv[1]) + sp = statepoint.StatePoint(sys.argv[1]) else: - sp = StatePoint('statepoint.10.binary') + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_resonance_scattering/results.py b/tests/test_resonance_scattering/results.py index e1c7836111..e199f43d71 100644 --- a/tests/test_resonance_scattering/results.py +++ b/tests/test_resonance_scattering/results.py @@ -17,7 +17,7 @@ outstr = '' # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_rotation/results.py b/tests/test_rotation/results.py index e1c7836111..37b1af8048 100644 --- a/tests/test_rotation/results.py +++ b/tests/test_rotation/results.py @@ -3,21 +3,21 @@ import sys # import statepoint -from openmc.statepoint import StatePoint +import openmc.statepoint as statepoint # read in statepoint file if len(sys.argv) > 1: - sp = StatePoint(sys.argv[1]) + sp = statepoint.StatePoint(sys.argv[1]) else: - sp = StatePoint('statepoint.10.binary') + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_salphabeta/results.py b/tests/test_salphabeta/results.py index e1c7836111..37b1af8048 100644 --- a/tests/test_salphabeta/results.py +++ b/tests/test_salphabeta/results.py @@ -3,21 +3,21 @@ import sys # import statepoint -from openmc.statepoint import StatePoint +import openmc.statepoint as statepoint # read in statepoint file if len(sys.argv) > 1: - sp = StatePoint(sys.argv[1]) + sp = statepoint.StatePoint(sys.argv[1]) else: - sp = StatePoint('statepoint.10.binary') + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_salphabeta_multiple/results.py b/tests/test_salphabeta_multiple/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_salphabeta_multiple/results.py +++ b/tests/test_salphabeta_multiple/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_score_MT/results.py b/tests/test_score_MT/results.py index 51cc325fa7..3eb6c65279 100644 --- a/tests/test_score_MT/results.py +++ b/tests/test_score_MT/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_score_absorption/results.py b/tests/test_score_absorption/results.py index 4e4a4b39d8..0695245ada 100644 --- a/tests/test_score_absorption/results.py +++ b/tests/test_score_absorption/results.py @@ -1,3 +1,4 @@ + #!/usr/bin/env python import sys @@ -11,24 +12,26 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) +tally1 = sp._tallies[1] +results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) +results1[0::2] = tally1._sum.ravel() +results1[1::2] = tally1._sum_sq.ravel() + +tally2 = sp._tallies[2] +results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) +results2[0::2] = tally2._sum.ravel() +results2[1::2] = tally2._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' diff --git a/tests/test_score_current/results.py b/tests/test_score_current/results.py index 4e4a4b39d8..e6160e0513 100644 --- a/tests/test_score_current/results.py +++ b/tests/test_score_current/results.py @@ -11,24 +11,26 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) +tally1 = sp._tallies[1] +results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) +results1[0::2] = tally1._sum.ravel() +results1[1::2] = tally1._sum_sq.ravel() + +tally2 = sp._tallies[2] +results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) +results2[0::2] = tally2._sum.ravel() +results2[1::2] = tally2._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' diff --git a/tests/test_score_events/results.py b/tests/test_score_events/results.py index 4e4a4b39d8..e6160e0513 100644 --- a/tests/test_score_events/results.py +++ b/tests/test_score_events/results.py @@ -11,24 +11,26 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) +tally1 = sp._tallies[1] +results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) +results1[0::2] = tally1._sum.ravel() +results1[1::2] = tally1._sum_sq.ravel() + +tally2 = sp._tallies[2] +results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) +results2[0::2] = tally2._sum.ravel() +results2[1::2] = tally2._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' diff --git a/tests/test_score_fission/results.py b/tests/test_score_fission/results.py index 4e4a4b39d8..e6160e0513 100644 --- a/tests/test_score_fission/results.py +++ b/tests/test_score_fission/results.py @@ -11,24 +11,26 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) +tally1 = sp._tallies[1] +results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) +results1[0::2] = tally1._sum.ravel() +results1[1::2] = tally1._sum_sq.ravel() + +tally2 = sp._tallies[2] +results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) +results2[0::2] = tally2._sum.ravel() +results2[1::2] = tally2._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' diff --git a/tests/test_score_flux/results.py b/tests/test_score_flux/results.py index 51cc325fa7..3eb6c65279 100644 --- a/tests/test_score_flux/results.py +++ b/tests/test_score_flux/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_score_flux_yn/results.py b/tests/test_score_flux_yn/results.py index 4e4a4b39d8..e6160e0513 100644 --- a/tests/test_score_flux_yn/results.py +++ b/tests/test_score_flux_yn/results.py @@ -11,24 +11,26 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) +tally1 = sp._tallies[1] +results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) +results1[0::2] = tally1._sum.ravel() +results1[1::2] = tally1._sum_sq.ravel() + +tally2 = sp._tallies[2] +results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) +results2[0::2] = tally2._sum.ravel() +results2[1::2] = tally2._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' diff --git a/tests/test_score_kappafission/results.py b/tests/test_score_kappafission/results.py index 51cc325fa7..3eb6c65279 100644 --- a/tests/test_score_kappafission/results.py +++ b/tests/test_score_kappafission/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_score_nufission/results.py b/tests/test_score_nufission/results.py index 51cc325fa7..3eb6c65279 100644 --- a/tests/test_score_nufission/results.py +++ b/tests/test_score_nufission/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_score_nuscatter/results.py b/tests/test_score_nuscatter/results.py index 51cc325fa7..3eb6c65279 100644 --- a/tests/test_score_nuscatter/results.py +++ b/tests/test_score_nuscatter/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_score_nuscatter_n/results.py b/tests/test_score_nuscatter_n/results.py index 51cc325fa7..3eb6c65279 100644 --- a/tests/test_score_nuscatter_n/results.py +++ b/tests/test_score_nuscatter_n/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_score_nuscatter_pn/results.py b/tests/test_score_nuscatter_pn/results.py index 4e4a4b39d8..e6160e0513 100644 --- a/tests/test_score_nuscatter_pn/results.py +++ b/tests/test_score_nuscatter_pn/results.py @@ -11,24 +11,26 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) +tally1 = sp._tallies[1] +results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) +results1[0::2] = tally1._sum.ravel() +results1[1::2] = tally1._sum_sq.ravel() + +tally2 = sp._tallies[2] +results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) +results2[0::2] = tally2._sum.ravel() +results2[1::2] = tally2._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' diff --git a/tests/test_score_nuscatter_yn/results.py b/tests/test_score_nuscatter_yn/results.py index 4e4a4b39d8..e6160e0513 100644 --- a/tests/test_score_nuscatter_yn/results.py +++ b/tests/test_score_nuscatter_yn/results.py @@ -11,24 +11,26 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) +tally1 = sp._tallies[1] +results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) +results1[0::2] = tally1._sum.ravel() +results1[1::2] = tally1._sum_sq.ravel() + +tally2 = sp._tallies[2] +results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) +results2[0::2] = tally2._sum.ravel() +results2[1::2] = tally2._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' diff --git a/tests/test_score_scatter/results.py b/tests/test_score_scatter/results.py index 51cc325fa7..3eb6c65279 100644 --- a/tests/test_score_scatter/results.py +++ b/tests/test_score_scatter/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_score_scatter_n/results.py b/tests/test_score_scatter_n/results.py index 51cc325fa7..3eb6c65279 100644 --- a/tests/test_score_scatter_n/results.py +++ b/tests/test_score_scatter_n/results.py @@ -11,20 +11,21 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.zeros((tally._sum.size + tally._sum.size, )) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_score_scatter_pn/results.py b/tests/test_score_scatter_pn/results.py index 4e4a4b39d8..e6160e0513 100644 --- a/tests/test_score_scatter_pn/results.py +++ b/tests/test_score_scatter_pn/results.py @@ -11,24 +11,26 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) +tally1 = sp._tallies[1] +results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) +results1[0::2] = tally1._sum.ravel() +results1[1::2] = tally1._sum_sq.ravel() + +tally2 = sp._tallies[2] +results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) +results2[0::2] = tally2._sum.ravel() +results2[1::2] = tally2._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' diff --git a/tests/test_score_scatter_yn/results.py b/tests/test_score_scatter_yn/results.py index 4e4a4b39d8..e6160e0513 100644 --- a/tests/test_score_scatter_yn/results.py +++ b/tests/test_score_scatter_yn/results.py @@ -11,24 +11,26 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) +tally1 = sp._tallies[1] +results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) +results1[0::2] = tally1._sum.ravel() +results1[1::2] = tally1._sum_sq.ravel() + +tally2 = sp._tallies[2] +results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) +results2[0::2] = tally2._sum.ravel() +results2[1::2] = tally2._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' diff --git a/tests/test_score_total/results.py b/tests/test_score_total/results.py index 51cc325fa7..209d1c1224 100644 --- a/tests/test_score_total/results.py +++ b/tests/test_score_total/results.py @@ -14,17 +14,17 @@ else: sp.read_results() # extract tally results and convert to vector -results = sp.tallies[0].results -shape = results.shape -size = (np.product(shape)) -results = np.reshape(results, size) +tally = sp._tallies[1] +results = np.empty((tally._sum.size + tally._sum.size, ), dtype=np.float64) +results[0::2] = tally._sum.ravel() +results[1::2] = tally._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_score_total_yn/results.py b/tests/test_score_total_yn/results.py index 4e4a4b39d8..bafa851f54 100644 --- a/tests/test_score_total_yn/results.py +++ b/tests/test_score_total_yn/results.py @@ -14,21 +14,22 @@ else: sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) +tally1 = sp._tallies[1] +results1 = np.empty((tally1._sum.size + tally1._sum.size, ), dtype=np.float64) +results1[0::2] = tally1._sum.ravel() +results1[1::2] = tally1._sum_sq.ravel() + +tally2 = sp._tallies[2] +results2 = np.empty((tally2._sum.size + tally2._sum.size, ), dtype=np.float64) +results2[0::2] = tally2._sum.ravel() +results2[1::2] = tally2._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' diff --git a/tests/test_seed/results.py b/tests/test_seed/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_seed/results.py +++ b/tests/test_seed/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_source_angle_mono/results.py b/tests/test_source_angle_mono/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_source_angle_mono/results.py +++ b/tests/test_source_angle_mono/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_source_energy_maxwell/results.py b/tests/test_source_energy_maxwell/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_source_energy_maxwell/results.py +++ b/tests/test_source_energy_maxwell/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_source_energy_mono/results.py b/tests/test_source_energy_mono/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_source_energy_mono/results.py +++ b/tests/test_source_energy_mono/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_source_file/results.py b/tests/test_source_file/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_source_file/results.py +++ b/tests/test_source_file/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_source_point/results.py b/tests/test_source_point/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_source_point/results.py +++ b/tests/test_source_point/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_sourcepoint_batch/results.py b/tests/test_sourcepoint_batch/results.py index 5af810c485..9ad1956767 100644 --- a/tests/test_sourcepoint_batch/results.py +++ b/tests/test_sourcepoint_batch/results.py @@ -10,18 +10,19 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.08.binary') + sp.read_results() sp.read_source() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out xyz -xyz = sp.source[0].xyz +xyz = sp._source[0]._xyz for i in xyz: outstr += "{0:12.6E} ".format(i) outstr += "\n" diff --git a/tests/test_sourcepoint_interval/results.py b/tests/test_sourcepoint_interval/results.py index 5af810c485..9ad1956767 100644 --- a/tests/test_sourcepoint_interval/results.py +++ b/tests/test_sourcepoint_interval/results.py @@ -10,18 +10,19 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.08.binary') + sp.read_results() sp.read_source() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out xyz -xyz = sp.source[0].xyz +xyz = sp._source[0]._xyz for i in xyz: outstr += "{0:12.6E} ".format(i) outstr += "\n" diff --git a/tests/test_sourcepoint_latest/results.py b/tests/test_sourcepoint_latest/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_sourcepoint_latest/results.py +++ b/tests/test_sourcepoint_latest/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_sourcepoint_restart/results.py b/tests/test_sourcepoint_restart/results.py index 4e4a4b39d8..6cbf6b259f 100644 --- a/tests/test_sourcepoint_restart/results.py +++ b/tests/test_sourcepoint_restart/results.py @@ -11,31 +11,33 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) +tally10 = sp._tallies[10] +results10 = np.zeros((tally10._sum.size + tally10._sum.size, )) +results10[0::2] = tally10._sum.ravel() +results10[1::2] = tally10._sum_sq.ravel() + +tally5 = sp._tallies[5] +results5 = np.zeros((tally5._sum.size + tally5._sum.size, )) +results5[0::2] = tally5._sum.ravel() +results5[1::2] = tally5._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' -for item in results1: +for item in results10: outstr += "{0:12.6E}\n".format(item) outstr += 'tally 2:\n' -for item in results2: +for item in results5: outstr += "{0:12.6E}\n".format(item) # write results to file diff --git a/tests/test_statepoint_batch/results.py b/tests/test_statepoint_batch/results.py index b0a772e937..1560305302 100644 --- a/tests/test_statepoint_batch/results.py +++ b/tests/test_statepoint_batch/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.09.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_statepoint_interval/results.py b/tests/test_statepoint_interval/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_statepoint_interval/results.py +++ b/tests/test_statepoint_interval/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_statepoint_restart/results.py b/tests/test_statepoint_restart/results.py index cd666289ed..6f7ac25d13 100644 --- a/tests/test_statepoint_restart/results.py +++ b/tests/test_statepoint_restart/results.py @@ -11,31 +11,33 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.07.binary') + sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) +tally5 = sp._tallies[5] +results5 = np.zeros((tally5._sum.size + tally5._sum.size, )) +results5[0::2] = tally5._sum.ravel() +results5[1::2] = tally5._sum_sq.ravel() + +tally10 = sp._tallies[10] +results10 = np.zeros((tally10._sum.size + tally10._sum.size, )) +results10[0::2] = tally10._sum.ravel() +results10[1::2] = tally10._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' -for item in results1: +for item in results10: outstr += "{0:12.6E}\n".format(item) outstr += 'tally 2:\n' -for item in results2: +for item in results5: outstr += "{0:12.6E}\n".format(item) # write results to file diff --git a/tests/test_statepoint_restart/settings.xml b/tests/test_statepoint_restart/settings.xml index 328be2d790..ec9adfb1dc 100644 --- a/tests/test_statepoint_restart/settings.xml +++ b/tests/test_statepoint_restart/settings.xml @@ -1,7 +1,7 @@ - + 10 diff --git a/tests/test_statepoint_sourcesep/results.py b/tests/test_statepoint_sourcesep/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_statepoint_sourcesep/results.py +++ b/tests/test_statepoint_sourcesep/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_survival_biasing/results.py b/tests/test_survival_biasing/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_survival_biasing/results.py +++ b/tests/test_survival_biasing/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_tally_assumesep/results.py b/tests/test_tally_assumesep/results.py index c6fb1932ee..c8870fbc1b 100644 --- a/tests/test_tally_assumesep/results.py +++ b/tests/test_tally_assumesep/results.py @@ -11,28 +11,31 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results1 = sp.tallies[0].results -shape1 = results1.shape -size1 = (np.product(shape1)) -results1 = np.reshape(results1, size1) -results2 = sp.tallies[1].results -shape2 = results2.shape -size2 = (np.product(shape2)) -results2 = np.reshape(results2, size2) -results3 = sp.tallies[2].results -shape3 = results3.shape -size3 = (np.product(shape3)) -results3 = np.reshape(results3, size3) +tally1 = sp._tallies[1] +results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) +results1[0::2] = tally1._sum.ravel() +results1[1::2] = tally1._sum_sq.ravel() + +tally2 = sp._tallies[2] +results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) +results2[0::2] = tally2._sum.ravel() +results2[1::2] = tally2._sum_sq.ravel() + +tally3 = sp._tallies[3] +results3 = np.zeros((tally3._sum.size + tally3._sum.size, )) +results3[0::2] = tally3._sum.ravel() +results3[1::2] = tally3._sum_sq.ravel() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tally 1:\n' diff --git a/tests/test_tally_nuclides/results.py b/tests/test_tally_nuclides/results.py index e12fb11a41..f8cffae959 100644 --- a/tests/test_tally_nuclides/results.py +++ b/tests/test_tally_nuclides/results.py @@ -11,19 +11,28 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # extract tally results and convert to vector -results0 = sp.tallies[0].results -results1 = sp.tallies[1].results -results = np.concatenate((results0.flatten(), results1.flatten())) +tally1 = sp._tallies[1] +results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) +results1[0::2] = tally1._sum.ravel() +results1[1::2] = tally1._sum_sq.ravel() + +tally2 = sp._tallies[2] +results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) +results2[0::2] = tally2._sum.ravel() +results2[1::2] = tally2._sum_sq.ravel() + +results = np.concatenate((results1.flatten(), results2.flatten())) # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write out tally results outstr += 'tallies:\n' diff --git a/tests/test_trace/results.py b/tests/test_trace/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_trace/results.py +++ b/tests/test_trace/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_translation/results.py b/tests/test_translation/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_translation/results.py +++ b/tests/test_translation/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_uniform_fs/results.py b/tests/test_uniform_fs/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_uniform_fs/results.py +++ b/tests/test_uniform_fs/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_universe/results.py b/tests/test_universe/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_universe/results.py +++ b/tests/test_universe/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: diff --git a/tests/test_void/results.py b/tests/test_void/results.py index e1c7836111..43032ef19a 100644 --- a/tests/test_void/results.py +++ b/tests/test_void/results.py @@ -10,14 +10,15 @@ if len(sys.argv) > 1: sp = StatePoint(sys.argv[1]) else: sp = StatePoint('statepoint.10.binary') + sp.read_results() # set up output string outstr = '' - + # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) # write results to file with open('results_test.dat','w') as fh: