# -*- coding: utf-8 -*-
# File generated according to Generator/ClassesRef/Slot/HoleM51.csv
# WARNING! All changes made in this file will be lost!
"""Method code available at https://github.com/Eomys/pyleecan/tree/master/pyleecan/Methods/Slot/HoleM51
"""
from os import linesep
from sys import getsizeof
from logging import getLogger
from ._check import check_var, raise_
from ..Functions.get_logger import get_logger
from ..Functions.save import save
from ..Functions.load import load_init_dict
from ..Functions.Load.import_class import import_class
from copy import deepcopy
from .HoleMag import HoleMag
# Import all class method
# Try/catch to remove unnecessary dependencies in unused method
try:
from ..Methods.Slot.HoleM51._comp_point_coordinate import _comp_point_coordinate
except ImportError as error:
_comp_point_coordinate = error
try:
from ..Methods.Slot.HoleM51.build_geometry import build_geometry
except ImportError as error:
build_geometry = error
try:
from ..Methods.Slot.HoleM51.check import check
except ImportError as error:
check = error
try:
from ..Methods.Slot.HoleM51.comp_alpha import comp_alpha
except ImportError as error:
comp_alpha = error
try:
from ..Methods.Slot.HoleM51.comp_magnetization_dict import comp_magnetization_dict
except ImportError as error:
comp_magnetization_dict = error
try:
from ..Methods.Slot.HoleM51.comp_radius import comp_radius
except ImportError as error:
comp_radius = error
try:
from ..Methods.Slot.HoleM51.comp_surface_magnet_id import comp_surface_magnet_id
except ImportError as error:
comp_surface_magnet_id = error
try:
from ..Methods.Slot.HoleM51.comp_width import comp_width
except ImportError as error:
comp_width = error
try:
from ..Methods.Slot.HoleM51.has_magnet import has_magnet
except ImportError as error:
has_magnet = error
try:
from ..Methods.Slot.HoleM51.plot_schematics import plot_schematics
except ImportError as error:
plot_schematics = error
try:
from ..Methods.Slot.HoleM51.remove_magnet import remove_magnet
except ImportError as error:
remove_magnet = error
from numpy import isnan
from ._check import InitUnKnowClassError
[docs]class HoleM51(HoleMag):
"""3 magnets V hole"""
VERSION = 1
IS_SYMMETRICAL = 1
# Check ImportError to remove unnecessary dependencies in unused method
# cf Methods.Slot.HoleM51._comp_point_coordinate
if isinstance(_comp_point_coordinate, ImportError):
_comp_point_coordinate = property(
fget=lambda x: raise_(
ImportError(
"Can't use HoleM51 method _comp_point_coordinate: "
+ str(_comp_point_coordinate)
)
)
)
else:
_comp_point_coordinate = _comp_point_coordinate
# cf Methods.Slot.HoleM51.build_geometry
if isinstance(build_geometry, ImportError):
build_geometry = property(
fget=lambda x: raise_(
ImportError(
"Can't use HoleM51 method build_geometry: " + str(build_geometry)
)
)
)
else:
build_geometry = build_geometry
# cf Methods.Slot.HoleM51.check
if isinstance(check, ImportError):
check = property(
fget=lambda x: raise_(
ImportError("Can't use HoleM51 method check: " + str(check))
)
)
else:
check = check
# cf Methods.Slot.HoleM51.comp_alpha
if isinstance(comp_alpha, ImportError):
comp_alpha = property(
fget=lambda x: raise_(
ImportError("Can't use HoleM51 method comp_alpha: " + str(comp_alpha))
)
)
else:
comp_alpha = comp_alpha
# cf Methods.Slot.HoleM51.comp_magnetization_dict
if isinstance(comp_magnetization_dict, ImportError):
comp_magnetization_dict = property(
fget=lambda x: raise_(
ImportError(
"Can't use HoleM51 method comp_magnetization_dict: "
+ str(comp_magnetization_dict)
)
)
)
else:
comp_magnetization_dict = comp_magnetization_dict
# cf Methods.Slot.HoleM51.comp_radius
if isinstance(comp_radius, ImportError):
comp_radius = property(
fget=lambda x: raise_(
ImportError("Can't use HoleM51 method comp_radius: " + str(comp_radius))
)
)
else:
comp_radius = comp_radius
# cf Methods.Slot.HoleM51.comp_surface_magnet_id
if isinstance(comp_surface_magnet_id, ImportError):
comp_surface_magnet_id = property(
fget=lambda x: raise_(
ImportError(
"Can't use HoleM51 method comp_surface_magnet_id: "
+ str(comp_surface_magnet_id)
)
)
)
else:
comp_surface_magnet_id = comp_surface_magnet_id
# cf Methods.Slot.HoleM51.comp_width
if isinstance(comp_width, ImportError):
comp_width = property(
fget=lambda x: raise_(
ImportError("Can't use HoleM51 method comp_width: " + str(comp_width))
)
)
else:
comp_width = comp_width
# cf Methods.Slot.HoleM51.has_magnet
if isinstance(has_magnet, ImportError):
has_magnet = property(
fget=lambda x: raise_(
ImportError("Can't use HoleM51 method has_magnet: " + str(has_magnet))
)
)
else:
has_magnet = has_magnet
# cf Methods.Slot.HoleM51.plot_schematics
if isinstance(plot_schematics, ImportError):
plot_schematics = property(
fget=lambda x: raise_(
ImportError(
"Can't use HoleM51 method plot_schematics: " + str(plot_schematics)
)
)
)
else:
plot_schematics = plot_schematics
# cf Methods.Slot.HoleM51.remove_magnet
if isinstance(remove_magnet, ImportError):
remove_magnet = property(
fget=lambda x: raise_(
ImportError(
"Can't use HoleM51 method remove_magnet: " + str(remove_magnet)
)
)
)
else:
remove_magnet = remove_magnet
# generic save method is available in all object
save = save
# get_logger method is available in all object
get_logger = get_logger
def __init__(
self,
H0=0.003,
H1=0,
H2=0.02,
W0=0.01,
W1=0,
W2=0.01,
W3=0,
W4=0.01,
W5=0.01,
W6=0,
W7=0,
magnet_0=-1,
magnet_1=-1,
magnet_2=-1,
Zh=36,
mat_void=-1,
magnetization_dict_offset=None,
Alpha0=0,
init_dict=None,
init_str=None,
):
"""Constructor of the class. Can be use in three ways :
- __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
for pyleecan type, -1 will call the default constructor
- __init__ (init_dict = d) d must be a dictionary with property names as keys
- __init__ (init_str = s) s must be a string
s is the file path to load
ndarray or list can be given for Vector and Matrix
object or dict can be given for pyleecan Object"""
if init_str is not None: # Load from a file
init_dict = load_init_dict(init_str)[1]
if init_dict is not None: # Initialisation by dict
assert type(init_dict) is dict
# Overwrite default value with init_dict content
if "H0" in list(init_dict.keys()):
H0 = init_dict["H0"]
if "H1" in list(init_dict.keys()):
H1 = init_dict["H1"]
if "H2" in list(init_dict.keys()):
H2 = init_dict["H2"]
if "W0" in list(init_dict.keys()):
W0 = init_dict["W0"]
if "W1" in list(init_dict.keys()):
W1 = init_dict["W1"]
if "W2" in list(init_dict.keys()):
W2 = init_dict["W2"]
if "W3" in list(init_dict.keys()):
W3 = init_dict["W3"]
if "W4" in list(init_dict.keys()):
W4 = init_dict["W4"]
if "W5" in list(init_dict.keys()):
W5 = init_dict["W5"]
if "W6" in list(init_dict.keys()):
W6 = init_dict["W6"]
if "W7" in list(init_dict.keys()):
W7 = init_dict["W7"]
if "magnet_0" in list(init_dict.keys()):
magnet_0 = init_dict["magnet_0"]
if "magnet_1" in list(init_dict.keys()):
magnet_1 = init_dict["magnet_1"]
if "magnet_2" in list(init_dict.keys()):
magnet_2 = init_dict["magnet_2"]
if "Zh" in list(init_dict.keys()):
Zh = init_dict["Zh"]
if "mat_void" in list(init_dict.keys()):
mat_void = init_dict["mat_void"]
if "magnetization_dict_offset" in list(init_dict.keys()):
magnetization_dict_offset = init_dict["magnetization_dict_offset"]
if "Alpha0" in list(init_dict.keys()):
Alpha0 = init_dict["Alpha0"]
# Set the properties (value check and convertion are done in setter)
self.H0 = H0
self.H1 = H1
self.H2 = H2
self.W0 = W0
self.W1 = W1
self.W2 = W2
self.W3 = W3
self.W4 = W4
self.W5 = W5
self.W6 = W6
self.W7 = W7
self.magnet_0 = magnet_0
self.magnet_1 = magnet_1
self.magnet_2 = magnet_2
# Call HoleMag init
super(HoleM51, self).__init__(
Zh=Zh,
mat_void=mat_void,
magnetization_dict_offset=magnetization_dict_offset,
Alpha0=Alpha0,
)
# The class is frozen (in HoleMag init), for now it's impossible to
# add new properties
def __str__(self):
"""Convert this object in a readeable string (for print)"""
HoleM51_str = ""
# Get the properties inherited from HoleMag
HoleM51_str += super(HoleM51, self).__str__()
HoleM51_str += "H0 = " + str(self.H0) + linesep
HoleM51_str += "H1 = " + str(self.H1) + linesep
HoleM51_str += "H2 = " + str(self.H2) + linesep
HoleM51_str += "W0 = " + str(self.W0) + linesep
HoleM51_str += "W1 = " + str(self.W1) + linesep
HoleM51_str += "W2 = " + str(self.W2) + linesep
HoleM51_str += "W3 = " + str(self.W3) + linesep
HoleM51_str += "W4 = " + str(self.W4) + linesep
HoleM51_str += "W5 = " + str(self.W5) + linesep
HoleM51_str += "W6 = " + str(self.W6) + linesep
HoleM51_str += "W7 = " + str(self.W7) + linesep
if self.magnet_0 is not None:
tmp = self.magnet_0.__str__().replace(linesep, linesep + "\t").rstrip("\t")
HoleM51_str += "magnet_0 = " + tmp
else:
HoleM51_str += "magnet_0 = None" + linesep + linesep
if self.magnet_1 is not None:
tmp = self.magnet_1.__str__().replace(linesep, linesep + "\t").rstrip("\t")
HoleM51_str += "magnet_1 = " + tmp
else:
HoleM51_str += "magnet_1 = None" + linesep + linesep
if self.magnet_2 is not None:
tmp = self.magnet_2.__str__().replace(linesep, linesep + "\t").rstrip("\t")
HoleM51_str += "magnet_2 = " + tmp
else:
HoleM51_str += "magnet_2 = None" + linesep + linesep
return HoleM51_str
def __eq__(self, other):
"""Compare two objects (skip parent)"""
if type(other) != type(self):
return False
# Check the properties inherited from HoleMag
if not super(HoleM51, self).__eq__(other):
return False
if other.H0 != self.H0:
return False
if other.H1 != self.H1:
return False
if other.H2 != self.H2:
return False
if other.W0 != self.W0:
return False
if other.W1 != self.W1:
return False
if other.W2 != self.W2:
return False
if other.W3 != self.W3:
return False
if other.W4 != self.W4:
return False
if other.W5 != self.W5:
return False
if other.W6 != self.W6:
return False
if other.W7 != self.W7:
return False
if other.magnet_0 != self.magnet_0:
return False
if other.magnet_1 != self.magnet_1:
return False
if other.magnet_2 != self.magnet_2:
return False
return True
[docs] def compare(self, other, name="self", ignore_list=None, is_add_value=False):
"""Compare two objects and return list of differences"""
if ignore_list is None:
ignore_list = list()
if type(other) != type(self):
return ["type(" + name + ")"]
diff_list = list()
# Check the properties inherited from HoleMag
diff_list.extend(
super(HoleM51, self).compare(
other, name=name, ignore_list=ignore_list, is_add_value=is_add_value
)
)
if (
other._H0 is not None
and self._H0 is not None
and isnan(other._H0)
and isnan(self._H0)
):
pass
elif other._H0 != self._H0:
if is_add_value:
val_str = " (self=" + str(self._H0) + ", other=" + str(other._H0) + ")"
diff_list.append(name + ".H0" + val_str)
else:
diff_list.append(name + ".H0")
if (
other._H1 is not None
and self._H1 is not None
and isnan(other._H1)
and isnan(self._H1)
):
pass
elif other._H1 != self._H1:
if is_add_value:
val_str = " (self=" + str(self._H1) + ", other=" + str(other._H1) + ")"
diff_list.append(name + ".H1" + val_str)
else:
diff_list.append(name + ".H1")
if (
other._H2 is not None
and self._H2 is not None
and isnan(other._H2)
and isnan(self._H2)
):
pass
elif other._H2 != self._H2:
if is_add_value:
val_str = " (self=" + str(self._H2) + ", other=" + str(other._H2) + ")"
diff_list.append(name + ".H2" + val_str)
else:
diff_list.append(name + ".H2")
if (
other._W0 is not None
and self._W0 is not None
and isnan(other._W0)
and isnan(self._W0)
):
pass
elif other._W0 != self._W0:
if is_add_value:
val_str = " (self=" + str(self._W0) + ", other=" + str(other._W0) + ")"
diff_list.append(name + ".W0" + val_str)
else:
diff_list.append(name + ".W0")
if (
other._W1 is not None
and self._W1 is not None
and isnan(other._W1)
and isnan(self._W1)
):
pass
elif other._W1 != self._W1:
if is_add_value:
val_str = " (self=" + str(self._W1) + ", other=" + str(other._W1) + ")"
diff_list.append(name + ".W1" + val_str)
else:
diff_list.append(name + ".W1")
if (
other._W2 is not None
and self._W2 is not None
and isnan(other._W2)
and isnan(self._W2)
):
pass
elif other._W2 != self._W2:
if is_add_value:
val_str = " (self=" + str(self._W2) + ", other=" + str(other._W2) + ")"
diff_list.append(name + ".W2" + val_str)
else:
diff_list.append(name + ".W2")
if (
other._W3 is not None
and self._W3 is not None
and isnan(other._W3)
and isnan(self._W3)
):
pass
elif other._W3 != self._W3:
if is_add_value:
val_str = " (self=" + str(self._W3) + ", other=" + str(other._W3) + ")"
diff_list.append(name + ".W3" + val_str)
else:
diff_list.append(name + ".W3")
if (
other._W4 is not None
and self._W4 is not None
and isnan(other._W4)
and isnan(self._W4)
):
pass
elif other._W4 != self._W4:
if is_add_value:
val_str = " (self=" + str(self._W4) + ", other=" + str(other._W4) + ")"
diff_list.append(name + ".W4" + val_str)
else:
diff_list.append(name + ".W4")
if (
other._W5 is not None
and self._W5 is not None
and isnan(other._W5)
and isnan(self._W5)
):
pass
elif other._W5 != self._W5:
if is_add_value:
val_str = " (self=" + str(self._W5) + ", other=" + str(other._W5) + ")"
diff_list.append(name + ".W5" + val_str)
else:
diff_list.append(name + ".W5")
if (
other._W6 is not None
and self._W6 is not None
and isnan(other._W6)
and isnan(self._W6)
):
pass
elif other._W6 != self._W6:
if is_add_value:
val_str = " (self=" + str(self._W6) + ", other=" + str(other._W6) + ")"
diff_list.append(name + ".W6" + val_str)
else:
diff_list.append(name + ".W6")
if (
other._W7 is not None
and self._W7 is not None
and isnan(other._W7)
and isnan(self._W7)
):
pass
elif other._W7 != self._W7:
if is_add_value:
val_str = " (self=" + str(self._W7) + ", other=" + str(other._W7) + ")"
diff_list.append(name + ".W7" + val_str)
else:
diff_list.append(name + ".W7")
if (other.magnet_0 is None and self.magnet_0 is not None) or (
other.magnet_0 is not None and self.magnet_0 is None
):
diff_list.append(name + ".magnet_0 None mismatch")
elif self.magnet_0 is not None:
diff_list.extend(
self.magnet_0.compare(
other.magnet_0,
name=name + ".magnet_0",
ignore_list=ignore_list,
is_add_value=is_add_value,
)
)
if (other.magnet_1 is None and self.magnet_1 is not None) or (
other.magnet_1 is not None and self.magnet_1 is None
):
diff_list.append(name + ".magnet_1 None mismatch")
elif self.magnet_1 is not None:
diff_list.extend(
self.magnet_1.compare(
other.magnet_1,
name=name + ".magnet_1",
ignore_list=ignore_list,
is_add_value=is_add_value,
)
)
if (other.magnet_2 is None and self.magnet_2 is not None) or (
other.magnet_2 is not None and self.magnet_2 is None
):
diff_list.append(name + ".magnet_2 None mismatch")
elif self.magnet_2 is not None:
diff_list.extend(
self.magnet_2.compare(
other.magnet_2,
name=name + ".magnet_2",
ignore_list=ignore_list,
is_add_value=is_add_value,
)
)
# Filter ignore differences
diff_list = list(filter(lambda x: x not in ignore_list, diff_list))
return diff_list
def __sizeof__(self):
"""Return the size in memory of the object (including all subobject)"""
S = 0 # Full size of the object
# Get size of the properties inherited from HoleMag
S += super(HoleM51, self).__sizeof__()
S += getsizeof(self.H0)
S += getsizeof(self.H1)
S += getsizeof(self.H2)
S += getsizeof(self.W0)
S += getsizeof(self.W1)
S += getsizeof(self.W2)
S += getsizeof(self.W3)
S += getsizeof(self.W4)
S += getsizeof(self.W5)
S += getsizeof(self.W6)
S += getsizeof(self.W7)
S += getsizeof(self.magnet_0)
S += getsizeof(self.magnet_1)
S += getsizeof(self.magnet_2)
return S
[docs] def as_dict(self, type_handle_ndarray=0, keep_function=False, **kwargs):
"""
Convert this object in a json serializable dict (can be use in __init__).
type_handle_ndarray: int
How to handle ndarray (0: tolist, 1: copy, 2: nothing)
keep_function : bool
True to keep the function object, else return str
Optional keyword input parameter is for internal use only
and may prevent json serializability.
"""
# Get the properties inherited from HoleMag
HoleM51_dict = super(HoleM51, self).as_dict(
type_handle_ndarray=type_handle_ndarray,
keep_function=keep_function,
**kwargs
)
HoleM51_dict["H0"] = self.H0
HoleM51_dict["H1"] = self.H1
HoleM51_dict["H2"] = self.H2
HoleM51_dict["W0"] = self.W0
HoleM51_dict["W1"] = self.W1
HoleM51_dict["W2"] = self.W2
HoleM51_dict["W3"] = self.W3
HoleM51_dict["W4"] = self.W4
HoleM51_dict["W5"] = self.W5
HoleM51_dict["W6"] = self.W6
HoleM51_dict["W7"] = self.W7
if self.magnet_0 is None:
HoleM51_dict["magnet_0"] = None
else:
HoleM51_dict["magnet_0"] = self.magnet_0.as_dict(
type_handle_ndarray=type_handle_ndarray,
keep_function=keep_function,
**kwargs
)
if self.magnet_1 is None:
HoleM51_dict["magnet_1"] = None
else:
HoleM51_dict["magnet_1"] = self.magnet_1.as_dict(
type_handle_ndarray=type_handle_ndarray,
keep_function=keep_function,
**kwargs
)
if self.magnet_2 is None:
HoleM51_dict["magnet_2"] = None
else:
HoleM51_dict["magnet_2"] = self.magnet_2.as_dict(
type_handle_ndarray=type_handle_ndarray,
keep_function=keep_function,
**kwargs
)
# The class name is added to the dict for deserialisation purpose
# Overwrite the mother class name
HoleM51_dict["__class__"] = "HoleM51"
return HoleM51_dict
[docs] def copy(self):
"""Creates a deepcopy of the object"""
# Handle deepcopy of all the properties
H0_val = self.H0
H1_val = self.H1
H2_val = self.H2
W0_val = self.W0
W1_val = self.W1
W2_val = self.W2
W3_val = self.W3
W4_val = self.W4
W5_val = self.W5
W6_val = self.W6
W7_val = self.W7
if self.magnet_0 is None:
magnet_0_val = None
else:
magnet_0_val = self.magnet_0.copy()
if self.magnet_1 is None:
magnet_1_val = None
else:
magnet_1_val = self.magnet_1.copy()
if self.magnet_2 is None:
magnet_2_val = None
else:
magnet_2_val = self.magnet_2.copy()
Zh_val = self.Zh
if self.mat_void is None:
mat_void_val = None
else:
mat_void_val = self.mat_void.copy()
if self.magnetization_dict_offset is None:
magnetization_dict_offset_val = None
else:
magnetization_dict_offset_val = self.magnetization_dict_offset.copy()
Alpha0_val = self.Alpha0
# Creates new object of the same type with the copied properties
obj_copy = type(self)(
H0=H0_val,
H1=H1_val,
H2=H2_val,
W0=W0_val,
W1=W1_val,
W2=W2_val,
W3=W3_val,
W4=W4_val,
W5=W5_val,
W6=W6_val,
W7=W7_val,
magnet_0=magnet_0_val,
magnet_1=magnet_1_val,
magnet_2=magnet_2_val,
Zh=Zh_val,
mat_void=mat_void_val,
magnetization_dict_offset=magnetization_dict_offset_val,
Alpha0=Alpha0_val,
)
return obj_copy
def _set_None(self):
"""Set all the properties to None (except pyleecan object)"""
self.H0 = None
self.H1 = None
self.H2 = None
self.W0 = None
self.W1 = None
self.W2 = None
self.W3 = None
self.W4 = None
self.W5 = None
self.W6 = None
self.W7 = None
if self.magnet_0 is not None:
self.magnet_0._set_None()
if self.magnet_1 is not None:
self.magnet_1._set_None()
if self.magnet_2 is not None:
self.magnet_2._set_None()
# Set to None the properties inherited from HoleMag
super(HoleM51, self)._set_None()
def _get_H0(self):
"""getter of H0"""
return self._H0
def _set_H0(self, value):
"""setter of H0"""
check_var("H0", value, "float", Vmin=0)
self._H0 = value
H0 = property(
fget=_get_H0,
fset=_set_H0,
doc=u"""Hole depth
:Type: float
:min: 0
""",
)
def _get_H1(self):
"""getter of H1"""
return self._H1
def _set_H1(self, value):
"""setter of H1"""
check_var("H1", value, "float", Vmin=0)
self._H1 = value
H1 = property(
fget=_get_H1,
fset=_set_H1,
doc=u"""Distance from the lamination Bore
:Type: float
:min: 0
""",
)
def _get_H2(self):
"""getter of H2"""
return self._H2
def _set_H2(self, value):
"""setter of H2"""
check_var("H2", value, "float", Vmin=0)
self._H2 = value
H2 = property(
fget=_get_H2,
fset=_set_H2,
doc=u"""Hole width
:Type: float
:min: 0
""",
)
def _get_W0(self):
"""getter of W0"""
return self._W0
def _set_W0(self, value):
"""setter of W0"""
check_var("W0", value, "float", Vmin=0)
self._W0 = value
W0 = property(
fget=_get_W0,
fset=_set_W0,
doc=u"""Hole bottom width
:Type: float
:min: 0
""",
)
def _get_W1(self):
"""getter of W1"""
return self._W1
def _set_W1(self, value):
"""setter of W1"""
check_var("W1", value, "float", Vmin=0)
self._W1 = value
W1 = property(
fget=_get_W1,
fset=_set_W1,
doc=u"""Hole angular width
:Type: float
:min: 0
""",
)
def _get_W2(self):
"""getter of W2"""
return self._W2
def _set_W2(self, value):
"""setter of W2"""
check_var("W2", value, "float", Vmin=0)
self._W2 = value
W2 = property(
fget=_get_W2,
fset=_set_W2,
doc=u"""magnet_1 position
:Type: float
:min: 0
""",
)
def _get_W3(self):
"""getter of W3"""
return self._W3
def _set_W3(self, value):
"""setter of W3"""
check_var("W3", value, "float", Vmin=0)
self._W3 = value
W3 = property(
fget=_get_W3,
fset=_set_W3,
doc=u"""magnet_1 width
:Type: float
:min: 0
""",
)
def _get_W4(self):
"""getter of W4"""
return self._W4
def _set_W4(self, value):
"""setter of W4"""
check_var("W4", value, "float", Vmin=0)
self._W4 = value
W4 = property(
fget=_get_W4,
fset=_set_W4,
doc=u"""magnet_2 position
:Type: float
:min: 0
""",
)
def _get_W5(self):
"""getter of W5"""
return self._W5
def _set_W5(self, value):
"""setter of W5"""
check_var("W5", value, "float", Vmin=0)
self._W5 = value
W5 = property(
fget=_get_W5,
fset=_set_W5,
doc=u"""magnet_2 width
:Type: float
:min: 0
""",
)
def _get_W6(self):
"""getter of W6"""
return self._W6
def _set_W6(self, value):
"""setter of W6"""
check_var("W6", value, "float", Vmin=0)
self._W6 = value
W6 = property(
fget=_get_W6,
fset=_set_W6,
doc=u"""magnet_0 position
:Type: float
:min: 0
""",
)
def _get_W7(self):
"""getter of W7"""
return self._W7
def _set_W7(self, value):
"""setter of W7"""
check_var("W7", value, "float", Vmin=0)
self._W7 = value
W7 = property(
fget=_get_W7,
fset=_set_W7,
doc=u"""magnet_0 width
:Type: float
:min: 0
""",
)
def _get_magnet_0(self):
"""getter of magnet_0"""
return self._magnet_0
def _set_magnet_0(self, value):
"""setter of magnet_0"""
if isinstance(value, str): # Load from file
try:
value = load_init_dict(value)[1]
except Exception as e:
self.get_logger().error(
"Error while loading " + value + ", setting None instead"
)
value = None
if isinstance(value, dict) and "__class__" in value:
class_obj = import_class(
"pyleecan.Classes", value.get("__class__"), "magnet_0"
)
value = class_obj(init_dict=value)
elif type(value) is int and value == -1: # Default constructor
Magnet = import_class("pyleecan.Classes", "Magnet", "magnet_0")
value = Magnet()
check_var("magnet_0", value, "Magnet")
self._magnet_0 = value
if self._magnet_0 is not None:
self._magnet_0.parent = self
magnet_0 = property(
fget=_get_magnet_0,
fset=_set_magnet_0,
doc=u"""First Magnet
:Type: Magnet
""",
)
def _get_magnet_1(self):
"""getter of magnet_1"""
return self._magnet_1
def _set_magnet_1(self, value):
"""setter of magnet_1"""
if isinstance(value, str): # Load from file
try:
value = load_init_dict(value)[1]
except Exception as e:
self.get_logger().error(
"Error while loading " + value + ", setting None instead"
)
value = None
if isinstance(value, dict) and "__class__" in value:
class_obj = import_class(
"pyleecan.Classes", value.get("__class__"), "magnet_1"
)
value = class_obj(init_dict=value)
elif type(value) is int and value == -1: # Default constructor
Magnet = import_class("pyleecan.Classes", "Magnet", "magnet_1")
value = Magnet()
check_var("magnet_1", value, "Magnet")
self._magnet_1 = value
if self._magnet_1 is not None:
self._magnet_1.parent = self
magnet_1 = property(
fget=_get_magnet_1,
fset=_set_magnet_1,
doc=u"""Second Magnet
:Type: Magnet
""",
)
def _get_magnet_2(self):
"""getter of magnet_2"""
return self._magnet_2
def _set_magnet_2(self, value):
"""setter of magnet_2"""
if isinstance(value, str): # Load from file
try:
value = load_init_dict(value)[1]
except Exception as e:
self.get_logger().error(
"Error while loading " + value + ", setting None instead"
)
value = None
if isinstance(value, dict) and "__class__" in value:
class_obj = import_class(
"pyleecan.Classes", value.get("__class__"), "magnet_2"
)
value = class_obj(init_dict=value)
elif type(value) is int and value == -1: # Default constructor
Magnet = import_class("pyleecan.Classes", "Magnet", "magnet_2")
value = Magnet()
check_var("magnet_2", value, "Magnet")
self._magnet_2 = value
if self._magnet_2 is not None:
self._magnet_2.parent = self
magnet_2 = property(
fget=_get_magnet_2,
fset=_set_magnet_2,
doc=u"""Third Magnet
:Type: Magnet
""",
)