示例#1
0
    def __init__(
        self,
        rotor=-1,
        stator=-1,
        frame=-1,
        shaft=-1,
        name="default_machine",
        desc="",
        type_machine=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 rotor == -1:
            rotor = LamSlot()
        if stator == -1:
            stator = LamSlotWind()
        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",
                    "type_machine"
                ],
            )
            # 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"]
            if "type_machine" in list(init_dict.keys()):
                type_machine = init_dict["type_machine"]
        # Initialisation by argument
        # rotor can be None, a LamSlot 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 [
                    "LamSlot",
                    "LamSlotMag",
                    "LamSlotWind",
                    "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 LamSlotWind 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 ["LamSlotWind", "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
        # Call MachineSync init
        super(MachineSRM, self).__init__(frame=frame,
                                         shaft=shaft,
                                         name=name,
                                         desc=desc,
                                         type_machine=type_machine)
示例#2
0
    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__()
示例#3
0
    def __init__(
        self,
        output_ref=-1,
        outputs=list(),
        is_valid=[],
        design_var=[],
        design_var_names=[],
        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 output_ref == -1:
            output_ref = Output()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "output_ref", "outputs", "is_valid", "design_var",
                    "design_var_names"
                ],
            )
            # Overwrite default value with init_dict content
            if "output_ref" in list(init_dict.keys()):
                output_ref = init_dict["output_ref"]
            if "outputs" in list(init_dict.keys()):
                outputs = init_dict["outputs"]
            if "is_valid" in list(init_dict.keys()):
                is_valid = init_dict["is_valid"]
            if "design_var" in list(init_dict.keys()):
                design_var = init_dict["design_var"]
            if "design_var_names" in list(init_dict.keys()):
                design_var_names = init_dict["design_var_names"]
        # Initialisation by argument
        self.parent = None
        # output_ref can be None, a Output object or a dict
        if isinstance(output_ref, dict):
            self.output_ref = Output(init_dict=output_ref)
        else:
            self.output_ref = output_ref
        # outputs can be None or a list of Output object
        self.outputs = list()
        if type(outputs) is list:
            for obj in outputs:
                if obj is None:  # Default value
                    self.outputs.append(Output())
                elif isinstance(obj, dict):
                    self.outputs.append(Output(init_dict=obj))
                else:
                    self.outputs.append(obj)
        elif outputs is None:
            self.outputs = list()
        else:
            self.outputs = outputs
        self.is_valid = is_valid
        self.design_var = design_var
        self.design_var_names = design_var_names

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
示例#4
0
    def __init__(
            self,
            H0=0,
            W0=0.0122,
            W0_is_rad=False,
            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,
                            ["H0", "W0", "W0_is_rad", "magnet", "W3", "Zs"])
            # 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 "W0_is_rad" in list(init_dict.keys()):
                W0_is_rad = init_dict["W0_is_rad"]
            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.H0 = H0
        self.W0 = W0
        self.W0_is_rad = W0_is_rad
        # magnet can be None or a list of MagnetFlat object
        self.magnet = list()
        if type(magnet) is list:
            for obj in magnet:
                if obj is None:  # Default value
                    self.magnet.append(MagnetFlat())
                elif isinstance(obj, dict):
                    # Check that the type is correct (including daughter)
                    class_name = obj.get("__class__")
                    if class_name not in [
                            "MagnetFlat",
                            "MagnetType10",
                            "MagnetType12",
                            "MagnetType13",
                    ]:
                        raise InitUnKnowClassError("Unknow class name " +
                                                   class_name +
                                                   " in init_dict for magnet")
                    # Dynamic import to call the correct constructor
                    module = __import__("pyleecan.Classes." + class_name,
                                        fromlist=[class_name])
                    class_obj = getattr(module, class_name)
                    self.magnet.append(class_obj(init_dict=obj))
                else:
                    self.magnet.append(obj)
        elif magnet is None:
            self.magnet = list()
        else:
            self.magnet = magnet
        # Call SlotMag init
        super(SlotMFlat, self).__init__(W3=W3, Zs=Zs)
示例#5
0
    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)
示例#6
0
    def __init__(self,
                 nodal=dict(),
                 edge=dict(),
                 face=dict(),
                 volume=dict(),
                 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, ["nodal", "edge", "face", "volume"])
            # Overwrite default value with init_dict content
            if "nodal" in list(init_dict.keys()):
                nodal = init_dict["nodal"]
            if "edge" in list(init_dict.keys()):
                edge = init_dict["edge"]
            if "face" in list(init_dict.keys()):
                face = init_dict["face"]
            if "volume" in list(init_dict.keys()):
                volume = init_dict["volume"]
        # Initialisation by argument
        self.parent = None
        # nodal can be None or a dict of ndarray
        self.nodal = dict()
        if type(nodal) is dict:
            for key, obj in nodal.items():
                if obj is None:  # Default value
                    value = empty(0)
                elif isinstance(obj, list):
                    value = array(obj)
                self.nodal[key] = value
        elif nodal is None:
            self.nodal = dict()
        else:
            self.nodal = nodal  # Should raise an error
        # edge can be None or a dict of ndarray
        self.edge = dict()
        if type(edge) is dict:
            for key, obj in edge.items():
                if obj is None:  # Default value
                    value = empty(0)
                elif isinstance(obj, list):
                    value = array(obj)
                self.edge[key] = value
        elif edge is None:
            self.edge = dict()
        else:
            self.edge = edge  # Should raise an error
        # face can be None or a dict of ndarray
        self.face = dict()
        if type(face) is dict:
            for key, obj in face.items():
                if obj is None:  # Default value
                    value = empty(0)
                elif isinstance(obj, list):
                    value = array(obj)
                self.face[key] = value
        elif face is None:
            self.face = dict()
        else:
            self.face = face  # Should raise an error
        # volume can be None or a dict of ndarray
        self.volume = dict()
        if type(volume) is dict:
            for key, obj in volume.items():
                if obj is None:  # Default value
                    value = empty(0)
                elif isinstance(obj, list):
                    value = array(obj)
                self.volume[key] = value
        elif volume is None:
            self.volume = dict()
        else:
            self.volume = volume  # Should raise an error

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
示例#7
0
    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
        # Call Winding init
        super(WindingCW2LT, self).__init__(
            is_reverse_wind=is_reverse_wind,
            Nslot_shift_wind=Nslot_shift_wind,
            qs=qs,
            Ntcoil=Ntcoil,
            Npcpp=Npcpp,
            type_connection=type_connection,
            p=p,
            Lewout=Lewout,
            conductor=conductor,
        )