Skip to content

Commit

Permalink
Merge pull request #25 from fusion-energy/develop
Browse files Browse the repository at this point in the history
Adding support for unit conversion of damage tallies to DPA
  • Loading branch information
shimwell authored Nov 2, 2021
2 parents 8ff9f34 + f9f78c5 commit 57e8a36
Show file tree
Hide file tree
Showing 18 changed files with 607 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_with_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
- name: install package
run: |
conda install -c conda-forge openmc
# conda install -c cadquery -c conda-forge cadquery=2.1
python setup.py install
- name: install packages for tests
Expand All @@ -45,6 +44,7 @@ jobs:
run: |
cd examples
python processing_2d_mesh_effective_dose_tally.py
python processing_cell_damage-energy_tally.py
python processing_cell_effective_dose_tally.py
python processing_cell_flux_tally.py
python processing_cell_heating_tally.py
Expand Down
3 changes: 1 addition & 2 deletions examples/processing_2d_mesh_effective_dose_tally.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

# scaled from picosievert to sievert
result = opp.process_dose_tally(
tally=my_tally,
required_units="sievert cm **2 / simulated_particle"
tally=my_tally, required_units="sievert cm **2 / simulated_particle"
)
# the tally result with required units
print(result)
68 changes: 68 additions & 0 deletions examples/processing_cell_damage-energy_tally.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import openmc_post_processor as opp
import openmc

# loads in the statepoint file containing tallies
statepoint = openmc.StatePoint(filepath="statepoint.2.h5")

# gets one tally from the available tallies
my_tally = statepoint.get_tally(name="2_damage-energy")


# returns the tally with base units
result = opp.process_damage_energy_tally(
tally=my_tally, required_units="eV / simulated_particle"
)
print(f"damage-energy base units = {result}", end="\n\n")


# returns the tally with scalled based units (MeV instead of eV)
result, std_dev = opp.process_damage_energy_tally(
tally=my_tally,
required_units="MeV / simulated_particle"
# required_units="displacements per atoms"
)
print(f"damage-energy scaled base units = {result}", end="\n\n")

# # returns the tally with scalled based units (MeV instead of eV)
result, std_dev = opp.process_damage_energy_tally(
tally=my_tally,
required_units="MeV",
source_strength=1,
)
print(f"damage-energy scaled base units = {result}", end="\n\n")


my_mat = openmc.Material()
my_mat.add_element("Fe", 1)
my_mat.set_density("g/cm3", 1)

result, std_dev = opp.process_damage_energy_tally(
tally=my_tally,
required_units="MeV per atom",
source_strength=1,
volume=5,
material=my_mat,
)
print(f"damage-energy scaled base units = {result}", end="\n\n")

result, std_dev = opp.process_damage_energy_tally(
tally=my_tally,
required_units="displacements",
source_strength=1,
volume=5,
material=my_mat,
energy_per_displacement=10,
recombination_fraction=0.1,
)
print(f"damage-energy = {result}", end="\n\n")

result, std_dev = opp.process_damage_energy_tally(
tally=my_tally,
required_units="displacements per pulse",
source_strength=0.5,
volume=5,
material=my_mat,
energy_per_displacement=10,
recombination_fraction=0.1,
)
print(f"damage-energy = {result}", end="\n\n")
3 changes: 1 addition & 2 deletions examples/processing_cell_flux_tally.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

# returns the tally with base units
result = opp.process_tally(
tally=my_tally,
required_units="centimeter / simulated_particle"
tally=my_tally, required_units="centimeter / simulated_particle"
)
print(f"flux base units = {result[0].units}", end="\n\n")

Expand Down
5 changes: 1 addition & 4 deletions examples/processing_cell_heating_tally.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@


# returns the tally with base units
result = opp.process_tally(
tally=my_tally,
required_units='eV / simulated_particle'
)
result = opp.process_tally(tally=my_tally, required_units="eV / simulated_particle")
print(f"heating base units = {result}", end="\n\n")


Expand Down
4 changes: 2 additions & 2 deletions examples/processing_cell_spectra_tally.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
tally=my_tally,
required_units="centimeter / pulse",
required_energy_units="eV",
source_strength=1.3e6
source_strength=1.3e6,
)
print(f"spectra per pulse = {result}", end="\n\n")

Expand All @@ -40,6 +40,6 @@
tally=my_tally,
required_units="centimeter / second",
required_energy_units="MeV",
source_strength=1e9
source_strength=1e9,
)
print(f"spectra per pulse = {result}", end="\n\n")
8 changes: 4 additions & 4 deletions examples/processing_mutliple_cell_spectra_tally.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
y_scale="log",
filename="combine_spectra_plot_1.html",
required_energy_units="eV",
plotting_package='plotly',
plotting_package="plotly",
required_units="centimeters / simulated_particle",
)

Expand All @@ -33,7 +33,7 @@
y_scale="log",
filename="combine_spectra_plot_2.html",
required_energy_units="MeV",
plotting_package='plotly',
plotting_package="plotly",
required_units="centimeter / second",
source_strength=1.3e6,
)
Expand All @@ -47,8 +47,8 @@
y_scale="log",
filename="combine_spectra_plot_3.html",
required_energy_units="MeV",
plotting_package='plotly',
plotting_package="plotly",
required_units="neutrons / second * cm ** -2",
source_strength=1.3e7,
volume=100
volume=100,
)
3 changes: 2 additions & 1 deletion openmc_post_processor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
process_tally,
process_dose_tally,
process_spectra_tally,
scale_tally
process_damage_energy_tally,
scale_tally,
)
2 changes: 2 additions & 0 deletions openmc_post_processor/neutronics_units.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ particle = []
neutron = []
photon = []
simulated_particle = []
atom = [atom]
displacements = [displacements]
pulse = [pulse]
Loading

0 comments on commit 57e8a36

Please sign in to comment.