def __init__( self, mag=-1, struct=-1, name="", desc="", machine=-1, input=-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 mag == -1: mag = Magnetics() if struct == -1: struct = Structural() if machine == -1: machine = Machine() if input == -1: input = Input() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, ["mag", "struct", "name", "desc", "machine", "input"] ) # Overwrite default value with init_dict content if "mag" in list(init_dict.keys()): mag = init_dict["mag"] if "struct" in list(init_dict.keys()): struct = init_dict["struct"] if "name" in list(init_dict.keys()): name = init_dict["name"] if "desc" in list(init_dict.keys()): desc = init_dict["desc"] if "machine" in list(init_dict.keys()): machine = init_dict["machine"] if "input" in list(init_dict.keys()): input = init_dict["input"] # Initialisation by argument # mag can be None, a Magnetics object or a dict if isinstance(mag, dict): # Check that the type is correct (including daughter) class_name = mag.get("__class__") if class_name not in ["Magnetics", "MagFEMM"]: raise InitUnKnowClassError( "Unknow class name " + class_name + " in init_dict for mag" ) # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.mag = class_obj(init_dict=mag) else: self.mag = mag # struct can be None, a Structural object or a dict if isinstance(struct, dict): self.struct = Structural(init_dict=struct) else: self.struct = struct # Call Simulation init super(Simu1, self).__init__(name=name, desc=desc, machine=machine, input=input)
def __init__( self, mag=-1, struct=-1, name="", desc="", machine=-1, input=-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 mag == -1: mag = Magnetics() if struct == -1: struct = Structural() if machine == -1: machine = Machine() if input == -1: input = Input() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, ["mag", "struct", "name", "desc", "machine", "input"] ) # Overwrite default value with init_dict content if "mag" in list(init_dict.keys()): mag = init_dict["mag"] if "struct" in list(init_dict.keys()): struct = init_dict["struct"] if "name" in list(init_dict.keys()): name = init_dict["name"] if "desc" in list(init_dict.keys()): desc = init_dict["desc"] if "machine" in list(init_dict.keys()): machine = init_dict["machine"] if "input" in list(init_dict.keys()): input = init_dict["input"] # Initialisation by argument # mag can be None, a Magnetics object or a dict if isinstance(mag, dict): # Call the correct constructor according to the dict load_dict = {"MagFEMM": MagFEMM, "Magnetics": Magnetics} obj_class = mag.get("__class__") if obj_class is None: self.mag = Magnetics(init_dict=mag) elif obj_class in list(load_dict.keys()): self.mag = load_dict[obj_class](init_dict=mag) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError("Unknow class name in init_dict for mag") else: self.mag = mag # struct can be None, a Structural object or a dict if isinstance(struct, dict): self.struct = Structural(init_dict=struct) else: self.struct = struct # Call Simulation init super(Simu1, self).__init__(name=name, desc=desc, machine=machine, input=input)
def __init__(self, line_list=list(), point_ref=0, label="", init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["line_list", "point_ref", "label"]) # Overwrite default value with init_dict content if "line_list" in list(init_dict.keys()): line_list = init_dict["line_list"] if "point_ref" in list(init_dict.keys()): point_ref = init_dict["point_ref"] if "label" in list(init_dict.keys()): label = init_dict["label"] # Initialisation by argument # line_list can be None or a list of Line object self.line_list = list() if type(line_list) is list: for obj in line_list: if obj is None: # Default value self.line_list.append(Line()) elif isinstance(obj, dict): # Call the correct constructor according to the dict load_dict = { "Segment": Segment, "Arc1": Arc1, "Arc2": Arc2, "Arc3": Arc3, "Arc": Arc, "Line": Line, } obj_class = obj.get("__class__") if obj_class is None: self.line_list.append(Line(init_dict=obj)) elif obj_class in list(load_dict.keys()): self.line_list.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 line_list") else: self.line_list.append(obj) elif line_list is None: self.line_list = list() else: self.line_list = line_list # Call Surface init super(SurfLine, self).__init__(point_ref=point_ref, label=label)
def __init__( self, mesh=None, parent_elem=None, parent_node=None, group_number=None, init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if mesh == -1: mesh = Mesh() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, ["mesh", "parent_elem", "parent_node", "group_number"]) # Overwrite default value with init_dict content if "mesh" in list(init_dict.keys()): mesh = init_dict["mesh"] if "parent_elem" in list(init_dict.keys()): parent_elem = init_dict["parent_elem"] if "parent_node" in list(init_dict.keys()): parent_node = init_dict["parent_node"] if "group_number" in list(init_dict.keys()): group_number = init_dict["group_number"] # Initialisation by argument self.parent = None # mesh can be None, a Mesh object or a dict if isinstance(mesh, dict): # Check that the type is correct (including daughter) class_name = mesh.get("__class__") if class_name not in ["Mesh", "MeshFEMM", "MeshMat", "MeshForce"]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for mesh") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.mesh = class_obj(init_dict=mesh) else: self.mesh = mesh # parent_elem can be None, a ndarray or a list set_array(self, "parent_elem", parent_elem) # parent_node can be None, a ndarray or a list set_array(self, "parent_node", parent_node) # group_number can be None, a ndarray or a list set_array(self, "group_number", group_number) # The class is frozen, for now it's impossible to add new properties self._freeze()
def __init__(self, line_list=list(), point_ref=0, label="", init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["line_list", "point_ref", "label"]) # Overwrite default value with init_dict content if "line_list" in list(init_dict.keys()): line_list = init_dict["line_list"] if "point_ref" in list(init_dict.keys()): point_ref = init_dict["point_ref"] if "label" in list(init_dict.keys()): label = init_dict["label"] # Initialisation by argument # line_list can be None or a list of Line object self.line_list = list() if type(line_list) is list: for obj in line_list: if obj is None: # Default value self.line_list.append(Line()) elif isinstance(obj, dict): # Check that the type is correct (including daughter) class_name = obj.get("__class__") if class_name not in [ "Line", "Segment", "Arc1", "Arc2", "Arc3", "Arc", ]: raise InitUnKnowClassError( "Unknow class name " + class_name + " in init_dict for line_list") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.line_list.append(class_obj(init_dict=obj)) else: self.line_list.append(obj) elif line_list is None: self.line_list = list() else: self.line_list = line_list # Call Surface init super(SurfLine, self).__init__(point_ref=point_ref, label=label)
def __init__(self, geo=-1, elec=-1, simu=-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 geo == -1: geo = OutGeo() if elec == -1: elec = OutElec() if simu == -1: simu = Simulation() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["geo", "elec", "simu"]) # Overwrite default value with init_dict content if "geo" in list(init_dict.keys()): geo = init_dict["geo"] if "elec" in list(init_dict.keys()): elec = init_dict["elec"] if "simu" in list(init_dict.keys()): simu = init_dict["simu"] # Initialisation by argument self.parent = None # geo can be None, a OutGeo object or a dict if isinstance(geo, dict): self.geo = OutGeo(init_dict=geo) else: self.geo = geo # elec can be None, a OutElec object or a dict if isinstance(elec, dict): self.elec = OutElec(init_dict=elec) else: self.elec = elec # simu can be None, a Simulation object or a dict if isinstance(simu, dict): # Call the correct constructor according to the dict load_dict = {"Simu1": Simu1, "Simulation": Simulation} obj_class = simu.get("__class__") if obj_class is None: self.simu = Simulation(init_dict=simu) elif obj_class in list(load_dict.keys()): self.simu = load_dict[obj_class](init_dict=simu) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for simu") else: self.simu = simu # The class is frozen, for now it's impossible to add new properties self._freeze()
def __init__(self, name=None, mesh=None, solution=None, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if mesh == -1: mesh = Mesh() if solution == -1: solution = Solution() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["name", "mesh", "solution"]) # Overwrite default value with init_dict content if "name" in list(init_dict.keys()): name = init_dict["name"] if "mesh" in list(init_dict.keys()): mesh = init_dict["mesh"] if "solution" in list(init_dict.keys()): solution = init_dict["solution"] # Initialisation by argument self.parent = None self.name = name # mesh can be None, a Mesh object or a dict if isinstance(mesh, dict): self.mesh = Mesh(init_dict=mesh) else: self.mesh = mesh # solution can be None, a Solution object or a dict if isinstance(solution, dict): # Check that the type is correct (including daughter) class_name = solution.get("__class__") if class_name not in ["Solution", "SolutionFEMM"]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for solution") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.solution = class_obj(init_dict=solution) else: self.solution = solution # The class is frozen, for now it's impossible to add new properties self._freeze()
def __init__(self, Wlam=0.0005, BH_curve=-1, mur_lin=1, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if BH_curve == -1: BH_curve = ImportMatrix() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["Wlam", "BH_curve", "mur_lin"]) # Overwrite default value with init_dict content if "Wlam" in list(init_dict.keys()): Wlam = init_dict["Wlam"] if "BH_curve" in list(init_dict.keys()): BH_curve = init_dict["BH_curve"] if "mur_lin" in list(init_dict.keys()): mur_lin = init_dict["mur_lin"] # Initialisation by argument self.Wlam = Wlam # BH_curve can be None, a ImportMatrix object or a dict if isinstance(BH_curve, dict): # Call the correct constructor according to the dict load_dict = { "ImportMatrixVal": ImportMatrixVal, "ImportMatrixXls": ImportMatrixXls, "ImportGenVectSin": ImportGenVectSin, "ImportGenMatrixSin": ImportGenMatrixSin, "ImportGenVectLin": ImportGenVectLin, "ImportMatrix": ImportMatrix, } obj_class = BH_curve.get("__class__") if obj_class is None: self.BH_curve = ImportMatrix(init_dict=BH_curve) elif obj_class in list(load_dict.keys()): self.BH_curve = load_dict[obj_class](init_dict=BH_curve) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for BH_curve") else: self.BH_curve = BH_curve # Call MatMagnetics init super(MatLamination, self).__init__(mur_lin=mur_lin)
def __init__(self, Wlam=0.0005, BH_curve=-1, mur_lin=1, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if BH_curve == -1: BH_curve = ImportMatrix() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["Wlam", "BH_curve", "mur_lin"]) # Overwrite default value with init_dict content if "Wlam" in list(init_dict.keys()): Wlam = init_dict["Wlam"] if "BH_curve" in list(init_dict.keys()): BH_curve = init_dict["BH_curve"] if "mur_lin" in list(init_dict.keys()): mur_lin = init_dict["mur_lin"] # Initialisation by argument self.Wlam = Wlam # BH_curve can be None, a ImportMatrix object or a dict if isinstance(BH_curve, dict): # Check that the type is correct (including daughter) class_name = BH_curve.get("__class__") if class_name not in [ "ImportMatrix", "ImportGenMatrixSin", "ImportGenVectLin", "ImportGenVectSin", "ImportMatrixVal", "ImportMatrixXls", ]: raise InitUnKnowClassError( "Unknow class name " + class_name + " in init_dict for BH_curve" ) # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.BH_curve = class_obj(init_dict=BH_curve) else: self.BH_curve = BH_curve # Call MatMagnetics init super(MatLamination, self).__init__(mur_lin=mur_lin)
def __init__(self, force=-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 force == -1: force = Force() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["force"]) # Overwrite default value with init_dict content if "force" in list(init_dict.keys()): force = init_dict["force"] # Initialisation by argument self.parent = None # force can be None, a Force object or a dict if isinstance(force, dict): # Call the correct constructor according to the dict load_dict = {"ForceMT": ForceMT, "Force": Force} obj_class = force.get("__class__") if obj_class is None: self.force = Force(init_dict=force) elif obj_class in list(load_dict.keys()): self.force = load_dict[obj_class](init_dict=force) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for force") else: self.force = force # The class is frozen, for now it's impossible to add new properties self._freeze()
def __init__(self, force=-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 force == -1: force = Force() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["force"]) # Overwrite default value with init_dict content if "force" in list(init_dict.keys()): force = init_dict["force"] # Initialisation by argument self.parent = None # force can be None, a Force object or a dict if isinstance(force, dict): # Check that the type is correct (including daughter) class_name = force.get("__class__") if class_name not in ["Force", "ForceMT"]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for force") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.force = class_obj(init_dict=force) else: self.force = force # The class is frozen, for now it's impossible to add new properties self._freeze()
def __init__(self, W0=0.314, H0=0, magnet=list(), W3=0, Zs=36, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["W0", "H0", "magnet", "W3", "Zs"]) # Overwrite default value with init_dict content if "W0" in list(init_dict.keys()): W0 = init_dict["W0"] if "H0" in list(init_dict.keys()): H0 = init_dict["H0"] if "magnet" in list(init_dict.keys()): magnet = init_dict["magnet"] if "W3" in list(init_dict.keys()): W3 = init_dict["W3"] if "Zs" in list(init_dict.keys()): Zs = init_dict["Zs"] # Initialisation by argument self.W0 = W0 self.H0 = H0 # magnet can be None or a list of MagnetPolar object self.magnet = list() if type(magnet) is list: for obj in magnet: if obj is None: # Default value self.magnet.append(MagnetPolar()) elif isinstance(obj, dict): # Call the correct constructor according to the dict load_dict = { "MagnetType11": MagnetType11, "MagnetType14": MagnetType14, "MagnetPolar": MagnetPolar, } obj_class = obj.get("__class__") if obj_class is None: self.magnet.append(MagnetPolar(init_dict=obj)) elif obj_class in list(load_dict.keys()): self.magnet.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 magnet") else: self.magnet.append(obj) elif magnet is None: self.magnet = list() else: self.magnet = magnet # Call SlotMag init super(SlotMPolar, self).__init__(W3=W3, Zs=Zs)
def __init__( self, name="M400-50A", is_isotropic=False, elec=-1, mag=-1, struct=-1, HT=-1, eco=-1, desc="Lamination M400-50A", path="", 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 elec == -1: elec = MatElectrical() if mag == -1: mag = MatMagnetics() if struct == -1: struct = MatStructural() if HT == -1: HT = MatHT() if eco == -1: eco = MatEconomical() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "name", "is_isotropic", "elec", "mag", "struct", "HT", "eco", "desc", "path", ], ) # Overwrite default value with init_dict content if "name" in list(init_dict.keys()): name = init_dict["name"] if "is_isotropic" in list(init_dict.keys()): is_isotropic = init_dict["is_isotropic"] if "elec" in list(init_dict.keys()): elec = init_dict["elec"] if "mag" in list(init_dict.keys()): mag = init_dict["mag"] if "struct" in list(init_dict.keys()): struct = init_dict["struct"] if "HT" in list(init_dict.keys()): HT = init_dict["HT"] if "eco" in list(init_dict.keys()): eco = init_dict["eco"] if "desc" in list(init_dict.keys()): desc = init_dict["desc"] if "path" in list(init_dict.keys()): path = init_dict["path"] # Initialisation by argument self.parent = None self.name = name self.is_isotropic = is_isotropic # elec can be None, a MatElectrical object or a dict if isinstance(elec, dict): self.elec = MatElectrical(init_dict=elec) else: self.elec = elec # mag can be None, a MatMagnetics object or a dict if isinstance(mag, dict): # Check that the type is correct (including daughter) class_name = mag.get("__class__") if class_name not in [ "MatMagnetics", "MatLamination", "MatMagnet" ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for mag") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.mag = class_obj(init_dict=mag) else: self.mag = mag # struct can be None, a MatStructural object or a dict if isinstance(struct, dict): self.struct = MatStructural(init_dict=struct) else: self.struct = struct # HT can be None, a MatHT object or a dict if isinstance(HT, dict): self.HT = MatHT(init_dict=HT) else: self.HT = HT # eco can be None, a MatEconomical object or a dict if isinstance(eco, dict): self.eco = MatEconomical(init_dict=eco) else: self.eco = eco self.desc = desc self.path = path # The class is frozen, for now it's impossible to add new properties self._freeze()
def __init__( self, time=None, angle=None, Is=None, Ir=None, angle_rotor=None, Nr=None, rot_dir=-1, angle_rotor_initial=0, init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if time == -1: time = Import() if angle == -1: angle = Import() if Is == -1: Is = Import() if Ir == -1: Ir = Import() if angle_rotor == -1: angle_rotor = Import() if Nr == -1: Nr = Import() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "time", "angle", "Is", "Ir", "angle_rotor", "Nr", "rot_dir", "angle_rotor_initial", ], ) # Overwrite default value with init_dict content if "time" in list(init_dict.keys()): time = init_dict["time"] if "angle" in list(init_dict.keys()): angle = init_dict["angle"] if "Is" in list(init_dict.keys()): Is = init_dict["Is"] if "Ir" in list(init_dict.keys()): Ir = init_dict["Ir"] if "angle_rotor" in list(init_dict.keys()): angle_rotor = init_dict["angle_rotor"] if "Nr" in list(init_dict.keys()): Nr = init_dict["Nr"] if "rot_dir" in list(init_dict.keys()): rot_dir = init_dict["rot_dir"] if "angle_rotor_initial" in list(init_dict.keys()): angle_rotor_initial = init_dict["angle_rotor_initial"] # Initialisation by argument # time can be None, a Import object or a dict if isinstance(time, dict): # Check that the type is correct (including daughter) class_name = time.get("__class__") if class_name not in [ "Import", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", "ImportGenVectSin", "ImportGenMatrixSin", "ImportGenVectLin", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for time") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.time = class_obj(init_dict=time) else: self.time = time # angle can be None, a Import object or a dict if isinstance(angle, dict): # Check that the type is correct (including daughter) class_name = angle.get("__class__") if class_name not in [ "Import", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", "ImportGenVectSin", "ImportGenMatrixSin", "ImportGenVectLin", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for angle") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.angle = class_obj(init_dict=angle) else: self.angle = angle # Is can be None, a Import object or a dict if isinstance(Is, dict): # Check that the type is correct (including daughter) class_name = Is.get("__class__") if class_name not in [ "Import", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", "ImportGenVectSin", "ImportGenMatrixSin", "ImportGenVectLin", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for Is") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.Is = class_obj(init_dict=Is) else: self.Is = Is # Ir can be None, a Import object or a dict if isinstance(Ir, dict): # Check that the type is correct (including daughter) class_name = Ir.get("__class__") if class_name not in [ "Import", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", "ImportGenVectSin", "ImportGenMatrixSin", "ImportGenVectLin", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for Ir") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.Ir = class_obj(init_dict=Ir) else: self.Ir = Ir # angle_rotor can be None, a Import object or a dict if isinstance(angle_rotor, dict): # Check that the type is correct (including daughter) class_name = angle_rotor.get("__class__") if class_name not in [ "Import", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", "ImportGenVectSin", "ImportGenMatrixSin", "ImportGenVectLin", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for angle_rotor") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.angle_rotor = class_obj(init_dict=angle_rotor) else: self.angle_rotor = angle_rotor # Nr can be None, a Import object or a dict if isinstance(Nr, dict): # Check that the type is correct (including daughter) class_name = Nr.get("__class__") if class_name not in [ "Import", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", "ImportGenVectSin", "ImportGenMatrixSin", "ImportGenVectLin", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for Nr") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.Nr = class_obj(init_dict=Nr) else: self.Nr = Nr self.rot_dir = rot_dir self.angle_rotor_initial = angle_rotor_initial # Call Input init super(InCurrent, self).__init__()
def __init__( self, time=None, angle=None, Is=None, Ir=None, angle_rotor=None, Nr=None, rot_dir=-1, angle_rotor_initial=0, init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if time == -1: time = Import() if angle == -1: angle = Import() if Is == -1: Is = Import() if Ir == -1: Ir = Import() if angle_rotor == -1: angle_rotor = Import() if Nr == -1: Nr = Import() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "time", "angle", "Is", "Ir", "angle_rotor", "Nr", "rot_dir", "angle_rotor_initial", ], ) # Overwrite default value with init_dict content if "time" in list(init_dict.keys()): time = init_dict["time"] if "angle" in list(init_dict.keys()): angle = init_dict["angle"] if "Is" in list(init_dict.keys()): Is = init_dict["Is"] if "Ir" in list(init_dict.keys()): Ir = init_dict["Ir"] if "angle_rotor" in list(init_dict.keys()): angle_rotor = init_dict["angle_rotor"] if "Nr" in list(init_dict.keys()): Nr = init_dict["Nr"] if "rot_dir" in list(init_dict.keys()): rot_dir = init_dict["rot_dir"] if "angle_rotor_initial" in list(init_dict.keys()): angle_rotor_initial = init_dict["angle_rotor_initial"] # Initialisation by argument # time can be None, a Import object or a dict if isinstance(time, dict): # Call the correct constructor according to the dict load_dict = { "ImportMatlab": ImportMatlab, "ImportMatrix": ImportMatrix, "ImportMatrixVal": ImportMatrixVal, "ImportMatrixXls": ImportMatrixXls, "ImportGenVectSin": ImportGenVectSin, "ImportGenMatrixSin": ImportGenMatrixSin, "ImportGenVectLin": ImportGenVectLin, "Import": Import, } obj_class = time.get("__class__") if obj_class is None: self.time = Import(init_dict=time) elif obj_class in list(load_dict.keys()): self.time = load_dict[obj_class](init_dict=time) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError("Unknow class name in init_dict for time") else: self.time = time # angle can be None, a Import object or a dict if isinstance(angle, dict): # Call the correct constructor according to the dict load_dict = { "ImportMatlab": ImportMatlab, "ImportMatrix": ImportMatrix, "ImportMatrixVal": ImportMatrixVal, "ImportMatrixXls": ImportMatrixXls, "ImportGenVectSin": ImportGenVectSin, "ImportGenMatrixSin": ImportGenMatrixSin, "ImportGenVectLin": ImportGenVectLin, "Import": Import, } obj_class = angle.get("__class__") if obj_class is None: self.angle = Import(init_dict=angle) elif obj_class in list(load_dict.keys()): self.angle = load_dict[obj_class](init_dict=angle) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError("Unknow class name in init_dict for angle") else: self.angle = angle # Is can be None, a Import object or a dict if isinstance(Is, dict): # Call the correct constructor according to the dict load_dict = { "ImportMatlab": ImportMatlab, "ImportMatrix": ImportMatrix, "ImportMatrixVal": ImportMatrixVal, "ImportMatrixXls": ImportMatrixXls, "ImportGenVectSin": ImportGenVectSin, "ImportGenMatrixSin": ImportGenMatrixSin, "ImportGenVectLin": ImportGenVectLin, "Import": Import, } obj_class = Is.get("__class__") if obj_class is None: self.Is = Import(init_dict=Is) elif obj_class in list(load_dict.keys()): self.Is = load_dict[obj_class](init_dict=Is) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError("Unknow class name in init_dict for Is") else: self.Is = Is # Ir can be None, a Import object or a dict if isinstance(Ir, dict): # Call the correct constructor according to the dict load_dict = { "ImportMatlab": ImportMatlab, "ImportMatrix": ImportMatrix, "ImportMatrixVal": ImportMatrixVal, "ImportMatrixXls": ImportMatrixXls, "ImportGenVectSin": ImportGenVectSin, "ImportGenMatrixSin": ImportGenMatrixSin, "ImportGenVectLin": ImportGenVectLin, "Import": Import, } obj_class = Ir.get("__class__") if obj_class is None: self.Ir = Import(init_dict=Ir) elif obj_class in list(load_dict.keys()): self.Ir = load_dict[obj_class](init_dict=Ir) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError("Unknow class name in init_dict for Ir") else: self.Ir = Ir # angle_rotor can be None, a Import object or a dict if isinstance(angle_rotor, dict): # Call the correct constructor according to the dict load_dict = { "ImportMatlab": ImportMatlab, "ImportMatrix": ImportMatrix, "ImportMatrixVal": ImportMatrixVal, "ImportMatrixXls": ImportMatrixXls, "ImportGenVectSin": ImportGenVectSin, "ImportGenMatrixSin": ImportGenMatrixSin, "ImportGenVectLin": ImportGenVectLin, "Import": Import, } obj_class = angle_rotor.get("__class__") if obj_class is None: self.angle_rotor = Import(init_dict=angle_rotor) elif obj_class in list(load_dict.keys()): self.angle_rotor = load_dict[obj_class](init_dict=angle_rotor) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for angle_rotor" ) else: self.angle_rotor = angle_rotor # Nr can be None, a Import object or a dict if isinstance(Nr, dict): # Call the correct constructor according to the dict load_dict = { "ImportMatlab": ImportMatlab, "ImportMatrix": ImportMatrix, "ImportMatrixVal": ImportMatrixVal, "ImportMatrixXls": ImportMatrixXls, "ImportGenVectSin": ImportGenVectSin, "ImportGenMatrixSin": ImportGenMatrixSin, "ImportGenVectLin": ImportGenVectLin, "Import": Import, } obj_class = Nr.get("__class__") if obj_class is None: self.Nr = Import(init_dict=Nr) elif obj_class in list(load_dict.keys()): self.Nr = load_dict[obj_class](init_dict=Nr) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError("Unknow class name in init_dict for Nr") else: self.Nr = Nr self.rot_dir = rot_dir self.angle_rotor_initial = angle_rotor_initial # Call Input init super(InCurrent, self).__init__()
def __init__( self, L1=0.35, mat_type=-1, Nrvd=0, Wrvd=0, Kf1=0.95, is_internal=True, Rint=0, Rext=1, is_stator=True, axial_vent=list(), notch=list(), init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if mat_type == -1: mat_type = Material() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "L1", "mat_type", "Nrvd", "Wrvd", "Kf1", "is_internal", "Rint", "Rext", "is_stator", "axial_vent", "notch", ], ) # Overwrite default value with init_dict content if "L1" in list(init_dict.keys()): L1 = init_dict["L1"] if "mat_type" in list(init_dict.keys()): mat_type = init_dict["mat_type"] if "Nrvd" in list(init_dict.keys()): Nrvd = init_dict["Nrvd"] if "Wrvd" in list(init_dict.keys()): Wrvd = init_dict["Wrvd"] if "Kf1" in list(init_dict.keys()): Kf1 = init_dict["Kf1"] if "is_internal" in list(init_dict.keys()): is_internal = init_dict["is_internal"] if "Rint" in list(init_dict.keys()): Rint = init_dict["Rint"] if "Rext" in list(init_dict.keys()): Rext = init_dict["Rext"] if "is_stator" in list(init_dict.keys()): is_stator = init_dict["is_stator"] if "axial_vent" in list(init_dict.keys()): axial_vent = init_dict["axial_vent"] if "notch" in list(init_dict.keys()): notch = init_dict["notch"] # Initialisation by argument self.parent = None self.L1 = L1 # mat_type can be None, a Material object or a dict if isinstance(mat_type, dict): self.mat_type = Material(init_dict=mat_type) else: self.mat_type = mat_type self.Nrvd = Nrvd self.Wrvd = Wrvd self.Kf1 = Kf1 self.is_internal = is_internal self.Rint = Rint self.Rext = Rext self.is_stator = is_stator # axial_vent can be None or a list of Hole object self.axial_vent = list() if type(axial_vent) is list: for obj in axial_vent: if obj is None: # Default value self.axial_vent.append(Hole()) elif isinstance(obj, dict): # Check that the type is correct (including daughter) class_name = obj.get("__class__") if class_name not in [ "Hole", "HoleMag", "HoleM50", "HoleM51", "HoleM52", "HoleM53", "HoleM54", "VentilationCirc", "VentilationPolar", "VentilationTrap", ]: raise InitUnKnowClassError( "Unknow class name " + class_name + " in init_dict for axial_vent") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.axial_vent.append(class_obj(init_dict=obj)) else: self.axial_vent.append(obj) elif axial_vent is None: self.axial_vent = list() else: self.axial_vent = axial_vent # notch can be None or a list of Notch object self.notch = list() if type(notch) is list: for obj in notch: if obj is None: # Default value self.notch.append(Notch()) elif isinstance(obj, dict): # Check that the type is correct (including daughter) class_name = obj.get("__class__") if class_name not in ["Notch", "NotchEvenDist"]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for notch") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.notch.append(class_obj(init_dict=obj)) else: self.notch.append(obj) elif notch is None: self.notch = list() else: self.notch = notch # The class is frozen, for now it's impossible to add new properties self._freeze()
def __init__(self, element=dict(), node=-1, submesh=list(), init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if node == -1: node = Node() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["element", "node", "submesh"]) # Overwrite default value with init_dict content if "element" in list(init_dict.keys()): element = init_dict["element"] if "node" in list(init_dict.keys()): node = init_dict["node"] if "submesh" in list(init_dict.keys()): submesh = init_dict["submesh"] # Initialisation by argument self.parent = None # element can be None or a list of Element object self.element = dict() if type(element) is dict: for key, obj in element.items(): if isinstance(obj, dict): # Check that the type is correct (including daughter) class_name = obj.get("__class__") if class_name not in ["Element", "ElementMat"]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for element") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.element[key] = class_obj(init_dict=obj) else: element = element # Should raise an error elif element is None: self.element = dict() else: self.element = element # Should raise an error # node can be None, a Node object or a dict if isinstance(node, dict): # Check that the type is correct (including daughter) class_name = node.get("__class__") if class_name not in ["Node", "NodeMat"]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for node") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.node = class_obj(init_dict=node) else: self.node = node # submesh can be None or a list of Mesh object self.submesh = list() if type(submesh) is list: for obj in submesh: if obj is None: # Default value self.submesh.append(Mesh()) elif isinstance(obj, dict): self.submesh.append(Mesh(init_dict=obj)) else: self.submesh.append(obj) elif submesh is None: self.submesh = list() else: self.submesh = submesh # The class is frozen, for now it's impossible to add new properties self._freeze()
def __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, H0=0.003, W0=0.003, H1=0, W3=0.013, H2=0.02, magnet_0=-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 mat_void == -1: mat_void = Material() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, ["H0", "W0", "H1", "W3", "H2", "magnet_0", "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 "W3" in list(init_dict.keys()): W3 = init_dict["W3"] if "H2" in list(init_dict.keys()): H2 = init_dict["H2"] if "magnet_0" in list(init_dict.keys()): magnet_0 = init_dict["magnet_0"] 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.W3 = W3 self.H2 = H2 # 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 # Call HoleMag init super(HoleM52, self).__init__(Zh=Zh, mat_void=mat_void)
def __init__( self, rotor=-1, stator=-1, frame=-1, shaft=-1, name="default_machine", desc="", init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if rotor == -1: rotor = Lamination() if stator == -1: stator = Lamination() if frame == -1: frame = Frame() if shaft == -1: shaft = Shaft() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, ["rotor", "stator", "frame", "shaft", "name", "desc"]) # Overwrite default value with init_dict content if "rotor" in list(init_dict.keys()): rotor = init_dict["rotor"] if "stator" in list(init_dict.keys()): stator = init_dict["stator"] if "frame" in list(init_dict.keys()): frame = init_dict["frame"] if "shaft" in list(init_dict.keys()): shaft = init_dict["shaft"] if "name" in list(init_dict.keys()): name = init_dict["name"] if "desc" in list(init_dict.keys()): desc = init_dict["desc"] # Initialisation by argument self.parent = None # rotor can be None, a Lamination object or a dict if isinstance(rotor, dict): # Check that the type is correct (including daughter) class_name = rotor.get("__class__") if class_name not in [ "Lamination", "LamHole", "LamSlot", "LamSlotWind", "LamSlotMag", "LamSquirrelCage", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for rotor") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.rotor = class_obj(init_dict=rotor) else: self.rotor = rotor # stator can be None, a Lamination object or a dict if isinstance(stator, dict): # Check that the type is correct (including daughter) class_name = stator.get("__class__") if class_name not in [ "Lamination", "LamHole", "LamSlot", "LamSlotWind", "LamSlotMag", "LamSquirrelCage", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for stator") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.stator = class_obj(init_dict=stator) else: self.stator = stator # frame can be None, a Frame object or a dict if isinstance(frame, dict): self.frame = Frame(init_dict=frame) else: self.frame = frame # shaft can be None, a Shaft object or a dict if isinstance(shaft, dict): self.shaft = Shaft(init_dict=shaft) else: self.shaft = shaft self.name = name self.desc = desc # The class is frozen, for now it's impossible to add new properties self._freeze()
def __init__(self, name="", desc="", machine=-1, input=-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 machine == -1: machine = Machine() if input == -1: input = Input() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["name", "desc", "machine", "input"]) # Overwrite default value with init_dict content if "name" in list(init_dict.keys()): name = init_dict["name"] if "desc" in list(init_dict.keys()): desc = init_dict["desc"] if "machine" in list(init_dict.keys()): machine = init_dict["machine"] if "input" in list(init_dict.keys()): input = init_dict["input"] # Initialisation by argument self.parent = None self.name = name self.desc = desc # machine can be None, a Machine object or a dict if isinstance(machine, dict): # Check that the type is correct (including daughter) class_name = machine.get("__class__") if class_name not in [ "Machine", "MachineAsync", "MachineDFIM", "MachineIPMSM", "MachineSCIM", "MachineSIPMSM", "MachineSRM", "MachineSyRM", "MachineSync", "MachineWRSM", ]: raise InitUnKnowClassError( "Unknow class name " + class_name + " in init_dict for machine" ) # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.machine = class_obj(init_dict=machine) else: self.machine = machine # input can be None, a Input object or a dict if isinstance(input, dict): # Check that the type is correct (including daughter) class_name = input.get("__class__") if class_name not in ["Input", "InCurrent", "InFlux", "InForce"]: raise InitUnKnowClassError( "Unknow class name " + class_name + " in init_dict for input" ) # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.input = class_obj(init_dict=input) else: self.input = input # The class is frozen, for now it's impossible to add new properties self._freeze()
def __init__( self, is_reverse_wind=False, Nslot_shift_wind=0, qs=3, Ntcoil=7, Npcpp=2, type_connection=0, p=3, Lewout=0.015, conductor=-1, init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if conductor == -1: conductor = Conductor() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "is_reverse_wind", "Nslot_shift_wind", "qs", "Ntcoil", "Npcpp", "type_connection", "p", "Lewout", "conductor", ], ) # Overwrite default value with init_dict content if "is_reverse_wind" in list(init_dict.keys()): is_reverse_wind = init_dict["is_reverse_wind"] if "Nslot_shift_wind" in list(init_dict.keys()): Nslot_shift_wind = init_dict["Nslot_shift_wind"] if "qs" in list(init_dict.keys()): qs = init_dict["qs"] if "Ntcoil" in list(init_dict.keys()): Ntcoil = init_dict["Ntcoil"] if "Npcpp" in list(init_dict.keys()): Npcpp = init_dict["Npcpp"] if "type_connection" in list(init_dict.keys()): type_connection = init_dict["type_connection"] if "p" in list(init_dict.keys()): p = init_dict["p"] if "Lewout" in list(init_dict.keys()): Lewout = init_dict["Lewout"] if "conductor" in list(init_dict.keys()): conductor = init_dict["conductor"] # Initialisation by argument self.parent = None self.is_reverse_wind = is_reverse_wind self.Nslot_shift_wind = Nslot_shift_wind self.qs = qs self.Ntcoil = Ntcoil self.Npcpp = Npcpp self.type_connection = type_connection self.p = p self.Lewout = Lewout # conductor can be None, a Conductor object or a dict if isinstance(conductor, dict): # Call the correct constructor according to the dict load_dict = { "CondType11": CondType11, "CondType12": CondType12, "CondType21": CondType21, "CondType22": CondType22, "Conductor": Conductor, } obj_class = conductor.get("__class__") if obj_class is None: self.conductor = Conductor(init_dict=conductor) elif obj_class in list(load_dict.keys()): self.conductor = load_dict[obj_class](init_dict=conductor) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for conductor") else: self.conductor = conductor # The class is frozen, for now it's impossible to add new properties self._freeze()
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, 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): # 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(HoleM53, self).__init__(Zh=Zh, mat_void=mat_void)
def __init__(self, name="", desc="", machine=-1, input=-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 machine == -1: machine = Machine() if input == -1: input = Input() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["name", "desc", "machine", "input"]) # Overwrite default value with init_dict content if "name" in list(init_dict.keys()): name = init_dict["name"] if "desc" in list(init_dict.keys()): desc = init_dict["desc"] if "machine" in list(init_dict.keys()): machine = init_dict["machine"] if "input" in list(init_dict.keys()): input = init_dict["input"] # Initialisation by argument self.parent = None self.name = name self.desc = desc # machine can be None, a Machine object or a dict if isinstance(machine, dict): # Call the correct constructor according to the dict load_dict = { "MachineSync": MachineSync, "MachineAsync": MachineAsync, "MachineSCIM": MachineSCIM, "MachineDFIM": MachineDFIM, "MachineSIPMSM": MachineSIPMSM, "MachineIPMSM": MachineIPMSM, "MachineWRSM": MachineWRSM, "MachineSyRM": MachineSyRM, "Machine": Machine, } obj_class = machine.get("__class__") if obj_class is None: self.machine = Machine(init_dict=machine) elif obj_class in list(load_dict.keys()): self.machine = load_dict[obj_class](init_dict=machine) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for machine") else: self.machine = machine # input can be None, a Input object or a dict if isinstance(input, dict): # Call the correct constructor according to the dict load_dict = {"InCurrent": InCurrent, "Input": Input} obj_class = input.get("__class__") if obj_class is None: self.input = Input(init_dict=input) elif obj_class in list(load_dict.keys()): self.input = load_dict[obj_class](init_dict=input) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for input") else: self.input = input # The class is frozen, for now it's impossible to add new properties self._freeze()
def __init__(self, time=None, angle=None, Br=None, Bt=None, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if time == -1: time = Import() if angle == -1: angle = Import() if Br == -1: Br = Import() if Bt == -1: Bt = Import() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["time", "angle", "Br", "Bt"]) # Overwrite default value with init_dict content if "time" in list(init_dict.keys()): time = init_dict["time"] if "angle" in list(init_dict.keys()): angle = init_dict["angle"] if "Br" in list(init_dict.keys()): Br = init_dict["Br"] if "Bt" in list(init_dict.keys()): Bt = init_dict["Bt"] # Initialisation by argument # time can be None, a Import object or a dict if isinstance(time, dict): # Call the correct constructor according to the dict load_dict = { "ImportMatlab": ImportMatlab, "ImportMatrix": ImportMatrix, "ImportMatrixVal": ImportMatrixVal, "ImportMatrixXls": ImportMatrixXls, "ImportGenVectSin": ImportGenVectSin, "ImportGenMatrixSin": ImportGenMatrixSin, "ImportGenVectLin": ImportGenVectLin, "Import": Import, } obj_class = time.get("__class__") if obj_class is None: self.time = Import(init_dict=time) elif obj_class in list(load_dict.keys()): self.time = load_dict[obj_class](init_dict=time) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for time") else: self.time = time # angle can be None, a Import object or a dict if isinstance(angle, dict): # Call the correct constructor according to the dict load_dict = { "ImportMatlab": ImportMatlab, "ImportMatrix": ImportMatrix, "ImportMatrixVal": ImportMatrixVal, "ImportMatrixXls": ImportMatrixXls, "ImportGenVectSin": ImportGenVectSin, "ImportGenMatrixSin": ImportGenMatrixSin, "ImportGenVectLin": ImportGenVectLin, "Import": Import, } obj_class = angle.get("__class__") if obj_class is None: self.angle = Import(init_dict=angle) elif obj_class in list(load_dict.keys()): self.angle = load_dict[obj_class](init_dict=angle) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for angle") else: self.angle = angle # Br can be None, a Import object or a dict if isinstance(Br, dict): # Call the correct constructor according to the dict load_dict = { "ImportMatlab": ImportMatlab, "ImportMatrix": ImportMatrix, "ImportMatrixVal": ImportMatrixVal, "ImportMatrixXls": ImportMatrixXls, "ImportGenVectSin": ImportGenVectSin, "ImportGenMatrixSin": ImportGenMatrixSin, "ImportGenVectLin": ImportGenVectLin, "Import": Import, } obj_class = Br.get("__class__") if obj_class is None: self.Br = Import(init_dict=Br) elif obj_class in list(load_dict.keys()): self.Br = load_dict[obj_class](init_dict=Br) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for Br") else: self.Br = Br # Bt can be None, a Import object or a dict if isinstance(Bt, dict): # Call the correct constructor according to the dict load_dict = { "ImportMatlab": ImportMatlab, "ImportMatrix": ImportMatrix, "ImportMatrixVal": ImportMatrixVal, "ImportMatrixXls": ImportMatrixXls, "ImportGenVectSin": ImportGenVectSin, "ImportGenMatrixSin": ImportGenMatrixSin, "ImportGenVectLin": ImportGenVectLin, "Import": Import, } obj_class = Bt.get("__class__") if obj_class is None: self.Bt = Import(init_dict=Bt) elif obj_class in list(load_dict.keys()): self.Bt = load_dict[obj_class](init_dict=Bt) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for Bt") else: self.Bt = Bt # Call Input init super(InFlux, self).__init__()
def __init__( self, rotor=-1, stator=-1, frame=-1, shaft=-1, name="default_machine", desc="", init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if rotor == -1: rotor = Lamination() if stator == -1: stator = Lamination() if frame == -1: frame = Frame() if shaft == -1: shaft = Shaft() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, ["rotor", "stator", "frame", "shaft", "name", "desc"]) # Overwrite default value with init_dict content if "rotor" in list(init_dict.keys()): rotor = init_dict["rotor"] if "stator" in list(init_dict.keys()): stator = init_dict["stator"] if "frame" in list(init_dict.keys()): frame = init_dict["frame"] if "shaft" in list(init_dict.keys()): shaft = init_dict["shaft"] if "name" in list(init_dict.keys()): name = init_dict["name"] if "desc" in list(init_dict.keys()): desc = init_dict["desc"] # Initialisation by argument self.parent = None # rotor can be None, a Lamination object or a dict if isinstance(rotor, dict): # Call the correct constructor according to the dict load_dict = { "LamHole": LamHole, "LamSlot": LamSlot, "LamSlotWind": LamSlotWind, "LamSlotMag": LamSlotMag, "LamSquirrelCage": LamSquirrelCage, "Lamination": Lamination, } obj_class = rotor.get("__class__") if obj_class is None: self.rotor = Lamination(init_dict=rotor) elif obj_class in list(load_dict.keys()): self.rotor = load_dict[obj_class](init_dict=rotor) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for rotor") else: self.rotor = rotor # stator can be None, a Lamination object or a dict if isinstance(stator, dict): # Call the correct constructor according to the dict load_dict = { "LamHole": LamHole, "LamSlot": LamSlot, "LamSlotWind": LamSlotWind, "LamSlotMag": LamSlotMag, "LamSquirrelCage": LamSquirrelCage, "Lamination": Lamination, } obj_class = stator.get("__class__") if obj_class is None: self.stator = Lamination(init_dict=stator) elif obj_class in list(load_dict.keys()): self.stator = load_dict[obj_class](init_dict=stator) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for stator") else: self.stator = stator # frame can be None, a Frame object or a dict if isinstance(frame, dict): self.frame = Frame(init_dict=frame) else: self.frame = frame # shaft can be None, a Shaft object or a dict if isinstance(shaft, dict): self.shaft = Shaft(init_dict=shaft) else: self.shaft = shaft self.name = name self.desc = desc # The class is frozen, for now it's impossible to add new properties self._freeze()
def __init__( self, time=None, angle=None, Nt_tot=None, Na_tot=None, Br=None, Bt=None, Tem=None, Tem_av=None, Tem_rip=None, Phi_wind_stator=None, emf=None, mesh=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, [ "time", "angle", "Nt_tot", "Na_tot", "Br", "Bt", "Tem", "Tem_av", "Tem_rip", "Phi_wind_stator", "emf", "mesh", ], ) # Overwrite default value with init_dict content if "time" in list(init_dict.keys()): time = init_dict["time"] if "angle" in list(init_dict.keys()): angle = init_dict["angle"] if "Nt_tot" in list(init_dict.keys()): Nt_tot = init_dict["Nt_tot"] if "Na_tot" in list(init_dict.keys()): Na_tot = init_dict["Na_tot"] if "Br" in list(init_dict.keys()): Br = init_dict["Br"] if "Bt" in list(init_dict.keys()): Bt = init_dict["Bt"] if "Tem" in list(init_dict.keys()): Tem = init_dict["Tem"] if "Tem_av" in list(init_dict.keys()): Tem_av = init_dict["Tem_av"] if "Tem_rip" in list(init_dict.keys()): Tem_rip = init_dict["Tem_rip"] if "Phi_wind_stator" in list(init_dict.keys()): Phi_wind_stator = init_dict["Phi_wind_stator"] if "emf" in list(init_dict.keys()): emf = init_dict["emf"] if "mesh" in list(init_dict.keys()): mesh = init_dict["mesh"] # Initialisation by argument self.parent = None # time can be None, a ndarray or a list set_array(self, "time", time) # angle can be None, a ndarray or a list set_array(self, "angle", angle) self.Nt_tot = Nt_tot self.Na_tot = Na_tot # Br can be None, a ndarray or a list set_array(self, "Br", Br) # Bt can be None, a ndarray or a list set_array(self, "Bt", Bt) # Tem can be None, a ndarray or a list set_array(self, "Tem", Tem) self.Tem_av = Tem_av self.Tem_rip = Tem_rip # Phi_wind_stator can be None, a ndarray or a list set_array(self, "Phi_wind_stator", Phi_wind_stator) # emf can be None, a ndarray or a list set_array(self, "emf", emf) # mesh can be None or a list of Mesh object self.mesh = list() if type(mesh) is list: for obj in mesh: if obj is None: # Default value self.mesh.append(Mesh()) elif isinstance(obj, dict): # Check that the type is correct (including daughter) class_name = obj.get("__class__") if class_name not in [ "Mesh", "MeshFEMM", "MeshMat", "MeshForce" ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for mesh") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.mesh.append(class_obj(init_dict=obj)) else: self.mesh.append(obj) elif mesh is None: self.mesh = list() else: self.mesh = mesh # The class is frozen, for now it's impossible to add new properties self._freeze()
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, time=None, angle=None, Prad=None, Ptan=None, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if time == -1: time = Import() if angle == -1: angle = Import() if Prad == -1: Prad = Import() if Ptan == -1: Ptan = Import() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["time", "angle", "Prad", "Ptan"]) # Overwrite default value with init_dict content if "time" in list(init_dict.keys()): time = init_dict["time"] if "angle" in list(init_dict.keys()): angle = init_dict["angle"] if "Prad" in list(init_dict.keys()): Prad = init_dict["Prad"] if "Ptan" in list(init_dict.keys()): Ptan = init_dict["Ptan"] # Initialisation by argument # time can be None, a Import object or a dict if isinstance(time, dict): # Check that the type is correct (including daughter) class_name = time.get("__class__") if class_name not in [ "Import", "ImportGenMatrixSin", "ImportGenVectLin", "ImportGenVectSin", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for time") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.time = class_obj(init_dict=time) else: self.time = time # angle can be None, a Import object or a dict if isinstance(angle, dict): # Check that the type is correct (including daughter) class_name = angle.get("__class__") if class_name not in [ "Import", "ImportGenMatrixSin", "ImportGenVectLin", "ImportGenVectSin", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for angle") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.angle = class_obj(init_dict=angle) else: self.angle = angle # Prad can be None, a Import object or a dict if isinstance(Prad, dict): # Check that the type is correct (including daughter) class_name = Prad.get("__class__") if class_name not in [ "Import", "ImportGenMatrixSin", "ImportGenVectLin", "ImportGenVectSin", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for Prad") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.Prad = class_obj(init_dict=Prad) else: self.Prad = Prad # Ptan can be None, a Import object or a dict if isinstance(Ptan, dict): # Check that the type is correct (including daughter) class_name = Ptan.get("__class__") if class_name not in [ "Import", "ImportGenMatrixSin", "ImportGenVectLin", "ImportGenVectSin", "ImportMatlab", "ImportMatrix", "ImportMatrixVal", "ImportMatrixXls", ]: raise InitUnKnowClassError("Unknow class name " + class_name + " in init_dict for Ptan") # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.Ptan = class_obj(init_dict=Ptan) else: self.Ptan = Ptan # Call Input init super(InForce, self).__init__()