class Solution(FrozenClass): """Define a solution related to a Mesh object.""" VERSION = 1 # cf Methods.Mesh.Solution.get_field if isinstance(get_field, ImportError): get_field = property(fget=lambda x: raise_( ImportError("Can't use Solution method get_field: " + str(get_field )))) else: get_field = get_field # save method is available in all object save = save def __init__(self, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, []) # The class is frozen, for now it's impossible to add new properties self.parent = None self._freeze() def __str__(self): """Convert this objet in a readeable string (for print)""" Solution_str = "" if self.parent is None: Solution_str += "parent = None " + linesep else: Solution_str += "parent = " + str(type( self.parent)) + " object" + linesep return Solution_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ Solution_dict = dict() # The class name is added to the dict fordeserialisation purpose Solution_dict["__class__"] = "Solution" return Solution_dict def _set_None(self): """Set all the properties to None (except pyleecan object)"""
class Frame(FrozenClass): """machine frame""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Machine.Frame.build_geometry if isinstance(build_geometry, ImportError): build_geometry = property(fget=lambda x: raise_( ImportError("Can't use Frame method build_geometry: " + str( build_geometry)))) else: build_geometry = build_geometry # cf Methods.Machine.Frame.comp_height_eq if isinstance(comp_height_eq, ImportError): comp_height_eq = property(fget=lambda x: raise_( ImportError("Can't use Frame method comp_height_eq: " + str( comp_height_eq)))) else: comp_height_eq = comp_height_eq # cf Methods.Machine.Frame.comp_mass if isinstance(comp_mass, ImportError): comp_mass = property(fget=lambda x: raise_( ImportError("Can't use Frame method comp_mass: " + str(comp_mass))) ) else: comp_mass = comp_mass # cf Methods.Machine.Frame.comp_surface if isinstance(comp_surface, ImportError): comp_surface = property(fget=lambda x: raise_( ImportError("Can't use Frame method comp_surface: " + str( comp_surface)))) else: comp_surface = comp_surface # cf Methods.Machine.Frame.comp_volume if isinstance(comp_volume, ImportError): comp_volume = property(fget=lambda x: raise_( ImportError("Can't use Frame method comp_volume: " + str( comp_volume)))) else: comp_volume = comp_volume # cf Methods.Machine.Frame.get_length if isinstance(get_length, ImportError): get_length = property(fget=lambda x: raise_( ImportError("Can't use Frame method get_length: " + str(get_length) ))) else: get_length = get_length # cf Methods.Machine.Frame.plot if isinstance(plot, ImportError): plot = property(fget=lambda x: raise_( ImportError("Can't use Frame method plot: " + str(plot)))) else: plot = plot # save method is available in all object save = save def __init__(self, Lfra=0.35, Rint=0.2, Rext=0.2, mat_type=-1, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if mat_type == -1: mat_type = Material() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["Lfra", "Rint", "Rext", "mat_type"]) # Overwrite default value with init_dict content if "Lfra" in list(init_dict.keys()): Lfra = init_dict["Lfra"] if "Rint" in list(init_dict.keys()): Rint = init_dict["Rint"] if "Rext" in list(init_dict.keys()): Rext = init_dict["Rext"] if "mat_type" in list(init_dict.keys()): mat_type = init_dict["mat_type"] # Initialisation by argument self.parent = None self.Lfra = Lfra self.Rint = Rint self.Rext = Rext # mat_type can be None, a Material object or a dict if isinstance(mat_type, dict): self.mat_type = Material(init_dict=mat_type) else: self.mat_type = mat_type # The class is frozen, for now it's impossible to add new properties self._freeze() def __str__(self): """Convert this objet in a readeable string (for print)""" Frame_str = "" if self.parent is None: Frame_str += "parent = None " + linesep else: Frame_str += "parent = " + str(type( self.parent)) + " object" + linesep Frame_str += "Lfra = " + str(self.Lfra) + linesep Frame_str += "Rint = " + str(self.Rint) + linesep Frame_str += "Rext = " + str(self.Rext) + linesep if self.mat_type is not None: Frame_str += ("mat_type = " + str(self.mat_type.as_dict()) + linesep + linesep) else: Frame_str += "mat_type = None" return Frame_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False if other.Lfra != self.Lfra: return False if other.Rint != self.Rint: return False if other.Rext != self.Rext: return False if other.mat_type != self.mat_type: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ Frame_dict = dict() Frame_dict["Lfra"] = self.Lfra Frame_dict["Rint"] = self.Rint Frame_dict["Rext"] = self.Rext if self.mat_type is None: Frame_dict["mat_type"] = None else: Frame_dict["mat_type"] = self.mat_type.as_dict() # The class name is added to the dict fordeserialisation purpose Frame_dict["__class__"] = "Frame" return Frame_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.Lfra = None self.Rint = None self.Rext = None if self.mat_type is not None: self.mat_type._set_None() def _get_Lfra(self): """getter of Lfra""" return self._Lfra def _set_Lfra(self, value): """setter of Lfra""" check_var("Lfra", value, "float", Vmin=0) self._Lfra = value # frame length [m] # Type : float, min = 0 Lfra = property(fget=_get_Lfra, fset=_set_Lfra, doc=u"""frame length [m]""") def _get_Rint(self): """getter of Rint""" return self._Rint def _set_Rint(self, value): """setter of Rint""" check_var("Rint", value, "float", Vmin=0) self._Rint = value # frame internal radius # Type : float, min = 0 Rint = property(fget=_get_Rint, fset=_set_Rint, doc=u"""frame internal radius""") def _get_Rext(self): """getter of Rext""" return self._Rext def _set_Rext(self, value): """setter of Rext""" check_var("Rext", value, "float", Vmin=0) self._Rext = value # Frame external radius # Type : float, min = 0 Rext = property(fget=_get_Rext, fset=_set_Rext, doc=u"""Frame external radius""") def _get_mat_type(self): """getter of mat_type""" return self._mat_type def _set_mat_type(self, value): """setter of mat_type""" check_var("mat_type", value, "Material") self._mat_type = value if self._mat_type is not None: self._mat_type.parent = self # Frame material # Type : Material mat_type = property(fget=_get_mat_type, fset=_set_mat_type, doc=u"""Frame material""")
class Notch(FrozenClass): """Abstract class for notches""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Machine.Notch.get_Rbo if isinstance(get_Rbo, ImportError): get_Rbo = property( fget=lambda x: raise_( ImportError("Can't use Notch method get_Rbo: " + str(get_Rbo)) ) ) else: get_Rbo = get_Rbo # cf Methods.Machine.Notch.is_outwards if isinstance(is_outwards, ImportError): is_outwards = property( fget=lambda x: raise_( ImportError("Can't use Notch method is_outwards: " + str(is_outwards)) ) ) else: is_outwards = is_outwards # save method is available in all object save = save def __init__(self, notch_shape=list(), init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["notch_shape"]) # Overwrite default value with init_dict content if "notch_shape" in list(init_dict.keys()): notch_shape = init_dict["notch_shape"] # Initialisation by argument self.parent = None # notch_shape can be None or a list of Slot object self.notch_shape = list() if type(notch_shape) is list: for obj in notch_shape: if obj is None: # Default value self.notch_shape.append(Slot()) elif isinstance(obj, dict): # Check that the type is correct (including daughter) class_name = obj.get("__class__") if class_name not in [ "Slot", "Slot19", "SlotMFlat", "SlotMPolar", "SlotMag", "SlotUD", "SlotW10", "SlotW11", "SlotW12", "SlotW13", "SlotW14", "SlotW15", "SlotW16", "SlotW21", "SlotW22", "SlotW23", "SlotW24", "SlotW25", "SlotW26", "SlotW27", "SlotW28", "SlotW29", "SlotW60", "SlotW61", "SlotWind", ]: raise InitUnKnowClassError( "Unknow class name " + class_name + " in init_dict for notch_shape" ) # Dynamic import to call the correct constructor module = __import__( "pyleecan.Classes." + class_name, fromlist=[class_name] ) class_obj = getattr(module, class_name) self.notch_shape.append(class_obj(init_dict=obj)) else: self.notch_shape.append(obj) elif notch_shape is None: self.notch_shape = list() else: self.notch_shape = notch_shape # The class is frozen, for now it's impossible to add new properties self._freeze() def __str__(self): """Convert this objet in a readeable string (for print)""" Notch_str = "" if self.parent is None: Notch_str += "parent = None " + linesep else: Notch_str += "parent = " + str(type(self.parent)) + " object" + linesep if len(self.notch_shape) == 0: Notch_str += "notch_shape = []" for ii in range(len(self.notch_shape)): Notch_str += ( "notch_shape[" + str(ii) + "] = " + str(self.notch_shape[ii].as_dict()) + "\n" ) return Notch_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False if other.notch_shape != self.notch_shape: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ Notch_dict = dict() Notch_dict["notch_shape"] = list() for obj in self.notch_shape: Notch_dict["notch_shape"].append(obj.as_dict()) # The class name is added to the dict fordeserialisation purpose Notch_dict["__class__"] = "Notch" return Notch_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" for obj in self.notch_shape: obj._set_None() def _get_notch_shape(self): """getter of notch_shape""" for obj in self._notch_shape: if obj is not None: obj.parent = self return self._notch_shape def _set_notch_shape(self, value): """setter of notch_shape""" check_var("notch_shape", value, "[Slot]") self._notch_shape = value for obj in self._notch_shape: if obj is not None: obj.parent = self # Shape of Notch # Type : [Slot] notch_shape = property( fget=_get_notch_shape, fset=_set_notch_shape, doc=u"""Shape of Notch""" )
class SlotW25(SlotWind): VERSION = 1 IS_SYMMETRICAL = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Slot.SlotW25._comp_point_coordinate if isinstance(_comp_point_coordinate, ImportError): _comp_point_coordinate = property(fget=lambda x: raise_( ImportError("Can't use SlotW25 method _comp_point_coordinate: " + str(_comp_point_coordinate)))) else: _comp_point_coordinate = _comp_point_coordinate # cf Methods.Slot.SlotW25.build_geometry if isinstance(build_geometry, ImportError): build_geometry = property(fget=lambda x: raise_( ImportError("Can't use SlotW25 method build_geometry: " + str( build_geometry)))) else: build_geometry = build_geometry # cf Methods.Slot.SlotW25.build_geometry_wind if isinstance(build_geometry_wind, ImportError): build_geometry_wind = property(fget=lambda x: raise_( ImportError("Can't use SlotW25 method build_geometry_wind: " + str( build_geometry_wind)))) else: build_geometry_wind = build_geometry_wind # cf Methods.Slot.SlotW25.check if isinstance(check, ImportError): check = property(fget=lambda x: raise_( ImportError("Can't use SlotW25 method check: " + str(check)))) else: check = check # cf Methods.Slot.SlotW25.comp_angle_opening if isinstance(comp_angle_opening, ImportError): comp_angle_opening = property(fget=lambda x: raise_( ImportError("Can't use SlotW25 method comp_angle_opening: " + str( comp_angle_opening)))) else: comp_angle_opening = comp_angle_opening # cf Methods.Slot.SlotW25.comp_height if isinstance(comp_height, ImportError): comp_height = property(fget=lambda x: raise_( ImportError("Can't use SlotW25 method comp_height: " + str( comp_height)))) else: comp_height = comp_height # cf Methods.Slot.SlotW25.comp_height_wind if isinstance(comp_height_wind, ImportError): comp_height_wind = property(fget=lambda x: raise_( ImportError("Can't use SlotW25 method comp_height_wind: " + str( comp_height_wind)))) else: comp_height_wind = comp_height_wind # cf Methods.Slot.SlotW25.comp_surface if isinstance(comp_surface, ImportError): comp_surface = property(fget=lambda x: raise_( ImportError("Can't use SlotW25 method comp_surface: " + str( comp_surface)))) else: comp_surface = comp_surface # cf Methods.Slot.SlotW25.comp_surface_wind if isinstance(comp_surface_wind, ImportError): comp_surface_wind = property(fget=lambda x: raise_( ImportError("Can't use SlotW25 method comp_surface_wind: " + str( comp_surface_wind)))) else: comp_surface_wind = comp_surface_wind # save method is available in all object save = save def __init__(self, W3=0.003, H2=0.003, W4=0.003, H1=0.003, Zs=36, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["W3", "H2", "W4", "H1", "Zs"]) # Overwrite default value with init_dict content if "W3" in list(init_dict.keys()): W3 = init_dict["W3"] if "H2" in list(init_dict.keys()): H2 = init_dict["H2"] if "W4" in list(init_dict.keys()): W4 = init_dict["W4"] if "H1" in list(init_dict.keys()): H1 = init_dict["H1"] if "Zs" in list(init_dict.keys()): Zs = init_dict["Zs"] # Initialisation by argument self.W3 = W3 self.H2 = H2 self.W4 = W4 self.H1 = H1 # Call SlotWind init super(SlotW25, self).__init__(Zs=Zs) # The class is frozen (in SlotWind init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" SlotW25_str = "" # Get the properties inherited from SlotWind SlotW25_str += super(SlotW25, self).__str__() + linesep SlotW25_str += "W3 = " + str(self.W3) + linesep SlotW25_str += "H2 = " + str(self.H2) + linesep SlotW25_str += "W4 = " + str(self.W4) + linesep SlotW25_str += "H1 = " + str(self.H1) return SlotW25_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from SlotWind if not super(SlotW25, self).__eq__(other): return False if other.W3 != self.W3: return False if other.H2 != self.H2: return False if other.W4 != self.W4: return False if other.H1 != self.H1: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from SlotWind SlotW25_dict = super(SlotW25, self).as_dict() SlotW25_dict["W3"] = self.W3 SlotW25_dict["H2"] = self.H2 SlotW25_dict["W4"] = self.W4 SlotW25_dict["H1"] = self.H1 # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name SlotW25_dict["__class__"] = "SlotW25" return SlotW25_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.W3 = None self.H2 = None self.W4 = None self.H1 = None # Set to None the properties inherited from SlotWind super(SlotW25, self)._set_None() 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 # Teeth bottom width # Type : float, min = 0 W3 = property(fget=_get_W3, fset=_set_W3, doc=u"""Teeth bottom width""") 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 # Slot bottom height # Type : float, min = 0 H2 = property(fget=_get_H2, fset=_set_H2, doc=u"""Slot bottom height""") 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 # Teeth top width # Type : float, min = 0 W4 = property(fget=_get_W4, fset=_set_W4, doc=u"""Teeth top width""") 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 # Slot top height # Type : float, min = 0 H1 = property(fget=_get_H1, fset=_set_H1, doc=u"""Slot top height""")
class LamSlotWind(LamSlot): """Lamination with Slot filled with winding""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Machine.LamSlotWind.build_geometry if isinstance(build_geometry, ImportError): build_geometry = property(fget=lambda x: raise_( ImportError("Can't use LamSlotWind method build_geometry: " + str( build_geometry)))) else: build_geometry = build_geometry # cf Methods.Machine.LamSlotWind.check if isinstance(check, ImportError): check = property(fget=lambda x: raise_( ImportError("Can't use LamSlotWind method check: " + str(check)))) else: check = check # cf Methods.Machine.LamSlotWind.comp_masses if isinstance(comp_masses, ImportError): comp_masses = property(fget=lambda x: raise_( ImportError("Can't use LamSlotWind method comp_masses: " + str( comp_masses)))) else: comp_masses = comp_masses # cf Methods.Machine.LamSlotWind.comp_surfaces if isinstance(comp_surfaces, ImportError): comp_surfaces = property(fget=lambda x: raise_( ImportError("Can't use LamSlotWind method comp_surfaces: " + str( comp_surfaces)))) else: comp_surfaces = comp_surfaces # cf Methods.Machine.LamSlotWind.comp_volumes if isinstance(comp_volumes, ImportError): comp_volumes = property(fget=lambda x: raise_( ImportError("Can't use LamSlotWind method comp_volumes: " + str( comp_volumes)))) else: comp_volumes = comp_volumes # cf Methods.Machine.LamSlotWind.get_pole_pair_number if isinstance(get_pole_pair_number, ImportError): get_pole_pair_number = property(fget=lambda x: raise_( ImportError("Can't use LamSlotWind method get_pole_pair_number: " + str(get_pole_pair_number)))) else: get_pole_pair_number = get_pole_pair_number # cf Methods.Machine.LamSlotWind.get_name_phase if isinstance(get_name_phase, ImportError): get_name_phase = property(fget=lambda x: raise_( ImportError("Can't use LamSlotWind method get_name_phase: " + str( get_name_phase)))) else: get_name_phase = get_name_phase # cf Methods.Machine.LamSlotWind.plot if isinstance(plot, ImportError): plot = property(fget=lambda x: raise_( ImportError("Can't use LamSlotWind method plot: " + str(plot)))) else: plot = plot # cf Methods.Machine.LamSlotWind.plot_winding if isinstance(plot_winding, ImportError): plot_winding = property(fget=lambda x: raise_( ImportError("Can't use LamSlotWind method plot_winding: " + str( plot_winding)))) else: plot_winding = plot_winding # cf Methods.Machine.LamSlotWind.comp_fill_factor if isinstance(comp_fill_factor, ImportError): comp_fill_factor = property(fget=lambda x: raise_( ImportError("Can't use LamSlotWind method comp_fill_factor: " + str(comp_fill_factor)))) else: comp_fill_factor = comp_fill_factor # cf Methods.Machine.LamSlotWind.comp_output_geo if isinstance(comp_output_geo, ImportError): comp_output_geo = property(fget=lambda x: raise_( ImportError("Can't use LamSlotWind method comp_output_geo: " + str( comp_output_geo)))) else: comp_output_geo = comp_output_geo # cf Methods.Machine.LamSlotWind.get_polar_eq if isinstance(get_polar_eq, ImportError): get_polar_eq = property(fget=lambda x: raise_( ImportError("Can't use LamSlotWind method get_polar_eq: " + str( get_polar_eq)))) else: get_polar_eq = get_polar_eq # save method is available in all object save = save def __init__( self, Ksfill=None, winding=-1, slot=-1, L1=0.35, mat_type=-1, Nrvd=0, Wrvd=0, Kf1=0.95, is_internal=True, Rint=0, Rext=1, is_stator=True, axial_vent=list(), notch=list(), init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if winding == -1: winding = Winding() if slot == -1: slot = Slot() if mat_type == -1: mat_type = Material() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "Ksfill", "winding", "slot", "L1", "mat_type", "Nrvd", "Wrvd", "Kf1", "is_internal", "Rint", "Rext", "is_stator", "axial_vent", "notch", ], ) # Overwrite default value with init_dict content if "Ksfill" in list(init_dict.keys()): Ksfill = init_dict["Ksfill"] if "winding" in list(init_dict.keys()): winding = init_dict["winding"] if "slot" in list(init_dict.keys()): slot = init_dict["slot"] if "L1" in list(init_dict.keys()): L1 = init_dict["L1"] if "mat_type" in list(init_dict.keys()): mat_type = init_dict["mat_type"] if "Nrvd" in list(init_dict.keys()): Nrvd = init_dict["Nrvd"] if "Wrvd" in list(init_dict.keys()): Wrvd = init_dict["Wrvd"] if "Kf1" in list(init_dict.keys()): Kf1 = init_dict["Kf1"] if "is_internal" in list(init_dict.keys()): is_internal = init_dict["is_internal"] if "Rint" in list(init_dict.keys()): Rint = init_dict["Rint"] if "Rext" in list(init_dict.keys()): Rext = init_dict["Rext"] if "is_stator" in list(init_dict.keys()): is_stator = init_dict["is_stator"] if "axial_vent" in list(init_dict.keys()): axial_vent = init_dict["axial_vent"] if "notch" in list(init_dict.keys()): notch = init_dict["notch"] # Initialisation by argument self.Ksfill = Ksfill # winding can be None, a Winding object or a dict if isinstance(winding, dict): # Check that the type is correct (including daughter) class_name = winding.get("__class__") if class_name not in [ "Winding", "WindingCW1L", "WindingCW2LR", "WindingCW2LT", "WindingDW1L", "WindingDW2L", "WindingSC", "WindingUD", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for winding") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.winding = class_obj(init_dict=winding) else: self.winding = winding # Call LamSlot init super(LamSlotWind, self).__init__( slot=slot, L1=L1, mat_type=mat_type, Nrvd=Nrvd, Wrvd=Wrvd, Kf1=Kf1, is_internal=is_internal, Rint=Rint, Rext=Rext, is_stator=is_stator, axial_vent=axial_vent, notch=notch, ) # The class is frozen (in LamSlot init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" LamSlotWind_str = "" # Get the properties inherited from LamSlot LamSlotWind_str += super(LamSlotWind, self).__str__() + linesep LamSlotWind_str += "Ksfill = " + str(self.Ksfill) + linesep if self.winding is not None: LamSlotWind_str += ("winding = " + str(self.winding.as_dict()) + linesep + linesep) else: LamSlotWind_str += "winding = None" return LamSlotWind_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from LamSlot if not super(LamSlotWind, self).__eq__(other): return False if other.Ksfill != self.Ksfill: return False if other.winding != self.winding: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from LamSlot LamSlotWind_dict = super(LamSlotWind, self).as_dict() LamSlotWind_dict["Ksfill"] = self.Ksfill if self.winding is None: LamSlotWind_dict["winding"] = None else: LamSlotWind_dict["winding"] = self.winding.as_dict() # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name LamSlotWind_dict["__class__"] = "LamSlotWind" return LamSlotWind_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.Ksfill = None if self.winding is not None: self.winding._set_None() # Set to None the properties inherited from LamSlot super(LamSlotWind, self)._set_None() def _get_Ksfill(self): """getter of Ksfill""" return self._Ksfill def _set_Ksfill(self, value): """setter of Ksfill""" check_var("Ksfill", value, "float", Vmin=0, Vmax=1) self._Ksfill = value # Imposed Slot Fill factor (if None, will be computed according to the winding and the slot) # Type : float, min = 0, max = 1 Ksfill = property( fget=_get_Ksfill, fset=_set_Ksfill, doc= u"""Imposed Slot Fill factor (if None, will be computed according to the winding and the slot)""", ) def _get_winding(self): """getter of winding""" return self._winding def _set_winding(self, value): """setter of winding""" check_var("winding", value, "Winding") self._winding = value if self._winding is not None: self._winding.parent = self # Lamination's Winding # Type : Winding winding = property(fget=_get_winding, fset=_set_winding, doc=u"""Lamination's Winding""")
class SlotW26(SlotWind): VERSION = 1 IS_SYMMETRICAL = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Slot.SlotW26._comp_point_coordinate if isinstance(_comp_point_coordinate, ImportError): _comp_point_coordinate = property(fget=lambda x: raise_( ImportError("Can't use SlotW26 method _comp_point_coordinate: " + str(_comp_point_coordinate)))) else: _comp_point_coordinate = _comp_point_coordinate # cf Methods.Slot.SlotW26.build_geometry if isinstance(build_geometry, ImportError): build_geometry = property(fget=lambda x: raise_( ImportError("Can't use SlotW26 method build_geometry: " + str( build_geometry)))) else: build_geometry = build_geometry # cf Methods.Slot.SlotW26.build_geometry_wind if isinstance(build_geometry_wind, ImportError): build_geometry_wind = property(fget=lambda x: raise_( ImportError("Can't use SlotW26 method build_geometry_wind: " + str( build_geometry_wind)))) else: build_geometry_wind = build_geometry_wind # cf Methods.Slot.SlotW26.check if isinstance(check, ImportError): check = property(fget=lambda x: raise_( ImportError("Can't use SlotW26 method check: " + str(check)))) else: check = check # cf Methods.Slot.SlotW26.comp_angle_opening if isinstance(comp_angle_opening, ImportError): comp_angle_opening = property(fget=lambda x: raise_( ImportError("Can't use SlotW26 method comp_angle_opening: " + str( comp_angle_opening)))) else: comp_angle_opening = comp_angle_opening # cf Methods.Slot.SlotW26.comp_height if isinstance(comp_height, ImportError): comp_height = property(fget=lambda x: raise_( ImportError("Can't use SlotW26 method comp_height: " + str( comp_height)))) else: comp_height = comp_height # cf Methods.Slot.SlotW26.comp_height_wind if isinstance(comp_height_wind, ImportError): comp_height_wind = property(fget=lambda x: raise_( ImportError("Can't use SlotW26 method comp_height_wind: " + str( comp_height_wind)))) else: comp_height_wind = comp_height_wind # cf Methods.Slot.SlotW26.comp_surface if isinstance(comp_surface, ImportError): comp_surface = property(fget=lambda x: raise_( ImportError("Can't use SlotW26 method comp_surface: " + str( comp_surface)))) else: comp_surface = comp_surface # cf Methods.Slot.SlotW26.comp_surface_wind if isinstance(comp_surface_wind, ImportError): comp_surface_wind = property(fget=lambda x: raise_( ImportError("Can't use SlotW26 method comp_surface_wind: " + str( comp_surface_wind)))) else: comp_surface_wind = comp_surface_wind # save method is available in all object save = save def __init__(self, W0=0.0122, H0=0.001, H1=0.003, R1=0.003, Zs=36, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["W0", "H0", "H1", "R1", "Zs"]) # Overwrite default value with init_dict content if "W0" in list(init_dict.keys()): W0 = init_dict["W0"] if "H0" in list(init_dict.keys()): H0 = init_dict["H0"] if "H1" in list(init_dict.keys()): H1 = init_dict["H1"] if "R1" in list(init_dict.keys()): R1 = init_dict["R1"] if "Zs" in list(init_dict.keys()): Zs = init_dict["Zs"] # Initialisation by argument self.W0 = W0 self.H0 = H0 self.H1 = H1 self.R1 = R1 # Call SlotWind init super(SlotW26, self).__init__(Zs=Zs) # The class is frozen (in SlotWind init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" SlotW26_str = "" # Get the properties inherited from SlotWind SlotW26_str += super(SlotW26, self).__str__() + linesep SlotW26_str += "W0 = " + str(self.W0) + linesep SlotW26_str += "H0 = " + str(self.H0) + linesep SlotW26_str += "H1 = " + str(self.H1) + linesep SlotW26_str += "R1 = " + str(self.R1) return SlotW26_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from SlotWind if not super(SlotW26, self).__eq__(other): return False if other.W0 != self.W0: return False if other.H0 != self.H0: return False if other.H1 != self.H1: return False if other.R1 != self.R1: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from SlotWind SlotW26_dict = super(SlotW26, self).as_dict() SlotW26_dict["W0"] = self.W0 SlotW26_dict["H0"] = self.H0 SlotW26_dict["H1"] = self.H1 SlotW26_dict["R1"] = self.R1 # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name SlotW26_dict["__class__"] = "SlotW26" return SlotW26_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.W0 = None self.H0 = None self.H1 = None self.R1 = None # Set to None the properties inherited from SlotWind super(SlotW26, self)._set_None() 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 # Slot isthmus width. # Type : float, min = 0 W0 = property(fget=_get_W0, fset=_set_W0, doc=u"""Slot isthmus width.""") 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 # Slot isthmus height. # Type : float, min = 0 H0 = property(fget=_get_H0, fset=_set_H0, doc=u"""Slot isthmus height.""") 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 # Slot depth # Type : float, min = 0 H1 = property(fget=_get_H1, fset=_set_H1, doc=u"""Slot depth """) def _get_R1(self): """getter of R1""" return self._R1 def _set_R1(self, value): """setter of R1""" check_var("R1", value, "float", Vmin=0) self._R1 = value # Slot edge radius # Type : float, min = 0 R1 = property(fget=_get_R1, fset=_set_R1, doc=u"""Slot edge radius""")
class Slot19(Slot): """trapezoidal slot with rounded bottom""" VERSION = 1 IS_SYMMETRICAL = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Slot.Slot19._comp_point_coordinate if isinstance(_comp_point_coordinate, ImportError): _comp_point_coordinate = property( fget=lambda x: raise_( ImportError( "Can't use Slot19 method _comp_point_coordinate: " + str(_comp_point_coordinate) ) ) ) else: _comp_point_coordinate = _comp_point_coordinate # cf Methods.Slot.Slot19.build_geometry if isinstance(build_geometry, ImportError): build_geometry = property( fget=lambda x: raise_( ImportError( "Can't use Slot19 method build_geometry: " + str(build_geometry) ) ) ) else: build_geometry = build_geometry # cf Methods.Slot.Slot19.check if isinstance(check, ImportError): check = property( fget=lambda x: raise_( ImportError("Can't use Slot19 method check: " + str(check)) ) ) else: check = check # cf Methods.Slot.Slot19.comp_angle_opening if isinstance(comp_angle_opening, ImportError): comp_angle_opening = property( fget=lambda x: raise_( ImportError( "Can't use Slot19 method comp_angle_opening: " + str(comp_angle_opening) ) ) ) else: comp_angle_opening = comp_angle_opening # cf Methods.Slot.Slot19.comp_angle_bottom if isinstance(comp_angle_bottom, ImportError): comp_angle_bottom = property( fget=lambda x: raise_( ImportError( "Can't use Slot19 method comp_angle_bottom: " + str(comp_angle_bottom) ) ) ) else: comp_angle_bottom = comp_angle_bottom # cf Methods.Slot.Slot19.comp_height if isinstance(comp_height, ImportError): comp_height = property( fget=lambda x: raise_( ImportError("Can't use Slot19 method comp_height: " + str(comp_height)) ) ) else: comp_height = comp_height # cf Methods.Slot.Slot19.comp_surface if isinstance(comp_surface, ImportError): comp_surface = property( fget=lambda x: raise_( ImportError( "Can't use Slot19 method comp_surface: " + str(comp_surface) ) ) ) else: comp_surface = comp_surface # save method is available in all object save = save def __init__( self, W0=0.013, H0=0.02, W1=0.01, Wx_is_rad=False, Zs=36, init_dict=None ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["W0", "H0", "W1", "Wx_is_rad", "Zs"]) # Overwrite default value with init_dict content if "W0" in list(init_dict.keys()): W0 = init_dict["W0"] if "H0" in list(init_dict.keys()): H0 = init_dict["H0"] if "W1" in list(init_dict.keys()): W1 = init_dict["W1"] if "Wx_is_rad" in list(init_dict.keys()): Wx_is_rad = init_dict["Wx_is_rad"] if "Zs" in list(init_dict.keys()): Zs = init_dict["Zs"] # Initialisation by argument self.W0 = W0 self.H0 = H0 self.W1 = W1 self.Wx_is_rad = Wx_is_rad # Call Slot init super(Slot19, self).__init__(Zs=Zs) # The class is frozen (in Slot init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" Slot19_str = "" # Get the properties inherited from Slot Slot19_str += super(Slot19, self).__str__() + linesep Slot19_str += "W0 = " + str(self.W0) + linesep Slot19_str += "H0 = " + str(self.H0) + linesep Slot19_str += "W1 = " + str(self.W1) + linesep Slot19_str += "Wx_is_rad = " + str(self.Wx_is_rad) return Slot19_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from Slot if not super(Slot19, self).__eq__(other): return False if other.W0 != self.W0: return False if other.H0 != self.H0: return False if other.W1 != self.W1: return False if other.Wx_is_rad != self.Wx_is_rad: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from Slot Slot19_dict = super(Slot19, self).as_dict() Slot19_dict["W0"] = self.W0 Slot19_dict["H0"] = self.H0 Slot19_dict["W1"] = self.W1 Slot19_dict["Wx_is_rad"] = self.Wx_is_rad # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name Slot19_dict["__class__"] = "Slot19" return Slot19_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.W0 = None self.H0 = None self.W1 = None self.Wx_is_rad = None # Set to None the properties inherited from Slot super(Slot19, self)._set_None() 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 # Slot top width # Type : float, min = 0 W0 = property(fget=_get_W0, fset=_set_W0, doc=u"""Slot top width""") 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 # Slot height # Type : float, min = 0 H0 = property(fget=_get_H0, fset=_set_H0, doc=u"""Slot height""") 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 # Slot bottom width. # Type : float, min = 0 W1 = property(fget=_get_W1, fset=_set_W1, doc=u"""Slot bottom width.""") def _get_Wx_is_rad(self): """getter of Wx_is_rad""" return self._Wx_is_rad def _set_Wx_is_rad(self, value): """setter of Wx_is_rad""" check_var("Wx_is_rad", value, "bool") self._Wx_is_rad = value # Wx unit, 0 for m, 1 for rad # Type : bool Wx_is_rad = property( fget=_get_Wx_is_rad, fset=_set_Wx_is_rad, doc=u"""Wx unit, 0 for m, 1 for rad""" )
class MatLamination(MatMagnetics): """lamination properties""" VERSION = 1 # cf Methods.Material.MatLamination.get_BH if isinstance(get_BH, ImportError): get_BH = property( fget=lambda x: raise_( ImportError("Can't use MatLamination method get_BH: " + str(get_BH)) ) ) else: get_BH = get_BH # save method is available in all object save = save def __init__(self, Wlam=0.0005, BH_curve=-1, mur_lin=1, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if BH_curve == -1: BH_curve = ImportMatrix() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["Wlam", "BH_curve", "mur_lin"]) # Overwrite default value with init_dict content if "Wlam" in list(init_dict.keys()): Wlam = init_dict["Wlam"] if "BH_curve" in list(init_dict.keys()): BH_curve = init_dict["BH_curve"] if "mur_lin" in list(init_dict.keys()): mur_lin = init_dict["mur_lin"] # Initialisation by argument self.Wlam = Wlam # BH_curve can be None, a ImportMatrix object or a dict if isinstance(BH_curve, dict): # Check that the type is correct (including daughter) class_name = BH_curve.get("__class__") if class_name not in [ "ImportMatrix", "ImportGenMatrixSin", "ImportGenVectLin", "ImportGenVectSin", "ImportMatrixVal", "ImportMatrixXls", ]: raise InitUnKnowClassError( "Unknow class name " + class_name + " in init_dict for BH_curve" ) # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.BH_curve = class_obj(init_dict=BH_curve) else: self.BH_curve = BH_curve # Call MatMagnetics init super(MatLamination, self).__init__(mur_lin=mur_lin) # The class is frozen (in MatMagnetics init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" MatLamination_str = "" # Get the properties inherited from MatMagnetics MatLamination_str += super(MatLamination, self).__str__() + linesep MatLamination_str += "Wlam = " + str(self.Wlam) + linesep if self.BH_curve is not None: MatLamination_str += ( "BH_curve = " + str(self.BH_curve.as_dict()) + linesep + linesep ) else: MatLamination_str += "BH_curve = None" return MatLamination_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from MatMagnetics if not super(MatLamination, self).__eq__(other): return False if other.Wlam != self.Wlam: return False if other.BH_curve != self.BH_curve: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from MatMagnetics MatLamination_dict = super(MatLamination, self).as_dict() MatLamination_dict["Wlam"] = self.Wlam if self.BH_curve is None: MatLamination_dict["BH_curve"] = None else: MatLamination_dict["BH_curve"] = self.BH_curve.as_dict() # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name MatLamination_dict["__class__"] = "MatLamination" return MatLamination_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.Wlam = None if self.BH_curve is not None: self.BH_curve._set_None() # Set to None the properties inherited from MatMagnetics super(MatLamination, self)._set_None() def _get_Wlam(self): """getter of Wlam""" return self._Wlam def _set_Wlam(self, value): """setter of Wlam""" check_var("Wlam", value, "float", Vmin=0) self._Wlam = value # lamination sheet width without insulation [m] (for magnetic loss model) # Type : float, min = 0 Wlam = property( fget=_get_Wlam, fset=_set_Wlam, doc=u"""lamination sheet width without insulation [m] (for magnetic loss model)""", ) def _get_BH_curve(self): """getter of BH_curve""" return self._BH_curve def _set_BH_curve(self, value): """setter of BH_curve""" check_var("BH_curve", value, "ImportMatrix") self._BH_curve = value if self._BH_curve is not None: self._BH_curve.parent = self # B(H) curve (two columns matrix, H and B(H)) # Type : ImportMatrix BH_curve = property( fget=_get_BH_curve, fset=_set_BH_curve, doc=u"""B(H) curve (two columns matrix, H and B(H))""", )
class CondType21(Conductor): """single rectangular conductor \nhas to be used for LamSquirrelCages's conductor""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Machine.CondType21.comp_surface_active if isinstance(comp_surface_active, ImportError): comp_surface_active = property( fget=lambda x: raise_( ImportError( "Can't use CondType21 method comp_surface_active: " + str(comp_surface_active) ) ) ) else: comp_surface_active = comp_surface_active # cf Methods.Machine.CondType21.comp_height if isinstance(comp_height, ImportError): comp_height = property( fget=lambda x: raise_( ImportError( "Can't use CondType21 method comp_height: " + str(comp_height) ) ) ) else: comp_height = comp_height # cf Methods.Machine.CondType21.comp_surface if isinstance(comp_surface, ImportError): comp_surface = property( fget=lambda x: raise_( ImportError( "Can't use CondType21 method comp_surface: " + str(comp_surface) ) ) ) else: comp_surface = comp_surface # cf Methods.Machine.CondType21.comp_width if isinstance(comp_width, ImportError): comp_width = property( fget=lambda x: raise_( ImportError( "Can't use CondType21 method comp_width: " + str(comp_width) ) ) ) else: comp_width = comp_width # cf Methods.Machine.CondType21.plot if isinstance(plot, ImportError): plot = property( fget=lambda x: raise_( ImportError("Can't use CondType21 method plot: " + str(plot)) ) ) else: plot = plot # save method is available in all object save = save def __init__( self, Hbar=0.01, Wbar=0.01, Wins=0, cond_mat=-1, ins_mat=-1, init_dict=None ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if cond_mat == -1: cond_mat = Material() if ins_mat == -1: ins_mat = Material() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["Hbar", "Wbar", "Wins", "cond_mat", "ins_mat"]) # Overwrite default value with init_dict content if "Hbar" in list(init_dict.keys()): Hbar = init_dict["Hbar"] if "Wbar" in list(init_dict.keys()): Wbar = init_dict["Wbar"] if "Wins" in list(init_dict.keys()): Wins = init_dict["Wins"] if "cond_mat" in list(init_dict.keys()): cond_mat = init_dict["cond_mat"] if "ins_mat" in list(init_dict.keys()): ins_mat = init_dict["ins_mat"] # Initialisation by argument self.Hbar = Hbar self.Wbar = Wbar self.Wins = Wins # Call Conductor init super(CondType21, self).__init__(cond_mat=cond_mat, ins_mat=ins_mat) # The class is frozen (in Conductor init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" CondType21_str = "" # Get the properties inherited from Conductor CondType21_str += super(CondType21, self).__str__() + linesep CondType21_str += "Hbar = " + str(self.Hbar) + linesep CondType21_str += "Wbar = " + str(self.Wbar) + linesep CondType21_str += "Wins = " + str(self.Wins) return CondType21_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from Conductor if not super(CondType21, self).__eq__(other): return False if other.Hbar != self.Hbar: return False if other.Wbar != self.Wbar: return False if other.Wins != self.Wins: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from Conductor CondType21_dict = super(CondType21, self).as_dict() CondType21_dict["Hbar"] = self.Hbar CondType21_dict["Wbar"] = self.Wbar CondType21_dict["Wins"] = self.Wins # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name CondType21_dict["__class__"] = "CondType21" return CondType21_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.Hbar = None self.Wbar = None self.Wins = None # Set to None the properties inherited from Conductor super(CondType21, self)._set_None() def _get_Hbar(self): """getter of Hbar""" return self._Hbar def _set_Hbar(self, value): """setter of Hbar""" check_var("Hbar", value, "float", Vmin=0) self._Hbar = value # Bar height # Type : float, min = 0 Hbar = property(fget=_get_Hbar, fset=_set_Hbar, doc=u"""Bar height""") def _get_Wbar(self): """getter of Wbar""" return self._Wbar def _set_Wbar(self, value): """setter of Wbar""" check_var("Wbar", value, "float", Vmin=0) self._Wbar = value # Bar width # Type : float, min = 0 Wbar = property(fget=_get_Wbar, fset=_set_Wbar, doc=u"""Bar width""") def _get_Wins(self): """getter of Wins""" return self._Wins def _set_Wins(self, value): """setter of Wins""" check_var("Wins", value, "float", Vmin=0) self._Wins = value # Width of insulation # Type : float, min = 0 Wins = property(fget=_get_Wins, fset=_set_Wins, doc=u"""Width of insulation""")
class ElementMat(Element): """Define the connectivity under matricial format containing one type of element (example: only triangles with 3 nodes). """ VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Mesh.ElementMat.get_group if isinstance(get_group, ImportError): get_group = property(fget=lambda x: raise_( ImportError("Can't use ElementMat method get_group: " + str( get_group)))) else: get_group = get_group # cf Methods.Mesh.ElementMat.get_node_tags if isinstance(get_node_tags, ImportError): get_node_tags = property(fget=lambda x: raise_( ImportError("Can't use ElementMat method get_node_tags: " + str( get_node_tags)))) else: get_node_tags = get_node_tags # cf Methods.Mesh.ElementMat.get_node2element if isinstance(get_node2element, ImportError): get_node2element = property(fget=lambda x: raise_( ImportError("Can't use ElementMat method get_node2element: " + str( get_node2element)))) else: get_node2element = get_node2element # cf Methods.Mesh.ElementMat.convert_element if isinstance(convert_element, ImportError): convert_element = property(fget=lambda x: raise_( ImportError("Can't use ElementMat method convert_element: " + str( convert_element)))) else: convert_element = convert_element # cf Methods.Mesh.ElementMat.add_element if isinstance(add_element, ImportError): add_element = property(fget=lambda x: raise_( ImportError("Can't use ElementMat method add_element: " + str( add_element)))) else: add_element = add_element # cf Methods.Mesh.ElementMat.get_connectivity if isinstance(get_connectivity, ImportError): get_connectivity = property(fget=lambda x: raise_( ImportError("Can't use ElementMat method get_connectivity: " + str( get_connectivity)))) else: get_connectivity = get_connectivity # save method is available in all object save = save def __init__( self, connectivity=None, nb_elem=None, nb_node_per_element=None, group=None, init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, ["connectivity", "nb_elem", "nb_node_per_element", "group"]) # Overwrite default value with init_dict content if "connectivity" in list(init_dict.keys()): connectivity = init_dict["connectivity"] if "nb_elem" in list(init_dict.keys()): nb_elem = init_dict["nb_elem"] if "nb_node_per_element" in list(init_dict.keys()): nb_node_per_element = init_dict["nb_node_per_element"] if "group" in list(init_dict.keys()): group = init_dict["group"] # Initialisation by argument # connectivity can be None, a ndarray or a list set_array(self, "connectivity", connectivity) self.nb_elem = nb_elem self.nb_node_per_element = nb_node_per_element # group can be None, a ndarray or a list set_array(self, "group", group) # Call Element init super(ElementMat, self).__init__() # The class is frozen (in Element init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" ElementMat_str = "" # Get the properties inherited from Element ElementMat_str += super(ElementMat, self).__str__() + linesep ElementMat_str += ("connectivity = " + linesep + str(self.connectivity) + linesep + linesep) ElementMat_str += "nb_elem = " + str(self.nb_elem) + linesep ElementMat_str += ("nb_node_per_element = " + str(self.nb_node_per_element) + linesep) ElementMat_str += "group = " + linesep + str(self.group) return ElementMat_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from Element if not super(ElementMat, self).__eq__(other): return False if not array_equal(other.connectivity, self.connectivity): return False if other.nb_elem != self.nb_elem: return False if other.nb_node_per_element != self.nb_node_per_element: return False if not array_equal(other.group, self.group): return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from Element ElementMat_dict = super(ElementMat, self).as_dict() if self.connectivity is None: ElementMat_dict["connectivity"] = None else: ElementMat_dict["connectivity"] = self.connectivity.tolist() ElementMat_dict["nb_elem"] = self.nb_elem ElementMat_dict["nb_node_per_element"] = self.nb_node_per_element if self.group is None: ElementMat_dict["group"] = None else: ElementMat_dict["group"] = self.group.tolist() # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name ElementMat_dict["__class__"] = "ElementMat" return ElementMat_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.connectivity = None self.nb_elem = None self.nb_node_per_element = None self.group = None # Set to None the properties inherited from Element super(ElementMat, self)._set_None() def _get_connectivity(self): """getter of connectivity""" return self._connectivity def _set_connectivity(self, value): """setter of connectivity""" if type(value) is list: try: value = array(value) except: pass check_var("connectivity", value, "ndarray") self._connectivity = value # Matrix of connectivity for one element type # Type : ndarray connectivity = property( fget=_get_connectivity, fset=_set_connectivity, doc=u"""Matrix of connectivity for one element type""", ) def _get_nb_elem(self): """getter of nb_elem""" return self._nb_elem def _set_nb_elem(self, value): """setter of nb_elem""" check_var("nb_elem", value, "int") self._nb_elem = value # Total number of elements # Type : int nb_elem = property(fget=_get_nb_elem, fset=_set_nb_elem, doc=u"""Total number of elements""") def _get_nb_node_per_element(self): """getter of nb_node_per_element""" return self._nb_node_per_element def _set_nb_node_per_element(self, value): """setter of nb_node_per_element""" check_var("nb_node_per_element", value, "int") self._nb_node_per_element = value # Define the number of node per element # Type : int nb_node_per_element = property( fget=_get_nb_node_per_element, fset=_set_nb_node_per_element, doc=u"""Define the number of node per element""", ) def _get_group(self): """getter of group""" return self._group def _set_group(self, value): """setter of group""" if type(value) is list: try: value = array(value) except: pass check_var("group", value, "ndarray") self._group = value # Attribute a group number (int) to each element . This group number should correspond to a subpart of the machine. # Type : ndarray group = property( fget=_get_group, fset=_set_group, doc= u"""Attribute a group number (int) to each element . This group number should correspond to a subpart of the machine.""", )
class CondType12(Conductor): """parallel stranded conductor consisting of at least a single round wire""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Machine.CondType12.check if isinstance(check, ImportError): check = property( fget=lambda x: raise_( ImportError("Can't use CondType12 method check: " + str(check)) ) ) else: check = check # cf Methods.Machine.CondType12.comp_surface_active if isinstance(comp_surface_active, ImportError): comp_surface_active = property( fget=lambda x: raise_( ImportError( "Can't use CondType12 method comp_surface_active: " + str(comp_surface_active) ) ) ) else: comp_surface_active = comp_surface_active # cf Methods.Machine.CondType12.comp_height if isinstance(comp_height, ImportError): comp_height = property( fget=lambda x: raise_( ImportError( "Can't use CondType12 method comp_height: " + str(comp_height) ) ) ) else: comp_height = comp_height # cf Methods.Machine.CondType12.comp_surface if isinstance(comp_surface, ImportError): comp_surface = property( fget=lambda x: raise_( ImportError( "Can't use CondType12 method comp_surface: " + str(comp_surface) ) ) ) else: comp_surface = comp_surface # cf Methods.Machine.CondType12.comp_width if isinstance(comp_width, ImportError): comp_width = property( fget=lambda x: raise_( ImportError( "Can't use CondType12 method comp_width: " + str(comp_width) ) ) ) else: comp_width = comp_width # cf Methods.Machine.CondType12.plot if isinstance(plot, ImportError): plot = property( fget=lambda x: raise_( ImportError("Can't use CondType12 method plot: " + str(plot)) ) ) else: plot = plot # save method is available in all object save = save def __init__( self, Wwire=0.015, Wins_cond=0.015, Nwppc=1, Wins_wire=0, Kwoh=0.5, cond_mat=-1, ins_mat=-1, init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if cond_mat == -1: cond_mat = Material() if ins_mat == -1: ins_mat = Material() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "Wwire", "Wins_cond", "Nwppc", "Wins_wire", "Kwoh", "cond_mat", "ins_mat", ], ) # Overwrite default value with init_dict content if "Wwire" in list(init_dict.keys()): Wwire = init_dict["Wwire"] if "Wins_cond" in list(init_dict.keys()): Wins_cond = init_dict["Wins_cond"] if "Nwppc" in list(init_dict.keys()): Nwppc = init_dict["Nwppc"] if "Wins_wire" in list(init_dict.keys()): Wins_wire = init_dict["Wins_wire"] if "Kwoh" in list(init_dict.keys()): Kwoh = init_dict["Kwoh"] if "cond_mat" in list(init_dict.keys()): cond_mat = init_dict["cond_mat"] if "ins_mat" in list(init_dict.keys()): ins_mat = init_dict["ins_mat"] # Initialisation by argument self.Wwire = Wwire self.Wins_cond = Wins_cond self.Nwppc = Nwppc self.Wins_wire = Wins_wire self.Kwoh = Kwoh # Call Conductor init super(CondType12, self).__init__(cond_mat=cond_mat, ins_mat=ins_mat) # The class is frozen (in Conductor init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" CondType12_str = "" # Get the properties inherited from Conductor CondType12_str += super(CondType12, self).__str__() + linesep CondType12_str += "Wwire = " + str(self.Wwire) + linesep CondType12_str += "Wins_cond = " + str(self.Wins_cond) + linesep CondType12_str += "Nwppc = " + str(self.Nwppc) + linesep CondType12_str += "Wins_wire = " + str(self.Wins_wire) + linesep CondType12_str += "Kwoh = " + str(self.Kwoh) return CondType12_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from Conductor if not super(CondType12, self).__eq__(other): return False if other.Wwire != self.Wwire: return False if other.Wins_cond != self.Wins_cond: return False if other.Nwppc != self.Nwppc: return False if other.Wins_wire != self.Wins_wire: return False if other.Kwoh != self.Kwoh: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from Conductor CondType12_dict = super(CondType12, self).as_dict() CondType12_dict["Wwire"] = self.Wwire CondType12_dict["Wins_cond"] = self.Wins_cond CondType12_dict["Nwppc"] = self.Nwppc CondType12_dict["Wins_wire"] = self.Wins_wire CondType12_dict["Kwoh"] = self.Kwoh # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name CondType12_dict["__class__"] = "CondType12" return CondType12_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.Wwire = None self.Wins_cond = None self.Nwppc = None self.Wins_wire = None self.Kwoh = None # Set to None the properties inherited from Conductor super(CondType12, self)._set_None() def _get_Wwire(self): """getter of Wwire""" return self._Wwire def _set_Wwire(self, value): """setter of Wwire""" check_var("Wwire", value, "float", Vmin=0) self._Wwire = value # cf schematics, single wire diameter without insulation [m] # Type : float, min = 0 Wwire = property( fget=_get_Wwire, fset=_set_Wwire, doc=u"""cf schematics, single wire diameter without insulation [m]""", ) def _get_Wins_cond(self): """getter of Wins_cond""" return self._Wins_cond def _set_Wins_cond(self, value): """setter of Wins_cond""" check_var("Wins_cond", value, "float", Vmin=0) self._Wins_cond = value # (advanced) cf schematics, winding coil insulation diameter [m] # Type : float, min = 0 Wins_cond = property( fget=_get_Wins_cond, fset=_set_Wins_cond, doc=u"""(advanced) cf schematics, winding coil insulation diameter [m]""", ) def _get_Nwppc(self): """getter of Nwppc""" return self._Nwppc def _set_Nwppc(self, value): """setter of Nwppc""" check_var("Nwppc", value, "int", Vmin=1) self._Nwppc = value # cf schematics, winding number of random wires (strands) in parallel per coil # Type : int, min = 1 Nwppc = property( fget=_get_Nwppc, fset=_set_Nwppc, doc=u"""cf schematics, winding number of random wires (strands) in parallel per coil""", ) def _get_Wins_wire(self): """getter of Wins_wire""" return self._Wins_wire def _set_Wins_wire(self, value): """setter of Wins_wire""" check_var("Wins_wire", value, "float", Vmin=0) self._Wins_wire = value # (advanced) cf schematics, winding strand insulation thickness [m] # Type : float, min = 0 Wins_wire = property( fget=_get_Wins_wire, fset=_set_Wins_wire, doc=u"""(advanced) cf schematics, winding strand insulation thickness [m]""", ) def _get_Kwoh(self): """getter of Kwoh""" return self._Kwoh def _set_Kwoh(self, value): """setter of Kwoh""" check_var("Kwoh", value, "float", Vmin=0) self._Kwoh = value # winding overhang factor which describes the fact that random round wire end-windings can be more or less compressed (0.5 for small motors, 0.8 for large motors) - can be used to tune the average turn length (relevant if type_cond==1) # Type : float, min = 0 Kwoh = property( fget=_get_Kwoh, fset=_set_Kwoh, doc=u"""winding overhang factor which describes the fact that random round wire end-windings can be more or less compressed (0.5 for small motors, 0.8 for large motors) - can be used to tune the average turn length (relevant if type_cond==1)""", )
class Magnet(FrozenClass): """abstract class of magnets""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Machine.Magnet.comp_angle_opening if isinstance(comp_angle_opening, ImportError): comp_angle_opening = property(fget=lambda x: raise_( ImportError("Can't use Magnet method comp_angle_opening: " + str( comp_angle_opening)))) else: comp_angle_opening = comp_angle_opening # cf Methods.Machine.Magnet.comp_height if isinstance(comp_height, ImportError): comp_height = property(fget=lambda x: raise_( ImportError("Can't use Magnet method comp_height: " + str( comp_height)))) else: comp_height = comp_height # cf Methods.Machine.Magnet.comp_mass if isinstance(comp_mass, ImportError): comp_mass = property(fget=lambda x: raise_( ImportError("Can't use Magnet method comp_mass: " + str(comp_mass)) )) else: comp_mass = comp_mass # cf Methods.Machine.Magnet.comp_ratio_opening if isinstance(comp_ratio_opening, ImportError): comp_ratio_opening = property(fget=lambda x: raise_( ImportError("Can't use Magnet method comp_ratio_opening: " + str( comp_ratio_opening)))) else: comp_ratio_opening = comp_ratio_opening # cf Methods.Machine.Magnet.comp_surface if isinstance(comp_surface, ImportError): comp_surface = property(fget=lambda x: raise_( ImportError("Can't use Magnet method comp_surface: " + str( comp_surface)))) else: comp_surface = comp_surface # cf Methods.Machine.Magnet.comp_volume if isinstance(comp_volume, ImportError): comp_volume = property(fget=lambda x: raise_( ImportError("Can't use Magnet method comp_volume: " + str( comp_volume)))) else: comp_volume = comp_volume # cf Methods.Machine.Magnet.is_outwards if isinstance(is_outwards, ImportError): is_outwards = property(fget=lambda x: raise_( ImportError("Can't use Magnet method is_outwards: " + str( is_outwards)))) else: is_outwards = is_outwards # cf Methods.Machine.Magnet.plot if isinstance(plot, ImportError): plot = property(fget=lambda x: raise_( ImportError("Can't use Magnet method plot: " + str(plot)))) else: plot = plot # save method is available in all object save = save def __init__(self, mat_type=-1, type_magnetization=0, Lmag=0.95, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if mat_type == -1: mat_type = Material() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["mat_type", "type_magnetization", "Lmag"]) # Overwrite default value with init_dict content if "mat_type" in list(init_dict.keys()): mat_type = init_dict["mat_type"] if "type_magnetization" in list(init_dict.keys()): type_magnetization = init_dict["type_magnetization"] if "Lmag" in list(init_dict.keys()): Lmag = init_dict["Lmag"] # Initialisation by argument self.parent = None # mat_type can be None, a Material object or a dict if isinstance(mat_type, dict): self.mat_type = Material(init_dict=mat_type) else: self.mat_type = mat_type self.type_magnetization = type_magnetization self.Lmag = Lmag # The class is frozen, for now it's impossible to add new properties self._freeze() def __str__(self): """Convert this objet in a readeable string (for print)""" Magnet_str = "" if self.parent is None: Magnet_str += "parent = None " + linesep else: Magnet_str += "parent = " + str(type( self.parent)) + " object" + linesep if self.mat_type is not None: Magnet_str += ("mat_type = " + str(self.mat_type.as_dict()) + linesep + linesep) else: Magnet_str += "mat_type = None" + linesep + linesep Magnet_str += "type_magnetization = " + str( self.type_magnetization) + linesep Magnet_str += "Lmag = " + str(self.Lmag) return Magnet_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False if other.mat_type != self.mat_type: return False if other.type_magnetization != self.type_magnetization: return False if other.Lmag != self.Lmag: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ Magnet_dict = dict() if self.mat_type is None: Magnet_dict["mat_type"] = None else: Magnet_dict["mat_type"] = self.mat_type.as_dict() Magnet_dict["type_magnetization"] = self.type_magnetization Magnet_dict["Lmag"] = self.Lmag # The class name is added to the dict fordeserialisation purpose Magnet_dict["__class__"] = "Magnet" return Magnet_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" if self.mat_type is not None: self.mat_type._set_None() self.type_magnetization = None self.Lmag = None def _get_mat_type(self): """getter of mat_type""" return self._mat_type def _set_mat_type(self, value): """setter of mat_type""" check_var("mat_type", value, "Material") self._mat_type = value if self._mat_type is not None: self._mat_type.parent = self # The Magnet material # Type : Material mat_type = property(fget=_get_mat_type, fset=_set_mat_type, doc=u"""The Magnet material""") def _get_type_magnetization(self): """getter of type_magnetization""" return self._type_magnetization def _set_type_magnetization(self, value): """setter of type_magnetization""" check_var("type_magnetization", value, "int", Vmin=0, Vmax=5) self._type_magnetization = value # Permanent magnet magnetization type: 0 for radial, 1 for parallel, 2 for HallBach [] # Type : int, min = 0, max = 5 type_magnetization = property( fget=_get_type_magnetization, fset=_set_type_magnetization, doc= u"""Permanent magnet magnetization type: 0 for radial, 1 for parallel, 2 for HallBach []""", ) def _get_Lmag(self): """getter of Lmag""" return self._Lmag def _set_Lmag(self, value): """setter of Lmag""" check_var("Lmag", value, "float", Vmin=0) self._Lmag = value # Magnet axial length # Type : float, min = 0 Lmag = property(fget=_get_Lmag, fset=_set_Lmag, doc=u"""Magnet axial length""")
class Machine(FrozenClass): """Abstract class for machines""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Machine.Machine.build_geometry if isinstance(build_geometry, ImportError): build_geometry = property(fget=lambda x: raise_( ImportError("Can't use Machine method build_geometry: " + str( build_geometry)))) else: build_geometry = build_geometry # cf Methods.Machine.Machine.check if isinstance(check, ImportError): check = property(fget=lambda x: raise_( ImportError("Can't use Machine method check: " + str(check)))) else: check = check # cf Methods.Machine.Machine.comp_masses if isinstance(comp_masses, ImportError): comp_masses = property(fget=lambda x: raise_( ImportError("Can't use Machine method comp_masses: " + str( comp_masses)))) else: comp_masses = comp_masses # cf Methods.Machine.Machine.comp_width_airgap_mag if isinstance(comp_width_airgap_mag, ImportError): comp_width_airgap_mag = property(fget=lambda x: raise_( ImportError("Can't use Machine method comp_width_airgap_mag: " + str(comp_width_airgap_mag)))) else: comp_width_airgap_mag = comp_width_airgap_mag # cf Methods.Machine.Machine.comp_width_airgap_mec if isinstance(comp_width_airgap_mec, ImportError): comp_width_airgap_mec = property(fget=lambda x: raise_( ImportError("Can't use Machine method comp_width_airgap_mec: " + str(comp_width_airgap_mec)))) else: comp_width_airgap_mec = comp_width_airgap_mec # cf Methods.Machine.Machine.get_lamination if isinstance(get_lamination, ImportError): get_lamination = property(fget=lambda x: raise_( ImportError("Can't use Machine method get_lamination: " + str( get_lamination)))) else: get_lamination = get_lamination # cf Methods.Machine.Machine.comp_Rgap_mec if isinstance(comp_Rgap_mec, ImportError): comp_Rgap_mec = property(fget=lambda x: raise_( ImportError("Can't use Machine method comp_Rgap_mec: " + str( comp_Rgap_mec)))) else: comp_Rgap_mec = comp_Rgap_mec # cf Methods.Machine.Machine.plot if isinstance(plot, ImportError): plot = property(fget=lambda x: raise_( ImportError("Can't use Machine method plot: " + str(plot)))) else: plot = plot # cf Methods.Machine.Machine.comp_output_geo if isinstance(comp_output_geo, ImportError): comp_output_geo = property(fget=lambda x: raise_( ImportError("Can't use Machine method comp_output_geo: " + str( comp_output_geo)))) else: comp_output_geo = comp_output_geo # cf Methods.Machine.Machine.comp_length_airgap_active if isinstance(comp_length_airgap_active, ImportError): comp_length_airgap_active = property(fget=lambda x: raise_( ImportError("Can't use Machine method comp_length_airgap_active: " + str(comp_length_airgap_active)))) else: comp_length_airgap_active = comp_length_airgap_active # cf Methods.Machine.Machine.get_polar_eq if isinstance(get_polar_eq, ImportError): get_polar_eq = property(fget=lambda x: raise_( ImportError("Can't use Machine method get_polar_eq: " + str( get_polar_eq)))) else: get_polar_eq = get_polar_eq # save method is available in all object save = save def __init__( self, rotor=-1, stator=-1, frame=-1, shaft=-1, name="default_machine", desc="", init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if rotor == -1: rotor = Lamination() if stator == -1: stator = Lamination() if frame == -1: frame = Frame() if shaft == -1: shaft = Shaft() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, ["rotor", "stator", "frame", "shaft", "name", "desc"]) # Overwrite default value with init_dict content if "rotor" in list(init_dict.keys()): rotor = init_dict["rotor"] if "stator" in list(init_dict.keys()): stator = init_dict["stator"] if "frame" in list(init_dict.keys()): frame = init_dict["frame"] if "shaft" in list(init_dict.keys()): shaft = init_dict["shaft"] if "name" in list(init_dict.keys()): name = init_dict["name"] if "desc" in list(init_dict.keys()): desc = init_dict["desc"] # Initialisation by argument self.parent = None # rotor can be None, a Lamination object or a dict if isinstance(rotor, dict): # Check that the type is correct (including daughter) class_name = rotor.get("__class__") if class_name not in [ "Lamination", "LamHole", "LamSlot", "LamSlotWind", "LamSlotMag", "LamSquirrelCage", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for rotor") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.rotor = class_obj(init_dict=rotor) else: self.rotor = rotor # stator can be None, a Lamination object or a dict if isinstance(stator, dict): # Check that the type is correct (including daughter) class_name = stator.get("__class__") if class_name not in [ "Lamination", "LamHole", "LamSlot", "LamSlotWind", "LamSlotMag", "LamSquirrelCage", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for stator") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.stator = class_obj(init_dict=stator) else: self.stator = stator # frame can be None, a Frame object or a dict if isinstance(frame, dict): self.frame = Frame(init_dict=frame) else: self.frame = frame # shaft can be None, a Shaft object or a dict if isinstance(shaft, dict): self.shaft = Shaft(init_dict=shaft) else: self.shaft = shaft self.name = name self.desc = desc # The class is frozen, for now it's impossible to add new properties self._freeze() def __str__(self): """Convert this objet in a readeable string (for print)""" Machine_str = "" if self.parent is None: Machine_str += "parent = None " + linesep else: Machine_str += "parent = " + str(type( self.parent)) + " object" + linesep Machine_str += "rotor = " + str( self.rotor.as_dict()) + linesep + linesep Machine_str += "stator = " + str( self.stator.as_dict()) + linesep + linesep Machine_str += "frame = " + str( self.frame.as_dict()) + linesep + linesep Machine_str += "shaft = " + str( self.shaft.as_dict()) + linesep + linesep Machine_str += 'name = "' + str(self.name) + '"' + linesep Machine_str += 'desc = "' + str(self.desc) + '"' return Machine_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False if other.rotor != self.rotor: return False if other.stator != self.stator: return False if other.frame != self.frame: return False if other.shaft != self.shaft: return False if other.name != self.name: return False if other.desc != self.desc: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ Machine_dict = dict() if self.rotor is None: Machine_dict["rotor"] = None else: Machine_dict["rotor"] = self.rotor.as_dict() if self.stator is None: Machine_dict["stator"] = None else: Machine_dict["stator"] = self.stator.as_dict() if self.frame is None: Machine_dict["frame"] = None else: Machine_dict["frame"] = self.frame.as_dict() if self.shaft is None: Machine_dict["shaft"] = None else: Machine_dict["shaft"] = self.shaft.as_dict() Machine_dict["name"] = self.name Machine_dict["desc"] = self.desc # The class name is added to the dict fordeserialisation purpose Machine_dict["__class__"] = "Machine" return Machine_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" if self.rotor is not None: self.rotor._set_None() if self.stator is not None: self.stator._set_None() if self.frame is not None: self.frame._set_None() if self.shaft is not None: self.shaft._set_None() self.name = None self.desc = None def _get_rotor(self): """getter of rotor""" return self._rotor def _set_rotor(self, value): """setter of rotor""" check_var("rotor", value, "Lamination") self._rotor = value if self._rotor is not None: self._rotor.parent = self # Machine's Rotor # Type : Lamination rotor = property(fget=_get_rotor, fset=_set_rotor, doc=u"""Machine's Rotor""") def _get_stator(self): """getter of stator""" return self._stator def _set_stator(self, value): """setter of stator""" check_var("stator", value, "Lamination") self._stator = value if self._stator is not None: self._stator.parent = self # Machine's Stator # Type : Lamination stator = property(fget=_get_stator, fset=_set_stator, doc=u"""Machine's Stator""") def _get_frame(self): """getter of frame""" return self._frame def _set_frame(self, value): """setter of frame""" check_var("frame", value, "Frame") self._frame = value if self._frame is not None: self._frame.parent = self # Machine's Frame # Type : Frame frame = property(fget=_get_frame, fset=_set_frame, doc=u"""Machine's Frame""") def _get_shaft(self): """getter of shaft""" return self._shaft def _set_shaft(self, value): """setter of shaft""" check_var("shaft", value, "Shaft") self._shaft = value if self._shaft is not None: self._shaft.parent = self # Machine's Shaft # Type : Shaft shaft = property(fget=_get_shaft, fset=_set_shaft, doc=u"""Machine's Shaft""") def _get_name(self): """getter of name""" return self._name def _set_name(self, value): """setter of name""" check_var("name", value, "str") self._name = value # Name of the machine # Type : str name = property(fget=_get_name, fset=_set_name, doc=u"""Name of the machine""") def _get_desc(self): """getter of desc""" return self._desc def _set_desc(self, value): """setter of desc""" check_var("desc", value, "str") self._desc = value # Machine description # Type : str desc = property(fget=_get_desc, fset=_set_desc, doc=u"""Machine description""")
class NotchEvenDist(Notch): """Class for evenly distributed notches""" VERSION = 1 # cf Methods.Machine.NotchEvenDist.build_geometry if isinstance(build_geometry, ImportError): build_geometry = property(fget=lambda x: raise_( ImportError("Can't use NotchEvenDist method build_geometry: " + str(build_geometry)))) else: build_geometry = build_geometry # save method is available in all object save = save def __init__(self, alpha=None, notch_shape=list(), init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["alpha", "notch_shape"]) # Overwrite default value with init_dict content if "alpha" in list(init_dict.keys()): alpha = init_dict["alpha"] if "notch_shape" in list(init_dict.keys()): notch_shape = init_dict["notch_shape"] # Initialisation by argument # alpha can be None, a ndarray or a list set_array(self, "alpha", alpha) # Call Notch init super(NotchEvenDist, self).__init__(notch_shape=notch_shape) # The class is frozen (in Notch init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" NotchEvenDist_str = "" # Get the properties inherited from Notch NotchEvenDist_str += super(NotchEvenDist, self).__str__() + linesep NotchEvenDist_str += "alpha = " + linesep + str(self.alpha) return NotchEvenDist_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from Notch if not super(NotchEvenDist, self).__eq__(other): return False if not array_equal(other.alpha, self.alpha): return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from Notch NotchEvenDist_dict = super(NotchEvenDist, self).as_dict() if self.alpha is None: NotchEvenDist_dict["alpha"] = None else: NotchEvenDist_dict["alpha"] = self.alpha.tolist() # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name NotchEvenDist_dict["__class__"] = "NotchEvenDist" return NotchEvenDist_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.alpha = None # Set to None the properties inherited from Notch super(NotchEvenDist, self)._set_None() def _get_alpha(self): """getter of alpha""" return self._alpha def _set_alpha(self, value): """setter of alpha""" if type(value) is list: try: value = array(value) except: pass check_var("alpha", value, "ndarray") self._alpha = value # angular positon of the first notch # Type : ndarray alpha = property(fget=_get_alpha, fset=_set_alpha, doc=u"""angular positon of the first notch""")
class Arc1(Arc): """An arc between two points (defined by a radius)""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Geometry.Arc1.check if isinstance(check, ImportError): check = property(fget=lambda x: raise_( ImportError("Can't use Arc1 method check: " + str(check)))) else: check = check # cf Methods.Geometry.Arc1.comp_length if isinstance(comp_length, ImportError): comp_length = property(fget=lambda x: raise_( ImportError("Can't use Arc1 method comp_length: " + str(comp_length )))) else: comp_length = comp_length # cf Methods.Geometry.Arc1.comp_radius if isinstance(comp_radius, ImportError): comp_radius = property(fget=lambda x: raise_( ImportError("Can't use Arc1 method comp_radius: " + str(comp_radius )))) else: comp_radius = comp_radius # cf Methods.Geometry.Arc1.discretize if isinstance(discretize, ImportError): discretize = property(fget=lambda x: raise_( ImportError("Can't use Arc1 method discretize: " + str(discretize)) )) else: discretize = discretize # cf Methods.Geometry.Arc1.get_angle if isinstance(get_angle, ImportError): get_angle = property(fget=lambda x: raise_( ImportError("Can't use Arc1 method get_angle: " + str(get_angle)))) else: get_angle = get_angle # cf Methods.Geometry.Arc1.get_begin if isinstance(get_begin, ImportError): get_begin = property(fget=lambda x: raise_( ImportError("Can't use Arc1 method get_begin: " + str(get_begin)))) else: get_begin = get_begin # cf Methods.Geometry.Arc1.get_center if isinstance(get_center, ImportError): get_center = property(fget=lambda x: raise_( ImportError("Can't use Arc1 method get_center: " + str(get_center)) )) else: get_center = get_center # cf Methods.Geometry.Arc1.get_end if isinstance(get_end, ImportError): get_end = property(fget=lambda x: raise_( ImportError("Can't use Arc1 method get_end: " + str(get_end)))) else: get_end = get_end # cf Methods.Geometry.Arc1.get_middle if isinstance(get_middle, ImportError): get_middle = property(fget=lambda x: raise_( ImportError("Can't use Arc1 method get_middle: " + str(get_middle)) )) else: get_middle = get_middle # cf Methods.Geometry.Arc1.reverse if isinstance(reverse, ImportError): reverse = property(fget=lambda x: raise_( ImportError("Can't use Arc1 method reverse: " + str(reverse)))) else: reverse = reverse # cf Methods.Geometry.Arc1.rotate if isinstance(rotate, ImportError): rotate = property(fget=lambda x: raise_( ImportError("Can't use Arc1 method rotate: " + str(rotate)))) else: rotate = rotate # cf Methods.Geometry.Arc1.split_half if isinstance(split_half, ImportError): split_half = property(fget=lambda x: raise_( ImportError("Can't use Arc1 method split_half: " + str(split_half)) )) else: split_half = split_half # cf Methods.Geometry.Arc1.translate if isinstance(translate, ImportError): translate = property(fget=lambda x: raise_( ImportError("Can't use Arc1 method translate: " + str(translate)))) else: translate = translate # save method is available in all object save = save def __init__( self, begin=0, end=0, radius=0, is_trigo_direction=True, label="", init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, ["begin", "end", "radius", "is_trigo_direction", "label"]) # Overwrite default value with init_dict content if "begin" in list(init_dict.keys()): begin = init_dict["begin"] if "end" in list(init_dict.keys()): end = init_dict["end"] if "radius" in list(init_dict.keys()): radius = init_dict["radius"] if "is_trigo_direction" in list(init_dict.keys()): is_trigo_direction = init_dict["is_trigo_direction"] if "label" in list(init_dict.keys()): label = init_dict["label"] # Initialisation by argument self.begin = begin self.end = end self.radius = radius self.is_trigo_direction = is_trigo_direction # Call Arc init super(Arc1, self).__init__(label=label) # The class is frozen (in Arc init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" Arc1_str = "" # Get the properties inherited from Arc Arc1_str += super(Arc1, self).__str__() + linesep Arc1_str += "begin = " + str(self.begin) + linesep Arc1_str += "end = " + str(self.end) + linesep Arc1_str += "radius = " + str(self.radius) + linesep Arc1_str += "is_trigo_direction = " + str(self.is_trigo_direction) return Arc1_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from Arc if not super(Arc1, self).__eq__(other): return False if other.begin != self.begin: return False if other.end != self.end: return False if other.radius != self.radius: return False if other.is_trigo_direction != self.is_trigo_direction: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from Arc Arc1_dict = super(Arc1, self).as_dict() Arc1_dict["begin"] = self.begin Arc1_dict["end"] = self.end Arc1_dict["radius"] = self.radius Arc1_dict["is_trigo_direction"] = self.is_trigo_direction # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name Arc1_dict["__class__"] = "Arc1" return Arc1_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.begin = None self.end = None self.radius = None self.is_trigo_direction = None # Set to None the properties inherited from Arc super(Arc1, self)._set_None() def _get_begin(self): """getter of begin""" return self._begin def _set_begin(self, value): """setter of begin""" check_var("begin", value, "complex") self._begin = value # begin point of the arc # Type : complex begin = property(fget=_get_begin, fset=_set_begin, doc=u"""begin point of the arc""") def _get_end(self): """getter of end""" return self._end def _set_end(self, value): """setter of end""" check_var("end", value, "complex") self._end = value # end point of the arc # Type : complex end = property(fget=_get_end, fset=_set_end, doc=u"""end point of the arc""") def _get_radius(self): """getter of radius""" return self._radius def _set_radius(self, value): """setter of radius""" check_var("radius", value, "float") self._radius = value # Radius of the arc (can be + or -) # Type : float radius = property(fget=_get_radius, fset=_set_radius, doc=u"""Radius of the arc (can be + or -)""") def _get_is_trigo_direction(self): """getter of is_trigo_direction""" return self._is_trigo_direction def _set_is_trigo_direction(self, value): """setter of is_trigo_direction""" check_var("is_trigo_direction", value, "bool") self._is_trigo_direction = value # Rotation direction of the arc # Type : bool is_trigo_direction = property( fget=_get_is_trigo_direction, fset=_set_is_trigo_direction, doc=u"""Rotation direction of the arc""", )
class MachineSRM(MachineSync): """Switched Reluctance Machine""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Machine.MachineSRM.check if isinstance(check, ImportError): check = property(fget=lambda x: raise_( ImportError("Can't use MachineSRM method check: " + str(check)))) else: check = check # cf Methods.Machine.MachineSRM.get_machine_type if isinstance(get_machine_type, ImportError): get_machine_type = property(fget=lambda x: raise_( ImportError("Can't use MachineSRM method get_machine_type: " + str( get_machine_type)))) else: get_machine_type = get_machine_type # save method is available in all object save = save def __init__( self, rotor=-1, stator=-1, frame=-1, shaft=-1, name="default_machine", desc="", type_machine=1, init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if rotor == -1: rotor = Lamination() if stator == -1: stator = Lamination() if frame == -1: frame = Frame() if shaft == -1: shaft = Shaft() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "rotor", "stator", "frame", "shaft", "name", "desc", "type_machine" ], ) # Overwrite default value with init_dict content if "rotor" in list(init_dict.keys()): rotor = init_dict["rotor"] if "stator" in list(init_dict.keys()): stator = init_dict["stator"] if "frame" in list(init_dict.keys()): frame = init_dict["frame"] if "shaft" in list(init_dict.keys()): shaft = init_dict["shaft"] if "name" in list(init_dict.keys()): name = init_dict["name"] if "desc" in list(init_dict.keys()): desc = init_dict["desc"] if "type_machine" in list(init_dict.keys()): type_machine = init_dict["type_machine"] # Initialisation by argument # Call MachineSync init super(MachineSRM, self).__init__( rotor=rotor, stator=stator, frame=frame, shaft=shaft, name=name, desc=desc, type_machine=type_machine, ) # The class is frozen (in MachineSync init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" MachineSRM_str = "" # Get the properties inherited from MachineSync MachineSRM_str += super(MachineSRM, self).__str__() + linesep return MachineSRM_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from MachineSync if not super(MachineSRM, self).__eq__(other): return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from MachineSync MachineSRM_dict = super(MachineSRM, self).as_dict() # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name MachineSRM_dict["__class__"] = "MachineSRM" return MachineSRM_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" # Set to None the properties inherited from MachineSync super(MachineSRM, self)._set_None()
class InCurrent(Input): """Input to skip the electrical module and start with the magnetic one""" VERSION = 1 # cf Methods.Simulation.InCurrent.gen_input if isinstance(gen_input, ImportError): gen_input = property(fget=lambda x: raise_( ImportError("Can't use InCurrent method gen_input: " + str( gen_input)))) else: gen_input = gen_input # save method is available in all object save = save def __init__( self, time=None, angle=None, Is=None, Ir=None, angle_rotor=None, Nr=None, rot_dir=-1, angle_rotor_initial=0, init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if time == -1: time = Import() if angle == -1: angle = Import() if Is == -1: Is = Import() if Ir == -1: Ir = Import() if angle_rotor == -1: angle_rotor = Import() if Nr == -1: Nr = Import() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "time", "angle", "Is", "Ir", "angle_rotor", "Nr", "rot_dir", "angle_rotor_initial", ], ) # Overwrite default value with init_dict content if "time" in list(init_dict.keys()): time = init_dict["time"] if "angle" in list(init_dict.keys()): angle = init_dict["angle"] if "Is" in list(init_dict.keys()): Is = init_dict["Is"] if "Ir" in list(init_dict.keys()): Ir = init_dict["Ir"] if "angle_rotor" in list(init_dict.keys()): angle_rotor = init_dict["angle_rotor"] if "Nr" in list(init_dict.keys()): Nr = init_dict["Nr"] if "rot_dir" in list(init_dict.keys()): rot_dir = init_dict["rot_dir"] if "angle_rotor_initial" in list(init_dict.keys()): angle_rotor_initial = init_dict["angle_rotor_initial"] # Initialisation by argument # time can be None, a Import object or a dict if isinstance(time, dict): # Check that the type is correct (including daughter) class_name = time.get("__class__") if class_name not in [ "Import", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", "ImportGenVectSin", "ImportGenMatrixSin", "ImportGenVectLin", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for time") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.time = class_obj(init_dict=time) else: self.time = time # angle can be None, a Import object or a dict if isinstance(angle, dict): # Check that the type is correct (including daughter) class_name = angle.get("__class__") if class_name not in [ "Import", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", "ImportGenVectSin", "ImportGenMatrixSin", "ImportGenVectLin", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for angle") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.angle = class_obj(init_dict=angle) else: self.angle = angle # Is can be None, a Import object or a dict if isinstance(Is, dict): # Check that the type is correct (including daughter) class_name = Is.get("__class__") if class_name not in [ "Import", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", "ImportGenVectSin", "ImportGenMatrixSin", "ImportGenVectLin", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for Is") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.Is = class_obj(init_dict=Is) else: self.Is = Is # Ir can be None, a Import object or a dict if isinstance(Ir, dict): # Check that the type is correct (including daughter) class_name = Ir.get("__class__") if class_name not in [ "Import", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", "ImportGenVectSin", "ImportGenMatrixSin", "ImportGenVectLin", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for Ir") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.Ir = class_obj(init_dict=Ir) else: self.Ir = Ir # angle_rotor can be None, a Import object or a dict if isinstance(angle_rotor, dict): # Check that the type is correct (including daughter) class_name = angle_rotor.get("__class__") if class_name not in [ "Import", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", "ImportGenVectSin", "ImportGenMatrixSin", "ImportGenVectLin", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for angle_rotor") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.angle_rotor = class_obj(init_dict=angle_rotor) else: self.angle_rotor = angle_rotor # Nr can be None, a Import object or a dict if isinstance(Nr, dict): # Check that the type is correct (including daughter) class_name = Nr.get("__class__") if class_name not in [ "Import", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", "ImportGenVectSin", "ImportGenMatrixSin", "ImportGenVectLin", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for Nr") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.Nr = class_obj(init_dict=Nr) else: self.Nr = Nr self.rot_dir = rot_dir self.angle_rotor_initial = angle_rotor_initial # Call Input init super(InCurrent, self).__init__() # The class is frozen (in Input init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" InCurrent_str = "" # Get the properties inherited from Input InCurrent_str += super(InCurrent, self).__str__() + linesep InCurrent_str += "time = " + str( self.time.as_dict()) + linesep + linesep InCurrent_str += "angle = " + str( self.angle.as_dict()) + linesep + linesep InCurrent_str += "Is = " + str(self.Is.as_dict()) + linesep + linesep InCurrent_str += "Ir = " + str(self.Ir.as_dict()) + linesep + linesep InCurrent_str += ("angle_rotor = " + str(self.angle_rotor.as_dict()) + linesep + linesep) InCurrent_str += "Nr = " + str(self.Nr.as_dict()) + linesep + linesep InCurrent_str += "rot_dir = " + str(self.rot_dir) + linesep InCurrent_str += "angle_rotor_initial = " + str( self.angle_rotor_initial) return InCurrent_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from Input if not super(InCurrent, self).__eq__(other): return False if other.time != self.time: return False if other.angle != self.angle: return False if other.Is != self.Is: return False if other.Ir != self.Ir: return False if other.angle_rotor != self.angle_rotor: return False if other.Nr != self.Nr: return False if other.rot_dir != self.rot_dir: return False if other.angle_rotor_initial != self.angle_rotor_initial: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from Input InCurrent_dict = super(InCurrent, self).as_dict() if self.time is None: InCurrent_dict["time"] = None else: InCurrent_dict["time"] = self.time.as_dict() if self.angle is None: InCurrent_dict["angle"] = None else: InCurrent_dict["angle"] = self.angle.as_dict() if self.Is is None: InCurrent_dict["Is"] = None else: InCurrent_dict["Is"] = self.Is.as_dict() if self.Ir is None: InCurrent_dict["Ir"] = None else: InCurrent_dict["Ir"] = self.Ir.as_dict() if self.angle_rotor is None: InCurrent_dict["angle_rotor"] = None else: InCurrent_dict["angle_rotor"] = self.angle_rotor.as_dict() if self.Nr is None: InCurrent_dict["Nr"] = None else: InCurrent_dict["Nr"] = self.Nr.as_dict() InCurrent_dict["rot_dir"] = self.rot_dir InCurrent_dict["angle_rotor_initial"] = self.angle_rotor_initial # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name InCurrent_dict["__class__"] = "InCurrent" return InCurrent_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" if self.time is not None: self.time._set_None() if self.angle is not None: self.angle._set_None() if self.Is is not None: self.Is._set_None() if self.Ir is not None: self.Ir._set_None() if self.angle_rotor is not None: self.angle_rotor._set_None() if self.Nr is not None: self.Nr._set_None() self.rot_dir = None self.angle_rotor_initial = None # Set to None the properties inherited from Input super(InCurrent, self)._set_None() def _get_time(self): """getter of time""" return self._time def _set_time(self, value): """setter of time""" check_var("time", value, "Import") self._time = value if self._time is not None: self._time.parent = self # Electrical time vector (no symmetry) to import # Type : Import time = property( fget=_get_time, fset=_set_time, doc=u"""Electrical time vector (no symmetry) to import""", ) def _get_angle(self): """getter of angle""" return self._angle def _set_angle(self, value): """setter of angle""" check_var("angle", value, "Import") self._angle = value if self._angle is not None: self._angle.parent = self # Electrical position vector (no symmetry) to import # Type : Import angle = property( fget=_get_angle, fset=_set_angle, doc=u"""Electrical position vector (no symmetry) to import""", ) def _get_Is(self): """getter of Is""" return self._Is def _set_Is(self, value): """setter of Is""" check_var("Is", value, "Import") self._Is = value if self._Is is not None: self._Is.parent = self # Stator currents as a function of time (each column correspond to one phase) to import # Type : Import Is = property( fget=_get_Is, fset=_set_Is, doc= u"""Stator currents as a function of time (each column correspond to one phase) to import""", ) def _get_Ir(self): """getter of Ir""" return self._Ir def _set_Ir(self, value): """setter of Ir""" check_var("Ir", value, "Import") self._Ir = value if self._Ir is not None: self._Ir.parent = self # Rotor currents as a function of time (each column correspond to one phase) to import # Type : Import Ir = property( fget=_get_Ir, fset=_set_Ir, doc= u"""Rotor currents as a function of time (each column correspond to one phase) to import""", ) def _get_angle_rotor(self): """getter of angle_rotor""" return self._angle_rotor def _set_angle_rotor(self, value): """setter of angle_rotor""" check_var("angle_rotor", value, "Import") self._angle_rotor = value if self._angle_rotor is not None: self._angle_rotor.parent = self # Rotor angular position as a function of time (if None computed according to Nr) to import # Type : Import angle_rotor = property( fget=_get_angle_rotor, fset=_set_angle_rotor, doc= u"""Rotor angular position as a function of time (if None computed according to Nr) to import""", ) def _get_Nr(self): """getter of Nr""" return self._Nr def _set_Nr(self, value): """setter of Nr""" check_var("Nr", value, "Import") self._Nr = value if self._Nr is not None: self._Nr.parent = self # Rotor speed as a function of time to import # Type : Import Nr = property( fget=_get_Nr, fset=_set_Nr, doc=u"""Rotor speed as a function of time to import""", ) def _get_rot_dir(self): """getter of rot_dir""" return self._rot_dir def _set_rot_dir(self, value): """setter of rot_dir""" check_var("rot_dir", value, "float", Vmin=-1, Vmax=1) self._rot_dir = value # Rotation direction of the rotor 1 trigo, -1 clockwise # Type : float, min = -1, max = 1 rot_dir = property( fget=_get_rot_dir, fset=_set_rot_dir, doc=u"""Rotation direction of the rotor 1 trigo, -1 clockwise""", ) def _get_angle_rotor_initial(self): """getter of angle_rotor_initial""" return self._angle_rotor_initial def _set_angle_rotor_initial(self, value): """setter of angle_rotor_initial""" check_var("angle_rotor_initial", value, "float") self._angle_rotor_initial = value # Initial angular position of the rotor at t=0 # Type : float angle_rotor_initial = property( fget=_get_angle_rotor_initial, fset=_set_angle_rotor_initial, doc=u"""Initial angular position of the rotor at t=0""", )
class SlotWind(Slot): """Slot for winding (abstract)""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Slot.SlotWind.comp_angle_wind_eq if isinstance(comp_angle_wind_eq, ImportError): comp_angle_wind_eq = property( fget=lambda x: raise_( ImportError( "Can't use SlotWind method comp_angle_wind_eq: " + str(comp_angle_wind_eq) ) ) ) else: comp_angle_wind_eq = comp_angle_wind_eq # cf Methods.Slot.SlotWind.comp_height_wind if isinstance(comp_height_wind, ImportError): comp_height_wind = property( fget=lambda x: raise_( ImportError( "Can't use SlotWind method comp_height_wind: " + str(comp_height_wind) ) ) ) else: comp_height_wind = comp_height_wind # cf Methods.Slot.SlotWind.comp_radius_mid_wind if isinstance(comp_radius_mid_wind, ImportError): comp_radius_mid_wind = property( fget=lambda x: raise_( ImportError( "Can't use SlotWind method comp_radius_mid_wind: " + str(comp_radius_mid_wind) ) ) ) else: comp_radius_mid_wind = comp_radius_mid_wind # cf Methods.Slot.SlotWind.comp_surface_wind if isinstance(comp_surface_wind, ImportError): comp_surface_wind = property( fget=lambda x: raise_( ImportError( "Can't use SlotWind method comp_surface_wind: " + str(comp_surface_wind) ) ) ) else: comp_surface_wind = comp_surface_wind # cf Methods.Slot.SlotWind.plot_wind if isinstance(plot_wind, ImportError): plot_wind = property( fget=lambda x: raise_( ImportError("Can't use SlotWind method plot_wind: " + str(plot_wind)) ) ) else: plot_wind = plot_wind # save method is available in all object save = save def __init__(self, Zs=36, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["Zs"]) # Overwrite default value with init_dict content if "Zs" in list(init_dict.keys()): Zs = init_dict["Zs"] # Initialisation by argument # Call Slot init super(SlotWind, self).__init__(Zs=Zs) # The class is frozen (in Slot init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" SlotWind_str = "" # Get the properties inherited from Slot SlotWind_str += super(SlotWind, self).__str__() + linesep return SlotWind_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from Slot if not super(SlotWind, self).__eq__(other): return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from Slot SlotWind_dict = super(SlotWind, self).as_dict() # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name SlotWind_dict["__class__"] = "SlotWind" return SlotWind_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" # Set to None the properties inherited from Slot super(SlotWind, self)._set_None()
class Trapeze(Surface): """Trapeze defined by the center of symmetry(point_ref), the label, the polar angle, the height and the big and small weight""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Geometry.Trapeze.check if isinstance(check, ImportError): check = property(fget=lambda x: raise_( ImportError("Can't use Trapeze method check: " + str(check)))) else: check = check # cf Methods.Geometry.Trapeze.comp_length if isinstance(comp_length, ImportError): comp_length = property(fget=lambda x: raise_( ImportError("Can't use Trapeze method comp_length: " + str( comp_length)))) else: comp_length = comp_length # cf Methods.Geometry.Trapeze.comp_surface if isinstance(comp_surface, ImportError): comp_surface = property(fget=lambda x: raise_( ImportError("Can't use Trapeze method comp_surface: " + str( comp_surface)))) else: comp_surface = comp_surface # cf Methods.Geometry.Trapeze.discretize if isinstance(discretize, ImportError): discretize = property(fget=lambda x: raise_( ImportError("Can't use Trapeze method discretize: " + str( discretize)))) else: discretize = discretize # cf Methods.Geometry.Trapeze.get_lines if isinstance(get_lines, ImportError): get_lines = property(fget=lambda x: raise_( ImportError("Can't use Trapeze method get_lines: " + str(get_lines) ))) else: get_lines = get_lines # cf Methods.Geometry.Trapeze.get_patch if isinstance(get_patch, ImportError): get_patch = property(fget=lambda x: raise_( ImportError("Can't use Trapeze method get_patch: " + str(get_patch) ))) else: get_patch = get_patch # cf Methods.Geometry.Trapeze.rotate if isinstance(rotate, ImportError): rotate = property(fget=lambda x: raise_( ImportError("Can't use Trapeze method rotate: " + str(rotate)))) else: rotate = rotate # cf Methods.Geometry.Trapeze.translate if isinstance(translate, ImportError): translate = property(fget=lambda x: raise_( ImportError("Can't use Trapeze method translate: " + str(translate) ))) else: translate = translate # save method is available in all object save = save def __init__(self, height=1, W2=1, W1=1, point_ref=0, label="", init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["height", "W2", "W1", "point_ref", "label"]) # Overwrite default value with init_dict content if "height" in list(init_dict.keys()): height = init_dict["height"] if "W2" in list(init_dict.keys()): W2 = init_dict["W2"] if "W1" in list(init_dict.keys()): W1 = init_dict["W1"] if "point_ref" in list(init_dict.keys()): point_ref = init_dict["point_ref"] if "label" in list(init_dict.keys()): label = init_dict["label"] # Initialisation by argument self.height = height self.W2 = W2 self.W1 = W1 # Call Surface init super(Trapeze, self).__init__(point_ref=point_ref, label=label) # The class is frozen (in Surface init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" Trapeze_str = "" # Get the properties inherited from Surface Trapeze_str += super(Trapeze, self).__str__() + linesep Trapeze_str += "height = " + str(self.height) + linesep Trapeze_str += "W2 = " + str(self.W2) + linesep Trapeze_str += "W1 = " + str(self.W1) return Trapeze_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from Surface if not super(Trapeze, self).__eq__(other): return False if other.height != self.height: return False if other.W2 != self.W2: return False if other.W1 != self.W1: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from Surface Trapeze_dict = super(Trapeze, self).as_dict() Trapeze_dict["height"] = self.height Trapeze_dict["W2"] = self.W2 Trapeze_dict["W1"] = self.W1 # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name Trapeze_dict["__class__"] = "Trapeze" return Trapeze_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.height = None self.W2 = None self.W1 = None # Set to None the properties inherited from Surface super(Trapeze, self)._set_None() def _get_height(self): """getter of height""" return self._height def _set_height(self, value): """setter of height""" check_var("height", value, "float", Vmin=0) self._height = value # the height of the Trapeze # Type : float, min = 0 height = property(fget=_get_height, fset=_set_height, doc=u"""the height of the Trapeze""") 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 # the big base of Trapeze # Type : float, min = 0 W2 = property(fget=_get_W2, fset=_set_W2, doc=u"""the big base of Trapeze""") 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 # the small base of the Trapeze # Type : float, min = 0 W1 = property(fget=_get_W1, fset=_set_W1, doc=u"""the small base of the Trapeze""")
class Conductor(FrozenClass): """abstact class for conductors""" VERSION = 1 # cf Methods.Machine.Conductor.check if isinstance(check, ImportError): check = property( fget=lambda x: raise_( ImportError("Can't use Conductor method check: " + str(check)) ) ) else: check = check # save method is available in all object save = save def __init__(self, cond_mat=-1, ins_mat=-1, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if cond_mat == -1: cond_mat = Material() if ins_mat == -1: ins_mat = Material() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["cond_mat", "ins_mat"]) # Overwrite default value with init_dict content if "cond_mat" in list(init_dict.keys()): cond_mat = init_dict["cond_mat"] if "ins_mat" in list(init_dict.keys()): ins_mat = init_dict["ins_mat"] # Initialisation by argument self.parent = None # cond_mat can be None, a Material object or a dict if isinstance(cond_mat, dict): self.cond_mat = Material(init_dict=cond_mat) else: self.cond_mat = cond_mat # ins_mat can be None, a Material object or a dict if isinstance(ins_mat, dict): self.ins_mat = Material(init_dict=ins_mat) else: self.ins_mat = ins_mat # The class is frozen, for now it's impossible to add new properties self._freeze() def __str__(self): """Convert this objet in a readeable string (for print)""" Conductor_str = "" if self.parent is None: Conductor_str += "parent = None " + linesep else: Conductor_str += "parent = " + str(type(self.parent)) + " object" + linesep if self.cond_mat is not None: Conductor_str += ( "cond_mat = " + str(self.cond_mat.as_dict()) + linesep + linesep ) else: Conductor_str += "cond_mat = None" + linesep + linesep if self.ins_mat is not None: Conductor_str += ( "ins_mat = " + str(self.ins_mat.as_dict()) + linesep + linesep ) else: Conductor_str += "ins_mat = None" return Conductor_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False if other.cond_mat != self.cond_mat: return False if other.ins_mat != self.ins_mat: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ Conductor_dict = dict() if self.cond_mat is None: Conductor_dict["cond_mat"] = None else: Conductor_dict["cond_mat"] = self.cond_mat.as_dict() if self.ins_mat is None: Conductor_dict["ins_mat"] = None else: Conductor_dict["ins_mat"] = self.ins_mat.as_dict() # The class name is added to the dict fordeserialisation purpose Conductor_dict["__class__"] = "Conductor" return Conductor_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" if self.cond_mat is not None: self.cond_mat._set_None() if self.ins_mat is not None: self.ins_mat._set_None() def _get_cond_mat(self): """getter of cond_mat""" return self._cond_mat def _set_cond_mat(self, value): """setter of cond_mat""" check_var("cond_mat", value, "Material") self._cond_mat = value if self._cond_mat is not None: self._cond_mat.parent = self # Material of the conductor # Type : Material cond_mat = property( fget=_get_cond_mat, fset=_set_cond_mat, doc=u"""Material of the conductor""" ) def _get_ins_mat(self): """getter of ins_mat""" return self._ins_mat def _set_ins_mat(self, value): """setter of ins_mat""" check_var("ins_mat", value, "Material") self._ins_mat = value if self._ins_mat is not None: self._ins_mat.parent = self # Material of the insulation # Type : Material ins_mat = property( fget=_get_ins_mat, fset=_set_ins_mat, doc=u"""Material of the insulation""" )
class WindingDW1L(Winding): """single layer overlapping integral distributed winding""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Machine.WindingDW1L.comp_connection_mat if isinstance(comp_connection_mat, ImportError): comp_connection_mat = property(fget=lambda x: raise_( ImportError("Can't use WindingDW1L method comp_connection_mat: " + str(comp_connection_mat)))) else: comp_connection_mat = comp_connection_mat # cf Methods.Machine.WindingDW1L.get_dim_wind if isinstance(get_dim_wind, ImportError): get_dim_wind = property(fget=lambda x: raise_( ImportError("Can't use WindingDW1L method get_dim_wind: " + str( get_dim_wind)))) else: get_dim_wind = get_dim_wind # save method is available in all object save = save def __init__( self, coil_pitch=5, is_reverse_wind=False, Nslot_shift_wind=0, qs=3, Ntcoil=7, Npcpp=2, type_connection=0, p=3, Lewout=0.015, conductor=-1, init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if conductor == -1: conductor = Conductor() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "coil_pitch", "is_reverse_wind", "Nslot_shift_wind", "qs", "Ntcoil", "Npcpp", "type_connection", "p", "Lewout", "conductor", ], ) # Overwrite default value with init_dict content if "coil_pitch" in list(init_dict.keys()): coil_pitch = init_dict["coil_pitch"] if "is_reverse_wind" in list(init_dict.keys()): is_reverse_wind = init_dict["is_reverse_wind"] if "Nslot_shift_wind" in list(init_dict.keys()): Nslot_shift_wind = init_dict["Nslot_shift_wind"] if "qs" in list(init_dict.keys()): qs = init_dict["qs"] if "Ntcoil" in list(init_dict.keys()): Ntcoil = init_dict["Ntcoil"] if "Npcpp" in list(init_dict.keys()): Npcpp = init_dict["Npcpp"] if "type_connection" in list(init_dict.keys()): type_connection = init_dict["type_connection"] if "p" in list(init_dict.keys()): p = init_dict["p"] if "Lewout" in list(init_dict.keys()): Lewout = init_dict["Lewout"] if "conductor" in list(init_dict.keys()): conductor = init_dict["conductor"] # Initialisation by argument self.coil_pitch = coil_pitch # Call Winding init super(WindingDW1L, self).__init__( is_reverse_wind=is_reverse_wind, Nslot_shift_wind=Nslot_shift_wind, qs=qs, Ntcoil=Ntcoil, Npcpp=Npcpp, type_connection=type_connection, p=p, Lewout=Lewout, conductor=conductor, ) # The class is frozen (in Winding init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" WindingDW1L_str = "" # Get the properties inherited from Winding WindingDW1L_str += super(WindingDW1L, self).__str__() + linesep WindingDW1L_str += "coil_pitch = " + str(self.coil_pitch) return WindingDW1L_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from Winding if not super(WindingDW1L, self).__eq__(other): return False if other.coil_pitch != self.coil_pitch: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from Winding WindingDW1L_dict = super(WindingDW1L, self).as_dict() WindingDW1L_dict["coil_pitch"] = self.coil_pitch # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name WindingDW1L_dict["__class__"] = "WindingDW1L" return WindingDW1L_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.coil_pitch = None # Set to None the properties inherited from Winding super(WindingDW1L, self)._set_None() def _get_coil_pitch(self): """getter of coil_pitch""" return self._coil_pitch def _set_coil_pitch(self, value): """setter of coil_pitch""" check_var("coil_pitch", value, "int", Vmin=0, Vmax=1000) self._coil_pitch = value # winding coil pitch or coil span expressed in slots (coil_pitch1=Zs/(2p)->full-pitch distributed winding, coil_pitch1<Zs/(2p)->chorded/shorted-pitch distributed winding, coil_pitch1=1->tooth-winding). Coil pitch is sometimes written 1/9 means Input.Magnetics.coil_pitch1=9-1=8 # Type : int, min = 0, max = 1000 coil_pitch = property( fget=_get_coil_pitch, fset=_set_coil_pitch, doc= u"""winding coil pitch or coil span expressed in slots (coil_pitch1=Zs/(2p)->full-pitch distributed winding, coil_pitch1<Zs/(2p)->chorded/shorted-pitch distributed winding, coil_pitch1=1->tooth-winding). Coil pitch is sometimes written 1/9 means Input.Magnetics.coil_pitch1=9-1=8""", )
class ImportMatrix(Import): """Abstract class to Import/Generate 1D or D matrix""" VERSION = 1 # cf Methods.Import.ImportMatrix.edit_matrix if isinstance(edit_matrix, ImportError): edit_matrix = property(fget=lambda x: raise_( ImportError("Can't use ImportMatrix method edit_matrix: " + str( edit_matrix)))) else: edit_matrix = edit_matrix # save method is available in all object save = save def __init__(self, is_transpose=False, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["is_transpose"]) # Overwrite default value with init_dict content if "is_transpose" in list(init_dict.keys()): is_transpose = init_dict["is_transpose"] # Initialisation by argument self.is_transpose = is_transpose # Call Import init super(ImportMatrix, self).__init__() # The class is frozen (in Import init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" ImportMatrix_str = "" # Get the properties inherited from Import ImportMatrix_str += super(ImportMatrix, self).__str__() + linesep ImportMatrix_str += "is_transpose = " + str(self.is_transpose) return ImportMatrix_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from Import if not super(ImportMatrix, self).__eq__(other): return False if other.is_transpose != self.is_transpose: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from Import ImportMatrix_dict = super(ImportMatrix, self).as_dict() ImportMatrix_dict["is_transpose"] = self.is_transpose # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name ImportMatrix_dict["__class__"] = "ImportMatrix" return ImportMatrix_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.is_transpose = None # Set to None the properties inherited from Import super(ImportMatrix, self)._set_None() def _get_is_transpose(self): """getter of is_transpose""" return self._is_transpose def _set_is_transpose(self, value): """setter of is_transpose""" check_var("is_transpose", value, "bool") self._is_transpose = value # 1 to transpose the Imported/Generated matrix # Type : bool is_transpose = property( fget=_get_is_transpose, fset=_set_is_transpose, doc=u"""1 to transpose the Imported/Generated matrix""", )
class SolutionFEMM(Solution): """Gather the electromagnetic solution from FEMM (only 2D triangles)""" VERSION = 1 # cf Methods.Mesh.SolutionFEMM.get_field if isinstance(get_field, ImportError): get_field = property(fget=lambda x: raise_( ImportError("Can't use SolutionFEMM method get_field: " + str( get_field)))) else: get_field = get_field # save method is available in all object save = save def __init__(self, B=None, H=None, mu=None, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["B", "H", "mu"]) # Overwrite default value with init_dict content if "B" in list(init_dict.keys()): B = init_dict["B"] if "H" in list(init_dict.keys()): H = init_dict["H"] if "mu" in list(init_dict.keys()): mu = init_dict["mu"] # Initialisation by argument # B can be None, a ndarray or a list set_array(self, "B", B) # H can be None, a ndarray or a list set_array(self, "H", H) # mu can be None, a ndarray or a list set_array(self, "mu", mu) # Call Solution init super(SolutionFEMM, self).__init__() # The class is frozen (in Solution init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" SolutionFEMM_str = "" # Get the properties inherited from Solution SolutionFEMM_str += super(SolutionFEMM, self).__str__() + linesep SolutionFEMM_str += "B = " + linesep + str(self.B) + linesep + linesep SolutionFEMM_str += "H = " + linesep + str(self.H) + linesep + linesep SolutionFEMM_str += "mu = " + linesep + str(self.mu) return SolutionFEMM_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from Solution if not super(SolutionFEMM, self).__eq__(other): return False if not array_equal(other.B, self.B): return False if not array_equal(other.H, self.H): return False if not array_equal(other.mu, self.mu): return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from Solution SolutionFEMM_dict = super(SolutionFEMM, self).as_dict() if self.B is None: SolutionFEMM_dict["B"] = None else: SolutionFEMM_dict["B"] = self.B.tolist() if self.H is None: SolutionFEMM_dict["H"] = None else: SolutionFEMM_dict["H"] = self.H.tolist() if self.mu is None: SolutionFEMM_dict["mu"] = None else: SolutionFEMM_dict["mu"] = self.mu.tolist() # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name SolutionFEMM_dict["__class__"] = "SolutionFEMM" return SolutionFEMM_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.B = None self.H = None self.mu = None # Set to None the properties inherited from Solution super(SolutionFEMM, self)._set_None() def _get_B(self): """getter of B""" return self._B def _set_B(self, value): """setter of B""" if type(value) is list: try: value = array(value) except: pass check_var("B", value, "ndarray") self._B = value # Magnetic flux per element (Bx, By) # Type : ndarray B = property(fget=_get_B, fset=_set_B, doc=u"""Magnetic flux per element (Bx, By)""") def _get_H(self): """getter of H""" return self._H def _set_H(self, value): """setter of H""" if type(value) is list: try: value = array(value) except: pass check_var("H", value, "ndarray") self._H = value # Magnetic field per element (Hx, Hy) # Type : ndarray H = property(fget=_get_H, fset=_set_H, doc=u"""Magnetic field per element (Hx, Hy)""") def _get_mu(self): """getter of mu""" return self._mu def _set_mu(self, value): """setter of mu""" if type(value) is list: try: value = array(value) except: pass check_var("mu", value, "ndarray") self._mu = value # Pemreability per element # Type : ndarray mu = property(fget=_get_mu, fset=_set_mu, doc=u"""Pemreability per element""")
class Mesh(FrozenClass): """Gather the mesh storage format""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Mesh.Mesh.set_submesh if isinstance(set_submesh, ImportError): set_submesh = property(fget=lambda x: raise_( ImportError("Can't use Mesh method set_submesh: " + str(set_submesh )))) else: set_submesh = set_submesh # cf Methods.Mesh.Mesh.get_all_node_coord if isinstance(get_all_node_coord, ImportError): get_all_node_coord = property(fget=lambda x: raise_( ImportError("Can't use Mesh method get_all_node_coord: " + str( get_all_node_coord)))) else: get_all_node_coord = get_all_node_coord # cf Methods.Mesh.Mesh.add_element if isinstance(add_element, ImportError): add_element = property(fget=lambda x: raise_( ImportError("Can't use Mesh method add_element: " + str(add_element )))) else: add_element = add_element # cf Methods.Mesh.Mesh.get_all_connectivity if isinstance(get_all_connectivity, ImportError): get_all_connectivity = property(fget=lambda x: raise_( ImportError("Can't use Mesh method get_all_connectivity: " + str( get_all_connectivity)))) else: get_all_connectivity = get_all_connectivity # cf Methods.Mesh.Mesh.get_connectivity if isinstance(get_connectivity, ImportError): get_connectivity = property(fget=lambda x: raise_( ImportError("Can't use Mesh method get_connectivity: " + str( get_connectivity)))) else: get_connectivity = get_connectivity # cf Methods.Mesh.Mesh.get_new_tag if isinstance(get_new_tag, ImportError): get_new_tag = property(fget=lambda x: raise_( ImportError("Can't use Mesh method get_new_tag: " + str(get_new_tag )))) else: get_new_tag = get_new_tag # cf Methods.Mesh.Mesh.interface if isinstance(interface, ImportError): interface = property(fget=lambda x: raise_( ImportError("Can't use Mesh method interface: " + str(interface)))) else: interface = interface # cf Methods.Mesh.Mesh.get_node_tags if isinstance(get_node_tags, ImportError): get_node_tags = property(fget=lambda x: raise_( ImportError("Can't use Mesh method get_node_tags: " + str( get_node_tags)))) else: get_node_tags = get_node_tags # cf Methods.Mesh.Mesh.get_vertice if isinstance(get_vertice, ImportError): get_vertice = property(fget=lambda x: raise_( ImportError("Can't use Mesh method get_vertice: " + str(get_vertice )))) else: get_vertice = get_vertice # save method is available in all object save = save def __init__(self, element=dict(), node=-1, submesh=list(), init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if node == -1: node = Node() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["element", "node", "submesh"]) # Overwrite default value with init_dict content if "element" in list(init_dict.keys()): element = init_dict["element"] if "node" in list(init_dict.keys()): node = init_dict["node"] if "submesh" in list(init_dict.keys()): submesh = init_dict["submesh"] # Initialisation by argument self.parent = None # element can be None or a list of Element object self.element = dict() if type(element) is dict: for key, obj in element.items(): if isinstance(obj, dict): # Check that the type is correct (including daughter) class_name = obj.get("__class__") if class_name not in ["Element", "ElementMat"]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for element") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.element[key] = class_obj(init_dict=obj) else: element = element # Should raise an error elif element is None: self.element = dict() else: self.element = element # Should raise an error # node can be None, a Node object or a dict if isinstance(node, dict): # Check that the type is correct (including daughter) class_name = node.get("__class__") if class_name not in ["Node", "NodeMat"]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for node") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.node = class_obj(init_dict=node) else: self.node = node # submesh can be None or a list of Mesh object self.submesh = list() if type(submesh) is list: for obj in submesh: if obj is None: # Default value self.submesh.append(Mesh()) elif isinstance(obj, dict): self.submesh.append(Mesh(init_dict=obj)) else: self.submesh.append(obj) elif submesh is None: self.submesh = list() else: self.submesh = submesh # The class is frozen, for now it's impossible to add new properties self._freeze() def __str__(self): """Convert this objet in a readeable string (for print)""" Mesh_str = "" if self.parent is None: Mesh_str += "parent = None " + linesep else: Mesh_str += "parent = " + str(type( self.parent)) + " object" + linesep if len(self.element) == 0: Mesh_str += "element = []" for key, obj in self.element.items(): Mesh_str += ("element[" + key + "] = " + str(self.element[key].as_dict()) + "\n" + linesep + linesep) if self.node is not None: Mesh_str += "node = " + str( self.node.as_dict()) + linesep + linesep else: Mesh_str += "node = None" + linesep + linesep if len(self.submesh) == 0: Mesh_str += "submesh = []" for ii in range(len(self.submesh)): Mesh_str += ("submesh[" + str(ii) + "] = " + str(self.submesh[ii].as_dict()) + "\n") return Mesh_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False if other.element != self.element: return False if other.node != self.node: return False if other.submesh != self.submesh: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ Mesh_dict = dict() Mesh_dict["element"] = dict() for key, obj in self.element.items(): Mesh_dict["element"][key] = obj.as_dict() if self.node is None: Mesh_dict["node"] = None else: Mesh_dict["node"] = self.node.as_dict() Mesh_dict["submesh"] = list() for obj in self.submesh: Mesh_dict["submesh"].append(obj.as_dict()) # The class name is added to the dict fordeserialisation purpose Mesh_dict["__class__"] = "Mesh" return Mesh_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" for key, obj in self.element.items(): obj._set_None() if self.node is not None: self.node._set_None() for obj in self.submesh: obj._set_None() def _get_element(self): """getter of element""" for key, obj in self._element.items(): if obj is not None: obj.parent = self return self._element def _set_element(self, value): """setter of element""" check_var("element", value, "{Element}") self._element = value # Storing connectivity # Type : {Element} element = property(fget=_get_element, fset=_set_element, doc=u"""Storing connectivity""") def _get_node(self): """getter of node""" return self._node def _set_node(self, value): """setter of node""" check_var("node", value, "Node") self._node = value if self._node is not None: self._node.parent = self # Storing nodes # Type : Node node = property(fget=_get_node, fset=_set_node, doc=u"""Storing nodes""") def _get_submesh(self): """getter of submesh""" for obj in self._submesh: if obj is not None: obj.parent = self return self._submesh def _set_submesh(self, value): """setter of submesh""" check_var("submesh", value, "[Mesh]") self._submesh = value for obj in self._submesh: if obj is not None: obj.parent = self # Storing submeshes. Node and element numbers/tags or group must be the same. # Type : [Mesh] submesh = property( fget=_get_submesh, fset=_set_submesh, doc= u"""Storing submeshes. Node and element numbers/tags or group must be the same.""", )
class WindingDW2L(WindingDW1L): """double layer overlapping integral distributed winding, radial coil superposition""" VERSION = 1 # cf Methods.Machine.WindingDW2L.get_dim_wind if isinstance(get_dim_wind, ImportError): get_dim_wind = property(fget=lambda x: raise_( ImportError("Can't use WindingDW2L method get_dim_wind: " + str( get_dim_wind)))) else: get_dim_wind = get_dim_wind # save method is available in all object save = save def __init__( self, coil_pitch=5, is_reverse_wind=False, Nslot_shift_wind=0, qs=3, Ntcoil=7, Npcpp=2, type_connection=0, p=3, Lewout=0.015, conductor=-1, init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if conductor == -1: conductor = Conductor() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "coil_pitch", "is_reverse_wind", "Nslot_shift_wind", "qs", "Ntcoil", "Npcpp", "type_connection", "p", "Lewout", "conductor", ], ) # Overwrite default value with init_dict content if "coil_pitch" in list(init_dict.keys()): coil_pitch = init_dict["coil_pitch"] if "is_reverse_wind" in list(init_dict.keys()): is_reverse_wind = init_dict["is_reverse_wind"] if "Nslot_shift_wind" in list(init_dict.keys()): Nslot_shift_wind = init_dict["Nslot_shift_wind"] if "qs" in list(init_dict.keys()): qs = init_dict["qs"] if "Ntcoil" in list(init_dict.keys()): Ntcoil = init_dict["Ntcoil"] if "Npcpp" in list(init_dict.keys()): Npcpp = init_dict["Npcpp"] if "type_connection" in list(init_dict.keys()): type_connection = init_dict["type_connection"] if "p" in list(init_dict.keys()): p = init_dict["p"] if "Lewout" in list(init_dict.keys()): Lewout = init_dict["Lewout"] if "conductor" in list(init_dict.keys()): conductor = init_dict["conductor"] # Initialisation by argument # Call WindingDW1L init super(WindingDW2L, self).__init__( coil_pitch=coil_pitch, is_reverse_wind=is_reverse_wind, Nslot_shift_wind=Nslot_shift_wind, qs=qs, Ntcoil=Ntcoil, Npcpp=Npcpp, type_connection=type_connection, p=p, Lewout=Lewout, conductor=conductor, ) # The class is frozen (in WindingDW1L init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" WindingDW2L_str = "" # Get the properties inherited from WindingDW1L WindingDW2L_str += super(WindingDW2L, self).__str__() + linesep return WindingDW2L_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from WindingDW1L if not super(WindingDW2L, self).__eq__(other): return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from WindingDW1L WindingDW2L_dict = super(WindingDW2L, self).as_dict() # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name WindingDW2L_dict["__class__"] = "WindingDW2L" return WindingDW2L_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" # Set to None the properties inherited from WindingDW1L super(WindingDW2L, self)._set_None()
class Lamination(FrozenClass): """abstract class for lamination""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Machine.Lamination.build_geometry if isinstance(build_geometry, ImportError): build_geometry = property(fget=lambda x: raise_( ImportError("Can't use Lamination method build_geometry: " + str( build_geometry)))) else: build_geometry = build_geometry # cf Methods.Machine.Lamination.check if isinstance(check, ImportError): check = property(fget=lambda x: raise_( ImportError("Can't use Lamination method check: " + str(check)))) else: check = check # cf Methods.Machine.Lamination.comp_length if isinstance(comp_length, ImportError): comp_length = property(fget=lambda x: raise_( ImportError("Can't use Lamination method comp_length: " + str( comp_length)))) else: comp_length = comp_length # cf Methods.Machine.Lamination.comp_masses if isinstance(comp_masses, ImportError): comp_masses = property(fget=lambda x: raise_( ImportError("Can't use Lamination method comp_masses: " + str( comp_masses)))) else: comp_masses = comp_masses # cf Methods.Machine.Lamination.comp_radius_mec if isinstance(comp_radius_mec, ImportError): comp_radius_mec = property(fget=lambda x: raise_( ImportError("Can't use Lamination method comp_radius_mec: " + str( comp_radius_mec)))) else: comp_radius_mec = comp_radius_mec # cf Methods.Machine.Lamination.comp_surface_axial_vent if isinstance(comp_surface_axial_vent, ImportError): comp_surface_axial_vent = property(fget=lambda x: raise_( ImportError("Can't use Lamination method comp_surface_axial_vent: " + str(comp_surface_axial_vent)))) else: comp_surface_axial_vent = comp_surface_axial_vent # cf Methods.Machine.Lamination.comp_surfaces if isinstance(comp_surfaces, ImportError): comp_surfaces = property(fget=lambda x: raise_( ImportError("Can't use Lamination method comp_surfaces: " + str( comp_surfaces)))) else: comp_surfaces = comp_surfaces # cf Methods.Machine.Lamination.comp_volumes if isinstance(comp_volumes, ImportError): comp_volumes = property(fget=lambda x: raise_( ImportError("Can't use Lamination method comp_volumes: " + str( comp_volumes)))) else: comp_volumes = comp_volumes # cf Methods.Machine.Lamination.get_bore_line if isinstance(get_bore_line, ImportError): get_bore_line = property(fget=lambda x: raise_( ImportError("Can't use Lamination method get_bore_line: " + str( get_bore_line)))) else: get_bore_line = get_bore_line # cf Methods.Machine.Lamination.get_Rbo if isinstance(get_Rbo, ImportError): get_Rbo = property(fget=lambda x: raise_( ImportError("Can't use Lamination method get_Rbo: " + str(get_Rbo)) )) else: get_Rbo = get_Rbo # cf Methods.Machine.Lamination.get_Ryoke if isinstance(get_Ryoke, ImportError): get_Ryoke = property(fget=lambda x: raise_( ImportError("Can't use Lamination method get_Ryoke: " + str( get_Ryoke)))) else: get_Ryoke = get_Ryoke # cf Methods.Machine.Lamination.get_name_phase if isinstance(get_name_phase, ImportError): get_name_phase = property(fget=lambda x: raise_( ImportError("Can't use Lamination method get_name_phase: " + str( get_name_phase)))) else: get_name_phase = get_name_phase # cf Methods.Machine.Lamination.plot if isinstance(plot, ImportError): plot = property(fget=lambda x: raise_( ImportError("Can't use Lamination method plot: " + str(plot)))) else: plot = plot # cf Methods.Machine.Lamination.comp_output_geo if isinstance(comp_output_geo, ImportError): comp_output_geo = property(fget=lambda x: raise_( ImportError("Can't use Lamination method comp_output_geo: " + str( comp_output_geo)))) else: comp_output_geo = comp_output_geo # cf Methods.Machine.Lamination.get_polar_eq if isinstance(get_polar_eq, ImportError): get_polar_eq = property(fget=lambda x: raise_( ImportError("Can't use Lamination method get_polar_eq: " + str( get_polar_eq)))) else: get_polar_eq = get_polar_eq # cf Methods.Machine.Lamination.is_outwards if isinstance(is_outwards, ImportError): is_outwards = property(fget=lambda x: raise_( ImportError("Can't use Lamination method is_outwards: " + str( is_outwards)))) else: is_outwards = is_outwards # cf Methods.Machine.Lamination.comp_height_yoke if isinstance(comp_height_yoke, ImportError): comp_height_yoke = property(fget=lambda x: raise_( ImportError("Can't use Lamination method comp_height_yoke: " + str( comp_height_yoke)))) else: comp_height_yoke = comp_height_yoke # save method is available in all object save = save def __init__( self, L1=0.35, mat_type=-1, Nrvd=0, Wrvd=0, Kf1=0.95, is_internal=True, Rint=0, Rext=1, is_stator=True, axial_vent=list(), notch=list(), init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if mat_type == -1: mat_type = Material() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "L1", "mat_type", "Nrvd", "Wrvd", "Kf1", "is_internal", "Rint", "Rext", "is_stator", "axial_vent", "notch", ], ) # Overwrite default value with init_dict content if "L1" in list(init_dict.keys()): L1 = init_dict["L1"] if "mat_type" in list(init_dict.keys()): mat_type = init_dict["mat_type"] if "Nrvd" in list(init_dict.keys()): Nrvd = init_dict["Nrvd"] if "Wrvd" in list(init_dict.keys()): Wrvd = init_dict["Wrvd"] if "Kf1" in list(init_dict.keys()): Kf1 = init_dict["Kf1"] if "is_internal" in list(init_dict.keys()): is_internal = init_dict["is_internal"] if "Rint" in list(init_dict.keys()): Rint = init_dict["Rint"] if "Rext" in list(init_dict.keys()): Rext = init_dict["Rext"] if "is_stator" in list(init_dict.keys()): is_stator = init_dict["is_stator"] if "axial_vent" in list(init_dict.keys()): axial_vent = init_dict["axial_vent"] if "notch" in list(init_dict.keys()): notch = init_dict["notch"] # Initialisation by argument self.parent = None self.L1 = L1 # mat_type can be None, a Material object or a dict if isinstance(mat_type, dict): self.mat_type = Material(init_dict=mat_type) else: self.mat_type = mat_type self.Nrvd = Nrvd self.Wrvd = Wrvd self.Kf1 = Kf1 self.is_internal = is_internal self.Rint = Rint self.Rext = Rext self.is_stator = is_stator # axial_vent can be None or a list of Hole object self.axial_vent = list() if type(axial_vent) is list: for obj in axial_vent: if obj is None: # Default value self.axial_vent.append(Hole()) elif isinstance(obj, dict): # Check that the type is correct (including daughter) class_name = obj.get("__class__") if class_name not in [ "Hole", "HoleMag", "HoleM50", "HoleM51", "HoleM52", "HoleM53", "HoleM54", "VentilationCirc", "VentilationPolar", "VentilationTrap", ]: raise InitUnKnowClassError( "Unknow class name " + class_name + " in init_dict for axial_vent") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.axial_vent.append(class_obj(init_dict=obj)) else: self.axial_vent.append(obj) elif axial_vent is None: self.axial_vent = list() else: self.axial_vent = axial_vent # notch can be None or a list of Notch object self.notch = list() if type(notch) is list: for obj in notch: if obj is None: # Default value self.notch.append(Notch()) elif isinstance(obj, dict): # Check that the type is correct (including daughter) class_name = obj.get("__class__") if class_name not in ["Notch", "NotchEvenDist"]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for notch") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.notch.append(class_obj(init_dict=obj)) else: self.notch.append(obj) elif notch is None: self.notch = list() else: self.notch = notch # The class is frozen, for now it's impossible to add new properties self._freeze() def __str__(self): """Convert this objet in a readeable string (for print)""" Lamination_str = "" if self.parent is None: Lamination_str += "parent = None " + linesep else: Lamination_str += "parent = " + str(type( self.parent)) + " object" + linesep Lamination_str += "L1 = " + str(self.L1) + linesep if self.mat_type is not None: Lamination_str += ("mat_type = " + str(self.mat_type.as_dict()) + linesep + linesep) else: Lamination_str += "mat_type = None" + linesep + linesep Lamination_str += "Nrvd = " + str(self.Nrvd) + linesep Lamination_str += "Wrvd = " + str(self.Wrvd) + linesep Lamination_str += "Kf1 = " + str(self.Kf1) + linesep Lamination_str += "is_internal = " + str(self.is_internal) + linesep Lamination_str += "Rint = " + str(self.Rint) + linesep Lamination_str += "Rext = " + str(self.Rext) + linesep Lamination_str += "is_stator = " + str(self.is_stator) + linesep if len(self.axial_vent) == 0: Lamination_str += "axial_vent = []" for ii in range(len(self.axial_vent)): Lamination_str += ("axial_vent[" + str(ii) + "] = " + str(self.axial_vent[ii].as_dict()) + "\n" + linesep + linesep) if len(self.notch) == 0: Lamination_str += "notch = []" for ii in range(len(self.notch)): Lamination_str += ("notch[" + str(ii) + "] = " + str(self.notch[ii].as_dict()) + "\n") return Lamination_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False if other.L1 != self.L1: return False if other.mat_type != self.mat_type: return False if other.Nrvd != self.Nrvd: return False if other.Wrvd != self.Wrvd: return False if other.Kf1 != self.Kf1: return False if other.is_internal != self.is_internal: return False if other.Rint != self.Rint: return False if other.Rext != self.Rext: return False if other.is_stator != self.is_stator: return False if other.axial_vent != self.axial_vent: return False if other.notch != self.notch: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ Lamination_dict = dict() Lamination_dict["L1"] = self.L1 if self.mat_type is None: Lamination_dict["mat_type"] = None else: Lamination_dict["mat_type"] = self.mat_type.as_dict() Lamination_dict["Nrvd"] = self.Nrvd Lamination_dict["Wrvd"] = self.Wrvd Lamination_dict["Kf1"] = self.Kf1 Lamination_dict["is_internal"] = self.is_internal Lamination_dict["Rint"] = self.Rint Lamination_dict["Rext"] = self.Rext Lamination_dict["is_stator"] = self.is_stator Lamination_dict["axial_vent"] = list() for obj in self.axial_vent: Lamination_dict["axial_vent"].append(obj.as_dict()) Lamination_dict["notch"] = list() for obj in self.notch: Lamination_dict["notch"].append(obj.as_dict()) # The class name is added to the dict fordeserialisation purpose Lamination_dict["__class__"] = "Lamination" return Lamination_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.L1 = None if self.mat_type is not None: self.mat_type._set_None() self.Nrvd = None self.Wrvd = None self.Kf1 = None self.is_internal = None self.Rint = None self.Rext = None self.is_stator = None for obj in self.axial_vent: obj._set_None() for obj in self.notch: obj._set_None() def _get_L1(self): """getter of L1""" return self._L1 def _set_L1(self, value): """setter of L1""" check_var("L1", value, "float", Vmin=0, Vmax=100) self._L1 = value # Lamination stack active length [m] without radial ventilation airducts but including insulation layers between lamination sheets # Type : float, min = 0, max = 100 L1 = property( fget=_get_L1, fset=_set_L1, doc= u"""Lamination stack active length [m] without radial ventilation airducts but including insulation layers between lamination sheets""", ) def _get_mat_type(self): """getter of mat_type""" return self._mat_type def _set_mat_type(self, value): """setter of mat_type""" check_var("mat_type", value, "Material") self._mat_type = value if self._mat_type is not None: self._mat_type.parent = self # Lamination's material # Type : Material mat_type = property(fget=_get_mat_type, fset=_set_mat_type, doc=u"""Lamination's material""") def _get_Nrvd(self): """getter of Nrvd""" return self._Nrvd def _set_Nrvd(self, value): """setter of Nrvd""" check_var("Nrvd", value, "int", Vmin=0) self._Nrvd = value # number of radial air ventilation ducts in lamination # Type : int, min = 0 Nrvd = property( fget=_get_Nrvd, fset=_set_Nrvd, doc=u"""number of radial air ventilation ducts in lamination """, ) def _get_Wrvd(self): """getter of Wrvd""" return self._Wrvd def _set_Wrvd(self, value): """setter of Wrvd""" check_var("Wrvd", value, "float", Vmin=0) self._Wrvd = value # axial width of ventilation ducts in lamination # Type : float, min = 0 Wrvd = property( fget=_get_Wrvd, fset=_set_Wrvd, doc=u"""axial width of ventilation ducts in lamination""", ) def _get_Kf1(self): """getter of Kf1""" return self._Kf1 def _set_Kf1(self, value): """setter of Kf1""" check_var("Kf1", value, "float", Vmin=0, Vmax=1) self._Kf1 = value # lamination stacking / packing factor # Type : float, min = 0, max = 1 Kf1 = property(fget=_get_Kf1, fset=_set_Kf1, doc=u"""lamination stacking / packing factor""") def _get_is_internal(self): """getter of is_internal""" return self._is_internal def _set_is_internal(self, value): """setter of is_internal""" check_var("is_internal", value, "bool") self._is_internal = value # 1 for internal lamination topology, 0 for external lamination # Type : bool is_internal = property( fget=_get_is_internal, fset=_set_is_internal, doc= u"""1 for internal lamination topology, 0 for external lamination""", ) def _get_Rint(self): """getter of Rint""" return self._Rint def _set_Rint(self, value): """setter of Rint""" check_var("Rint", value, "float", Vmin=0) self._Rint = value # To fill # Type : float, min = 0 Rint = property(fget=_get_Rint, fset=_set_Rint, doc=u"""To fill""") def _get_Rext(self): """getter of Rext""" return self._Rext def _set_Rext(self, value): """setter of Rext""" check_var("Rext", value, "float", Vmin=0) self._Rext = value # To fill # Type : float, min = 0 Rext = property(fget=_get_Rext, fset=_set_Rext, doc=u"""To fill""") def _get_is_stator(self): """getter of is_stator""" return self._is_stator def _set_is_stator(self, value): """setter of is_stator""" check_var("is_stator", value, "bool") self._is_stator = value # To fill # Type : bool is_stator = property(fget=_get_is_stator, fset=_set_is_stator, doc=u"""To fill""") def _get_axial_vent(self): """getter of axial_vent""" for obj in self._axial_vent: if obj is not None: obj.parent = self return self._axial_vent def _set_axial_vent(self, value): """setter of axial_vent""" check_var("axial_vent", value, "[Hole]") self._axial_vent = value for obj in self._axial_vent: if obj is not None: obj.parent = self # Axial ventilation ducts # Type : [Hole] axial_vent = property(fget=_get_axial_vent, fset=_set_axial_vent, doc=u"""Axial ventilation ducts""") def _get_notch(self): """getter of notch""" for obj in self._notch: if obj is not None: obj.parent = self return self._notch def _set_notch(self, value): """setter of notch""" check_var("notch", value, "[Notch]") self._notch = value for obj in self._notch: if obj is not None: obj.parent = self # Lamination bore notches # Type : [Notch] notch = property(fget=_get_notch, fset=_set_notch, doc=u"""Lamination bore notches""")
class MagnetType11(MagnetPolar): """single magnet with polar shape""" VERSION = 1 IS_FLAT_BOT = 0 IS_FLAT_TOP = 0 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Machine.MagnetType11._comp_point_coordinate if isinstance(_comp_point_coordinate, ImportError): _comp_point_coordinate = property( fget=lambda x: raise_( ImportError( "Can't use MagnetType11 method _comp_point_coordinate: " + str(_comp_point_coordinate) ) ) ) else: _comp_point_coordinate = _comp_point_coordinate # cf Methods.Machine.MagnetType11.build_geometry if isinstance(build_geometry, ImportError): build_geometry = property( fget=lambda x: raise_( ImportError( "Can't use MagnetType11 method build_geometry: " + str(build_geometry) ) ) ) else: build_geometry = build_geometry # cf Methods.Machine.MagnetType11.comp_height if isinstance(comp_height, ImportError): comp_height = property( fget=lambda x: raise_( ImportError( "Can't use MagnetType11 method comp_height: " + str(comp_height) ) ) ) else: comp_height = comp_height # cf Methods.Machine.MagnetType11.comp_surface if isinstance(comp_surface, ImportError): comp_surface = property( fget=lambda x: raise_( ImportError( "Can't use MagnetType11 method comp_surface: " + str(comp_surface) ) ) ) else: comp_surface = comp_surface # save method is available in all object save = save def __init__( self, Wmag=0.002, Hmag=0.001, mat_type=-1, type_magnetization=0, Lmag=0.95, init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if mat_type == -1: mat_type = Material() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, ["Wmag", "Hmag", "mat_type", "type_magnetization", "Lmag"] ) # Overwrite default value with init_dict content if "Wmag" in list(init_dict.keys()): Wmag = init_dict["Wmag"] if "Hmag" in list(init_dict.keys()): Hmag = init_dict["Hmag"] if "mat_type" in list(init_dict.keys()): mat_type = init_dict["mat_type"] if "type_magnetization" in list(init_dict.keys()): type_magnetization = init_dict["type_magnetization"] if "Lmag" in list(init_dict.keys()): Lmag = init_dict["Lmag"] # Initialisation by argument self.Wmag = Wmag self.Hmag = Hmag # Call MagnetPolar init super(MagnetType11, self).__init__( mat_type=mat_type, type_magnetization=type_magnetization, Lmag=Lmag ) # The class is frozen (in MagnetPolar init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" MagnetType11_str = "" # Get the properties inherited from MagnetPolar MagnetType11_str += super(MagnetType11, self).__str__() + linesep MagnetType11_str += "Wmag = " + str(self.Wmag) + linesep MagnetType11_str += "Hmag = " + str(self.Hmag) return MagnetType11_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from MagnetPolar if not super(MagnetType11, self).__eq__(other): return False if other.Wmag != self.Wmag: return False if other.Hmag != self.Hmag: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from MagnetPolar MagnetType11_dict = super(MagnetType11, self).as_dict() MagnetType11_dict["Wmag"] = self.Wmag MagnetType11_dict["Hmag"] = self.Hmag # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name MagnetType11_dict["__class__"] = "MagnetType11" return MagnetType11_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.Wmag = None self.Hmag = None # Set to None the properties inherited from MagnetPolar super(MagnetType11, self)._set_None() def _get_Wmag(self): """getter of Wmag""" return self._Wmag def _set_Wmag(self, value): """setter of Wmag""" check_var("Wmag", value, "float", Vmin=0) self._Wmag = value # magnet bottom width [rad] # Type : float, min = 0 Wmag = property( fget=_get_Wmag, fset=_set_Wmag, doc=u"""magnet bottom width [rad]""" ) def _get_Hmag(self): """getter of Hmag""" return self._Hmag def _set_Hmag(self, value): """setter of Hmag""" check_var("Hmag", value, "float", Vmin=0) self._Hmag = value # magnet radial height [m] # Type : float, min = 0 Hmag = property(fget=_get_Hmag, fset=_set_Hmag, doc=u"""magnet radial height [m]""")
class Hole(FrozenClass): """Holes for lamination (abstract)""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Slot.Hole.comp_radius if isinstance(comp_radius, ImportError): comp_radius = property( fget=lambda x: raise_( ImportError("Can't use Hole method comp_radius: " + str(comp_radius)) ) ) else: comp_radius = comp_radius # cf Methods.Slot.Hole.comp_surface if isinstance(comp_surface, ImportError): comp_surface = property( fget=lambda x: raise_( ImportError("Can't use Hole method comp_surface: " + str(comp_surface)) ) ) else: comp_surface = comp_surface # cf Methods.Slot.Hole.get_is_stator if isinstance(get_is_stator, ImportError): get_is_stator = property( fget=lambda x: raise_( ImportError( "Can't use Hole method get_is_stator: " + str(get_is_stator) ) ) ) else: get_is_stator = get_is_stator # cf Methods.Slot.Hole.get_Rbo if isinstance(get_Rbo, ImportError): get_Rbo = property( fget=lambda x: raise_( ImportError("Can't use Hole method get_Rbo: " + str(get_Rbo)) ) ) else: get_Rbo = get_Rbo # cf Methods.Slot.Hole.has_magnet if isinstance(has_magnet, ImportError): has_magnet = property( fget=lambda x: raise_( ImportError("Can't use Hole method has_magnet: " + str(has_magnet)) ) ) else: has_magnet = has_magnet # cf Methods.Slot.Hole.plot if isinstance(plot, ImportError): plot = property( fget=lambda x: raise_( ImportError("Can't use Hole method plot: " + str(plot)) ) ) else: plot = plot # save method is available in all object save = save def __init__(self, Zh=36, mat_void=-1, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if mat_void == -1: mat_void = Material() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["Zh", "mat_void"]) # Overwrite default value with init_dict content 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"] # Initialisation by argument self.parent = None self.Zh = Zh # mat_void can be None, a Material object or a dict if isinstance(mat_void, dict): self.mat_void = Material(init_dict=mat_void) else: self.mat_void = mat_void # The class is frozen, for now it's impossible to add new properties self._freeze() def __str__(self): """Convert this objet in a readeable string (for print)""" Hole_str = "" if self.parent is None: Hole_str += "parent = None " + linesep else: Hole_str += "parent = " + str(type(self.parent)) + " object" + linesep Hole_str += "Zh = " + str(self.Zh) + linesep if self.mat_void is not None: Hole_str += "mat_void = " + str(self.mat_void.as_dict()) + linesep + linesep else: Hole_str += "mat_void = None" return Hole_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False if other.Zh != self.Zh: return False if other.mat_void != self.mat_void: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ Hole_dict = dict() Hole_dict["Zh"] = self.Zh if self.mat_void is None: Hole_dict["mat_void"] = None else: Hole_dict["mat_void"] = self.mat_void.as_dict() # The class name is added to the dict fordeserialisation purpose Hole_dict["__class__"] = "Hole" return Hole_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.Zh = None if self.mat_void is not None: self.mat_void._set_None() def _get_Zh(self): """getter of Zh""" return self._Zh def _set_Zh(self, value): """setter of Zh""" check_var("Zh", value, "int", Vmin=0, Vmax=1000) self._Zh = value # Number of Hole around the circumference # Type : int, min = 0, max = 1000 Zh = property( fget=_get_Zh, fset=_set_Zh, doc=u"""Number of Hole around the circumference""" ) def _get_mat_void(self): """getter of mat_void""" return self._mat_void def _set_mat_void(self, value): """setter of mat_void""" check_var("mat_void", value, "Material") self._mat_void = value if self._mat_void is not None: self._mat_void.parent = self # Material of the void part of the hole (Air in general) # Type : Material mat_void = property( fget=_get_mat_void, fset=_set_mat_void, doc=u"""Material of the void part of the hole (Air in general)""", )
class HoleMag(Hole): """Hole with magnets for lamination (abstract)""" VERSION = 1 # cf Methods.Slot.HoleMag.has_magnet if isinstance(has_magnet, ImportError): has_magnet = property( fget=lambda x: raise_( ImportError("Can't use HoleMag method has_magnet: " + str(has_magnet)) ) ) else: has_magnet = has_magnet # save method is available in all object save = save def __init__(self, Zh=36, mat_void=-1, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if mat_void == -1: mat_void = Material() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["Zh", "mat_void"]) # Overwrite default value with init_dict content 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"] # Initialisation by argument # Call Hole init super(HoleMag, self).__init__(Zh=Zh, mat_void=mat_void) # The class is frozen (in Hole init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" HoleMag_str = "" # Get the properties inherited from Hole HoleMag_str += super(HoleMag, self).__str__() + linesep return HoleMag_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from Hole if not super(HoleMag, self).__eq__(other): return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ # Get the properties inherited from Hole HoleMag_dict = super(HoleMag, self).as_dict() # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name HoleMag_dict["__class__"] = "HoleMag" return HoleMag_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" # Set to None the properties inherited from Hole super(HoleMag, self)._set_None()
class Magnetics(FrozenClass): """Magnetic module abstract object""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Simulation.Magnetics.run if isinstance(run, ImportError): run = property(fget=lambda x: raise_( ImportError("Can't use Magnetics method run: " + str(run)))) else: run = run # cf Methods.Simulation.Magnetics.comp_time_angle if isinstance(comp_time_angle, ImportError): comp_time_angle = property(fget=lambda x: raise_( ImportError("Can't use Magnetics method comp_time_angle: " + str( comp_time_angle)))) else: comp_time_angle = comp_time_angle # cf Methods.Simulation.Magnetics.comp_emf if isinstance(comp_emf, ImportError): comp_emf = property(fget=lambda x: raise_( ImportError("Can't use Magnetics method comp_emf: " + str(comp_emf) ))) else: comp_emf = comp_emf # save method is available in all object save = save def __init__( self, is_remove_slotS=False, is_remove_slotR=False, is_remove_vent=False, is_mmfs=True, is_mmfr=True, is_stator_linear_BH=0, is_rotor_linear_BH=0, is_symmetry_t=False, sym_t=1, is_antiper_t=False, is_symmetry_a=False, sym_a=1, is_antiper_a=False, init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "is_remove_slotS", "is_remove_slotR", "is_remove_vent", "is_mmfs", "is_mmfr", "is_stator_linear_BH", "is_rotor_linear_BH", "is_symmetry_t", "sym_t", "is_antiper_t", "is_symmetry_a", "sym_a", "is_antiper_a", ], ) # Overwrite default value with init_dict content if "is_remove_slotS" in list(init_dict.keys()): is_remove_slotS = init_dict["is_remove_slotS"] if "is_remove_slotR" in list(init_dict.keys()): is_remove_slotR = init_dict["is_remove_slotR"] if "is_remove_vent" in list(init_dict.keys()): is_remove_vent = init_dict["is_remove_vent"] if "is_mmfs" in list(init_dict.keys()): is_mmfs = init_dict["is_mmfs"] if "is_mmfr" in list(init_dict.keys()): is_mmfr = init_dict["is_mmfr"] if "is_stator_linear_BH" in list(init_dict.keys()): is_stator_linear_BH = init_dict["is_stator_linear_BH"] if "is_rotor_linear_BH" in list(init_dict.keys()): is_rotor_linear_BH = init_dict["is_rotor_linear_BH"] if "is_symmetry_t" in list(init_dict.keys()): is_symmetry_t = init_dict["is_symmetry_t"] if "sym_t" in list(init_dict.keys()): sym_t = init_dict["sym_t"] if "is_antiper_t" in list(init_dict.keys()): is_antiper_t = init_dict["is_antiper_t"] if "is_symmetry_a" in list(init_dict.keys()): is_symmetry_a = init_dict["is_symmetry_a"] if "sym_a" in list(init_dict.keys()): sym_a = init_dict["sym_a"] if "is_antiper_a" in list(init_dict.keys()): is_antiper_a = init_dict["is_antiper_a"] # Initialisation by argument self.parent = None self.is_remove_slotS = is_remove_slotS self.is_remove_slotR = is_remove_slotR self.is_remove_vent = is_remove_vent self.is_mmfs = is_mmfs self.is_mmfr = is_mmfr self.is_stator_linear_BH = is_stator_linear_BH self.is_rotor_linear_BH = is_rotor_linear_BH self.is_symmetry_t = is_symmetry_t self.sym_t = sym_t self.is_antiper_t = is_antiper_t self.is_symmetry_a = is_symmetry_a self.sym_a = sym_a self.is_antiper_a = is_antiper_a # The class is frozen, for now it's impossible to add new properties self._freeze() def __str__(self): """Convert this objet in a readeable string (for print)""" Magnetics_str = "" if self.parent is None: Magnetics_str += "parent = None " + linesep else: Magnetics_str += "parent = " + str(type( self.parent)) + " object" + linesep Magnetics_str += "is_remove_slotS = " + str( self.is_remove_slotS) + linesep Magnetics_str += "is_remove_slotR = " + str( self.is_remove_slotR) + linesep Magnetics_str += "is_remove_vent = " + str( self.is_remove_vent) + linesep Magnetics_str += "is_mmfs = " + str(self.is_mmfs) + linesep Magnetics_str += "is_mmfr = " + str(self.is_mmfr) + linesep Magnetics_str += ("is_stator_linear_BH = " + str(self.is_stator_linear_BH) + linesep) Magnetics_str += ("is_rotor_linear_BH = " + str(self.is_rotor_linear_BH) + linesep) Magnetics_str += "is_symmetry_t = " + str(self.is_symmetry_t) + linesep Magnetics_str += "sym_t = " + str(self.sym_t) + linesep Magnetics_str += "is_antiper_t = " + str(self.is_antiper_t) + linesep Magnetics_str += "is_symmetry_a = " + str(self.is_symmetry_a) + linesep Magnetics_str += "sym_a = " + str(self.sym_a) + linesep Magnetics_str += "is_antiper_a = " + str(self.is_antiper_a) return Magnetics_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False if other.is_remove_slotS != self.is_remove_slotS: return False if other.is_remove_slotR != self.is_remove_slotR: return False if other.is_remove_vent != self.is_remove_vent: return False if other.is_mmfs != self.is_mmfs: return False if other.is_mmfr != self.is_mmfr: return False if other.is_stator_linear_BH != self.is_stator_linear_BH: return False if other.is_rotor_linear_BH != self.is_rotor_linear_BH: return False if other.is_symmetry_t != self.is_symmetry_t: return False if other.sym_t != self.sym_t: return False if other.is_antiper_t != self.is_antiper_t: return False if other.is_symmetry_a != self.is_symmetry_a: return False if other.sym_a != self.sym_a: return False if other.is_antiper_a != self.is_antiper_a: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ Magnetics_dict = dict() Magnetics_dict["is_remove_slotS"] = self.is_remove_slotS Magnetics_dict["is_remove_slotR"] = self.is_remove_slotR Magnetics_dict["is_remove_vent"] = self.is_remove_vent Magnetics_dict["is_mmfs"] = self.is_mmfs Magnetics_dict["is_mmfr"] = self.is_mmfr Magnetics_dict["is_stator_linear_BH"] = self.is_stator_linear_BH Magnetics_dict["is_rotor_linear_BH"] = self.is_rotor_linear_BH Magnetics_dict["is_symmetry_t"] = self.is_symmetry_t Magnetics_dict["sym_t"] = self.sym_t Magnetics_dict["is_antiper_t"] = self.is_antiper_t Magnetics_dict["is_symmetry_a"] = self.is_symmetry_a Magnetics_dict["sym_a"] = self.sym_a Magnetics_dict["is_antiper_a"] = self.is_antiper_a # The class name is added to the dict fordeserialisation purpose Magnetics_dict["__class__"] = "Magnetics" return Magnetics_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.is_remove_slotS = None self.is_remove_slotR = None self.is_remove_vent = None self.is_mmfs = None self.is_mmfr = None self.is_stator_linear_BH = None self.is_rotor_linear_BH = None self.is_symmetry_t = None self.sym_t = None self.is_antiper_t = None self.is_symmetry_a = None self.sym_a = None self.is_antiper_a = None def _get_is_remove_slotS(self): """getter of is_remove_slotS""" return self._is_remove_slotS def _set_is_remove_slotS(self, value): """setter of is_remove_slotS""" check_var("is_remove_slotS", value, "bool") self._is_remove_slotS = value # 1 to artificially remove stator slotting effects in permeance mmf calculations # Type : bool is_remove_slotS = property( fget=_get_is_remove_slotS, fset=_set_is_remove_slotS, doc= u"""1 to artificially remove stator slotting effects in permeance mmf calculations""", ) def _get_is_remove_slotR(self): """getter of is_remove_slotR""" return self._is_remove_slotR def _set_is_remove_slotR(self, value): """setter of is_remove_slotR""" check_var("is_remove_slotR", value, "bool") self._is_remove_slotR = value # 1 to artificially remove rotor slotting effects in permeance mmf calculations # Type : bool is_remove_slotR = property( fget=_get_is_remove_slotR, fset=_set_is_remove_slotR, doc= u"""1 to artificially remove rotor slotting effects in permeance mmf calculations""", ) def _get_is_remove_vent(self): """getter of is_remove_vent""" return self._is_remove_vent def _set_is_remove_vent(self, value): """setter of is_remove_vent""" check_var("is_remove_vent", value, "bool") self._is_remove_vent = value # 1 to artificially remove the ventilations duct # Type : bool is_remove_vent = property( fget=_get_is_remove_vent, fset=_set_is_remove_vent, doc=u"""1 to artificially remove the ventilations duct""", ) def _get_is_mmfs(self): """getter of is_mmfs""" return self._is_mmfs def _set_is_mmfs(self, value): """setter of is_mmfs""" check_var("is_mmfs", value, "bool") self._is_mmfs = value # 1 to compute the stator magnetomotive force / stator armature magnetic field # Type : bool is_mmfs = property( fget=_get_is_mmfs, fset=_set_is_mmfs, doc= u"""1 to compute the stator magnetomotive force / stator armature magnetic field""", ) def _get_is_mmfr(self): """getter of is_mmfr""" return self._is_mmfr def _set_is_mmfr(self, value): """setter of is_mmfr""" check_var("is_mmfr", value, "bool") self._is_mmfr = value # 1 to compute the rotor magnetomotive force / rotor magnetic field # Type : bool is_mmfr = property( fget=_get_is_mmfr, fset=_set_is_mmfr, doc= u"""1 to compute the rotor magnetomotive force / rotor magnetic field""", ) def _get_is_stator_linear_BH(self): """getter of is_stator_linear_BH""" return self._is_stator_linear_BH def _set_is_stator_linear_BH(self, value): """setter of is_stator_linear_BH""" check_var("is_stator_linear_BH", value, "int", Vmin=0, Vmax=2) self._is_stator_linear_BH = value # 0 to use the B(H) curve, 1 to use linear B(H) curve according to mur_lin, 2 to enforce infinite permeability (mur_lin =100000) # Type : int, min = 0, max = 2 is_stator_linear_BH = property( fget=_get_is_stator_linear_BH, fset=_set_is_stator_linear_BH, doc= u"""0 to use the B(H) curve, 1 to use linear B(H) curve according to mur_lin, 2 to enforce infinite permeability (mur_lin =100000)""", ) def _get_is_rotor_linear_BH(self): """getter of is_rotor_linear_BH""" return self._is_rotor_linear_BH def _set_is_rotor_linear_BH(self, value): """setter of is_rotor_linear_BH""" check_var("is_rotor_linear_BH", value, "int", Vmin=0, Vmax=2) self._is_rotor_linear_BH = value # 0 to use the B(H) curve, 1 to use linear B(H) curve according to mur_lin, 2 to enforce infinite permeability (mur_lin =100000) # Type : int, min = 0, max = 2 is_rotor_linear_BH = property( fget=_get_is_rotor_linear_BH, fset=_set_is_rotor_linear_BH, doc= u"""0 to use the B(H) curve, 1 to use linear B(H) curve according to mur_lin, 2 to enforce infinite permeability (mur_lin =100000)""", ) def _get_is_symmetry_t(self): """getter of is_symmetry_t""" return self._is_symmetry_t def _set_is_symmetry_t(self, value): """setter of is_symmetry_t""" check_var("is_symmetry_t", value, "bool") self._is_symmetry_t = value # 0 Compute on the complete time vector, 1 compute according to sym_t and is_antiper_t # Type : bool is_symmetry_t = property( fget=_get_is_symmetry_t, fset=_set_is_symmetry_t, doc= u"""0 Compute on the complete time vector, 1 compute according to sym_t and is_antiper_t""", ) def _get_sym_t(self): """getter of sym_t""" return self._sym_t def _set_sym_t(self, value): """setter of sym_t""" check_var("sym_t", value, "int", Vmin=1) self._sym_t = value # Number of symmetry for the time vector # Type : int, min = 1 sym_t = property( fget=_get_sym_t, fset=_set_sym_t, doc=u"""Number of symmetry for the time vector""", ) def _get_is_antiper_t(self): """getter of is_antiper_t""" return self._is_antiper_t def _set_is_antiper_t(self, value): """setter of is_antiper_t""" check_var("is_antiper_t", value, "bool") self._is_antiper_t = value # To add an antiperiodicity to the time vector # Type : bool is_antiper_t = property( fget=_get_is_antiper_t, fset=_set_is_antiper_t, doc=u"""To add an antiperiodicity to the time vector""", ) def _get_is_symmetry_a(self): """getter of is_symmetry_a""" return self._is_symmetry_a def _set_is_symmetry_a(self, value): """setter of is_symmetry_a""" check_var("is_symmetry_a", value, "bool") self._is_symmetry_a = value # 0 Compute on the complete machine, 1 compute according to sym_a and is_antiper_a # Type : bool is_symmetry_a = property( fget=_get_is_symmetry_a, fset=_set_is_symmetry_a, doc= u"""0 Compute on the complete machine, 1 compute according to sym_a and is_antiper_a""", ) def _get_sym_a(self): """getter of sym_a""" return self._sym_a def _set_sym_a(self, value): """setter of sym_a""" check_var("sym_a", value, "int", Vmin=1) self._sym_a = value # Number of symmetry for the angle vector # Type : int, min = 1 sym_a = property( fget=_get_sym_a, fset=_set_sym_a, doc=u"""Number of symmetry for the angle vector""", ) def _get_is_antiper_a(self): """getter of is_antiper_a""" return self._is_antiper_a def _set_is_antiper_a(self, value): """setter of is_antiper_a""" check_var("is_antiper_a", value, "bool") self._is_antiper_a = value # To add an antiperiodicity to the angle vector # Type : bool is_antiper_a = property( fget=_get_is_antiper_a, fset=_set_is_antiper_a, doc=u"""To add an antiperiodicity to the angle vector""", )