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: tmp = self.mat_type.__str__().replace(linesep, linesep + "\t").rstrip("\t") Magnet_str += "mat_type = " + tmp else: Magnet_str += "mat_type = None" + linesep + linesep Magnet_str += "type_magnetization = " + str( self.type_magnetization) + linesep Magnet_str += "Lmag = " + str(self.Lmag) + linesep 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 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 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 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 LamSquirrelCage(LamSlotWind): """squirrel cages lamination""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Machine.LamSquirrelCage.build_geometry if isinstance(build_geometry, ImportError): build_geometry = property(fget=lambda x: raise_( ImportError("Can't use LamSquirrelCage method build_geometry: " + str(build_geometry)))) else: build_geometry = build_geometry # cf Methods.Machine.LamSquirrelCage.check if isinstance(check, ImportError): check = property(fget=lambda x: raise_( ImportError("Can't use LamSquirrelCage method check: " + str(check) ))) else: check = check # cf Methods.Machine.LamSquirrelCage.comp_length_ring if isinstance(comp_length_ring, ImportError): comp_length_ring = property(fget=lambda x: raise_( ImportError("Can't use LamSquirrelCage method comp_length_ring: " + str(comp_length_ring)))) else: comp_length_ring = comp_length_ring # cf Methods.Machine.LamSquirrelCage.plot if isinstance(plot, ImportError): plot = property(fget=lambda x: raise_( ImportError("Can't use LamSquirrelCage method plot: " + str(plot))) ) else: plot = plot # save method is available in all object save = save def __init__( self, Hscr=0.03, Lscr=0.015, ring_mat=-1, 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 ring_mat == -1: ring_mat = Material() 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, [ "Hscr", "Lscr", "ring_mat", "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 "Hscr" in list(init_dict.keys()): Hscr = init_dict["Hscr"] if "Lscr" in list(init_dict.keys()): Lscr = init_dict["Lscr"] if "ring_mat" in list(init_dict.keys()): ring_mat = init_dict["ring_mat"] 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.Hscr = Hscr self.Lscr = Lscr # ring_mat can be None, a Material object or a dict if isinstance(ring_mat, dict): self.ring_mat = Material(init_dict=ring_mat) else: self.ring_mat = ring_mat # Call LamSlotWind init super(LamSquirrelCage, self).__init__( Ksfill=Ksfill, winding=winding, 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 LamSlotWind init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" LamSquirrelCage_str = "" # Get the properties inherited from LamSlotWind LamSquirrelCage_str += super(LamSquirrelCage, self).__str__() LamSquirrelCage_str += "Hscr = " + str(self.Hscr) + linesep LamSquirrelCage_str += "Lscr = " + str(self.Lscr) + linesep if self.ring_mat is not None: tmp = self.ring_mat.__str__().replace(linesep, linesep + "\t").rstrip("\t") LamSquirrelCage_str += "ring_mat = " + tmp else: LamSquirrelCage_str += "ring_mat = None" + linesep + linesep return LamSquirrelCage_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from LamSlotWind if not super(LamSquirrelCage, self).__eq__(other): return False if other.Hscr != self.Hscr: return False if other.Lscr != self.Lscr: return False if other.ring_mat != self.ring_mat: 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 LamSlotWind LamSquirrelCage_dict = super(LamSquirrelCage, self).as_dict() LamSquirrelCage_dict["Hscr"] = self.Hscr LamSquirrelCage_dict["Lscr"] = self.Lscr if self.ring_mat is None: LamSquirrelCage_dict["ring_mat"] = None else: LamSquirrelCage_dict["ring_mat"] = self.ring_mat.as_dict() # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name LamSquirrelCage_dict["__class__"] = "LamSquirrelCage" return LamSquirrelCage_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.Hscr = None self.Lscr = None if self.ring_mat is not None: self.ring_mat._set_None() # Set to None the properties inherited from LamSlotWind super(LamSquirrelCage, self)._set_None() def _get_Hscr(self): """getter of Hscr""" return self._Hscr def _set_Hscr(self, value): """setter of Hscr""" check_var("Hscr", value, "float", Vmin=0) self._Hscr = value # short circuit ring section radial height [m] # Type : float, min = 0 Hscr = property( fget=_get_Hscr, fset=_set_Hscr, doc=u"""short circuit ring section radial height [m]""", ) def _get_Lscr(self): """getter of Lscr""" return self._Lscr def _set_Lscr(self, value): """setter of Lscr""" check_var("Lscr", value, "float", Vmin=0) self._Lscr = value # short circuit ring section axial length # Type : float, min = 0 Lscr = property( fget=_get_Lscr, fset=_set_Lscr, doc=u"""short circuit ring section axial length""", ) def _get_ring_mat(self): """getter of ring_mat""" return self._ring_mat def _set_ring_mat(self, value): """setter of ring_mat""" check_var("ring_mat", value, "Material") self._ring_mat = value if self._ring_mat is not None: self._ring_mat.parent = self # Material of the Rotor short circuit ring # Type : Material ring_mat = property( fget=_get_ring_mat, fset=_set_ring_mat, doc=u"""Material of the Rotor short circuit ring""", )
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 Lamination(FrozenClass): """abstract class for lamination""" VERSION = 1 # cf Methods.Machine.Lamination.build_geometry build_geometry = build_geometry # cf Methods.Machine.Lamination.check check = check # cf Methods.Machine.Lamination.comp_length comp_length = comp_length # cf Methods.Machine.Lamination.comp_masses comp_masses = comp_masses # cf Methods.Machine.Lamination.comp_radius_mec comp_radius_mec = comp_radius_mec # cf Methods.Machine.Lamination.comp_surface_axial_vent comp_surface_axial_vent = comp_surface_axial_vent # cf Methods.Machine.Lamination.comp_surfaces comp_surfaces = comp_surfaces # cf Methods.Machine.Lamination.comp_volumes comp_volumes = comp_volumes # cf Methods.Machine.Lamination.get_bore_line get_bore_line = get_bore_line # cf Methods.Machine.Lamination.get_Rbo get_Rbo = get_Rbo # cf Methods.Machine.Lamination.get_Ryoke get_Ryoke = get_Ryoke # cf Methods.Machine.Lamination.get_name_phase get_name_phase = get_name_phase # cf Methods.Machine.Lamination.plot plot = plot # cf Methods.Machine.Lamination.comp_output_geo comp_output_geo = comp_output_geo # cf Methods.Machine.Lamination.get_polar_eq get_polar_eq = get_polar_eq # 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(), 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", ], ) # 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"] # 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): # Call the correct constructor according to the dict load_dict = { "HoleMag": HoleMag, "HoleM50": HoleM50, "HoleM51": HoleM51, "HoleM52": HoleM52, "HoleM53": HoleM53, "HoleM54": HoleM54, "VentilationCirc": VentilationCirc, "VentilationPolar": VentilationPolar, "VentilationTrap": VentilationTrap, "Hole": Hole, } obj_class = obj.get("__class__") if obj_class is None: self.axial_vent.append(Hole(init_dict=obj)) elif obj_class in list(load_dict.keys()): self.axial_vent.append( load_dict[obj_class](init_dict=obj)) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for axial_vent") else: self.axial_vent.append(obj) elif axial_vent is None: self.axial_vent = list() else: self.axial_vent = axial_vent # 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 Lamination_str += ("mat_type = " + str(self.mat_type.as_dict()) + 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") 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 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()) # 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() 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""")
class Shaft(FrozenClass): """machine shaft""" VERSION = 1 # cf Methods.Machine.Shaft.build_geometry build_geometry = build_geometry # cf Methods.Machine.Shaft.comp_mass comp_mass = comp_mass # cf Methods.Machine.Shaft.plot plot = plot # save method is available in all object save = save def __init__(self, Lshaft=0.442, mat_type=-1, Drsh=0.045, 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, ["Lshaft", "mat_type", "Drsh"]) # Overwrite default value with init_dict content if "Lshaft" in list(init_dict.keys()): Lshaft = init_dict["Lshaft"] if "mat_type" in list(init_dict.keys()): mat_type = init_dict["mat_type"] if "Drsh" in list(init_dict.keys()): Drsh = init_dict["Drsh"] # Initialisation by argument self.parent = None self.Lshaft = Lshaft # 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.Drsh = Drsh # 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)""" Shaft_str = "" if self.parent is None: Shaft_str += "parent = None " + linesep else: Shaft_str += "parent = " + str(type( self.parent)) + " object" + linesep Shaft_str += "Lshaft = " + str(self.Lshaft) + linesep Shaft_str += "mat_type = " + str( self.mat_type.as_dict()) + linesep + linesep Shaft_str += "Drsh = " + str(self.Drsh) return Shaft_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False if other.Lshaft != self.Lshaft: return False if other.mat_type != self.mat_type: return False if other.Drsh != self.Drsh: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ Shaft_dict = dict() Shaft_dict["Lshaft"] = self.Lshaft if self.mat_type is None: Shaft_dict["mat_type"] = None else: Shaft_dict["mat_type"] = self.mat_type.as_dict() Shaft_dict["Drsh"] = self.Drsh # The class name is added to the dict fordeserialisation purpose Shaft_dict["__class__"] = "Shaft" return Shaft_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.Lshaft = None if self.mat_type is not None: self.mat_type._set_None() self.Drsh = None def _get_Lshaft(self): """getter of Lshaft""" return self._Lshaft def _set_Lshaft(self, value): """setter of Lshaft""" check_var("Lshaft", value, "float", Vmin=0, Vmax=100) self._Lshaft = value # length of the rotor shaft [m] (used for weight & cost estimation only) # Type : float, min = 0, max = 100 Lshaft = property( fget=_get_Lshaft, fset=_set_Lshaft, doc= u"""length of the rotor shaft [m] (used for weight & cost estimation only)""", ) 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 # Shaft's Material # Type : Material mat_type = property(fget=_get_mat_type, fset=_set_mat_type, doc=u"""Shaft's Material""") def _get_Drsh(self): """getter of Drsh""" return self._Drsh def _set_Drsh(self, value): """setter of Drsh""" check_var("Drsh", value, "float", Vmin=0, Vmax=8) self._Drsh = value # diameter of the rotor shaft [m], used to estimate bearing diameter for friction losses # Type : float, min = 0, max = 8 Drsh = property( fget=_get_Drsh, fset=_set_Drsh, doc= u"""diameter of the rotor shaft [m], used to estimate bearing diameter for friction losses""", )