From c12a7ed928bb1b7d14d7098dbef8227f256506c9 Mon Sep 17 00:00:00 2001 From: Oliver Funk Date: Tue, 21 Jan 2025 15:36:11 +0000 Subject: [PATCH] added group by materials --- bluemira/base/tools.py | 9 ++++++++- eudemo/eudemo/reactor.py | 13 ++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bluemira/base/tools.py b/bluemira/base/tools.py index 49a5a4d229..e29d036cb8 100644 --- a/bluemira/base/tools.py +++ b/bluemira/base/tools.py @@ -136,6 +136,7 @@ class ConstructionParams(TypedDict): component_filter: NotRequired[Callable[[Component], bool] | None] n_sectors: NotRequired[int | None] total_sectors: NotRequired[int | None] + group_by_materials: NotRequired[bool] @dataclass(frozen=True) @@ -148,6 +149,7 @@ class ConstructionParamValues: component_filter: Callable[[Component], bool] | None n_sectors: int total_sectors: int + group_by_materials: bool @classmethod def empty(cls) -> ConstructionParamValues: @@ -164,6 +166,7 @@ def empty(cls) -> ConstructionParamValues: component_filter=None, n_sectors=1, total_sectors=1, + group_by_materials=False, ) @classmethod @@ -196,6 +199,7 @@ def from_construction_params(cls, construction_params: ConstructionParams | None component_filter=comp_filter, n_sectors=n_secs, total_sectors=tot_secs, + group_by_materials=construction_params.get("groups_by_materials", False), ) @@ -522,7 +526,10 @@ def build_comp_manager_save_xyz_cad_tree( comp_manager, construction_params ) - mat_to_comps_map = _group_physical_components_by_material(constructed_phy_comps) + if construction_params.group_by_materials: + mat_to_comps_map = _group_physical_components_by_material(constructed_phy_comps) + else: + mat_to_comps_map = {"": constructed_phy_comps} return_comp = Component(name=manager_name) return_comp.children = _build_compounds_from_map( diff --git a/eudemo/eudemo/reactor.py b/eudemo/eudemo/reactor.py index 2ad9012a41..18c9dcf279 100644 --- a/eudemo/eudemo/reactor.py +++ b/eudemo/eudemo/reactor.py @@ -20,7 +20,6 @@ 11. Produce power cycle report """ -import sys from pathlib import Path import matplotlib.pyplot as plt @@ -667,6 +666,14 @@ def build_radiation_plugs( vv_thermal_shield, cryostat_thermal_shield ) + reactor.save_cad( + "xyz", + { + "with_components": [reactor.thermal_shield, reactor.pf_coils], + "group_by_materials": True, + }, + ) + reactor.coil_structures = build_coil_structures( reactor_config.params_for("Coil structures"), reactor_config.config_for("Coil structures"), @@ -750,10 +757,6 @@ def build_radiation_plugs( n_TF=reactor_config.global_params.n_TF.value, ) - reactor.save_cad() - - sys.exit() - debug = [upper_port_koz_xz, eq_port_koz_xz, lower_port_koz_xz] debug.extend(reactor.pf_coils.xz_boundary) # I know there are clashes, I need to put in dynamic bounds on position opt to