コード例 #1
0
ファイル: NodeMat.py プロジェクト: Superomeg4/pyleecan
    def __init__(
        self, coordinate=None, nb_node=0, tag=None, delta=1e-10, 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, ["coordinate", "nb_node", "tag", "delta"])
            # Overwrite default value with init_dict content
            if "coordinate" in list(init_dict.keys()):
                coordinate = init_dict["coordinate"]
            if "nb_node" in list(init_dict.keys()):
                nb_node = init_dict["nb_node"]
            if "tag" in list(init_dict.keys()):
                tag = init_dict["tag"]
            if "delta" in list(init_dict.keys()):
                delta = init_dict["delta"]
        # Initialisation by argument
        # coordinate can be None, a ndarray or a list
        set_array(self, "coordinate", coordinate)
        self.nb_node = nb_node
        # tag can be None, a ndarray or a list
        set_array(self, "tag", tag)
        self.delta = delta
        # Call Node init
        super(NodeMat, self).__init__()
コード例 #2
0
ファイル: OutStruct.py プロジェクト: focus2010/pyleecan
    def __init__(
        self,
        time=None,
        angle=None,
        Nt_tot=None,
        Na_tot=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 init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                ["time", "angle", "Nt_tot", "Na_tot", "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 "Nt_tot" in list(init_dict.keys()):
                Nt_tot = init_dict["Nt_tot"]
            if "Na_tot" in list(init_dict.keys()):
                Na_tot = init_dict["Na_tot"]
            if "Prad" in list(init_dict.keys()):
                Prad = init_dict["Prad"]
            if "Ptan" in list(init_dict.keys()):
                Ptan = init_dict["Ptan"]
        # Initialisation by argument
        self.parent = None
        # time can be None, a ndarray or a list
        set_array(self, "time", time)
        # angle can be None, a ndarray or a list
        set_array(self, "angle", angle)
        self.Nt_tot = Nt_tot
        self.Na_tot = Na_tot
        # Prad can be None, a ndarray or a list
        set_array(self, "Prad", Prad)
        # Ptan can be None, a ndarray or a list
        set_array(self, "Ptan", Ptan)

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
コード例 #3
0
ファイル: SolutionFEMM.py プロジェクト: focus2010/pyleecan
    def __init__(self, B=None, H=None, mu=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 init_dict is not None:  # Initialisation by dict
            check_init_dict(init_dict, ["B", "H", "mu"])
            # Overwrite default value with init_dict content
            if "B" in list(init_dict.keys()):
                B = init_dict["B"]
            if "H" in list(init_dict.keys()):
                H = init_dict["H"]
            if "mu" in list(init_dict.keys()):
                mu = init_dict["mu"]
        # Initialisation by argument
        # B can be None, a ndarray or a list
        set_array(self, "B", B)
        # H can be None, a ndarray or a list
        set_array(self, "H", H)
        # mu can be None, a ndarray or a list
        set_array(self, "mu", mu)
        # Call Solution init
        super(SolutionFEMM, self).__init__()
コード例 #4
0
    def __init__(self, matrix=None, f=None, H=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 init_dict is not None:  # Initialisation by dict
            check_init_dict(init_dict, ["matrix", "f", "H"])
            # Overwrite default value with init_dict content
            if "matrix" in list(init_dict.keys()):
                matrix = init_dict["matrix"]
            if "f" in list(init_dict.keys()):
                f = init_dict["f"]
            if "H" in list(init_dict.keys()):
                H = init_dict["H"]
        # Initialisation by argument
        # matrix can be None, a ndarray or a list
        set_array(self, "matrix", matrix)
        # f can be None, a ndarray or a list
        set_array(self, "f", f)
        # H can be None, a ndarray or a list
        set_array(self, "H", H)
        # Call BHCurve init
        super(BHCurveMat, self).__init__()
コード例 #5
0
    def __init__(self, value=None, is_transpose=False, 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, ["value", "is_transpose"])
            # Overwrite default value with init_dict content
            if "value" in list(init_dict.keys()):
                value = init_dict["value"]
            if "is_transpose" in list(init_dict.keys()):
                is_transpose = init_dict["is_transpose"]
        # Initialisation by argument
        # value can be None, a ndarray or a list
        set_array(self, "value", value)
        # Call ImportMatrix init
        super(ImportMatrixVal, self).__init__(is_transpose=is_transpose)
コード例 #6
0
ファイル: ElementMat.py プロジェクト: russel90/pyleecan
    def __init__(
        self,
        connectivity=None,
        nb_elem=None,
        nb_node_per_element=None,
        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 init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                ["connectivity", "nb_elem", "nb_node_per_element", "group"])
            # Overwrite default value with init_dict content
            if "connectivity" in list(init_dict.keys()):
                connectivity = init_dict["connectivity"]
            if "nb_elem" in list(init_dict.keys()):
                nb_elem = init_dict["nb_elem"]
            if "nb_node_per_element" in list(init_dict.keys()):
                nb_node_per_element = init_dict["nb_node_per_element"]
            if "group" in list(init_dict.keys()):
                group = init_dict["group"]
        # Initialisation by argument
        # connectivity can be None, a ndarray or a list
        set_array(self, "connectivity", connectivity)
        self.nb_elem = nb_elem
        self.nb_node_per_element = nb_node_per_element
        # group can be None, a ndarray or a list
        set_array(self, "group", group)
        # Call Element init
        super(ElementMat, self).__init__()
コード例 #7
0
    def __init__(self, alpha=None, notch_shape=list(), init_dict=None):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

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

        if init_dict is not None:  # Initialisation by dict
            check_init_dict(init_dict, ["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
        # alpha can be None, a ndarray or a list
        set_array(self, "alpha", alpha)
        # Call Notch init
        super(NotchEvenDist, self).__init__(notch_shape=notch_shape)
コード例 #8
0
ファイル: SubMesh.py プロジェクト: dacodehack/pyleecan
    def __init__(
        self,
        mesh=None,
        parent_elem=None,
        parent_node=None,
        group_number=None,
        init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

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

        if mesh == -1:
            mesh = Mesh()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                ["mesh", "parent_elem", "parent_node", "group_number"])
            # Overwrite default value with init_dict content
            if "mesh" in list(init_dict.keys()):
                mesh = init_dict["mesh"]
            if "parent_elem" in list(init_dict.keys()):
                parent_elem = init_dict["parent_elem"]
            if "parent_node" in list(init_dict.keys()):
                parent_node = init_dict["parent_node"]
            if "group_number" in list(init_dict.keys()):
                group_number = init_dict["group_number"]
        # Initialisation by argument
        self.parent = None
        # mesh can be None, a Mesh object or a dict
        if isinstance(mesh, dict):
            # Check that the type is correct (including daughter)
            class_name = mesh.get("__class__")
            if class_name not in ["Mesh", "MeshFEMM", "MeshMat", "MeshForce"]:
                raise InitUnKnowClassError("Unknow class name " + class_name +
                                           " in init_dict for mesh")
            # Dynamic import to call the correct constructor
            module = __import__("pyleecan.Classes." + class_name,
                                fromlist=[class_name])
            class_obj = getattr(module, class_name)
            self.mesh = class_obj(init_dict=mesh)
        else:
            self.mesh = mesh
        # parent_elem can be None, a ndarray or a list
        set_array(self, "parent_elem", parent_elem)
        # parent_node can be None, a ndarray or a list
        set_array(self, "parent_node", parent_node)
        # group_number can be None, a ndarray or a list
        set_array(self, "group_number", group_number)

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
コード例 #9
0
    def __init__(
        self,
        name_phase=None,
        BH_curve=None,
        Ksfill=None,
        S_slot=None,
        S_slot_wind=None,
        S_wind_act=None,
        sym=None,
        is_asym_wind=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 init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "name_phase",
                    "BH_curve",
                    "Ksfill",
                    "S_slot",
                    "S_slot_wind",
                    "S_wind_act",
                    "sym",
                    "is_asym_wind",
                ],
            )
            # Overwrite default value with init_dict content
            if "name_phase" in list(init_dict.keys()):
                name_phase = init_dict["name_phase"]
            if "BH_curve" in list(init_dict.keys()):
                BH_curve = init_dict["BH_curve"]
            if "Ksfill" in list(init_dict.keys()):
                Ksfill = init_dict["Ksfill"]
            if "S_slot" in list(init_dict.keys()):
                S_slot = init_dict["S_slot"]
            if "S_slot_wind" in list(init_dict.keys()):
                S_slot_wind = init_dict["S_slot_wind"]
            if "S_wind_act" in list(init_dict.keys()):
                S_wind_act = init_dict["S_wind_act"]
            if "sym" in list(init_dict.keys()):
                sym = init_dict["sym"]
            if "is_asym_wind" in list(init_dict.keys()):
                is_asym_wind = init_dict["is_asym_wind"]
        # Initialisation by argument
        self.parent = None
        self.name_phase = name_phase
        # BH_curve can be None, a ndarray or a list
        set_array(self, "BH_curve", BH_curve)
        self.Ksfill = Ksfill
        self.S_slot = S_slot
        self.S_slot_wind = S_slot_wind
        self.S_wind_act = S_wind_act
        self.sym = sym
        self.is_asym_wind = is_asym_wind

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
コード例 #10
0
    def __init__(
        self,
        time=None,
        angle=None,
        Nt_tot=None,
        Na_tot=None,
        Br=None,
        Bt=None,
        Tem=None,
        Tem_av=None,
        Tem_rip=None,
        Phi_wind_stator=None,
        emf=None,
        meshsolution=-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 meshsolution == -1:
            meshsolution = MeshSolution()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "time",
                    "angle",
                    "Nt_tot",
                    "Na_tot",
                    "Br",
                    "Bt",
                    "Tem",
                    "Tem_av",
                    "Tem_rip",
                    "Phi_wind_stator",
                    "emf",
                    "meshsolution",
                ],
            )
            # Overwrite default value with init_dict content
            if "time" in list(init_dict.keys()):
                time = init_dict["time"]
            if "angle" in list(init_dict.keys()):
                angle = init_dict["angle"]
            if "Nt_tot" in list(init_dict.keys()):
                Nt_tot = init_dict["Nt_tot"]
            if "Na_tot" in list(init_dict.keys()):
                Na_tot = init_dict["Na_tot"]
            if "Br" in list(init_dict.keys()):
                Br = init_dict["Br"]
            if "Bt" in list(init_dict.keys()):
                Bt = init_dict["Bt"]
            if "Tem" in list(init_dict.keys()):
                Tem = init_dict["Tem"]
            if "Tem_av" in list(init_dict.keys()):
                Tem_av = init_dict["Tem_av"]
            if "Tem_rip" in list(init_dict.keys()):
                Tem_rip = init_dict["Tem_rip"]
            if "Phi_wind_stator" in list(init_dict.keys()):
                Phi_wind_stator = init_dict["Phi_wind_stator"]
            if "emf" in list(init_dict.keys()):
                emf = init_dict["emf"]
            if "meshsolution" in list(init_dict.keys()):
                meshsolution = init_dict["meshsolution"]
        # Initialisation by argument
        self.parent = None
        # time can be None, a ndarray or a list
        set_array(self, "time", time)
        # angle can be None, a ndarray or a list
        set_array(self, "angle", angle)
        self.Nt_tot = Nt_tot
        self.Na_tot = Na_tot
        # Br can be None, a ndarray or a list
        set_array(self, "Br", Br)
        # Bt can be None, a ndarray or a list
        set_array(self, "Bt", Bt)
        # Tem can be None, a ndarray or a list
        set_array(self, "Tem", Tem)
        self.Tem_av = Tem_av
        self.Tem_rip = Tem_rip
        # Phi_wind_stator can be None, a ndarray or a list
        set_array(self, "Phi_wind_stator", Phi_wind_stator)
        # emf can be None, a ndarray or a list
        set_array(self, "emf", emf)
        # meshsolution can be None, a MeshSolution object or a dict
        if isinstance(meshsolution, dict):
            self.meshsolution = MeshSolution(init_dict=meshsolution)
        else:
            self.meshsolution = meshsolution

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
コード例 #11
0
    def __init__(
            self,
            time=None,
            angle=None,
            Nt_tot=None,
            Na_tot=None,
            Br=None,
            Bt=None,
            Tem=None,
            Tem_av=None,
            Tem_rip=None,
            Phi_wind_stator=None,
            emf=None,
            mesh=list(),
            init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

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

        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "time",
                    "angle",
                    "Nt_tot",
                    "Na_tot",
                    "Br",
                    "Bt",
                    "Tem",
                    "Tem_av",
                    "Tem_rip",
                    "Phi_wind_stator",
                    "emf",
                    "mesh",
                ],
            )
            # Overwrite default value with init_dict content
            if "time" in list(init_dict.keys()):
                time = init_dict["time"]
            if "angle" in list(init_dict.keys()):
                angle = init_dict["angle"]
            if "Nt_tot" in list(init_dict.keys()):
                Nt_tot = init_dict["Nt_tot"]
            if "Na_tot" in list(init_dict.keys()):
                Na_tot = init_dict["Na_tot"]
            if "Br" in list(init_dict.keys()):
                Br = init_dict["Br"]
            if "Bt" in list(init_dict.keys()):
                Bt = init_dict["Bt"]
            if "Tem" in list(init_dict.keys()):
                Tem = init_dict["Tem"]
            if "Tem_av" in list(init_dict.keys()):
                Tem_av = init_dict["Tem_av"]
            if "Tem_rip" in list(init_dict.keys()):
                Tem_rip = init_dict["Tem_rip"]
            if "Phi_wind_stator" in list(init_dict.keys()):
                Phi_wind_stator = init_dict["Phi_wind_stator"]
            if "emf" in list(init_dict.keys()):
                emf = init_dict["emf"]
            if "mesh" in list(init_dict.keys()):
                mesh = init_dict["mesh"]
        # Initialisation by argument
        self.parent = None
        # time can be None, a ndarray or a list
        set_array(self, "time", time)
        # angle can be None, a ndarray or a list
        set_array(self, "angle", angle)
        self.Nt_tot = Nt_tot
        self.Na_tot = Na_tot
        # Br can be None, a ndarray or a list
        set_array(self, "Br", Br)
        # Bt can be None, a ndarray or a list
        set_array(self, "Bt", Bt)
        # Tem can be None, a ndarray or a list
        set_array(self, "Tem", Tem)
        self.Tem_av = Tem_av
        self.Tem_rip = Tem_rip
        # Phi_wind_stator can be None, a ndarray or a list
        set_array(self, "Phi_wind_stator", Phi_wind_stator)
        # emf can be None, a ndarray or a list
        set_array(self, "emf", emf)
        # mesh can be None or a list of Mesh object
        self.mesh = list()
        if type(mesh) is list:
            for obj in mesh:
                if obj is None:  # Default value
                    self.mesh.append(Mesh())
                elif isinstance(obj, dict):
                    # Check that the type is correct (including daughter)
                    class_name = obj.get("__class__")
                    if class_name not in [
                            "Mesh", "MeshFEMM", "MeshMat", "MeshForce"
                    ]:
                        raise InitUnKnowClassError("Unknow class name " +
                                                   class_name +
                                                   " in init_dict for mesh")
                    # Dynamic import to call the correct constructor
                    module = __import__("pyleecan.Classes." + class_name,
                                        fromlist=[class_name])
                    class_obj = getattr(module, class_name)
                    self.mesh.append(class_obj(init_dict=obj))
                else:
                    self.mesh.append(obj)
        elif mesh is None:
            self.mesh = list()
        else:
            self.mesh = mesh

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
コード例 #12
0
ファイル: WindingUD.py プロジェクト: focus2010/pyleecan
    def __init__(
        self,
        user_wind_mat=None,
        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,
                [
                    "user_wind_mat",
                    "is_reverse_wind",
                    "Nslot_shift_wind",
                    "qs",
                    "Ntcoil",
                    "Npcpp",
                    "type_connection",
                    "p",
                    "Lewout",
                    "conductor",
                ],
            )
            # Overwrite default value with init_dict content
            if "user_wind_mat" in list(init_dict.keys()):
                user_wind_mat = init_dict["user_wind_mat"]
            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
        # user_wind_mat can be None, a ndarray or a list
        set_array(self, "user_wind_mat", user_wind_mat)
        # Call Winding init
        super(WindingUD, 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,
        )
コード例 #13
0
    def __init__(
            self,
            B=None,
            H=None,
            mu=None,
            element=None,
            node=None,
            group=None,
            nb_elem=None,
            nb_node=None,
            submesh=list(),
            nb_node_per_element=None,
            name=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 init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "B",
                    "H",
                    "mu",
                    "element",
                    "node",
                    "group",
                    "nb_elem",
                    "nb_node",
                    "submesh",
                    "nb_node_per_element",
                    "name",
                ],
            )
            # Overwrite default value with init_dict content
            if "B" in list(init_dict.keys()):
                B = init_dict["B"]
            if "H" in list(init_dict.keys()):
                H = init_dict["H"]
            if "mu" in list(init_dict.keys()):
                mu = init_dict["mu"]
            if "element" in list(init_dict.keys()):
                element = init_dict["element"]
            if "node" in list(init_dict.keys()):
                node = init_dict["node"]
            if "group" in list(init_dict.keys()):
                group = init_dict["group"]
            if "nb_elem" in list(init_dict.keys()):
                nb_elem = init_dict["nb_elem"]
            if "nb_node" in list(init_dict.keys()):
                nb_node = init_dict["nb_node"]
            if "submesh" in list(init_dict.keys()):
                submesh = init_dict["submesh"]
            if "nb_node_per_element" in list(init_dict.keys()):
                nb_node_per_element = init_dict["nb_node_per_element"]
            if "name" in list(init_dict.keys()):
                name = init_dict["name"]
        # Initialisation by argument
        # B can be None, a ndarray or a list
        set_array(self, "B", B)
        # H can be None, a ndarray or a list
        set_array(self, "H", H)
        # mu can be None, a ndarray or a list
        set_array(self, "mu", mu)
        # Call MeshMat init
        super(MeshFEMM, self).__init__(
            element=element,
            node=node,
            group=group,
            nb_elem=nb_elem,
            nb_node=nb_node,
            submesh=submesh,
            nb_node_per_element=nb_node_per_element,
            name=name,
        )
コード例 #14
0
    def __init__(
            self,
            element=None,
            node=None,
            group=None,
            nb_elem=None,
            nb_node=None,
            submesh=list(),
            nb_node_per_element=None,
            name=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 init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "element",
                    "node",
                    "group",
                    "nb_elem",
                    "nb_node",
                    "submesh",
                    "nb_node_per_element",
                    "name",
                ],
            )
            # 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 "group" in list(init_dict.keys()):
                group = init_dict["group"]
            if "nb_elem" in list(init_dict.keys()):
                nb_elem = init_dict["nb_elem"]
            if "nb_node" in list(init_dict.keys()):
                nb_node = init_dict["nb_node"]
            if "submesh" in list(init_dict.keys()):
                submesh = init_dict["submesh"]
            if "nb_node_per_element" in list(init_dict.keys()):
                nb_node_per_element = init_dict["nb_node_per_element"]
            if "name" in list(init_dict.keys()):
                name = init_dict["name"]
        # Initialisation by argument
        # element can be None, a ndarray or a list
        set_array(self, "element", element)
        # node can be None, a ndarray or a list
        set_array(self, "node", node)
        # group can be None, a ndarray or a list
        set_array(self, "group", group)
        self.nb_elem = nb_elem
        self.nb_node = nb_node
        # submesh can be None or a list of SubMesh object
        self.submesh = list()
        if type(submesh) is list:
            for obj in submesh:
                if obj is None:  # Default value
                    self.submesh.append(SubMesh())
                elif isinstance(obj, dict):
                    self.submesh.append(SubMesh(init_dict=obj))
                else:
                    self.submesh.append(obj)
        elif submesh is None:
            self.submesh = list()
        else:
            self.submesh = submesh
        self.nb_node_per_element = nb_node_per_element
        # Call Mesh init
        super(MeshMat, self).__init__(name=name)
コード例 #15
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 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
        self.parent = None
        # time can be None, a ndarray or a list
        set_array(self, "time", time)
        # angle can be None, a ndarray or a list
        set_array(self, "angle", angle)
        # Is can be None, a ndarray or a list
        set_array(self, "Is", Is)
        # Ir can be None, a ndarray or a list
        set_array(self, "Ir", Ir)
        # angle_rotor can be None, a ndarray or a list
        set_array(self, "angle_rotor", angle_rotor)
        # Nr can be None, a ndarray or a list
        set_array(self, "Nr", Nr)
        self.rot_dir = rot_dir
        self.angle_rotor_initial = angle_rotor_initial

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()