def __init__( self, Ksfill=None, winding=-1, slot=-1, L1=0.35, mat_type=-1, Nrvd=0, Wrvd=0, Kf1=0.95, is_internal=True, Rint=0, Rext=1, is_stator=True, axial_vent=list(), notch=list(), init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if winding == -1: winding = Winding() if slot == -1: slot = Slot() if mat_type == -1: mat_type = Material() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "Ksfill", "winding", "slot", "L1", "mat_type", "Nrvd", "Wrvd", "Kf1", "is_internal", "Rint", "Rext", "is_stator", "axial_vent", "notch", ], ) # Overwrite default value with init_dict content if "Ksfill" in list(init_dict.keys()): Ksfill = init_dict["Ksfill"] if "winding" in list(init_dict.keys()): winding = init_dict["winding"] if "slot" in list(init_dict.keys()): slot = init_dict["slot"] if "L1" in list(init_dict.keys()): L1 = init_dict["L1"] if "mat_type" in list(init_dict.keys()): mat_type = init_dict["mat_type"] if "Nrvd" in list(init_dict.keys()): Nrvd = init_dict["Nrvd"] if "Wrvd" in list(init_dict.keys()): Wrvd = init_dict["Wrvd"] if "Kf1" in list(init_dict.keys()): Kf1 = init_dict["Kf1"] if "is_internal" in list(init_dict.keys()): is_internal = init_dict["is_internal"] if "Rint" in list(init_dict.keys()): Rint = init_dict["Rint"] if "Rext" in list(init_dict.keys()): Rext = init_dict["Rext"] if "is_stator" in list(init_dict.keys()): is_stator = init_dict["is_stator"] if "axial_vent" in list(init_dict.keys()): axial_vent = init_dict["axial_vent"] if "notch" in list(init_dict.keys()): notch = init_dict["notch"] # Initialisation by argument self.Ksfill = Ksfill # winding can be None, a Winding object or a dict if isinstance(winding, dict): # Check that the type is correct (including daughter) class_name = winding.get("__class__") if class_name not in [ "Winding", "WindingCW1L", "WindingCW2LR", "WindingCW2LT", "WindingDW1L", "WindingDW2L", "WindingSC", "WindingUD", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for winding") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.winding = class_obj(init_dict=winding) else: self.winding = winding # Call LamSlot init super(LamSlotWind, self).__init__( slot=slot, L1=L1, mat_type=mat_type, Nrvd=Nrvd, Wrvd=Wrvd, Kf1=Kf1, is_internal=is_internal, Rint=Rint, Rext=Rext, is_stator=is_stator, axial_vent=axial_vent, notch=notch, )
def __init__(self, notch_shape=list(), init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["notch_shape"]) # Overwrite default value with init_dict content if "notch_shape" in list(init_dict.keys()): notch_shape = init_dict["notch_shape"] # Initialisation by argument self.parent = None # notch_shape can be None or a list of Slot object self.notch_shape = list() if type(notch_shape) is list: for obj in notch_shape: if obj is None: # Default value self.notch_shape.append(Slot()) elif isinstance(obj, dict): # Check that the type is correct (including daughter) class_name = obj.get("__class__") if class_name not in [ "Slot", "Slot19", "SlotMFlat", "SlotMPolar", "SlotMag", "SlotUD", "SlotW10", "SlotW11", "SlotW12", "SlotW13", "SlotW14", "SlotW15", "SlotW16", "SlotW21", "SlotW22", "SlotW23", "SlotW24", "SlotW25", "SlotW26", "SlotW27", "SlotW28", "SlotW29", "SlotW60", "SlotW61", "SlotWind", ]: raise InitUnKnowClassError( "Unknow class name " + class_name + " in init_dict for notch_shape" ) # Dynamic import to call the correct constructor module = __import__( "pyleecan.Classes." + class_name, fromlist=[class_name] ) class_obj = getattr(module, class_name) self.notch_shape.append(class_obj(init_dict=obj)) else: self.notch_shape.append(obj) elif notch_shape is None: self.notch_shape = list() else: self.notch_shape = notch_shape # The class is frozen, for now it's impossible to add new properties self._freeze()
def __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 # Call LamSlot init super(LamSlotMag, self).__init__( slot=slot, L1=L1, mat_type=mat_type, Nrvd=Nrvd, Wrvd=Wrvd, Kf1=Kf1, is_internal=is_internal, Rint=Rint, Rext=Rext, is_stator=is_stator, axial_vent=axial_vent, notch=notch, )
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, slot_list=list(), alpha=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 mat_type == -1: mat_type = Material() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "slot_list", "alpha", "L1", "mat_type", "Nrvd", "Wrvd", "Kf1", "is_internal", "Rint", "Rext", "is_stator", "axial_vent", "notch", ], ) # Overwrite default value with init_dict content if "slot_list" in list(init_dict.keys()): slot_list = init_dict["slot_list"] if "alpha" in list(init_dict.keys()): alpha = init_dict["alpha"] 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_list can be None or a list of Slot object self.slot_list = list() if type(slot_list) is list: for obj in slot_list: if obj is None: # Default value self.slot_list.append(Slot()) elif isinstance(obj, dict): # Check that the type is correct (including daughter) class_name = obj.get("__class__") if class_name not in [ "Slot", "Slot19", "SlotMFlat", "SlotMPolar", "SlotMag", "SlotUD", "SlotW10", "SlotW11", "SlotW12", "SlotW13", "SlotW14", "SlotW15", "SlotW16", "SlotW21", "SlotW22", "SlotW23", "SlotW24", "SlotW25", "SlotW26", "SlotW27", "SlotW28", "SlotW29", "SlotW60", "SlotW61", "SlotWind", ]: raise InitUnKnowClassError( "Unknow class name " + class_name + " in init_dict for slot_list") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.slot_list.append(class_obj(init_dict=obj)) else: self.slot_list.append(obj) elif slot_list is None: self.slot_list = list() else: self.slot_list = slot_list # alpha can be None, a ndarray or a list set_array(self, "alpha", alpha) # Call Lamination init super(LamSlotMulti, 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, alpha=0, notch_shape=-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 notch_shape == -1: notch_shape = Slot() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["alpha", "notch_shape"]) # Overwrite default value with init_dict content if "alpha" in list(init_dict.keys()): alpha = init_dict["alpha"] if "notch_shape" in list(init_dict.keys()): notch_shape = init_dict["notch_shape"] # Initialisation by argument self.alpha = alpha # notch_shape can be None, a Slot object or a dict if isinstance(notch_shape, dict): # Check that the type is correct (including daughter) class_name = notch_shape.get("__class__") if class_name not in [ "Slot", "Slot19", "SlotMFlat", "SlotMPolar", "SlotMag", "SlotUD", "SlotW10", "SlotW11", "SlotW12", "SlotW13", "SlotW14", "SlotW15", "SlotW16", "SlotW21", "SlotW22", "SlotW23", "SlotW24", "SlotW25", "SlotW26", "SlotW27", "SlotW28", "SlotW29", "SlotW60", "SlotW61", "SlotWind", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for notch_shape") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.notch_shape = class_obj(init_dict=notch_shape) else: self.notch_shape = notch_shape # Call Notch init super(NotchEvenDist, self).__init__()
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, )
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, )
class LamSlot(Lamination): """Lamination with empty Slot""" VERSION = 1 # cf Methods.Machine.LamSlot.build_geometry build_geometry = build_geometry # cf Methods.Machine.LamSlot.check check = check # cf Methods.Machine.LamSlot.comp_height_yoke comp_height_yoke = comp_height_yoke # cf Methods.Machine.LamSlot.comp_radius_mec comp_radius_mec = comp_radius_mec # cf Methods.Machine.LamSlot.comp_surfaces comp_surfaces = comp_surfaces # cf Methods.Machine.LamSlot.get_pole_pair_number get_pole_pair_number = get_pole_pair_number # cf Methods.Machine.LamSlot.plot plot = plot # save method is available in all object save = save 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, ) # The class is frozen (in Lamination init), for now it's impossible to # add new properties def __str__(self): """Convert this objet in a readeable string (for print)""" LamSlot_str = "" # Get the properties inherited from Lamination LamSlot_str += super(LamSlot, self).__str__() + linesep LamSlot_str += "slot = " + str(self.slot.as_dict()) return LamSlot_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False # Check the properties inherited from Lamination if not super(LamSlot, self).__eq__(other): return False if other.slot != self.slot: 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 Lamination LamSlot_dict = super(LamSlot, self).as_dict() if self.slot is None: LamSlot_dict["slot"] = None else: LamSlot_dict["slot"] = self.slot.as_dict() # The class name is added to the dict fordeserialisation purpose # Overwrite the mother class name LamSlot_dict["__class__"] = "LamSlot" return LamSlot_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" if self.slot is not None: self.slot._set_None() # Set to None the properties inherited from Lamination super(LamSlot, self)._set_None() def _get_slot(self): """getter of slot""" return self._slot def _set_slot(self, value): """setter of slot""" check_var("slot", value, "Slot") self._slot = value if self._slot is not None: self._slot.parent = self # lamination Slot # Type : Slot slot = property(fget=_get_slot, fset=_set_slot, doc=u"""lamination Slot""")