-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from fusion-energy/develop
removing class usage and moving to functions
- Loading branch information
Showing
18 changed files
with
341 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,4 +134,5 @@ dmypy.json | |
*.out | ||
*.stl | ||
*.xml | ||
*.vscode/ | ||
*.vscode/ | ||
*.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
|
||
This Python package aims to help convert OpenMC tallies to user specified units. | ||
|
||
OpenMC tallies are recorded save saved without units. | ||
OpenMC tally results are save into at statepoint.h5 file without units. | ||
|
||
This package ascertains the units of common tallies using the tally filters and scores. | ||
|
||
The Pint Python package to scale the base tally units to different units. For example Pint can easily convert cm to meters or electron volts to joules. | ||
The package then allows users to scale the base tally units to different units. For example the package can easily convert cm to meters or electron volts to joules. | ||
|
||
Additional inputs can be applied to normalise the the tallies by the source strength of the source. For example if ```neutrons_per_second``` is provided then tallies can be scaled and the base units of tallies can be converted to more user friendly units. For example heating tallies are recorded in electron volts per source particle. However this can be converted to Watt. | ||
Additional inputs can be applied to normalise the the tallies. by the source strength of the source. For example if ```strength_strength``` is provided then tallies can converted from the base units to user friendly units. For example heating tallies are recorded in electron volts per source particle. However this can be converted to Watts. | ||
|
||
Scaling by the volume of the cell or mesh is also possible by ```volume``` and requesting units that require normalising with volume. Follow on from the previous example with would allow converion of heating tallies in thier base units of electron volts per source particle to be converted to Watts per cm3. | ||
|
||
:point_right: [Examples](https://github.com/fusion-energy/openmc_post_processor/tree/main/examples) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,24 @@ | ||
import openmc | ||
import openmc_post_processor as opp | ||
from regular_mesh_plotter import plot_mesh, plot_stl_slice, plot_mesh_tally | ||
from matplotlib.colors import LogNorm | ||
|
||
|
||
# loads in the statepoint file containing tallies | ||
statepoint = opp.StatePoint(filepath="statepoint.2.h5") | ||
statepoint = openmc.StatePoint(filepath="statepoint.2.h5") | ||
my_tally = statepoint.get_tally(name="neutron_effective_dose_on_2D_mesh_xy") | ||
|
||
|
||
# returns the tally with base units | ||
result = statepoint.process_tally( | ||
result = opp.process_dose_tally( | ||
tally=my_tally, | ||
) | ||
# the tally result with required units | ||
print(result) | ||
|
||
# opp.plot_2d_mesh_tally(result, "unprocessed_image.png") | ||
|
||
# scaled from picosievert to sievert | ||
result = statepoint.process_tally( | ||
tally=my_tally, required_units="sievert cm **2 / simulated_particle" | ||
) | ||
|
||
# opp.plot_2d_mesh_tally(result, "scaled_image.png") | ||
|
||
result = statepoint.process_tally( | ||
source_strength=1.3e6, tally=my_tally, required_units="sievert cm **2 / pulse" | ||
) | ||
# opp.plot_2d_mesh_tally(result, "scaled_per_pulse_image.png") | ||
|
||
|
||
result = statepoint.process_tally( | ||
source_strength=1.3e6, | ||
result = opp.process_dose_tally( | ||
tally=my_tally, | ||
required_units="picosievert / cm / pulse", | ||
required_units="sievert cm **2 / simulated_particle" | ||
) | ||
|
||
|
||
stl_slice = plot_stl_slice( | ||
stl_or_mesh='steel.stl', | ||
plane_origin = None, | ||
plane_normal = [0, 0, 1], | ||
rotate_plot = 0, | ||
filename='slice.png' | ||
) | ||
|
||
|
||
plot_mesh( | ||
# extent=[-200,200, -200,200], | ||
values= result, | ||
scale=None, # LogNorm(), | ||
vmin=None, | ||
label="picosievert / cm / pulse", | ||
base_plt=stl_slice, | ||
filename= 'test.png', | ||
# vmin=1e6, | ||
) | ||
|
||
mesh_filter = plot_mesh_tally(my_tally) | ||
|
||
# print(result) | ||
# print(result.shape) | ||
# the tally result with required units | ||
print(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,34 @@ | ||
import openmc | ||
import openmc_post_processor as opp | ||
|
||
|
||
# loads in the statepoint file containing tallies | ||
statepoint = opp.StatePoint(filepath="statepoint.2.h5") | ||
statepoint = openmc.StatePoint(filepath="statepoint.2.h5") | ||
|
||
# gets one tally from the available tallies | ||
my_tally = statepoint.get_tally(name="2_neutron_effective_dose") | ||
|
||
|
||
# returns the tally with base units | ||
result = statepoint.process_tally(tally=my_tally) | ||
result = opp.process_dose_tally(tally=my_tally) | ||
print(f"effective dose base units = {result}", end="\n\n") | ||
|
||
|
||
# returns the tally with scalled based units (MeV instead of eV) | ||
result = statepoint.process_tally( | ||
result = opp.process_dose_tally( | ||
tally=my_tally, required_units="sievert cm **2 / simulated_particle" | ||
) | ||
print(f"effective dose scaled base units = {result}", end="\n\n") | ||
|
||
|
||
# returns the tally with normalisation per pulse | ||
result = statepoint.process_tally( | ||
result = opp.process_dose_tally( | ||
source_strength=1.3e6, tally=my_tally, required_units="sievert cm **2 / pulse" | ||
) | ||
print(f"effective dose per pulse = {result}", end="\n\n") | ||
|
||
|
||
# returns the tally with normalisation for source strength | ||
statepoint.process_tally( | ||
opp.process_dose_tally( | ||
source_strength=1.3e6, tally=my_tally, required_units="Sv cm **2 / second" | ||
) | ||
print(f"effective dose per second = {result}", end="\n\n") | ||
|
||
|
||
# # returns the tally with normalisation per pulse and conversion to joules | ||
# result = statepoint.process_tally( | ||
# source_strength=1e9, | ||
# volume=100, | ||
# tally=my_tally, | ||
# required_units='joules / pulse' | ||
# ) | ||
# print(f'effective dose per pulse = {result}', end='\n\n') | ||
|
||
|
||
# # returns the tally with normalisation for source strength and conversion to joules | ||
# result = statepoint.process_tally( | ||
# fusion_power=1e9, | ||
# tally=my_tally, | ||
# required_units='joules / second' | ||
# ) | ||
# print(f'effective dose per second = {result}', end='\n\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
import openmc_post_processor as opp | ||
|
||
import openmc | ||
|
||
# loads in the statepoint file containing tallies | ||
statepoint = opp.StatePoint(filepath="statepoint.2.h5") | ||
statepoint = openmc.StatePoint(filepath="statepoint.2.h5") | ||
|
||
# gets one tally from the available tallies | ||
my_tally = statepoint.get_tally(name="2_heating") | ||
|
||
|
||
# returns the tally with base units | ||
result = statepoint.process_tally(tally=my_tally) | ||
result = opp.process_tally(tally=my_tally) | ||
print(f"heating base units = {result}", end="\n\n") | ||
|
||
|
||
# returns the tally with scalled based units (MeV instead of eV) | ||
result = statepoint.process_tally(tally=my_tally, required_units="MeV / simulated_particle") | ||
result = opp.process_tally(tally=my_tally, required_units="MeV / simulated_particle") | ||
print(f"heating scalled base units = {result}", end="\n\n") | ||
|
||
|
||
# returns the tally with normalisation per pulse | ||
result = statepoint.process_tally( | ||
result = opp.process_tally( | ||
source_strength=1.3e6, tally=my_tally, required_units="MeV / pulse" | ||
) | ||
print(f"heating per pulse = {result}", end="\n\n") | ||
|
||
|
||
# returns the tally with normalisation for source strength | ||
statepoint.process_tally(source_strength=1e9, tally=my_tally, required_units="MeV / second") | ||
opp.process_tally(source_strength=1e9, tally=my_tally, required_units="MeV / second") | ||
print(f"heating per second = {result}", end="\n\n") | ||
|
||
|
||
# returns the tally with normalisation per pulse and conversion to joules | ||
result = statepoint.process_tally( | ||
result = opp.process_tally( | ||
source_strength=1.3e6, tally=my_tally, required_units="joules / pulse" | ||
) | ||
print(f"heating per pulse = {result}", end="\n\n") | ||
|
||
|
||
# returns the tally with normalisation for source strength and conversion to joules | ||
result = statepoint.process_tally( | ||
result = opp.process_tally( | ||
source_strength=1e9, tally=my_tally, required_units="joules / second" | ||
) | ||
print(f"heating per second = {result}", end="\n\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,32 @@ | ||
import openmc | ||
import openmc_post_processor as opp | ||
from spectrum_plotter import plot_spectrum # a convenient plotting package | ||
|
||
|
||
# loads in the statepoint file containing tallies | ||
statepoint = opp.StatePoint(filepath="statepoint.2.h5") | ||
statepoint = openmc.StatePoint(filepath="statepoint.2.h5") | ||
|
||
# gets one tally from the available tallies | ||
my_tally = statepoint.get_tally(name="2_neutron_spectra") | ||
|
||
|
||
# returns the tally with base units | ||
result = statepoint.process_tally( | ||
result = opp.process_spectra_tally( | ||
tally=my_tally, | ||
) | ||
print(f"spectra with base units = {result}", end="\n\n") | ||
|
||
|
||
# returns the tally with normalisation per pulse | ||
result = statepoint.process_tally( | ||
result = opp.process_spectra_tally( | ||
tally=my_tally, required_units=["eV", "centimeter / pulse"], source_strength=1.3e6 | ||
) | ||
print(f"spectra per pulse = {result}", end="\n\n") | ||
|
||
|
||
# returns the tally scalled and normalisation for source strength | ||
print(f"spectra per second = {result}", end="\n\n") | ||
result = statepoint.process_tally( | ||
result = opp.process_spectra_tally( | ||
tally=my_tally, required_units=["MeV", "centimeter / second"], source_strength=1e9 | ||
) | ||
print(f"spectra per pulse = {result}", end="\n\n") | ||
|
||
# plots a graph of the results | ||
plot_spectrum( | ||
spectrum={"legend": (result[0], result[1])}, | ||
x_label="Energy [MeV]", | ||
y_label="neutron flux [centimeter / second]", | ||
x_scale="log", | ||
y_scale="log", | ||
# trim_zeros=False, | ||
filename="step_line_graph.png", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.