-
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 #23 from fusion-energy/develop
reproducing basic plots
- Loading branch information
Showing
15 changed files
with
659 additions
and
594 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
- main | ||
|
||
|
||
jobs: | ||
testing: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: openmc/openmc:v0.13.1 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: install package | ||
run: | | ||
pip install . | ||
python -c "import openmc_depletion_plotter" | ||
- name: run examples | ||
run: | | ||
python examples/plot_activity_vs_time.py | ||
python examples/plot_isotope_charts.py | ||
python examples/plot_multiple_isotope_charts.py | ||
python examples/plot_pulse_schedule.py | ||
- name: run tests | ||
run: | | ||
pip install .[tests] | ||
pytest tests -v |
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,2 +1,55 @@ | ||
# openmc_depletion_plotter | ||
Plot the atoms present during depletion steps on an isotope chart. | ||
Extends OpenMC to provides convienent plotting methods. | ||
This is done by Monkey Patching OpenMC to provide additional functionality to the base classes. | ||
One benefit of this is the user can continue to work with the familiar OpenMC classes and they simply get additional functionality. | ||
Another benefit is that if any of these functions ever become popular enough to include in OpenMC then it could be done with a simple copy paste into the existing class structure. | ||
Plotly figures or MatPlotLib figures are returned for user customization. | ||
|
||
# Plotting pulse schedule | ||
|
||
All the Integrator classes have been extended to include a ```.plot_pulse_schedule()``` method. | ||
|
||
This method plots the source rate as a function of time. | ||
|
||
This is useful when wanting to visually display a pulse schedule used in an depletion / activation study. | ||
|
||
Additional methods provided | ||
|
||
```python | ||
openmc.deplete.PredictorIntegrator.plot_pulse_schedule() | ||
openmc.deplete.CECMIntegrator.plot_pulse_schedule() | ||
openmc.deplete.CF4Integrator.plot_pulse_schedule() | ||
openmc.deplete.CELIIntegrator.plot_pulse_schedule() | ||
openmc.deplete.EPCRK4Integrator.plot_pulse_schedule() | ||
openmc.deplete.LEQIIntegrator.plot_pulse_schedule() | ||
openmc.deplete.SICELIIntegrator.plot_pulse_schedule() | ||
openmc.deplete.SILEQIIntegrator.plot_pulse_schedule() | ||
``` | ||
|
||
# Plotting activation or atoms as a function of time | ||
|
||
The ```openmc.deplete.Results()``` class has been extended to include a ```plot_atoms_vs_time()``` method and a ```plot_activity_vs_time``` method. | ||
|
||
These methods plot atoms or activity as a function of time. | ||
These plots optionally include a breakdown of the dominant nuclides. | ||
|
||
Additional methods provided | ||
|
||
```python | ||
openmc.deplete.Results.plot_atoms_vs_time() | ||
openmc.deplete.Results.plot_activity_vs_time() | ||
``` | ||
|
||
# Plotting activation or atoms on an isotope chart | ||
|
||
The ```openmc.Material()``` class has been extended to include a ```plot_isotope_chart_of_activity()``` method and ```plot_isotope_chart_of_atoms()``` method. | ||
|
||
This method plots the material atoms or the material activity on an isotope chart. | ||
|
||
I started making isotope plots back in 2010 so nice to finally distribute this :smile: | ||
|
||
Additional methods provided | ||
|
||
```python | ||
openmc.Material.plot_isotope_chart_of_atoms() | ||
openmc.Material.plot_isotope_chart_of_activity() | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import openmc | ||
import openmc.deplete | ||
import openmc_depletion_plotter | ||
from pathlib import Path | ||
|
||
|
||
output_dir = "/home/jshimwell/activation_example/outputs_Aluminum_maintenance" | ||
results = openmc.deplete.Results.from_hdf5(Path(output_dir) / "depletion_results.h5") | ||
|
||
# plot = results.plot_activity_vs_time() | ||
# plot.show() | ||
plot = results.plot_atoms_vs_time() | ||
plot.show() | ||
|
||
|
||
# def load_data(output_dir, time_units="d"): | ||
|
||
# results = openmc.deplete.Results.from_hdf5(Path(output_dir) / "depletion_results.h5") | ||
# time_steps = results.get_times(time_units=time_units) | ||
|
||
# unirradiated_material = openmc.Summary(str(Path(output_dir) / "summary.h5")).materials[0] | ||
|
||
# all_materials = [] | ||
# for counter, step in enumerate(time_steps): | ||
# materials = results.export_to_materials(counter)[ | ||
# 0 | ||
# ] # zero index as one material in problem | ||
# all_materials.append(materials) | ||
# openmc_materials = openmc.Materials(all_materials) | ||
|
||
# return openmc_materials, time_steps, unirradiated_material | ||
|
||
# openmc_materials, time_steps, unirradiated_material = load_data("/home/jshimwell/activation_example/outputs_Aluminum_maintenance") | ||
|
||
# openmc_materials[0].plot_isotope_atom_chart() |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import openmc | ||
import openmc_depletion_plotter # adds plotting methods to the material class | ||
|
||
my_mat = openmc.Material() | ||
my_mat.add_element("Fe", 1) | ||
my_mat.add_element("Li", 0.5) | ||
my_mat.add_element("Be", 0.5) | ||
my_mat.add_element("Al", 0.5) | ||
my_mat.add_element("B", 0.5) | ||
my_mat.add_element("Co", 0.5) | ||
my_mat.add_element("Cs", 0.5) | ||
my_mat.add_nuclide("Fe60", 0.1) | ||
my_mat.add_nuclide("Fe61", 0.2) | ||
my_mat.add_nuclide("Fe62", 0.3) | ||
my_mat.set_density("g/cm3", 7.7) | ||
my_mat.volume = 1 | ||
|
||
plotly_figure = my_mat.plot_isotope_chart_of_activity(my_mat) | ||
plotly_figure.write_html("my_mat_activity_on_isotope_chart.html") | ||
plotly_figure.write_image("my_mat_activity_on_isotope_chart.png") | ||
plotly_figure.show() | ||
|
||
plotly_figure_2 = my_mat.plot_isotope_chart_of_atoms(my_mat) | ||
plotly_figure_2.write_html("my_mat_atoms_on_isotope_chart.html") | ||
plotly_figure_2.write_image("my_mat_atoms_on_isotope_chart.png") | ||
plotly_figure_2.show() |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import openmc | ||
import openmc_depletion_plotter # adds plotting methods to the material class | ||
|
||
my_mat = openmc.Material() | ||
my_mat.add_element("Fe", 1) | ||
my_mat.add_element("Li", 0.5) | ||
my_mat.add_element("Be", 0.5) | ||
my_mat.add_element("Al", 0.5) | ||
my_mat.add_element("B", 0.5) | ||
my_mat.add_element("Co", 0.5) | ||
my_mat.set_density("g/cm3", 7.7) | ||
my_mat.volume = 1 | ||
|
||
my_mat_2 = openmc.Material() | ||
my_mat_2.add_element("Fe", 1) | ||
my_mat_2.add_element("Li", 0.5) | ||
my_mat_2.add_element("C", 0.5) | ||
my_mat_2.add_element("Al", 0.5) | ||
my_mat_2.add_element("Ni", 0.5) | ||
my_mat_2.add_element("Co", 0.5) | ||
my_mat_2.set_density("g/cm3", 7.7) | ||
my_mat_2.volume = 1 | ||
|
||
for mat, filename in zip([my_mat, my_mat_2], ["my_mat_1.png", "my_mat_2.png"]): | ||
plotly_figure = mat.plot_isotope_chart_of_atoms() | ||
plotly_figure.write_image(filename) |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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.