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, 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__()
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, 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__()