Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions freegsnke/build_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions freegsnke/copying.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down