Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to get toroidal models, add parastell tool, overhaul text wrapping, allow more generalized text in plot #13

Merged
merged 29 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6a902d0
begin work on parastell plotter
Edgar-21 Apr 26, 2024
7f4e279
added method to plot from parastell build dict, write yaml file
Edgar-21 Apr 26, 2024
9f6a77c
update to text wrapping, allow more flexibility in layer text, add pa…
Edgar-21 Apr 26, 2024
b8abd6a
added example for plot_parastell_build
Edgar-21 Apr 26, 2024
ff728b8
make writing yml optional behavior
Edgar-21 Apr 26, 2024
3c0c4e5
pep8
Edgar-21 Apr 26, 2024
2dd75a5
combined functions in plot_radial_build.py into the class radial_buil…
Edgar-21 May 10, 2024
4ddd7db
add get_toroidal_model function
Edgar-21 May 12, 2024
e763f0d
updated how args get passed to plotting function, updated examples
Edgar-21 May 12, 2024
2410523
reformatted keyError message
Edgar-21 May 12, 2024
bd9df66
updated radial_build() docstring
Edgar-21 May 12, 2024
1b7a2f4
updated radial_build() docstring
Edgar-21 May 12, 2024
4cf5bc7
raise after excepting keyError in get_toroidal_model()
Edgar-21 May 12, 2024
e9c6593
correct return values in get_toroidal_model() docstring
Edgar-21 May 12, 2024
2c9cfc7
skip zero thickness layers when building toroidal model
Edgar-21 Jun 3, 2024
af9b5d6
skip layer in plot if thickness is specified to be zero
Edgar-21 Jun 4, 2024
691bde3
update to use built in textwrap, fix zero thickness plotting logic
Edgar-21 Jun 7, 2024
ed05401
ignore xml and pkl files
Edgar-21 Jun 7, 2024
82c1dbf
use self.__dict__ to dump yaml
Edgar-21 Jun 7, 2024
0a9d9d9
split plotting and model building into two classes, update examples
Edgar-21 Jun 8, 2024
0fbf079
add method for getting plot from toroidal model
Edgar-21 Jun 9, 2024
504af87
skip zero thickness layers in model and plot
Edgar-21 Jun 9, 2024
7ef06e6
make the bounding surface slightly less huge
Edgar-21 Jun 9, 2024
9c5e780
added docstring to ToroidalModel.get_radial_build_plot()
Edgar-21 Jun 10, 2024
6210028
separate building and returning openmc model
Edgar-21 Jun 10, 2024
4df5327
changes per PR comments
Edgar-21 Jul 8, 2024
406d36c
use kwargs to handle default values
Edgar-21 Jul 8, 2024
6e4dfae
remove default data dict
Edgar-21 Jul 8, 2024
59fcf43
name radius variables in example script
Edgar-21 Jul 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,9 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

*.yml
*.png
*.xml
*.pkl
!ExampleRadialBuild.yml
2 changes: 1 addition & 1 deletion example.yaml → ExampleRadialBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ build:
JK2LB: 0.29
He: 0.14
Nb3Sn: 0.06
Insulator: 0.08
Insulator: 0.08
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@
Tools for building, manipulating and representing radial build for fusion power systems

[Early vision](https://docs.google.com/presentation/d/1yDzG23BL8KTqxQCjatCVnmPRx0kgijyP6wGbssfKwiQ/edit#slide=id.p)

See examples folders for demonstrations of tools

## plot_radial_build.py
Main plotting functionality can be called from command line via:

`python plot_radial_build.py ExampleRadialBuild.yml`

`plot_radial_build.py` will write both a png of a plot and a yml file which
can be used to recreate it.
84 changes: 84 additions & 0 deletions examples/ExampleRadialBuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
build:
sol:
thickness: 8
FW_armor:
thickness: 0.2
FW:
thickness: 3.8
composition:
MF82H: 0.34
HeT410P80: 0.66
breeder:
description: Composition and thickness vary
thickness: 8
BW:
thickness: 2
composition:
MF82H: 0.8
HeT410P80: 0.2
manifolds:
thickness: 10
description: composition varies
HTS:
description: Composition and thickness vary
thickness: 8
gap_1:
composition:
Void: 1.0
thickness: 8
vv_front_plate:
thickness: 2
composition:
SS316L: 1.0
vv_fill:
thickness: 6
composition:
SS316L: 0.6
HeT410P80: 0.4
vv_back_plate:
thickness: 2
composition:
SS316L: 1.0
gap_2:
thickness: 2
composition:
Void: 1.0
LTS:
description: Composition and thickness vary
thickness: 8
Thermal Insulator (Gap):
thickness: 10
composition:
Void: 1.0
Coil Pack:
thickness: 52.5
composition:
SS316L: 0.7435
HTS TAPE: 0.0622
Cu: 0.1307
Solder: 0.0438
HeT410P80: 0.0288
description: '[combines winding pack and coil case]'
title: Example Radial Build
colors:
- '#acc2d9'
- '#56ae57'
- '#b2996e'
- '#a8ff04'
- '#69d84f'
- '#894585'
- '#70b23f'
- '#d4ffff'
- '#65ab7c'
- '#952e8f'
- '#fcfc81'
- '#a5a391'
- '#388004'
- '#4c9085'
- '#5e9b8a'
max_characters: 40
max_thickness: 1000000.0
size:
- 10
- 4.2
unit: cm
49 changes: 49 additions & 0 deletions examples/make_toroidal_model_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import openmc
from radial_build_tools import ToroidalModel, RadialBuildPlot

# torus parameters
major_radius = 800
plasma_minor_z_radius = 300
plasma_minor_xy_radius = 100

# Define tungsten
W = openmc.Material(name="Tungsten")
W.add_element("W", 1.0)
W.set_density("g/cm3", 19.35)

# Define reduced-activation ferritic martensitic (RAFM) steel
RAFM = openmc.Material(name="RAFM")
RAFM.add_element("Fe", 0.895, "wo")
RAFM.add_element("Cr", 0.09, "wo")
RAFM.add_element("W", 0.015, "wo")
RAFM.set_density("g/cm3", 7.8)

# Define lead-lithium eutectic coolant/breeder
PbLi = openmc.Material(name="PbLi")
PbLi.add_element("Pb", 83.0, "ao")
PbLi.add_element("Li", 17.0, "ao", enrichment=90.0, enrichment_target="Li6")
PbLi.set_density("g/cm3", 9.806)

materials = openmc.Materials([RAFM, PbLi, W])

build = {
"sol": {"thickness": 5, "material": None, "description": "Vacuum"},
"FW": {"thickness": 4, "material": RAFM, "description": RAFM.name},
"Breeder": {"thickness": 20, "material": PbLi, "description": PbLi.name},
"bogus layer": {
"thickness": 0,
"description": "this layer will be skipped due to zero thickness",
},
"shield": {"thickness": 20, "material": W, "description": W.name},
}

toroidal_model = ToroidalModel(
build, major_radius, plasma_minor_z_radius, plasma_minor_xy_radius
)
model, cells = toroidal_model.get_openmc_model()
model.export_to_model_xml()

# make a radial build plot of the model
rbp = RadialBuildPlot(build, title="Toroidal Model Example", size=(4, 3))
rbp.plot_radial_build()
rbp.to_png()
65 changes: 65 additions & 0 deletions examples/plot_parastell_build_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import numpy as np
from radial_build_tools import RadialBuildPlot

num_phi = 80
num_theta = 90

phi_list = np.linspace(0, 90, num_phi)
theta_list = np.linspace(0, 360, num_theta)
ones = np.ones((len(phi_list), len(theta_list)))

build = {
"phi_list": phi_list,
"theta_list": theta_list,
"wall_s": 1.2,
"radial_build": {
"fw": {"thickness_matrix": ones * 4, "h5m_tag": "FNSFFW"}, # cell 3
"breeder": {
"thickness_matrix": ones * 50, # cell 4
"h5m_tag": "FNSFDCLL",
},
"BW": {"thickness_matrix": ones * 2, "h5m_tag": "FNSFBW"}, # cell 5
"manifolds": {
"thickness_matrix": ones * 6, # cell 6
"h5m_tag": "FNSFHeManifolds",
},
"HTS": {"thickness_matrix": ones * 20, "h5m_tag": "FNSFIBSR"}, # cell 7
"Gap_1": {"thickness_matrix": ones * 1, "h5m_tag": "Vacuum"}, # cell 8
"vvfrontplate": {
"thickness_matrix": ones * 2, # cell 9
"h5m_tag": "SS316L",
},
"VVFill": {
"thickness_matrix": ones * 6, # cell 10
"h5m_tag": "VVFill",
},
"VVBackPlate": {
"thickness_matrix": ones * 2, # cell 11
"h5m_tag": "SS316L",
},
"Gap_2": {"thickness_matrix": ones * 2, "h5m_tag": "AirSTP"}, # cell 12
"LTS": {"thickness_matrix": ones * 23, "h5m_tag": "LTS"}, # cell 13
"Thermal_Insulator": {
"thickness_matrix": ones * 10, # cell 14
"h5m_tag": "AirSTP",
},
"coilfrontplate": {
"thickness_matrix": ones * 2, # cell 15
"h5m_tag": "coils",
},
"coils": {
"thickness_matrix": ones * 50.5, # cell 16
"h5m_tag": "coils",
},
},
}

rbp = RadialBuildPlot.from_parastell_build(build, phi_list[-1], theta_list[-1])

# create the radial build plot png
rbp.title = "Example Parastell Build"
rbp.plot_radial_build()
rbp.to_png()

# save the plot configuration as a yml file
rbp.write_yml()
44 changes: 44 additions & 0 deletions examples/plot_radial_build_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from radial_build_tools import RadialBuildPlot

build_dict = {
# here is a layer with no optional data incluede
"sol": {},
# here is a layer where only thickness is included
"FW_armor": {"thickness": 0.2},
"FW": {"thickness": 3.8, "composition": {"MF82H": 0.34, "HeT410P80": 0.66}},
# here is a layer where only a description is included
"breeder": {"description": "Composition and thickness vary"},
"BW": {"thickness": 2, "composition": {"MF82H": 0.80, "HeT410P80": 0.20}},
# here is a layer where thickness and description are included
"manifolds": {"thickness": 10, "description": "composition varies"},
"HTS": {"description": "Composition and thickness vary"},
# here is a layer where only composition is inclued
"gap_1": {"composition": {"Void": 1.0}},
"vv_front_plate": {"thickness": 2, "composition": {"SS316L": 1.0}},
"vv_fill": {
"thickness": 6,
"composition": {"SS316L": 0.6, "HeT410P80": 0.4},
},
"vv_back_plate": {"thickness": 2, "composition": {"SS316L": 1.0}},
"gap_2": {"thickness": 2, "composition": {"Void": 1.0}},
"LTS": {"description": "Composition and thickness vary"},
"Thermal Insulator (Gap)": {"thickness": 10, "composition": {"Void": 1.0}},
# here is a layer with all optional data included
"Coil Pack": {
"thickness": 52.5,
"composition": {
"SS316L": 0.7435,
"HTS TAPE": 0.0622,
"Cu": 0.1307,
"Solder": 0.0438,
"HeT410P80": 0.0288,
},
"description": "[combines winding pack and coil case]",
},
}

rbp = RadialBuildPlot(
build_dict, title="Example Radial Build", max_characters=40, size=(8, 4.2)
)
rbp.plot_radial_build()
rbp.to_png()
Loading