Skip to content

Commit 3ba0581

Browse files
je-cookCoronelBuendiadependabot[bot]
authored
Move to new materials package (#4059)
* initial neutronics * 🚚 Initial structural * 🚚 Remove move * OperationalCondition -> OperationalConditions Co-authored-by: CoronelBuendia <[email protected]> * fix tests * 🐛 Fix renaming * ➕ Add matproplib dep * ✨ Caching fixes * 🐛 Missed void names * Li enrichment workaround * minor * still at a loss... * match eufoer and tungsten * ruff a bit * replace packing fraction * 🚨 Fix pre commit issues * Updated dependencies in requirements files [skip dependency] * 🔥 Remove old materials example * 🔥 Remove coil support stuff * 🐛 Fix opt example * 🎨 Docs moaning * material fixes --------- Co-authored-by: CoronelBuendia <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 733729c commit 3ba0581

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1204
-4160
lines changed

bluemira/base/builder.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
from bluemira.utilities.plot_tools import set_component_view
2323

2424
if TYPE_CHECKING:
25+
from matproplib.material import Material
26+
2527
from bluemira.base.components import ComponentT
2628
from bluemira.base.parameter_frame.typed import ParameterFrameLike
27-
from bluemira.materials.material import Material
2829

2930
BuildConfig: TypeAlias = dict[str, Union[int, float, str, "BuildConfig"]]
3031
"""

bluemira/base/components.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
from bluemira.display.plotter import Plottable
2222

2323
if TYPE_CHECKING:
24+
from matproplib.material import Material
25+
2426
from bluemira.geometry.base import BluemiraGeoT
25-
from bluemira.materials.material import Material
2627

2728

2829
ComponentT = TypeVar("ComponentT", bound="Component")

bluemira/base/tools.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from functools import wraps
1717
from typing import TYPE_CHECKING, Any, TypeVar, TypedDict
1818

19+
from matproplib.library.fluids import Void
1920
from typing_extensions import NotRequired
2021

2122
from bluemira.base.components import (
@@ -37,13 +38,14 @@
3738
save_cad,
3839
serialise_shape,
3940
)
40-
from bluemira.materials.material import Material, Void
4141
from bluemira.radiation_transport.neutronics.dagmc import save_cad_to_dagmc
4242

4343
if TYPE_CHECKING:
4444
from collections.abc import Callable, Iterable
4545
from pathlib import Path
4646

47+
from matproplib.material import Material
48+
4749
import bluemira.codes._freecadapi as cadapi
4850
from bluemira.base.reactor import ComponentManager
4951

bluemira/builders/thermal_shield.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
make_polygon,
3939
offset_wire,
4040
)
41-
from bluemira.materials.cache import Void
41+
from bluemira.materials.basic import vacuum_void
4242

4343
if TYPE_CHECKING:
4444
from bluemira.base.builder import BuildConfig
@@ -128,7 +128,7 @@ def build_xz(self, koz: BluemiraWire) -> tuple[PhysicalComponent, ...]:
128128

129129
vvts = PhysicalComponent(self.VVTS, vvts_face)
130130
vvts_void = PhysicalComponent(
131-
self.VOID, BluemiraFace(vvts_face.boundary[1]), material=Void("vacuum")
131+
self.VOID, BluemiraFace(vvts_face.boundary[1]), material=vacuum_void
132132
)
133133

134134
apply_component_display_options(vvts, color=BLUE_PALETTE["TS"][0])
@@ -166,10 +166,7 @@ def build_xyz(
166166
self.params.n_TF.value,
167167
[BLUE_PALETTE["TS"][0], (0, 0, 0)],
168168
degree,
169-
material=[
170-
self.get_material(self.VVTS),
171-
Void("vacuum"),
172-
],
169+
material=[self.get_material(self.VVTS), vacuum_void],
173170
)
174171

175172

@@ -297,7 +294,7 @@ def build_xz(
297294

298295
cryostat_ts = PhysicalComponent(self.CRYO_TS, cts)
299296
cryostat_ts_void = PhysicalComponent(
300-
self.VOID, cts_void_face, material=Void("vacuum")
297+
self.VOID, cts_void_face, material=vacuum_void
301298
)
302299

303300
apply_component_display_options(cryostat_ts, color=BLUE_PALETTE["TS"][0])
@@ -329,8 +326,5 @@ def build_xyz(
329326
[BLUE_PALETTE["TS"][0], (0, 0, 0)],
330327
degree,
331328
enable_sectioning=True,
332-
material=[
333-
self.get_material(self.CRYO_TS),
334-
Void("vacuum"),
335-
],
329+
material=[self.get_material(self.CRYO_TS), vacuum_void],
336330
)

bluemira/builders/tools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@
4242
if TYPE_CHECKING:
4343
from collections.abc import Iterable
4444

45+
from matproplib.material import Material
46+
4547
from bluemira.base.components import ComponentT
4648
from bluemira.geometry.base import BluemiraGeoT
4749
from bluemira.geometry.solid import BluemiraSolid
4850
from bluemira.geometry.wire import BluemiraWire
49-
from bluemira.materials.material import Material
5051

5152
__all__ = [
5253
"apply_component_display_options",

bluemira/codes/openmc/material.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
if TYPE_CHECKING:
1717
from pathlib import Path
1818

19+
from matproplib.conditions import OperationalConditions
20+
1921
from bluemira.radiation_transport.neutronics.materials import NeutronicsMaterials
2022

2123

@@ -75,10 +77,12 @@ class MaterialsLibrary:
7577
rad_shield: openmc.Material
7678

7779
@classmethod
78-
def from_neutronics_materials(cls, materials_lib: NeutronicsMaterials):
80+
def from_neutronics_materials(
81+
cls, materials_lib: NeutronicsMaterials, op_cond: OperationalConditions
82+
):
7983
"""Initialise from neutronics materials""" # noqa: DOC201
8084
return cls(**{
81-
field.name: getattr(materials_lib, field.name).to_openmc_material()
85+
field.name: getattr(materials_lib, field.name).convert("openmc", op_cond)
8286
for field in fields(materials_lib)
8387
})
8488

bluemira/codes/openmc/output.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def from_run(
116116
vessel_power, vessel_power_err = cls._load_filter_power_err(
117117
statepoint, src_rate, "vacuum vessel power"
118118
)
119+
dpa_coefs = DPACoefficients() # default assumes iron (Fe) is used.
119120

120121
return cls(
121122
universe=universe,
@@ -135,7 +136,7 @@ def from_run(
135136
vessel_power=vessel_power,
136137
vessel_power_err=vessel_power_err,
137138
neutron_wall_load=cls._load_neutron_wall_loading(
138-
statepoint, cell_names, cell_vols, src_rate
139+
statepoint, cell_names, cell_vols, src_rate, dpa_coefs
139140
),
140141
photon_heat_flux=cls._load_photon_heat_flux(
141142
statepoint, cell_names, cell_vols, src_rate
@@ -259,20 +260,21 @@ def _load_heating(cls, statepoint, mat_names, src_rate):
259260
return cls._convert_dict_contents(hdf)
260261

261262
@classmethod
262-
def _load_neutron_wall_loading(cls, statepoint, cell_names, cell_vols, src_rate):
263+
def _load_neutron_wall_loading(
264+
cls, statepoint, cell_names, cell_vols, src_rate, dpa_coefs
265+
):
263266
"""Load the neutron wall load dataframe"""
264-
dfa_coefs = DPACoefficients() # default assumes iron (Fe) is used.
265267
n_wl_df = cls._load_dataframe_from_statepoint(
266268
statepoint, "neutron flux in every cell"
267269
)
268270
n_wl_df["cell_name"] = n_wl_df["cell"].map(cell_names)
269271
n_wl_df["vol (m^3)"] = n_wl_df["cell"].map(cell_vols)
270272
total_displacements_per_second = (
271-
n_wl_df["mean"] * dfa_coefs.displacements_per_damage_eV * src_rate
273+
n_wl_df["mean"] * dpa_coefs.displacements_per_damage_eV * src_rate
272274
) # "mean" has units "eV per source particle"
273275
# total number of atomic displacements per second in the cell.
274276
num_atoms_in_cell = n_wl_df["vol (m^3)"] * raw_uc(
275-
dfa_coefs.atoms_per_cc, "1/cm^3", "1/m^3"
277+
dpa_coefs.atoms_per_cc, "1/cm^3", "1/m^3"
276278
)
277279
n_wl_df["dpa/fpy"] = raw_uc(
278280
total_displacements_per_second.to_numpy() / num_atoms_in_cell.to_numpy(),

bluemira/codes/openmc/solver.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from enum import auto
1414
from operator import attrgetter
1515
from pathlib import Path
16-
from typing import Literal, TypeAlias
16+
from typing import TYPE_CHECKING, Literal, TypeAlias
1717

1818
import numpy as np
1919
import openmc
@@ -44,6 +44,9 @@
4444
from bluemira.codes.openmc.tallying import filter_cells
4545
from bluemira.equilibria.equilibrium import Equilibrium
4646

47+
if TYPE_CHECKING:
48+
from matproplib.conditions import OperationalConditions
49+
4750

4851
class OpenMCRunModes(BaseRunMode):
4952
"""OpenMC run modes"""
@@ -436,6 +439,7 @@ def __init__(
436439
neutronics_pre_cell_model,
437440
eq: Equilibrium,
438441
source: NeutronSourceCreator,
442+
op_cond: OperationalConditions,
439443
tally_function: TALLY_FUNCTION_TYPE | None = None,
440444
):
441445
self.params = make_parameter_frame(params, self.param_cls)
@@ -448,7 +452,7 @@ def __init__(
448452

449453
self.pre_cell_model = neutronics_pre_cell_model
450454
self.materials = MaterialsLibrary.from_neutronics_materials(
451-
self.pre_cell_model.material_library
455+
self.pre_cell_model.material_library, op_cond
452456
)
453457

454458
self.cell_arrays = make_cell_arrays(

bluemira/codes/wrapper.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
from bluemira.codes.utilities import get_code_interface
1616

1717
if TYPE_CHECKING:
18+
from matproplib.conditions import OperationalConditions
19+
1820
from bluemira.base.builder import BuildConfig
1921
from bluemira.base.parameter_frame import Parameter as ParameterFrame
2022
from bluemira.codes._typing import TransportSolver
@@ -95,6 +97,7 @@ def neutronics_code_solver(
9597
neutronics_model,
9698
eq: Equilibrium,
9799
source: NeutronSourceCreator,
100+
op_cond: OperationalConditions,
98101
tally_function=None,
99102
module: str = "OPENMC",
100103
) -> CodesSolver:
@@ -117,5 +120,5 @@ def neutronics_code_solver(
117120
"""
118121
neutron = get_code_interface(module)
119122
return neutron.Solver(
120-
params, build_config, neutronics_model, eq, source, tally_function
123+
params, build_config, neutronics_model, eq, source, op_cond, tally_function
121124
)

bluemira/materials/__init__.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,6 @@
99
Module-level functionality for materials.
1010
"""
1111

12-
from bluemira.materials.cache import MaterialCache
13-
from bluemira.materials.material import (
14-
BePebbleBed,
15-
Liquid,
16-
MassFractionMaterial,
17-
NbSnSuperconductor,
18-
NbTiSuperconductor,
19-
Plasma,
20-
UnitCellCompound,
21-
Void,
22-
)
23-
from bluemira.materials.mixtures import HomogenisedMixture
12+
from matproplib.library.fluids import Void
2413

25-
__all__ = [
26-
"BePebbleBed",
27-
"HomogenisedMixture",
28-
"Liquid",
29-
"MassFractionMaterial",
30-
"MaterialCache",
31-
"NbSnSuperconductor",
32-
"NbTiSuperconductor",
33-
"Plasma",
34-
"UnitCellCompound",
35-
"Void",
36-
]
14+
__all__ = ["Void"]

0 commit comments

Comments
 (0)