diff --git a/freegsnke/build_machine.py b/freegsnke/build_machine.py index d742ef0..33841f1 100644 --- a/freegsnke/build_machine.py +++ b/freegsnke/build_machine.py @@ -27,6 +27,7 @@ from freegs4e.machine import Circuit, Wall from freegs4e.multi_coil import MultiCoil +from .copying import copy_into from .machine_config import build_tokamak_R_and_M from .machine_update import Machine from .magnetic_probes import Probes @@ -596,6 +597,10 @@ def copy_tokamak(tokamak: Machine): new_tokamak.n_passive_coils = tokamak.n_passive_coils new_tokamak.n_coils = tokamak.n_coils + copy_into(tokamak, new_tokamak, "coil_resist", mutable=True, strict=False) + copy_into(tokamak, new_tokamak, "coil_self_ind", mutable=True, strict=False) + copy_into(tokamak, new_tokamak, "current_vec", mutable=True, strict=False) + # add probe object attribute to tokamak (not strictly required) new_tokamak.probes = tokamak.probes diff --git a/freegsnke/copying.py b/freegsnke/copying.py index 7a22242..07d84c1 100644 --- a/freegsnke/copying.py +++ b/freegsnke/copying.py @@ -41,6 +41,11 @@ def copy_into( # will error if strict and attribute doesnt exist attribute_value = getattr(obj, attr) + # handle singletons + if attribute_value is None or attribute_value is True or attribute_value is False: + setattr(new_obj, attr, attribute_value) + return + if mutable: if ( isinstance(attribute_value, np.ndarray)