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", "HoleM50", "HoleM51", "HoleM52", "HoleM53", "HoleM54", "HoleMag", "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""")
from pyleecan.Classes.Material import Material from pyleecan.Classes.MatMagnet import MatMagnet Magnet3 = Material(name="Magnet3") Magnet3.mag = MatMagnet() Magnet3.elec.rho = 1.6e-06 Magnet3.mag.mur_lin = 1.05 Magnet3.mag.Hc = 909456.817667973 Magnet3.mag.alpha_Br = 0.0 Magnet3.mag.Brm20 = 1.2 Magnet3.struct.rho = 7500.0
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 Magnet(FrozenClass): VERSION = 1 # cf Methods.Machine.Magnet.comp_angle_opening comp_angle_opening = comp_angle_opening # cf Methods.Machine.Magnet.comp_height comp_height = comp_height # cf Methods.Machine.Magnet.comp_mass comp_mass = comp_mass # cf Methods.Machine.Magnet.comp_ratio_opening comp_ratio_opening = comp_ratio_opening # cf Methods.Machine.Magnet.comp_surface comp_surface = comp_surface # cf Methods.Machine.Magnet.comp_volume comp_volume = comp_volume # cf Methods.Machine.Magnet.is_outwards is_outwards = is_outwards # cf Methods.Machine.Magnet.plot 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 Magnet_str += "mat_type = " + str(self.mat_type.as_dict()) + 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""")
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, )
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(), 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", ], ) # 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"] # Initialisation by argument self.Ksfill = Ksfill # winding can be None, a Winding object or a dict if isinstance(winding, dict): # Call the correct constructor according to the dict load_dict = { "WindingCW1L": WindingCW1L, "WindingCW2LR": WindingCW2LR, "WindingCW2LT": WindingCW2LT, "WindingDW1L": WindingDW1L, "WindingDW2L": WindingDW2L, "WindingSC": WindingSC, "WindingUD": WindingUD, "Winding": Winding, } obj_class = winding.get("__class__") if obj_class is None: self.winding = Winding(init_dict=winding) elif obj_class in list(load_dict.keys()): self.winding = load_dict[obj_class](init_dict=winding) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for 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, )
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""" )
from pyleecan.Classes.Material import Material from pyleecan.Classes.MatMagnetics import MatMagnetics from pyleecan.Classes.ImportMatrixXls import ImportMatrixXls from os.path import dirname, abspath, join file_path = abspath(join(dirname(__file__), "M400-50A.xlsx")) M400_50A = Material(name="M400-50A") M400_50A.mag = MatMagnetics() M400_50A.mag.mur_lin = 2500.0 M400_50A.mag.Wlam = 0.0005 M400_50A.mag.BH_curve = ImportMatrixXls(file_path=file_path, sheet="BH") M400_50A.struct.rho = 7650.0 M400_50A.struct.Ex = 215000000000.0 M400_50A.struct.Ey = 215000000000.0 M400_50A.struct.Ez = 80000000000.0 M400_50A.struct.Gxy = 0.0 M400_50A.struct.Gxz = 2000000000.0 M400_50A.struct.Gyz = 2000000000.0 M400_50A.struct.nu_xy = 0.3 M400_50A.struct.nu_xz = 0.03 M400_50A.struct.nu_yz = 0.03
from pyleecan.Classes.Material import Material from pyleecan.Classes.MatMagnet import MatMagnet Magnet5 = Material(name="Magnet5") Magnet5.mag = MatMagnet() Magnet5.elec.rho = 1.6e-06 Magnet5.mag.mur_lin = 1.05 Magnet5.mag.Hc = 917035.624481873 Magnet5.mag.alpha_Br = 0.0 Magnet5.mag.Brm20 = 1.21 Magnet5.struct.rho = 7500.0
def __init__( self, 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 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, [ "slot", "L1", "mat_type", "Nrvd", "Wrvd", "Kf1", "is_internal", "Rint", "Rext", "is_stator", "axial_vent", "notch", ], ) # Overwrite default value with init_dict content 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 # slot can be None, a Slot object or a dict if isinstance(slot, dict): # Check that the type is correct (including daughter) class_name = slot.get("__class__") if class_name not in [ "Slot", "Slot19", "SlotMFlat", "SlotMPolar", "SlotW10", "SlotW11", "SlotW12", "SlotW13", "SlotW14", "SlotW15", "SlotW16", "SlotW21", "SlotW22", "SlotW23", "SlotW24", "SlotW25", "SlotW26", "SlotW27", "SlotW28", "SlotW29", "SlotW60", "SlotW61", ]: raise InitUnKnowClassError( "Unknow class name " + class_name + " in init_dict for slot" ) # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.slot = class_obj(init_dict=slot) else: self.slot = slot # Call Lamination init super(LamSlot, self).__init__( 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, )
def __init__( self, H0=0.003, H1=0, W1=0.013, H2=0.02, W2=0.01, H3=0.01, W3=0.01, W4=0.01, magnet_0=-1, magnet_1=-1, 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 magnet_0 == -1: magnet_0 = Magnet() if magnet_1 == -1: magnet_1 = Magnet() if mat_void == -1: mat_void = Material() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "H0", "H1", "W1", "H2", "W2", "H3", "W3", "W4", "magnet_0", "magnet_1", "Zh", "mat_void", ], ) # Overwrite default value with init_dict content if "H0" in list(init_dict.keys()): H0 = init_dict["H0"] if "H1" in list(init_dict.keys()): H1 = init_dict["H1"] if "W1" in list(init_dict.keys()): W1 = init_dict["W1"] if "H2" in list(init_dict.keys()): H2 = init_dict["H2"] if "W2" in list(init_dict.keys()): W2 = init_dict["W2"] if "H3" in list(init_dict.keys()): H3 = init_dict["H3"] if "W3" in list(init_dict.keys()): W3 = init_dict["W3"] if "W4" in list(init_dict.keys()): W4 = init_dict["W4"] if "magnet_0" in list(init_dict.keys()): magnet_0 = init_dict["magnet_0"] if "magnet_1" in list(init_dict.keys()): magnet_1 = init_dict["magnet_1"] if "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.H0 = H0 self.H1 = H1 self.W1 = W1 self.H2 = H2 self.W2 = W2 self.H3 = H3 self.W3 = W3 self.W4 = W4 # magnet_0 can be None, a Magnet object or a dict if isinstance(magnet_0, dict): # Call the correct constructor according to the dict load_dict = { "MagnetFlat": MagnetFlat, "MagnetPolar": MagnetPolar, "MagnetType10": MagnetType10, "MagnetType11": MagnetType11, "MagnetType12": MagnetType12, "MagnetType13": MagnetType13, "MagnetType14": MagnetType14, "Magnet": Magnet, } obj_class = magnet_0.get("__class__") if obj_class is None: self.magnet_0 = Magnet(init_dict=magnet_0) elif obj_class in list(load_dict.keys()): self.magnet_0 = load_dict[obj_class](init_dict=magnet_0) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for magnet_0" ) else: self.magnet_0 = magnet_0 # magnet_1 can be None, a Magnet object or a dict if isinstance(magnet_1, dict): # Call the correct constructor according to the dict load_dict = { "MagnetFlat": MagnetFlat, "MagnetPolar": MagnetPolar, "MagnetType10": MagnetType10, "MagnetType11": MagnetType11, "MagnetType12": MagnetType12, "MagnetType13": MagnetType13, "MagnetType14": MagnetType14, "Magnet": Magnet, } obj_class = magnet_1.get("__class__") if obj_class is None: self.magnet_1 = Magnet(init_dict=magnet_1) elif obj_class in list(load_dict.keys()): self.magnet_1 = load_dict[obj_class](init_dict=magnet_1) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for magnet_1" ) else: self.magnet_1 = magnet_1 # Call HoleMag init super(HoleM53, self).__init__(Zh=Zh, mat_void=mat_void)
def __init__( self, Hwire=0.01, Wwire=0.01, Nwppc_rad=1, Nwppc_tan=1, Wins_wire=0, Wins_coil=0, type_winding_shape=0, alpha_ew=58, 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, [ "Hwire", "Wwire", "Nwppc_rad", "Nwppc_tan", "Wins_wire", "Wins_coil", "type_winding_shape", "alpha_ew", "cond_mat", "ins_mat", ], ) # Overwrite default value with init_dict content if "Hwire" in list(init_dict.keys()): Hwire = init_dict["Hwire"] if "Wwire" in list(init_dict.keys()): Wwire = init_dict["Wwire"] if "Nwppc_rad" in list(init_dict.keys()): Nwppc_rad = init_dict["Nwppc_rad"] if "Nwppc_tan" in list(init_dict.keys()): Nwppc_tan = init_dict["Nwppc_tan"] if "Wins_wire" in list(init_dict.keys()): Wins_wire = init_dict["Wins_wire"] if "Wins_coil" in list(init_dict.keys()): Wins_coil = init_dict["Wins_coil"] if "type_winding_shape" in list(init_dict.keys()): type_winding_shape = init_dict["type_winding_shape"] if "alpha_ew" in list(init_dict.keys()): alpha_ew = init_dict["alpha_ew"] 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.Hwire = Hwire self.Wwire = Wwire self.Nwppc_rad = Nwppc_rad self.Nwppc_tan = Nwppc_tan self.Wins_wire = Wins_wire self.Wins_coil = Wins_coil self.type_winding_shape = type_winding_shape self.alpha_ew = alpha_ew # Call Conductor init super(CondType11, self).__init__(cond_mat=cond_mat, ins_mat=ins_mat)
def __init__( self, hole=list(), 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, [ "hole", "L1", "mat_type", "Nrvd", "Wrvd", "Kf1", "is_internal", "Rint", "Rext", "is_stator", "axial_vent", ], ) # Overwrite default value with init_dict content if "hole" in list(init_dict.keys()): hole = init_dict["hole"] 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 # hole can be None or a list of Hole object self.hole = list() if type(hole) is list: for obj in hole: if obj is None: # Default value self.hole.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.hole.append(Hole(init_dict=obj)) elif obj_class in list(load_dict.keys()): self.hole.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 hole") else: self.hole.append(obj) elif hole is None: self.hole = list() else: self.hole = hole # Call Lamination init super(LamHole, self).__init__( 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, )
def __init__(self, material): # Build the interface according to the .ui file QDialog.__init__(self) self.setupUi(self) # Copy to set the modification only if validated self.mat = Material(init_dict=material.as_dict()) self.le_name.setText(self.mat.name) if self.mat.is_isotropic: self.is_isotropic.setCheckState(Qt.Checked) self.nav_meca.setCurrentIndex(1) self.nav_ther.setCurrentIndex(1) else: self.is_isotropic.setCheckState(Qt.Unchecked) self.nav_meca.setCurrentIndex(0) self.nav_ther.setCurrentIndex(0) # === check material attribute and set values === # Elec if self.mat.elec is None: self.set_default("elec", "electrical") self.lf_rho_elec.setValue(self.mat.elec.rho) # Economical if self.mat.eco is None: self.set_default("eco", "economical") self.lf_cost_unit.setValue(self.mat.eco.cost_unit) # Thermics if self.mat.HT is None: self.set_default("HT", "thermaical") self.lf_Cp.setValue(self.mat.HT.Cp) self.lf_alpha.setValue(self.mat.HT.alpha) self.lf_L.setValue(self.mat.HT.lambda_x) self.lf_Lx.setValue(self.mat.HT.lambda_x) self.lf_Ly.setValue(self.mat.HT.lambda_y) self.lf_Lz.setValue(self.mat.HT.lambda_z) # Structural if self.mat.struct is None: self.set_default("struct", "structural") self.lf_rho_meca.setValue(self.mat.struct.rho) self.lf_E.setValue(self.mat.struct.Ex) self.lf_Ex.setValue(self.mat.struct.Ex) self.lf_Ey.setValue(self.mat.struct.Ey) self.lf_Ez.setValue(self.mat.struct.Ez) self.lf_G.setValue(self.mat.struct.Gxy) self.lf_Gxy.setValue(self.mat.struct.Gxy) self.lf_Gxz.setValue(self.mat.struct.Gxz) self.lf_Gyz.setValue(self.mat.struct.Gyz) self.lf_nu.setValue(self.mat.struct.nu_xy) self.lf_nu_xy.setValue(self.mat.struct.nu_xy) self.lf_nu_xz.setValue(self.mat.struct.nu_xz) self.lf_nu_yz.setValue(self.mat.struct.nu_yz) # Magnetical if self.mat.mag is None: self.set_default("mag", "magnetical") self.lf_mur_lin.setValue(self.mat.mag.mur_lin) self.lf_Brm20.setValue(self.mat.mag.Brm20) self.lf_alpha_Br.setValue(self.mat.mag.alpha_Br) self.lf_Wlam.setValue(self.mat.mag.Wlam) if isinstance(self.mat.mag.BH_curve, ImportMatrixXls): file_path = abs_file_path(self.mat.mag.BH_curve.file_path, is_check=False) self.in_BH_file.setText(split(file_path)[1]) self.b_plot.setEnabled(True) # Hide useless widget self.in_epsr.hide() self.lf_epsr.hide() # === setup signals === # Misc. self.le_name.editingFinished.connect(self.set_name) self.is_isotropic.toggled.connect(self.set_is_isotropic) self.lf_rho_elec.editingFinished.connect(self.set_rho_elec) self.b_xls.clicked.connect(self.set_xls_BH) self.b_plot.clicked.connect(self.plot_BH) # Magnetics self.lf_mur_lin.editingFinished.connect(self.set_mur_lin) self.lf_Brm20.editingFinished.connect(self.set_Brm20) self.lf_alpha_Br.editingFinished.connect(self.set_alpha_Br) self.lf_Wlam.editingFinished.connect(self.set_Wlam) # Economical self.lf_cost_unit.editingFinished.connect(self.set_cost_unit) # Thermics self.lf_Cp.editingFinished.connect(self.set_Cp) self.lf_alpha.editingFinished.connect(self.set_alpha) self.lf_L.editingFinished.connect(self.set_lambda) self.lf_Lx.editingFinished.connect(self.set_lambda_x) self.lf_Ly.editingFinished.connect(self.set_lambda_y) self.lf_Lz.editingFinished.connect(self.set_lambda_z) # Mechanics self.lf_rho_meca.editingFinished.connect(self.set_rho_meca) self.lf_E.editingFinished.connect(self.set_E) self.lf_Ex.editingFinished.connect(self.set_Ex) self.lf_Ey.editingFinished.connect(self.set_Ey) self.lf_Ez.editingFinished.connect(self.set_Ez) self.lf_G.editingFinished.connect(self.set_G) self.lf_Gxy.editingFinished.connect(self.set_Gxy) self.lf_Gxz.editingFinished.connect(self.set_Gxz) self.lf_Gyz.editingFinished.connect(self.set_Gyz) self.lf_nu.editingFinished.connect(self.set_nu) self.lf_nu_xy.editingFinished.connect(self.set_nu_xy) self.lf_nu_xz.editingFinished.connect(self.set_nu_xz) self.lf_nu_yz.editingFinished.connect(self.set_nu_yz)
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", "HoleM50", "HoleM51", "HoleM52", "HoleM53", "HoleM54", "HoleMag", "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 __init__( self, hole=list(), bore=None, 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 bore == -1: bore = Bore() if mat_type == -1: mat_type = Material() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "hole", "bore", "L1", "mat_type", "Nrvd", "Wrvd", "Kf1", "is_internal", "Rint", "Rext", "is_stator", "axial_vent", "notch", ], ) # Overwrite default value with init_dict content if "hole" in list(init_dict.keys()): hole = init_dict["hole"] if "bore" in list(init_dict.keys()): bore = init_dict["bore"] 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 # hole can be None or a list of Hole object self.hole = list() if type(hole) is list: for obj in hole: if obj is None: # Default value self.hole.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", "HoleM50", "HoleM51", "HoleM52", "HoleM53", "HoleM54", "HoleMag", "VentilationCirc", "VentilationPolar", "VentilationTrap", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for hole") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.hole.append(class_obj(init_dict=obj)) else: self.hole.append(obj) elif hole is None: self.hole = list() else: self.hole = hole # bore can be None, a Bore object or a dict if isinstance(bore, dict): # Check that the type is correct (including daughter) class_name = bore.get("__class__") if class_name not in ["Bore", "BoreFlower"]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for bore") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.bore = class_obj(init_dict=bore) else: self.bore = bore # Call Lamination init super(LamHole, self).__init__( 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, )
def __init__(self, material): # Build the interface according to the .ui file QDialog.__init__(self) self.setupUi(self) # Copy to set the modification only if validated self.mat = Material(init_dict=material.as_dict()) self.le_name.setText(material.name) if material.is_isotropic: self.is_isotropic.setCheckState(Qt.Checked) self.nav_meca.setCurrentIndex(1) self.nav_ther.setCurrentIndex(1) else: self.is_isotropic.setCheckState(Qt.Unchecked) self.nav_meca.setCurrentIndex(0) self.nav_ther.setCurrentIndex(0) # Elec self.lf_rho_elec.setValue(material.elec.rho) # Economical self.lf_cost_unit.setValue(material.eco.cost_unit) # Thermics self.lf_Cp.setValue(material.HT.Cp) self.lf_alpha.setValue(material.HT.alpha) self.lf_L.setValue(material.HT.lambda_x) self.lf_Lx.setValue(material.HT.lambda_x) self.lf_Ly.setValue(material.HT.lambda_y) self.lf_Lz.setValue(material.HT.lambda_z) # Structural self.lf_rho_meca.setValue(material.struct.rho) self.lf_E.setValue(material.struct.Ex) self.lf_Ex.setValue(material.struct.Ex) self.lf_Ey.setValue(material.struct.Ey) self.lf_Ez.setValue(material.struct.Ez) self.lf_G.setValue(material.struct.Gxy) self.lf_Gxy.setValue(material.struct.Gxy) self.lf_Gxz.setValue(material.struct.Gxz) self.lf_Gyz.setValue(material.struct.Gyz) self.lf_nu.setValue(material.struct.nu_xy) self.lf_nu_xy.setValue(material.struct.nu_xy) self.lf_nu_xz.setValue(material.struct.nu_xz) self.lf_nu_yz.setValue(material.struct.nu_yz) if type(material.mag) is MatLamination: self.c_type_mat.setCurrentIndex(2) self.nav_mag.setCurrentIndex(1) self.lf_mur_lin.setValue(material.mag.mur_lin) self.lf_Wlam.setValue(material.mag.Wlam) elif type(material.mag) is MatMagnet: self.c_type_mat.setCurrentIndex(1) self.nav_mag.setCurrentIndex(0) self.lf_mur_lin.setValue(material.mag.mur_lin) self.lf_Brm20.setValue(material.mag.Brm20) self.lf_alpha_Br.setValue(material.mag.alpha_Br) else: # Mat_Raw self.c_type_mat.setCurrentIndex(0) self.nav_phy.removeTab(1) # Hide useless widget self.in_epsr.hide() self.lf_epsr.hide() self.le_name.editingFinished.connect(self.set_name) self.c_type_mat.currentIndexChanged.connect(self.set_type_mat) self.is_isotropic.toggled.connect(self.set_is_isotropic) self.lf_rho_elec.editingFinished.connect(self.set_rho_elec) # Magnetics self.lf_mur_lin.editingFinished.connect(self.set_mur_lin) self.lf_Brm20.editingFinished.connect(self.set_Brm20) self.lf_alpha_Br.editingFinished.connect(self.set_alpha_Br) self.lf_Wlam.editingFinished.connect(self.set_Wlam) # Economical self.lf_cost_unit.editingFinished.connect(self.set_cost_unit) # Thermics self.lf_Cp.editingFinished.connect(self.set_Cp) self.lf_alpha.editingFinished.connect(self.set_alpha) self.lf_L.editingFinished.connect(self.set_lambda) self.lf_Lx.editingFinished.connect(self.set_lambda_x) self.lf_Ly.editingFinished.connect(self.set_lambda_y) self.lf_Lz.editingFinished.connect(self.set_lambda_z) # Mechanics self.lf_rho_meca.editingFinished.connect(self.set_rho_meca) self.lf_E.editingFinished.connect(self.set_E) self.lf_Ex.editingFinished.connect(self.set_Ex) self.lf_Ey.editingFinished.connect(self.set_Ey) self.lf_Ez.editingFinished.connect(self.set_Ez) self.lf_G.editingFinished.connect(self.set_G) self.lf_Gxy.editingFinished.connect(self.set_Gxy) self.lf_Gxz.editingFinished.connect(self.set_Gxz) self.lf_Gyz.editingFinished.connect(self.set_Gyz) self.lf_nu.editingFinished.connect(self.set_nu) self.lf_nu_xy.editingFinished.connect(self.set_nu_xy) self.lf_nu_xz.editingFinished.connect(self.set_nu_xz) self.lf_nu_yz.editingFinished.connect(self.set_nu_yz)
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: tmp = self.mat_type.__str__().replace(linesep, linesep + "\t").rstrip("\t") Frame_str += "mat_type = " + tmp else: Frame_str += "mat_type = None" + linesep + linesep 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 Shaft(FrozenClass): """machine shaft""" VERSION = 1 # Check ImportError to remove unnecessary dependencies in unused method # cf Methods.Machine.Shaft.build_geometry if isinstance(build_geometry, ImportError): build_geometry = property(fget=lambda x: raise_( ImportError("Can't use Shaft method build_geometry: " + str( build_geometry)))) else: build_geometry = build_geometry # cf Methods.Machine.Shaft.comp_mass if isinstance(comp_mass, ImportError): comp_mass = property(fget=lambda x: raise_( ImportError("Can't use Shaft method comp_mass: " + str(comp_mass))) ) else: comp_mass = comp_mass # cf Methods.Machine.Shaft.plot if isinstance(plot, ImportError): plot = property(fget=lambda x: raise_( ImportError("Can't use Shaft method plot: " + str(plot)))) else: 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 if self.mat_type is not None: Shaft_str += ("mat_type = " + str(self.mat_type.as_dict()) + linesep + linesep) else: Shaft_str += "mat_type = None" + 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""", )
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__() + linesep LamSquirrelCage_str += "Hscr = " + str(self.Hscr) + linesep LamSquirrelCage_str += "Lscr = " + str(self.Lscr) + linesep if self.ring_mat is not None: LamSquirrelCage_str += ("ring_mat = " + str(self.ring_mat.as_dict()) + linesep + linesep) else: LamSquirrelCage_str += "ring_mat = None" 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""", )
def __init__( self, H0=0.003, W0=0.003, H1=0, W1=0.013, H2=0.02, W2=0.01, H3=0.01, W3=0.01, H4=0, W4=0.01, magnet_0=-1, magnet_1=-1, 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 magnet_0 == -1: magnet_0 = Magnet() if magnet_1 == -1: magnet_1 = Magnet() if mat_void == -1: mat_void = Material() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "H0", "W0", "H1", "W1", "H2", "W2", "H3", "W3", "H4", "W4", "magnet_0", "magnet_1", "Zh", "mat_void", ], ) # Overwrite default value with init_dict content if "H0" in list(init_dict.keys()): H0 = init_dict["H0"] if "W0" in list(init_dict.keys()): W0 = init_dict["W0"] if "H1" in list(init_dict.keys()): H1 = init_dict["H1"] if "W1" in list(init_dict.keys()): W1 = init_dict["W1"] if "H2" in list(init_dict.keys()): H2 = init_dict["H2"] if "W2" in list(init_dict.keys()): W2 = init_dict["W2"] if "H3" in list(init_dict.keys()): H3 = init_dict["H3"] if "W3" in list(init_dict.keys()): W3 = init_dict["W3"] if "H4" in list(init_dict.keys()): H4 = init_dict["H4"] if "W4" in list(init_dict.keys()): W4 = init_dict["W4"] if "magnet_0" in list(init_dict.keys()): magnet_0 = init_dict["magnet_0"] if "magnet_1" in list(init_dict.keys()): magnet_1 = init_dict["magnet_1"] if "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.H0 = H0 self.W0 = W0 self.H1 = H1 self.W1 = W1 self.H2 = H2 self.W2 = W2 self.H3 = H3 self.W3 = W3 self.H4 = H4 self.W4 = W4 # magnet_0 can be None, a Magnet object or a dict if isinstance(magnet_0, dict): # Check that the type is correct (including daughter) class_name = magnet_0.get("__class__") if class_name not in [ "Magnet", "MagnetFlat", "MagnetPolar", "MagnetType10", "MagnetType11", "MagnetType12", "MagnetType13", "MagnetType14", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for magnet_0") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.magnet_0 = class_obj(init_dict=magnet_0) else: self.magnet_0 = magnet_0 # magnet_1 can be None, a Magnet object or a dict if isinstance(magnet_1, dict): # Check that the type is correct (including daughter) class_name = magnet_1.get("__class__") if class_name not in [ "Magnet", "MagnetFlat", "MagnetPolar", "MagnetType10", "MagnetType11", "MagnetType12", "MagnetType13", "MagnetType14", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for magnet_1") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.magnet_1 = class_obj(init_dict=magnet_1) else: self.magnet_1 = magnet_1 # Call HoleMag init super(HoleM50, self).__init__(Zh=Zh, mat_void=mat_void)
def __init__( self, 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(), 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 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, [ "slot", "L1", "mat_type", "Nrvd", "Wrvd", "Kf1", "is_internal", "Rint", "Rext", "is_stator", "axial_vent", ], ) # Overwrite default value with init_dict content 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"] # Initialisation by argument # slot can be None, a Slot object or a dict if isinstance(slot, dict): # Call the correct constructor according to the dict load_dict = { "SlotMFlat": SlotMFlat, "SlotMPolar": SlotMPolar, "SlotW10": SlotW10, "SlotW11": SlotW11, "SlotW12": SlotW12, "SlotW13": SlotW13, "SlotW14": SlotW14, "SlotW15": SlotW15, "SlotW16": SlotW16, "SlotW21": SlotW21, "SlotW22": SlotW22, "SlotW23": SlotW23, "SlotW24": SlotW24, "SlotW25": SlotW25, "SlotW26": SlotW26, "SlotW27": SlotW27, "SlotW28": SlotW28, "SlotW29": SlotW29, "SlotW60": SlotW60, "SlotW61": SlotW61, "Slot": Slot, } obj_class = slot.get("__class__") if obj_class is None: self.slot = Slot(init_dict=slot) elif obj_class in list(load_dict.keys()): self.slot = load_dict[obj_class](init_dict=slot) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError("Unknow class name in init_dict for slot") else: self.slot = slot # Call Lamination init super(LamSlot, self).__init__( 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, )