Esempio n. 1
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__()
Esempio n. 2
0
    def __init__(
            self,
            slot=-1,
            L1=0.35,
            mat_type=-1,
            Nrvd=0,
            Wrvd=0,
            Kf1=0.95,
            is_internal=True,
            Rint=0,
            Rext=1,
            is_stator=True,
            axial_vent=list(),
            notch=list(),
            init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

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

        if slot == -1:
            slot = Slot()
        if mat_type == -1:
            mat_type = Material()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "slot",
                    "L1",
                    "mat_type",
                    "Nrvd",
                    "Wrvd",
                    "Kf1",
                    "is_internal",
                    "Rint",
                    "Rext",
                    "is_stator",
                    "axial_vent",
                    "notch",
                ],
            )
            # Overwrite default value with init_dict content
            if "slot" in list(init_dict.keys()):
                slot = init_dict["slot"]
            if "L1" in list(init_dict.keys()):
                L1 = init_dict["L1"]
            if "mat_type" in list(init_dict.keys()):
                mat_type = init_dict["mat_type"]
            if "Nrvd" in list(init_dict.keys()):
                Nrvd = init_dict["Nrvd"]
            if "Wrvd" in list(init_dict.keys()):
                Wrvd = init_dict["Wrvd"]
            if "Kf1" in list(init_dict.keys()):
                Kf1 = init_dict["Kf1"]
            if "is_internal" in list(init_dict.keys()):
                is_internal = init_dict["is_internal"]
            if "Rint" in list(init_dict.keys()):
                Rint = init_dict["Rint"]
            if "Rext" in list(init_dict.keys()):
                Rext = init_dict["Rext"]
            if "is_stator" in list(init_dict.keys()):
                is_stator = init_dict["is_stator"]
            if "axial_vent" in list(init_dict.keys()):
                axial_vent = init_dict["axial_vent"]
            if "notch" in list(init_dict.keys()):
                notch = init_dict["notch"]
        # Initialisation by argument
        # slot can be None, a Slot object or a dict
        if isinstance(slot, dict):
            # Check that the type is correct (including daughter)
            class_name = slot.get("__class__")
            if class_name not in [
                    "Slot",
                    "Slot19",
                    "SlotMFlat",
                    "SlotMPolar",
                    "SlotW10",
                    "SlotW11",
                    "SlotW12",
                    "SlotW13",
                    "SlotW14",
                    "SlotW15",
                    "SlotW16",
                    "SlotW21",
                    "SlotW22",
                    "SlotW23",
                    "SlotW24",
                    "SlotW25",
                    "SlotW26",
                    "SlotW27",
                    "SlotW28",
                    "SlotW29",
                    "SlotW60",
                    "SlotW61",
            ]:
                raise InitUnKnowClassError("Unknow class name " + class_name +
                                           " in init_dict for slot")
            # Dynamic import to call the correct constructor
            module = __import__("pyleecan.Classes." + class_name,
                                fromlist=[class_name])
            class_obj = getattr(module, class_name)
            self.slot = class_obj(init_dict=slot)
        else:
            self.slot = slot
        # Call Lamination init
        super(LamSlot, self).__init__(
            L1=L1,
            mat_type=mat_type,
            Nrvd=Nrvd,
            Wrvd=Wrvd,
            Kf1=Kf1,
            is_internal=is_internal,
            Rint=Rint,
            Rext=Rext,
            is_stator=is_stator,
            axial_vent=axial_vent,
            notch=notch,
        )
Esempio n. 3
0
    def __init__(
        self,
        slot=-1,
        L1=0.35,
        mat_type=-1,
        Nrvd=0,
        Wrvd=0,
        Kf1=0.95,
        is_internal=True,
        Rint=0,
        Rext=1,
        is_stator=True,
        axial_vent=list(),
        init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

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

        if slot == -1:
            slot = Slot()
        if mat_type == -1:
            mat_type = Material()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "slot",
                    "L1",
                    "mat_type",
                    "Nrvd",
                    "Wrvd",
                    "Kf1",
                    "is_internal",
                    "Rint",
                    "Rext",
                    "is_stator",
                    "axial_vent",
                ],
            )
            # Overwrite default value with init_dict content
            if "slot" in list(init_dict.keys()):
                slot = init_dict["slot"]
            if "L1" in list(init_dict.keys()):
                L1 = init_dict["L1"]
            if "mat_type" in list(init_dict.keys()):
                mat_type = init_dict["mat_type"]
            if "Nrvd" in list(init_dict.keys()):
                Nrvd = init_dict["Nrvd"]
            if "Wrvd" in list(init_dict.keys()):
                Wrvd = init_dict["Wrvd"]
            if "Kf1" in list(init_dict.keys()):
                Kf1 = init_dict["Kf1"]
            if "is_internal" in list(init_dict.keys()):
                is_internal = init_dict["is_internal"]
            if "Rint" in list(init_dict.keys()):
                Rint = init_dict["Rint"]
            if "Rext" in list(init_dict.keys()):
                Rext = init_dict["Rext"]
            if "is_stator" in list(init_dict.keys()):
                is_stator = init_dict["is_stator"]
            if "axial_vent" in list(init_dict.keys()):
                axial_vent = init_dict["axial_vent"]
        # Initialisation by argument
        # slot can be None, a Slot object or a dict
        if isinstance(slot, dict):
            # Call the correct constructor according to the dict
            load_dict = {
                "SlotMFlat": SlotMFlat,
                "SlotMPolar": SlotMPolar,
                "SlotW10": SlotW10,
                "SlotW11": SlotW11,
                "SlotW12": SlotW12,
                "SlotW13": SlotW13,
                "SlotW14": SlotW14,
                "SlotW15": SlotW15,
                "SlotW16": SlotW16,
                "SlotW21": SlotW21,
                "SlotW22": SlotW22,
                "SlotW23": SlotW23,
                "SlotW24": SlotW24,
                "SlotW25": SlotW25,
                "SlotW26": SlotW26,
                "SlotW27": SlotW27,
                "SlotW28": SlotW28,
                "SlotW29": SlotW29,
                "SlotW60": SlotW60,
                "SlotW61": SlotW61,
                "Slot": Slot,
            }
            obj_class = slot.get("__class__")
            if obj_class is None:
                self.slot = Slot(init_dict=slot)
            elif obj_class in list(load_dict.keys()):
                self.slot = load_dict[obj_class](init_dict=slot)
            else:  # Avoid generation error or wrong modification in json
                raise InitUnKnowClassError("Unknow class name in init_dict for slot")
        else:
            self.slot = slot
        # Call Lamination init
        super(LamSlot, self).__init__(
            L1=L1,
            mat_type=mat_type,
            Nrvd=Nrvd,
            Wrvd=Wrvd,
            Kf1=Kf1,
            is_internal=is_internal,
            Rint=Rint,
            Rext=Rext,
            is_stator=is_stator,
            axial_vent=axial_vent,
        )