-
Notifications
You must be signed in to change notification settings - Fork 16
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
Adding materials to DEMO #3680
base: develop
Are you sure you want to change the base?
Adding materials to DEMO #3680
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
sweep_shape, | ||
) | ||
from bluemira.geometry.wire import BluemiraWire | ||
from bluemira.materials.cache import get_cached_material | ||
from bluemira.optimisation import OptimisationProblem | ||
from bluemira.utilities.tools import floatify | ||
|
||
|
@@ -283,7 +284,13 @@ def build_xyz( | |
# Finally, make the floor block | ||
shape_list.append(self._make_floor_block(floatify(v1.x), floatify(v4.x))) | ||
shape = boolean_fuse(shape_list) | ||
component = PhysicalComponent("ITER-like gravity support", shape) | ||
component = PhysicalComponent( | ||
"ITER-like gravity support", | ||
shape, | ||
material=get_cached_material( | ||
self.build_config.get("material", {}).get("GS") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The component material maybe should go as a class var so it can be accessed outside? Same as we do in some places for the PhysicalComponent name (and you've done below). |
||
), | ||
) | ||
apply_component_display_options(component, color=BLUE_PALETTE["TF"][2]) | ||
return component | ||
|
||
|
@@ -341,7 +348,13 @@ def build_xz(self, xyz): | |
result = slice_shape(xyz.shape, BluemiraPlane(axis=(0, 1, 0))) | ||
result.sort(key=lambda wire: -wire.length) | ||
face = BluemiraFace(result) | ||
component = PhysicalComponent(self.name, face) | ||
component = PhysicalComponent( | ||
self.name, | ||
face, | ||
material=get_cached_material( | ||
self.build_config.get("material", {}).get("PF ICS") | ||
), | ||
) | ||
apply_component_display_options(component, color=BLUE_PALETTE["TF"][2]) | ||
return component | ||
|
||
|
@@ -866,7 +879,13 @@ def build_xz(self): | |
components = [] | ||
for i, ois_profile in enumerate(self.ois_xz_profiles): | ||
face = BluemiraFace(ois_profile) | ||
component = PhysicalComponent(f"{self.OIS_XZ} {i}", face) | ||
component = PhysicalComponent( | ||
f"{self.OIS_XZ} {i}", | ||
face, | ||
material=get_cached_material( | ||
self.build_config.get("material", {}).get(self.OIS_XZ) | ||
), | ||
) | ||
apply_component_display_options(component, color=BLUE_PALETTE["TF"][2]) | ||
components.append(component) | ||
return components | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
from bluemira.geometry.face import BluemiraFace | ||
from bluemira.geometry.parameterisations import PictureFrame | ||
from bluemira.geometry.tools import make_circle, offset_wire, revolve_shape | ||
from bluemira.materials.cache import get_cached_material | ||
|
||
if TYPE_CHECKING: | ||
from bluemira.base.builder import BuildConfig | ||
|
@@ -120,16 +121,34 @@ def build_xz(self, shape: BluemiraWire) -> list[PhysicalComponent]: | |
""" | ||
Build the xz cross-section of the PF coil. | ||
""" | ||
wp = PhysicalComponent(self.WINDING_PACK, BluemiraFace(shape)) | ||
wp = PhysicalComponent( | ||
self.WINDING_PACK, | ||
BluemiraFace(shape), | ||
material=get_cached_material( | ||
self.build_config.get("material", {}).get(self.WINDING_PACK) | ||
), | ||
) | ||
idx = CoilType(self.params.ctype.value).value - 1 | ||
apply_component_display_options(wp, color=BLUE_PALETTE["PF"][idx]) | ||
|
||
ins_shape = offset_wire(shape, self.params.tk_insulation.value) | ||
ins = PhysicalComponent(self.GROUND_INSULATION, BluemiraFace([ins_shape, shape])) | ||
ins = PhysicalComponent( | ||
self.GROUND_INSULATION, | ||
BluemiraFace([ins_shape, shape]), | ||
material=get_cached_material( | ||
self.build_config.get("material", {}).get(self.GROUND_INSULATION) | ||
), | ||
) | ||
apply_component_display_options(ins, color=BLUE_PALETTE["PF"][3]) | ||
|
||
cas_shape = offset_wire(ins_shape, self.params.tk_casing.value) | ||
casing = PhysicalComponent(self.CASING, BluemiraFace([cas_shape, ins_shape])) | ||
casing = PhysicalComponent( | ||
self.CASING, | ||
BluemiraFace([cas_shape, ins_shape]), | ||
material=get_cached_material( | ||
self.build_config.get("material", {}).get(self.CASING) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe also we could have a wrapper function that does some of this so the user only passes in a dictionary and a key, possibly harder to work out whats going on: get_cached_material_for_component(self.build_config, self.CASING) |
||
), | ||
) | ||
apply_component_display_options(casing, color=BLUE_PALETTE["PF"][2]) | ||
return [wp, ins, casing] | ||
|
||
|
@@ -159,7 +178,7 @@ def build_xyz( | |
components = [] | ||
for c in xz_components: | ||
shape = revolve_shape(c.shape, degree=sector_degree * n_sectors) | ||
c_xyz = PhysicalComponent(c.name, shape) | ||
c_xyz = PhysicalComponent(c.name, shape, material=c.material) | ||
apply_component_display_options( | ||
c_xyz, color=c.plot_options.face_options["color"] | ||
) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really like these changes, nice! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts welcome:
Possibly build_config['material'] should be autocreated in the reactor config and then the materials entry could be a default dict https://docs.python.org/3/library/collections.html#collections.defaultdict. It might mean we can chain gets. Also could well have unintended side effects...probably a bad idea.