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

Mix HCPB Materials using fusion-materials-db #26

Merged
merged 29 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1ca2910
Mix HCPB Materials using fusion-materials-db
anu1217 Nov 5, 2024
722423d
Update HCPB_Build_Dict.py
anu1217 Nov 5, 2024
1ae265d
Fixed description of material library
anu1217 Nov 6, 2024
13f0893
Move HCPB build files to examples directory
anu1217 Nov 21, 2024
6915e51
Rename examples/HCPB_Build_Dict.py to examples/hcpb_radial_build_exam…
anu1217 Dec 6, 2024
c98cb30
Rename examples/HCPB_Mix_Materials.py to examples/hcpb_radial_build_e…
anu1217 Dec 6, 2024
c56c602
Rename examples/openmc_Materials_Object_from_json.py to examples/hcpb…
anu1217 Dec 6, 2024
dade192
Fix capitalization and add more information to docstrings
anu1217 Dec 6, 2024
cc9a60e
Change syntax when OpenMC Material is made
anu1217 Dec 6, 2024
8583ffb
Fix composition of manifold back plate
anu1217 Jan 13, 2025
6c5656e
Add NMM to breeder composition - to discuss
anu1217 Jan 13, 2025
ed9ec4e
Update examples/hcpb_radial_build_example/HCPB_Mix_Materials.py
anu1217 Jan 14, 2025
42ba0da
Change composition to match HCPB_Mix_Materials.py dictionary and load…
anu1217 Jan 14, 2025
a1982fc
Delete file since Materials object is now loaded in from xml
anu1217 Jan 14, 2025
cf81643
Modularize scripts and add main()
anu1217 Jan 14, 2025
c17c675
Merge branch 'hcpb_build' of https://github.com/anu1217/radial_build_…
anu1217 Jan 14, 2025
aff00d7
Add files via upload
anu1217 Jan 14, 2025
ff03d56
Change mixed_mat_xml to mat_xml
anu1217 Jan 14, 2025
adc3148
Change references to material compositions
anu1217 Jan 14, 2025
34fe50d
Update YAML file
anu1217 Jan 14, 2025
e3b9347
Delete HCPB_YAML.yaml
anu1217 Jan 14, 2025
c9dd690
Removed commented line
anu1217 Jan 15, 2025
ba95423
Remove plot filename
anu1217 Jan 15, 2025
6f6f9de
Change functions & indentation
anu1217 Jan 15, 2025
24ebcc4
Change location of parse_args() and read_yaml()
anu1217 Jan 15, 2025
23ef806
Rename examples/hcpb_radial_build_example/HCPB_Build_Dict.py to examp…
anu1217 Jan 15, 2025
7131c0e
Rename examples/hcpb_radial_build_example/HCPB_Mix_Materials.py to ex…
anu1217 Jan 15, 2025
9552122
Rename examples/hcpb_radial_build_example/HCPB_YAML.yaml to examples/…
anu1217 Jan 15, 2025
20a1de9
Add .xml extension to model_xml_name
anu1217 Jan 16, 2025
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
135 changes: 135 additions & 0 deletions examples/hcpb_radial_build_example/HCPB_Build_Dict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import openmc
import json
import yaml
import argparse
from radial_build_tools import ToroidalModel, RadialBuildPlot
from HCPB_Mix_Materials import make_mat_data

def make_build_dict(mat_info):
'''
Build a dictionary of material names, thicknesses, compositions, plot colors, and tally scores.
input:
mat_info : dictionary of material names, compositions, and citations.
'''
build_dict = {
"sol": {
anu1217 marked this conversation as resolved.
Show resolved Hide resolved
"thickness": 5,
"composition": {"Void": 1.0},
"colour": "#E0E0E0", # Light grey

},
"fw_armor": {
"thickness": 0.2,
"colour": "#FFD700", # Gold
"scores": ["heating"],
},
"fw": {
"thickness": 3.8,
"colour": "#DAA520", # Goldenrod
"scores": ["fast_fluence", "he_prod", "fe_dpa", "heating"],
},
"breeder": {
"thickness": 50,
"description": "Thickness Varies",
"colour": "#B22222", # Firebrick
"scores": ["tbr", "heating"],
},
"bw": {
"thickness": 10,
"colour": "#8B0000", # Dark red
"scores": ["tbr", "heating","fast_fluence"],
},

"manifold": {
"thickness": 20,
"colour": "#5F9EA0", # Cadet blue
},

"hts": {
"thickness": 10.5,
"description": "Thickness Varies",
"colour": "#00FF00", # Green
"scores": ["heating"],
},

"gap_1": {
"thickness": 1,
"colour": "#F5F5F5", # White smoke
},

"vv_fill": {
"thickness": 10,
"colour": "#778899", # Light slate grey
"scores": ["heating"],
},

"gap_2": {
"thickness": 2,
"colour": "#E0FFFF", # Light cyan
},

"lts": {
"thickness": 10.5,
"description": "Thickness Varies",
"colour": "#00FA9A", # Medium spring green
"scores": ["heating"],
},

"thermal_insulator": {
"thickness": 10,
"colour": "#B0E0E6", # Powder blue
"scores": ["heating"],
},

"coil_pack": {
"thickness": 53,
"colour": "#FF4500", # Orange red
"scores": ["heating"],
},
}
for component in list(build_dict.keys()):
if component in list(mat_info.keys()):
build_dict[component]['composition'] = mat_info[component]['composition']
build_dict[component]['material_name'] = component
return build_dict

def make_toroidal_model(materials_xml_file, major_radius, minor_radius_z, minor_radius_xy, build_dict):
# openmc Materials object:
materials = openmc.Materials.from_xml(materials_xml_file)
toroidal_model = ToroidalModel(
build_dict, major_radius, minor_radius_z, minor_radius_xy, materials)
mat_geom, cell_dict = toroidal_model.get_openmc_model()
return mat_geom, cell_dict

def plot_radial_build(radial_plot_name, build_dict):
radial_build_plot = RadialBuildPlot(build_dict, title=radial_plot_name, size=(15, 5))
radial_build_plot.plot_radial_build()
radial_build_plot.to_png()
return radial_build_plot

def main():
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--HCPB_YAML', default = 'HCPB_YAML.yaml', help="Path (str) to YAML containing inputs for HCPB build dictionary & mix materials")
args = parser.parse_args()
return args

def read_yaml(args):
with open(args.HCPB_YAML, 'r') as hcpb_yaml:
yaml_inputs = yaml.safe_load(hcpb_yaml)
return yaml_inputs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions can be defined outside of main at the global scope. I'm not sure I have a clear reason for this other than reduced complexity. I think it is rare to have functions defined within other functions, and usually serves a very specific purpose.


args = parse_args()
yaml_inputs = read_yaml(args)
mat_info = make_mat_data()
build_dict = make_build_dict(mat_info)
mat_geom, cell_dict = make_toroidal_model(yaml_inputs['filenames']['mat_xml'],
yaml_inputs['geom']['major_radius'],
yaml_inputs['geom']['minor_radius_z'],
yaml_inputs['geom']['minor_radius_xy'],
build_dict)
plot_radial_build(yaml_inputs['filenames']['radial_plot_name'], build_dict)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this can be an option governed by something in argparse

mat_geom.export_to_model_xml(yaml_inputs['filenames']['model_xml_name'])

if __name__ == "__main__":
main()
111 changes: 111 additions & 0 deletions examples/hcpb_radial_build_example/HCPB_Mix_Materials.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import openmc
import json
import yaml
import argparse
import material_db_tools as mdbt

'''
This script specifies the composition of each HCPB component and its corresponding citation.
mdbt.mix_by_volume is called to mix individual materials and generate a new .json file.
'''

def make_mat_data():
'''
Specfies volume fraction and corresponding citation for each radial component.
'''
#Volume fractions of constituent materials and corresponding citations
mat_info = {
'fw_armor' : {
'composition' : {"W": 1.00},
'citation' : "ZhouEUDEMOHCPB_2023"
},
'fw' : {
'composition' : {"W": 0.1, "EUROFER97" : 0.9},
'citation' : "ZhouEUDEMOHCPB_2023"
},
'breeder' : {
'composition' : {"Be12Ti": 0.8, "Li4SiO4Li60.0":0.14837, "Li2TiO3Li60.0":0.05163},
'citation' : "ZhouEUDEMOHCPB_2023"
},
'bw' : {
'composition' : {"MF82H" : 0.8, "HeNIST" : 0.2},
'citation' : "DavisFusEngDes_2018"
},
'manifold' : {
'composition' : {"HeT410P80": 1.00},
'citation' : "DavisFusEngDes_2018"
},
'hts' : {
'composition' : {"MF82H": 0.20, "HeNIST": 0.28, "BMF82H" : 0.52},
'citation' : "DavisFusEngDes_2018"
},
'vv_fill' : {
'composition' : {"HeNIST" : 0.4, "Cr3FS" : 0.6},
'citation' : "DavisFusEngDes_2018"
},
'gap_2' : {
'composition' : {"AirSTP": 1.0},
'citation' : "ZhouEUDEMOHCPB_2023"
},
'lts' : {
'composition' : {"Cr3FS": 0.39, "BMF82H": 0.29, "Water": 0.32},
'citation' : "DavisFusEngDes_2018"
},
'thermal_insulator':{
'composition' : {'AirSTP': 1.0},
'citation' : "ZhouEUDEMOHCPB_2023"
},
'coil_pack': {
'composition' : {"JK2LBSteel": 0.3, "Cu": 0.25, "TernaryNb3Sn" : 0.25, "Eins" : 0.1, "HeNIST" : 0.1},
'citation' : "DavisFusEngDes_2018"
},
}
return mat_info

def make_mixed_mat_lib(mat_info, pure_mat_json):
'''
Creates dictionary consisting of material name, composition, and citation.

pure_mat_json : path to .json containing pure material compositions
'''
mat_data = {}
for mat_name, comp_cit in mat_info.items():
mat_data[mat_name] = {
'vol_fracs' : comp_cit['composition'],
'mixture_citation' : comp_cit['citation'],
}

# Load material library
mat_lib = mdbt.MaterialLibrary()
mat_lib.from_json(pure_mat_json)

# Create PyNE material library object
mixmat_lib = mdbt.MaterialLibrary()
for mat_name, mat_input in mat_data.items():
mixmat_lib[mat_name] = mdbt.mix_by_volume(
mat_lib, mat_input["vol_fracs"], mat_input["mixture_citation"]
)
return mixmat_lib

def main():
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--HCPB_YAML', default = 'HCPB_YAML.yaml', help="Path (str) to YAML containing inputs for HCPB build dictionary & mix materials")
args = parser.parse_args()
return args

def read_yaml(args):
with open(args.HCPB_YAML, 'r') as hcpb_yaml:
yaml_inputs = yaml.safe_load(hcpb_yaml)
return yaml_inputs

args = parse_args()
yaml_inputs = read_yaml(args)
mat_info = make_mat_data()
mixmat_lib = make_mixed_mat_lib(mat_info,
yaml_inputs['filenames']['pure_mat_json'])
# write OpenMC Materials xml
mixmat_lib.write_openmc(yaml_inputs['filenames']['mat_xml'])

if __name__ == "__main__":
main()
11 changes: 11 additions & 0 deletions examples/hcpb_radial_build_example/HCPB_YAML.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
filenames:
mat_xml : mixedPureFusionMatsHCPB_libv1.xml
radial_plot_name : HCPB_Toroidal_Model
pure_mat_json : PureFusionMaterials_libv1.json
model_xml_name : HCPB_model

geom:
scoring_layer_thickness : 0.50
major_radius : 800.0
minor_radius_z : 114.0
minor_radius_xy : 114.0