From 2f0c2faa97197894290167e7f808cb42a58628db Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 3 Nov 2021 16:19:47 +0000 Subject: [PATCH 1/8] added specific version for pyparsing --- .github/workflows/ci_with_install.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index 9f56a05..a2f8c32 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -27,6 +27,7 @@ jobs: - name: install package run: | + pip install pyparsing<=2.47 conda install -c conda-forge h5py=3.2.1 conda install -c conda-forge moab conda install -c conda-forge openmc From 90a2850c30b84d076b69d26cacb7a5769c7bf8d4 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 3 Nov 2021 16:20:50 +0000 Subject: [PATCH 2/8] reverted last commit --- .github/workflows/ci_with_install.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index a2f8c32..9f56a05 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -27,7 +27,6 @@ jobs: - name: install package run: | - pip install pyparsing<=2.47 conda install -c conda-forge h5py=3.2.1 conda install -c conda-forge moab conda install -c conda-forge openmc From 5084152d15688230f187856e5105ee71aceedce2 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Thu, 4 Nov 2021 14:28:25 +0000 Subject: [PATCH 3/8] commented out print statements --- openmc_post_processor/utils.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/openmc_post_processor/utils.py b/openmc_post_processor/utils.py index acb2427..4858b94 100644 --- a/openmc_post_processor/utils.py +++ b/openmc_post_processor/utils.py @@ -51,7 +51,7 @@ def process_damage_energy_tally( data_frame = tally.get_pandas_dataframe() - print(f"tally {tally.name} base units {base_units}") + # print(f"tally {tally.name} base units {base_units}") tally_result = np.array(data_frame["mean"]) @@ -75,7 +75,7 @@ def process_damage_energy_tally( number_of_atoms_per_cm3 = density_in_g_per_cm3 / atomic_mass_in_g else: number_of_atoms_per_cm3 = None - print("number_of_atoms_per_cm3", number_of_atoms_per_cm3) + # print("number_of_atoms_per_cm3", number_of_atoms_per_cm3) scaled_tally_result = scale_tally( tally, @@ -146,7 +146,7 @@ def process_spectra_tally( # checks for user provided base units base_units = get_tally_units(tally) - print(f"tally {tally.name} base units {base_units}") + # print(f"tally {tally.name} base units {base_units}") # numpy array is needed as a pandas series can't have units @@ -225,7 +225,7 @@ def process_dose_tally( data_frame = tally.get_pandas_dataframe() - print(f"tally {tally.name} base units {base_units}") + # print(f"tally {tally.name} base units {base_units}") tally_result = np.array(data_frame["mean"]) * base_units @@ -294,7 +294,7 @@ def process_tally( base_units = get_tally_units(tally) - print(f"tally {tally.name} base units {base_units}") + # print(f"tally {tally.name} base units {base_units}") tally_result = np.array(data_frame["mean"]) * base_units @@ -356,7 +356,7 @@ def scale_tally( and displacement_diff == -1 ): - print("energy per displacement_diff scaling needed (eV)") + # print("energy per displacement_diff scaling needed (eV)") if energy_per_displacement: energy_per_displacement = ( energy_per_displacement * ureg.electron_volt / ureg["displacements"] @@ -372,7 +372,7 @@ def scale_tally( tally_result.units, required_units, "[displacements]" ) if displacement_diff == -1: - print("energy per displacement_diff scaling needed (eV)") + # print("energy per displacement_diff scaling needed (eV)") if energy_per_displacement: energy_per_displacement = ( energy_per_displacement * ureg.electron_volt / ureg["displacements"] @@ -387,7 +387,7 @@ def scale_tally( tally_result.units, required_units, "[time]" ) if time_diff != 0: - print("time scaling needed (seconds)") + # print("time scaling needed (seconds)") if source_strength: source_strength = source_strength * ureg["1 / second"] if time_diff == -1: @@ -403,7 +403,7 @@ def scale_tally( tally_result.units, required_units, "[pulse]" ) if time_diff != 0: - print("time scaling needed (pulse)") + # print("time scaling needed (pulse)") if source_strength: source_strength = source_strength * ureg["1 / pulse"] if time_diff == -1: @@ -419,7 +419,7 @@ def scale_tally( tally_result.units, required_units, "[length]" ) if length_diff != 0: - print("length scaling needed") + # print("length scaling needed") if volume: volume_with_units = volume * ureg["centimeter ** 3"] else: @@ -438,25 +438,25 @@ def scale_tally( raise ValueError(msg) if length_diff == 3: - print("dividing by volume") + # print("dividing by volume") tally_result = tally_result / volume_with_units elif length_diff == -3: - print("multiplying by volume") + # print("multiplying by volume") tally_result = tally_result * volume_with_units atom_diff = check_for_dimentionality_difference( tally_result.units, required_units, "[atom]" ) if atom_diff != 0: - print("atom scaling needed") + # print("atom scaling needed") if atoms: atoms = atoms * ureg["atom"] if atom_diff == 1: - print("dividing by atom") + # print("dividing by atom") tally_result = tally_result / atoms elif atom_diff == -1: - print("multiplying by atom") + # print("multiplying by atom") tally_result = tally_result * atoms else: @@ -573,7 +573,7 @@ def get_tally_units(tally): units = units / (ureg.simulated_particle * ureg.centimeter ** 2) if tally.scores == ["flux"]: - print("score is flux") + # print("score is flux") # tally has units of particle-cm2 per simulated_particle # https://openmc.discourse.group/t/normalizing-tally-to-get-flux-value/99/4 units = get_particles_from_tally_filters(tally, ureg) From 6d0a6fdccddddf0dfc045cb810b44c1d1b28f9ab Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Thu, 4 Nov 2021 15:08:25 +0000 Subject: [PATCH 4/8] added get_data_frame_columns --- openmc_post_processor/utils.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/openmc_post_processor/utils.py b/openmc_post_processor/utils.py index 4858b94..b30716a 100644 --- a/openmc_post_processor/utils.py +++ b/openmc_post_processor/utils.py @@ -3,6 +3,7 @@ import numpy as np import openmc +import pandas as pd import pint ureg = pint.UnitRegistry() @@ -89,7 +90,7 @@ def process_damage_energy_tally( tally_in_required_units = scaled_tally_result.to(required_units) - if "std. dev." in data_frame.columns.to_list(): + if "std. dev." in get_data_frame_columns(data_frame): tally_std_dev_base = np.array(data_frame["std. dev."]) * base_units scaled_tally_std_dev = scale_tally( tally, @@ -163,7 +164,7 @@ def process_spectra_tally( ) tally_in_required_units = scaled_tally_result.to(required_units) - if "std. dev." in data_frame.columns.to_list(): + if "std. dev." in get_data_frame_columns(data_frame): tally_std_dev_base = np.array(data_frame["std. dev."]) * base_units scaled_tally_std_dev = scale_tally( tally, @@ -238,7 +239,7 @@ def process_dose_tally( ) tally_in_required_units = scaled_tally_result.to(required_units) - if "std. dev." in data_frame.columns.to_list(): + if "std. dev." in get_data_frame_columns(data_frame): tally_std_dev_base = np.array(data_frame["std. dev."]) * base_units scaled_tally_std_dev = scale_tally( tally, @@ -307,7 +308,7 @@ def process_tally( ) tally_in_required_units = scaled_tally_result.to(required_units) - if "std. dev." in data_frame.columns.to_list(): + if "std. dev." in get_data_frame_columns(data_frame): tally_std_dev_base = np.array(data_frame["std. dev."]) * base_units scaled_tally_std_dev = scale_tally( tally, @@ -602,3 +603,11 @@ def check_for_dimentionality_difference(units_1, units_2, unit_to_compare): units_1_dimentions = units_1.dimensionality.get(unit_to_compare) units_2_dimentions = units_2.dimensionality.get(unit_to_compare) return units_1_dimentions - units_2_dimentions + + +def get_data_frame_columns(data_frame): + if isinstance(data_frame.columns, pd.MultiIndex): + data_frame_columns = data_frame.columns.get_level_values(0).to_list() + else: + data_frame_columns = data_frame.columns.to_list() + return data_frame_columns From fa871d840802f0fe7854103bc2190cb5839c8127 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 8 Nov 2021 19:37:28 +0000 Subject: [PATCH 5/8] fixed bug with tally --- openmc_post_processor/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openmc_post_processor/utils.py b/openmc_post_processor/utils.py index acb2427..62953bd 100644 --- a/openmc_post_processor/utils.py +++ b/openmc_post_processor/utils.py @@ -570,9 +570,9 @@ def get_tally_units(tally): if tally.scores == ["current"]: units = get_particles_from_tally_filters(tally, ureg) - units = units / (ureg.simulated_particle * ureg.centimeter ** 2) + units = units / (ureg.simulated_particle) - if tally.scores == ["flux"]: + elif tally.scores == ["flux"]: print("score is flux") # tally has units of particle-cm2 per simulated_particle # https://openmc.discourse.group/t/normalizing-tally-to-get-flux-value/99/4 From 73b1e92f80dae7d3f41bd7a6764fab3f15b6a5c9 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 8 Nov 2021 19:39:37 +0000 Subject: [PATCH 6/8] move to openmc docker image --- .github/workflows/ci_with_install.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index 9f56a05..77aa460 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -20,16 +20,13 @@ jobs: testing: runs-on: ubuntu-latest container: - image: continuumio/miniconda3:4.9.2 + image: openmc/openmc:stable steps: - name: Checkout repository uses: actions/checkout@v2 - name: install package run: | - conda install -c conda-forge h5py=3.2.1 - conda install -c conda-forge moab - conda install -c conda-forge openmc python setup.py install - name: install packages for tests From d0d23673d62afef37b14096e7d8905f06e256ab4 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 8 Nov 2021 19:44:46 +0000 Subject: [PATCH 7/8] using latest image --- .github/workflows/ci_with_install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index 77aa460..edc043c 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -20,7 +20,7 @@ jobs: testing: runs-on: ubuntu-latest container: - image: openmc/openmc:stable + image: openmc/openmc:latest steps: - name: Checkout repository uses: actions/checkout@v2 From edbc3ed66670d597353a807bdb7213ac46ce4a50 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 8 Nov 2021 19:48:35 +0000 Subject: [PATCH 8/8] using image with dagmc --- .github/workflows/ci_with_install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index edc043c..bb8024a 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -20,7 +20,7 @@ jobs: testing: runs-on: ubuntu-latest container: - image: openmc/openmc:latest + image: openmc/openmc:latest-dagmc steps: - name: Checkout repository uses: actions/checkout@v2