Skip to content

Commit

Permalink
Merge pull request #15 from fusion-energy/removing_reshaping
Browse files Browse the repository at this point in the history
removed reshaping of tallies
  • Loading branch information
shimwell authored Oct 27, 2021
2 parents 2f1bec3 + a47c7ea commit c282c06
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 122 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,4 @@ dmypy.json
*.xml
*.vscode/
*.png
*.html
10 changes: 4 additions & 6 deletions examples/processing_cell_flux_tally.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@
# gets one tally from the available tallies
my_tally = statepoint.get_tally(name="2_flux")

print("default openmc tally result in base units", my_tally, end="\n\n")

print(opp.find_source_strength(fusion_energy_per_second_or_per_pulse=1.3e6))
# print(opp.find_source_strength(fusion_energy_per_second_or_per_pulse=1.3e6))

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


# returns the tally with scalled based units (m instead of cm)
result = opp.process_tally(
tally=my_tally, required_units="meter / simulated_particle"
tally=my_tally, required_units="centimeter * particle / simulated_particle"
)
print(f"flux scaled base units = {result}", end="\n\n")
print(f"flux scaled base units = {result[0].units}", end="\n\n")


# returns the tally with normalisation per pulse
Expand Down
19 changes: 16 additions & 3 deletions examples/processing_cell_spectra_tally.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,31 @@
)
print(f"spectra with base units = {result}", end="\n\n")

# returns the tally with base units
result = opp.process_spectra_tally(
tally=my_tally,
required_units="centimeter",
required_energy_units="MeV",
)
print(f"spectra with base units = {result}", end="\n\n")


# returns the tally with normalisation per pulse
result = opp.process_spectra_tally(
tally=my_tally, required_units=["eV", "centimeter / pulse"], source_strength=1.3e6
tally=my_tally,
required_units="centimeter / pulse",
required_energy_units="eV",
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 = opp.process_spectra_tally(
tally=my_tally, required_units=["MeV", "centimeter / second"], source_strength=1e9
tally=my_tally,
required_units="centimeter / second",
required_energy_units="MeV",
source_strength=1e9
)
print(f"spectra per pulse = {result}", end="\n\n")

13 changes: 8 additions & 5 deletions examples/processing_mutliple_cell_spectra_tally.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
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")

results = {}
for tally_name in ["2_neutron_spectra", "3_neutron_spectra"]:
Expand All @@ -11,21 +12,23 @@
my_tally = statepoint.get_tally(name=tally_name)

# returns the tally with normalisation per pulse
result = statepoint.process_tally(
result = opp.process_spectra_tally(
tally=my_tally,
required_units=["MeV", "centimeter / pulse"],
required_units="centimeter / pulse",
required_energy_units="MeV",
source_strength=1.3e6,
)
results[tally_name] = result


# plots a graph of the results
plot_spectrum(
plot = plot_spectrum(
spectrum=results,
x_label="Energy [MeV]",
y_label="neutron flux [centimeter / second]",
x_scale="log",
y_scale="log",
# trim_zeros=False,
filename="combine_spectra_plot.png",
filename="combine_spectra_plot.html",
plotting_package='plotly'
)
2 changes: 0 additions & 2 deletions openmc_post_processor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from .utils import (
find_fusion_energy_per_reaction,
get_tally_units,
get_tally_units_dose,
get_tally_units_spectra,
check_for_dimentionality_difference,
find_source_strength,
compute_volume_of_voxels,
Expand Down
Loading

0 comments on commit c282c06

Please sign in to comment.