Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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",
                            "Arc",
                            "Arc1",
                            "Arc2",
                            "Arc3",
                            "Segment",
                    ]:
                        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)
Exemplo n.º 3
0
    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()
Exemplo n.º 4
0
    def __init__(
        self, mur_lin=1, Hc=0, Brm20=0, alpha_Br=0, Wlam=0, BH_curve=-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, ["mur_lin", "Hc", "Brm20", "alpha_Br", "Wlam", "BH_curve"]
            )
            # Overwrite default value with init_dict content
            if "mur_lin" in list(init_dict.keys()):
                mur_lin = init_dict["mur_lin"]
            if "Hc" in list(init_dict.keys()):
                Hc = init_dict["Hc"]
            if "Brm20" in list(init_dict.keys()):
                Brm20 = init_dict["Brm20"]
            if "alpha_Br" in list(init_dict.keys()):
                alpha_Br = init_dict["alpha_Br"]
            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"]
        # Initialisation by argument
        self.parent = None
        self.mur_lin = mur_lin
        self.Hc = Hc
        self.Brm20 = Brm20
        self.alpha_Br = alpha_Br
        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

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
Exemplo n.º 5
0
    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):
            # 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
        # Call HoleMag init
        super(HoleM52, self).__init__(Zh=Zh, mat_void=mat_void)
Exemplo n.º 6
0
    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):
                    # Check that the type is correct (including daughter)
                    class_name = obj.get("__class__")
                    if class_name not in [
                            "MagnetPolar",
                            "MagnetType11",
                            "MagnetType14",
                    ]:
                        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(SlotMPolar, self).__init__(W3=W3, Zs=Zs)
Exemplo n.º 7
0
    def __init__(
            self,
            slot_list=list(),
            alpha=None,
            L1=0.35,
            mat_type=-1,
            Nrvd=0,
            Wrvd=0,
            Kf1=0.95,
            is_internal=True,
            Rint=0,
            Rext=1,
            is_stator=True,
            axial_vent=list(),
            notch=list(),
            init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

        ndarray or list can be given for Vector and Matrix
        object or dict can be given for pyleecan Object"""

        if mat_type == -1:
            mat_type = Material()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "slot_list",
                    "alpha",
                    "L1",
                    "mat_type",
                    "Nrvd",
                    "Wrvd",
                    "Kf1",
                    "is_internal",
                    "Rint",
                    "Rext",
                    "is_stator",
                    "axial_vent",
                    "notch",
                ],
            )
            # Overwrite default value with init_dict content
            if "slot_list" in list(init_dict.keys()):
                slot_list = init_dict["slot_list"]
            if "alpha" in list(init_dict.keys()):
                alpha = init_dict["alpha"]
            if "L1" in list(init_dict.keys()):
                L1 = init_dict["L1"]
            if "mat_type" in list(init_dict.keys()):
                mat_type = init_dict["mat_type"]
            if "Nrvd" in list(init_dict.keys()):
                Nrvd = init_dict["Nrvd"]
            if "Wrvd" in list(init_dict.keys()):
                Wrvd = init_dict["Wrvd"]
            if "Kf1" in list(init_dict.keys()):
                Kf1 = init_dict["Kf1"]
            if "is_internal" in list(init_dict.keys()):
                is_internal = init_dict["is_internal"]
            if "Rint" in list(init_dict.keys()):
                Rint = init_dict["Rint"]
            if "Rext" in list(init_dict.keys()):
                Rext = init_dict["Rext"]
            if "is_stator" in list(init_dict.keys()):
                is_stator = init_dict["is_stator"]
            if "axial_vent" in list(init_dict.keys()):
                axial_vent = init_dict["axial_vent"]
            if "notch" in list(init_dict.keys()):
                notch = init_dict["notch"]
        # Initialisation by argument
        # slot_list can be None or a list of Slot object
        self.slot_list = list()
        if type(slot_list) is list:
            for obj in slot_list:
                if obj is None:  # Default value
                    self.slot_list.append(Slot())
                elif isinstance(obj, dict):
                    # Check that the type is correct (including daughter)
                    class_name = obj.get("__class__")
                    if class_name not in [
                            "Slot",
                            "Slot19",
                            "SlotMFlat",
                            "SlotMPolar",
                            "SlotMag",
                            "SlotUD",
                            "SlotW10",
                            "SlotW11",
                            "SlotW12",
                            "SlotW13",
                            "SlotW14",
                            "SlotW15",
                            "SlotW16",
                            "SlotW21",
                            "SlotW22",
                            "SlotW23",
                            "SlotW24",
                            "SlotW25",
                            "SlotW26",
                            "SlotW27",
                            "SlotW28",
                            "SlotW29",
                            "SlotW60",
                            "SlotW61",
                            "SlotWind",
                    ]:
                        raise InitUnKnowClassError(
                            "Unknow class name " + class_name +
                            " in init_dict for slot_list")
                    # Dynamic import to call the correct constructor
                    module = __import__("pyleecan.Classes." + class_name,
                                        fromlist=[class_name])
                    class_obj = getattr(module, class_name)
                    self.slot_list.append(class_obj(init_dict=obj))
                else:
                    self.slot_list.append(obj)
        elif slot_list is None:
            self.slot_list = list()
        else:
            self.slot_list = slot_list
        # alpha can be None, a ndarray or a list
        set_array(self, "alpha", alpha)
        # Call Lamination init
        super(LamSlotMulti, self).__init__(
            L1=L1,
            mat_type=mat_type,
            Nrvd=Nrvd,
            Wrvd=Wrvd,
            Kf1=Kf1,
            is_internal=is_internal,
            Rint=Rint,
            Rext=Rext,
            is_stator=is_stator,
            axial_vent=axial_vent,
            notch=notch,
        )
Exemplo n.º 8
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
        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):
            # Check that the type is correct (including daughter)
            class_name = conductor.get("__class__")
            if class_name not in [
                    "Conductor",
                    "CondType11",
                    "CondType12",
                    "CondType21",
                    "CondType22",
            ]:
                raise InitUnKnowClassError("Unknow class name " + class_name +
                                           " in init_dict for conductor")
            # Dynamic import to call the correct constructor
            module = __import__("pyleecan.Classes." + class_name,
                                fromlist=[class_name])
            class_obj = getattr(module, class_name)
            self.conductor = class_obj(init_dict=conductor)
        else:
            self.conductor = conductor

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
Exemplo n.º 9
0
    def __init__(self, alpha=0, notch_shape=-1, init_dict=None):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

        ndarray or list can be given for Vector and Matrix
        object or dict can be given for pyleecan Object"""

        if notch_shape == -1:
            notch_shape = Slot()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(init_dict, ["alpha", "notch_shape"])
            # Overwrite default value with init_dict content
            if "alpha" in list(init_dict.keys()):
                alpha = init_dict["alpha"]
            if "notch_shape" in list(init_dict.keys()):
                notch_shape = init_dict["notch_shape"]
        # Initialisation by argument
        self.alpha = alpha
        # notch_shape can be None, a Slot object or a dict
        if isinstance(notch_shape, dict):
            # Check that the type is correct (including daughter)
            class_name = notch_shape.get("__class__")
            if class_name not in [
                    "Slot",
                    "Slot19",
                    "SlotMFlat",
                    "SlotMPolar",
                    "SlotMag",
                    "SlotUD",
                    "SlotW10",
                    "SlotW11",
                    "SlotW12",
                    "SlotW13",
                    "SlotW14",
                    "SlotW15",
                    "SlotW16",
                    "SlotW21",
                    "SlotW22",
                    "SlotW23",
                    "SlotW24",
                    "SlotW25",
                    "SlotW26",
                    "SlotW27",
                    "SlotW28",
                    "SlotW29",
                    "SlotW60",
                    "SlotW61",
                    "SlotWind",
            ]:
                raise InitUnKnowClassError("Unknow class name " + class_name +
                                           " in init_dict for notch_shape")
            # Dynamic import to call the correct constructor
            module = __import__("pyleecan.Classes." + class_name,
                                fromlist=[class_name])
            class_obj = getattr(module, class_name)
            self.notch_shape = class_obj(init_dict=notch_shape)
        else:
            self.notch_shape = notch_shape
        # Call Notch init
        super(NotchEvenDist, self).__init__()
Exemplo n.º 10
0
    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",
                    "MachineUD",
                    "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",
                    "InCurrentDQ",
                    "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()
Exemplo n.º 11
0
    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):
            # 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
        # Br can be None, a Import object or a dict
        if isinstance(Br, dict):
            # Check that the type is correct (including daughter)
            class_name = Br.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 Br")
            # Dynamic import to call the correct constructor
            module = __import__("pyleecan.Classes." + class_name,
                                fromlist=[class_name])
            class_obj = getattr(module, class_name)
            self.Br = class_obj(init_dict=Br)
        else:
            self.Br = Br
        # Bt can be None, a Import object or a dict
        if isinstance(Bt, dict):
            # Check that the type is correct (including daughter)
            class_name = Bt.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 Bt")
            # Dynamic import to call the correct constructor
            module = __import__("pyleecan.Classes." + class_name,
                                fromlist=[class_name])
            class_obj = getattr(module, class_name)
            self.Bt = class_obj(init_dict=Bt)
        else:
            self.Bt = Bt
        # Call Input init
        super(InFlux, self).__init__()
Exemplo n.º 12
0
    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",
                    "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
        # 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",
                    "ImportGenMatrixSin",
                    "ImportGenVectLin",
                    "ImportGenVectSin",
                    "ImportMatlab",
                    "ImportMatrix",
                    "ImportMatrixVal",
                    "ImportMatrixXls",
            ]:
                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",
                    "ImportGenMatrixSin",
                    "ImportGenVectLin",
                    "ImportGenVectSin",
                    "ImportMatlab",
                    "ImportMatrix",
                    "ImportMatrixVal",
                    "ImportMatrixXls",
            ]:
                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",
                    "ImportGenMatrixSin",
                    "ImportGenVectLin",
                    "ImportGenVectSin",
                    "ImportMatlab",
                    "ImportMatrix",
                    "ImportMatrixVal",
                    "ImportMatrixXls",
            ]:
                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",
                    "ImportGenMatrixSin",
                    "ImportGenVectLin",
                    "ImportGenVectSin",
                    "ImportMatlab",
                    "ImportMatrix",
                    "ImportMatrixVal",
                    "ImportMatrixXls",
            ]:
                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__()
Exemplo n.º 13
0
    def __init__(
            self,
            L1=0.35,
            mat_type=-1,
            Nrvd=0,
            Wrvd=0,
            Kf1=0.95,
            is_internal=True,
            Rint=0,
            Rext=1,
            is_stator=True,
            axial_vent=list(),
            notch=list(),
            init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

        ndarray or list can be given for Vector and Matrix
        object or dict can be given for pyleecan Object"""

        if mat_type == -1:
            mat_type = Material()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "L1",
                    "mat_type",
                    "Nrvd",
                    "Wrvd",
                    "Kf1",
                    "is_internal",
                    "Rint",
                    "Rext",
                    "is_stator",
                    "axial_vent",
                    "notch",
                ],
            )
            # Overwrite default value with init_dict content
            if "L1" in list(init_dict.keys()):
                L1 = init_dict["L1"]
            if "mat_type" in list(init_dict.keys()):
                mat_type = init_dict["mat_type"]
            if "Nrvd" in list(init_dict.keys()):
                Nrvd = init_dict["Nrvd"]
            if "Wrvd" in list(init_dict.keys()):
                Wrvd = init_dict["Wrvd"]
            if "Kf1" in list(init_dict.keys()):
                Kf1 = init_dict["Kf1"]
            if "is_internal" in list(init_dict.keys()):
                is_internal = init_dict["is_internal"]
            if "Rint" in list(init_dict.keys()):
                Rint = init_dict["Rint"]
            if "Rext" in list(init_dict.keys()):
                Rext = init_dict["Rext"]
            if "is_stator" in list(init_dict.keys()):
                is_stator = init_dict["is_stator"]
            if "axial_vent" in list(init_dict.keys()):
                axial_vent = init_dict["axial_vent"]
            if "notch" in list(init_dict.keys()):
                notch = init_dict["notch"]
        # Initialisation by argument
        self.parent = None
        self.L1 = L1
        # mat_type can be None, a Material object or a dict
        if isinstance(mat_type, dict):
            self.mat_type = Material(init_dict=mat_type)
        else:
            self.mat_type = mat_type
        self.Nrvd = Nrvd
        self.Wrvd = Wrvd
        self.Kf1 = Kf1
        self.is_internal = is_internal
        self.Rint = Rint
        self.Rext = Rext
        self.is_stator = is_stator
        # axial_vent can be None or a list of Hole object
        self.axial_vent = list()
        if type(axial_vent) is list:
            for obj in axial_vent:
                if obj is None:  # Default value
                    self.axial_vent.append(Hole())
                elif isinstance(obj, dict):
                    # Check that the type is correct (including daughter)
                    class_name = obj.get("__class__")
                    if class_name not in [
                            "Hole",
                            "HoleM50",
                            "HoleM51",
                            "HoleM52",
                            "HoleM53",
                            "HoleM54",
                            "HoleMag",
                            "VentilationCirc",
                            "VentilationPolar",
                            "VentilationTrap",
                    ]:
                        raise InitUnKnowClassError(
                            "Unknow class name " + class_name +
                            " in init_dict for axial_vent")
                    # Dynamic import to call the correct constructor
                    module = __import__("pyleecan.Classes." + class_name,
                                        fromlist=[class_name])
                    class_obj = getattr(module, class_name)
                    self.axial_vent.append(class_obj(init_dict=obj))
                else:
                    self.axial_vent.append(obj)
        elif axial_vent is None:
            self.axial_vent = list()
        else:
            self.axial_vent = axial_vent
        # notch can be None or a list of Notch object
        self.notch = list()
        if type(notch) is list:
            for obj in notch:
                if obj is None:  # Default value
                    self.notch.append(Notch())
                elif isinstance(obj, dict):
                    # Check that the type is correct (including daughter)
                    class_name = obj.get("__class__")
                    if class_name not in ["Notch", "NotchEvenDist"]:
                        raise InitUnKnowClassError("Unknow class name " +
                                                   class_name +
                                                   " in init_dict for notch")
                    # Dynamic import to call the correct constructor
                    module = __import__("pyleecan.Classes." + class_name,
                                        fromlist=[class_name])
                    class_obj = getattr(module, class_name)
                    self.notch.append(class_obj(init_dict=obj))
                else:
                    self.notch.append(obj)
        elif notch is None:
            self.notch = list()
        else:
            self.notch = notch

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
Exemplo n.º 14
0
    def __init__(
            self,
            hole=list(),
            bore=None,
            L1=0.35,
            mat_type=-1,
            Nrvd=0,
            Wrvd=0,
            Kf1=0.95,
            is_internal=True,
            Rint=0,
            Rext=1,
            is_stator=True,
            axial_vent=list(),
            notch=list(),
            init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

        ndarray or list can be given for Vector and Matrix
        object or dict can be given for pyleecan Object"""

        if bore == -1:
            bore = Bore()
        if mat_type == -1:
            mat_type = Material()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "hole",
                    "bore",
                    "L1",
                    "mat_type",
                    "Nrvd",
                    "Wrvd",
                    "Kf1",
                    "is_internal",
                    "Rint",
                    "Rext",
                    "is_stator",
                    "axial_vent",
                    "notch",
                ],
            )
            # Overwrite default value with init_dict content
            if "hole" in list(init_dict.keys()):
                hole = init_dict["hole"]
            if "bore" in list(init_dict.keys()):
                bore = init_dict["bore"]
            if "L1" in list(init_dict.keys()):
                L1 = init_dict["L1"]
            if "mat_type" in list(init_dict.keys()):
                mat_type = init_dict["mat_type"]
            if "Nrvd" in list(init_dict.keys()):
                Nrvd = init_dict["Nrvd"]
            if "Wrvd" in list(init_dict.keys()):
                Wrvd = init_dict["Wrvd"]
            if "Kf1" in list(init_dict.keys()):
                Kf1 = init_dict["Kf1"]
            if "is_internal" in list(init_dict.keys()):
                is_internal = init_dict["is_internal"]
            if "Rint" in list(init_dict.keys()):
                Rint = init_dict["Rint"]
            if "Rext" in list(init_dict.keys()):
                Rext = init_dict["Rext"]
            if "is_stator" in list(init_dict.keys()):
                is_stator = init_dict["is_stator"]
            if "axial_vent" in list(init_dict.keys()):
                axial_vent = init_dict["axial_vent"]
            if "notch" in list(init_dict.keys()):
                notch = init_dict["notch"]
        # Initialisation by argument
        # hole can be None or a list of Hole object
        self.hole = list()
        if type(hole) is list:
            for obj in hole:
                if obj is None:  # Default value
                    self.hole.append(Hole())
                elif isinstance(obj, dict):
                    # Check that the type is correct (including daughter)
                    class_name = obj.get("__class__")
                    if class_name not in [
                            "Hole",
                            "HoleM50",
                            "HoleM51",
                            "HoleM52",
                            "HoleM53",
                            "HoleM54",
                            "HoleMag",
                            "VentilationCirc",
                            "VentilationPolar",
                            "VentilationTrap",
                    ]:
                        raise InitUnKnowClassError("Unknow class name " +
                                                   class_name +
                                                   " in init_dict for hole")
                    # Dynamic import to call the correct constructor
                    module = __import__("pyleecan.Classes." + class_name,
                                        fromlist=[class_name])
                    class_obj = getattr(module, class_name)
                    self.hole.append(class_obj(init_dict=obj))
                else:
                    self.hole.append(obj)
        elif hole is None:
            self.hole = list()
        else:
            self.hole = hole
        # bore can be None, a Bore object or a dict
        if isinstance(bore, dict):
            # Check that the type is correct (including daughter)
            class_name = bore.get("__class__")
            if class_name not in ["Bore", "BoreFlower"]:
                raise InitUnKnowClassError("Unknow class name " + class_name +
                                           " in init_dict for bore")
            # Dynamic import to call the correct constructor
            module = __import__("pyleecan.Classes." + class_name,
                                fromlist=[class_name])
            class_obj = getattr(module, class_name)
            self.bore = class_obj(init_dict=bore)
        else:
            self.bore = bore
        # Call Lamination init
        super(LamHole, self).__init__(
            L1=L1,
            mat_type=mat_type,
            Nrvd=Nrvd,
            Wrvd=Wrvd,
            Kf1=Kf1,
            is_internal=is_internal,
            Rint=Rint,
            Rext=Rext,
            is_stator=is_stator,
            axial_vent=axial_vent,
            notch=notch,
        )
Exemplo n.º 15
0
    def __init__(
        self,
        simu=-1,
        path_res="",
        geo=-1,
        elec=-1,
        mag=-1,
        struct=-1,
        post=-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 simu == -1:
            simu = Simulation()
        if geo == -1:
            geo = OutGeo()
        if elec == -1:
            elec = OutElec()
        if mag == -1:
            mag = OutMag()
        if struct == -1:
            struct = OutStruct()
        if post == -1:
            post = OutPost()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                ["simu", "path_res", "geo", "elec", "mag", "struct", "post"])
            # Overwrite default value with init_dict content
            if "simu" in list(init_dict.keys()):
                simu = init_dict["simu"]
            if "path_res" in list(init_dict.keys()):
                path_res = init_dict["path_res"]
            if "geo" in list(init_dict.keys()):
                geo = init_dict["geo"]
            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 "post" in list(init_dict.keys()):
                post = init_dict["post"]
        # Initialisation by argument
        self.parent = None
        # simu can be None, a Simulation object or a dict
        if isinstance(simu, dict):
            # Check that the type is correct (including daughter)
            class_name = simu.get("__class__")
            if class_name not in ["Simulation", "Simu1"]:
                raise InitUnKnowClassError("Unknow class name " + class_name +
                                           " in init_dict for simu")
            # Dynamic import to call the correct constructor
            module = __import__("pyleecan.Classes." + class_name,
                                fromlist=[class_name])
            class_obj = getattr(module, class_name)
            self.simu = class_obj(init_dict=simu)
        else:
            self.simu = simu
        self.path_res = path_res
        # 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
        # mag can be None, a OutMag object or a dict
        if isinstance(mag, dict):
            self.mag = OutMag(init_dict=mag)
        else:
            self.mag = mag
        # struct can be None, a OutStruct object or a dict
        if isinstance(struct, dict):
            self.struct = OutStruct(init_dict=struct)
        else:
            self.struct = struct
        # post can be None, a OutPost object or a dict
        if isinstance(post, dict):
            self.post = OutPost(init_dict=post)
        else:
            self.post = post

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
Exemplo n.º 16
0
    def __init__(self,
                 element=dict(),
                 node=-1,
                 submesh=list(),
                 group=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 node == -1:
            node = Node()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(init_dict, ["element", "node", "submesh", "group"])
            # 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"]
            if "group" in list(init_dict.keys()):
                group = init_dict["group"]
        # Initialisation by argument
        self.parent = None
        # element can be None or a dict 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:
                    self.element[key] = obj
        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
        # group can be None, a ndarray or a list
        set_array(self, "group", group)

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
Exemplo n.º 17
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 = LamSlotMag()
        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 LamSlotMag object or a dict
        if isinstance(rotor, dict):
            self.rotor = LamSlotMag(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(MachineSIPMSM, self).__init__(
            frame=frame, shaft=shaft, name=name, desc=desc, type_machine=type_machine
        )
Exemplo n.º 18
0
    def __init__(
        self,
        lam_list=list(),
        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 frame == -1:
            frame = Frame()
        if shaft == -1:
            shaft = Shaft()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                ["lam_list", "frame", "shaft", "name", "desc", "type_machine"],
            )
            # Overwrite default value with init_dict content
            if "lam_list" in list(init_dict.keys()):
                lam_list = init_dict["lam_list"]
            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
        # lam_list can be None or a list of Lamination object
        self.lam_list = list()
        if type(lam_list) is list:
            for obj in lam_list:
                if obj is None:  # Default value
                    self.lam_list.append(Lamination())
                elif isinstance(obj, dict):
                    # Check that the type is correct (including daughter)
                    class_name = obj.get("__class__")
                    if class_name not in [
                            "Lamination",
                            "LamHole",
                            "LamSlot",
                            "LamSlotMag",
                            "LamSlotMulti",
                            "LamSlotWind",
                            "LamSquirrelCage",
                    ]:
                        raise InitUnKnowClassError(
                            "Unknow class name " + class_name +
                            " in init_dict for lam_list")
                    # Dynamic import to call the correct constructor
                    module = __import__("pyleecan.Classes." + class_name,
                                        fromlist=[class_name])
                    class_obj = getattr(module, class_name)
                    self.lam_list.append(class_obj(init_dict=obj))
                else:
                    self.lam_list.append(obj)
        elif lam_list is None:
            self.lam_list = list()
        else:
            self.lam_list = lam_list
        # Call Machine init
        super(MachineUD, self).__init__(frame=frame,
                                        shaft=shaft,
                                        name=name,
                                        desc=desc,
                                        type_machine=type_machine)