Ejemplo n.º 1
0
class ForceMT(Force):
    """Force Maxwell tensor model"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Simulation.ForceMT.comp_force
    if isinstance(comp_force, ImportError):
        comp_force = property(fget=lambda x: raise_(
            ImportError("Can't use ForceMT method comp_force: " + str(
                comp_force))))
    else:
        comp_force = comp_force
    # cf Methods.Simulation.ForceMT.comp_force_nodal
    if isinstance(comp_force_nodal, ImportError):
        comp_force_nodal = property(fget=lambda x: raise_(
            ImportError("Can't use ForceMT method comp_force_nodal: " + str(
                comp_force_nodal))))
    else:
        comp_force_nodal = comp_force_nodal
    # save method is available in all object
    save = save

    def __init__(self, is_comp_nodal_force=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, ["is_comp_nodal_force"])
            # Overwrite default value with init_dict content
            if "is_comp_nodal_force" in list(init_dict.keys()):
                is_comp_nodal_force = init_dict["is_comp_nodal_force"]
        # Initialisation by argument
        # Call Force init
        super(ForceMT, self).__init__(is_comp_nodal_force=is_comp_nodal_force)
        # The class is frozen (in Force init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        ForceMT_str = ""
        # Get the properties inherited from Force
        ForceMT_str += super(ForceMT, self).__str__()
        return ForceMT_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from Force
        if not super(ForceMT, self).__eq__(other):
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from Force
        ForceMT_dict = super(ForceMT, self).as_dict()
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        ForceMT_dict["__class__"] = "ForceMT"
        return ForceMT_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        # Set to None the properties inherited from Force
        super(ForceMT, self)._set_None()
Ejemplo n.º 2
0
class SlotW24(SlotWind):

    VERSION = 1
    IS_SYMMETRICAL = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Slot.SlotW24._comp_point_coordinate
    if isinstance(_comp_point_coordinate, ImportError):
        _comp_point_coordinate = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW24 method _comp_point_coordinate: " +
                        str(_comp_point_coordinate))))
    else:
        _comp_point_coordinate = _comp_point_coordinate
    # cf Methods.Slot.SlotW24.build_geometry
    if isinstance(build_geometry, ImportError):
        build_geometry = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW24 method build_geometry: " + str(
                build_geometry))))
    else:
        build_geometry = build_geometry
    # cf Methods.Slot.SlotW24.build_geometry_wind
    if isinstance(build_geometry_wind, ImportError):
        build_geometry_wind = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW24 method build_geometry_wind: " + str(
                build_geometry_wind))))
    else:
        build_geometry_wind = build_geometry_wind
    # cf Methods.Slot.SlotW24.check
    if isinstance(check, ImportError):
        check = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW24 method check: " + str(check))))
    else:
        check = check
    # cf Methods.Slot.SlotW24.comp_alphas
    if isinstance(comp_alphas, ImportError):
        comp_alphas = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW24 method comp_alphas: " + str(
                comp_alphas))))
    else:
        comp_alphas = comp_alphas
    # cf Methods.Slot.SlotW24.comp_angle_opening
    if isinstance(comp_angle_opening, ImportError):
        comp_angle_opening = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW24 method comp_angle_opening: " + str(
                comp_angle_opening))))
    else:
        comp_angle_opening = comp_angle_opening
    # cf Methods.Slot.SlotW24.comp_height
    if isinstance(comp_height, ImportError):
        comp_height = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW24 method comp_height: " + str(
                comp_height))))
    else:
        comp_height = comp_height
    # cf Methods.Slot.SlotW24.comp_height_wind
    if isinstance(comp_height_wind, ImportError):
        comp_height_wind = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW24 method comp_height_wind: " + str(
                comp_height_wind))))
    else:
        comp_height_wind = comp_height_wind
    # cf Methods.Slot.SlotW24.comp_surface
    if isinstance(comp_surface, ImportError):
        comp_surface = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW24 method comp_surface: " + str(
                comp_surface))))
    else:
        comp_surface = comp_surface
    # cf Methods.Slot.SlotW24.comp_surface_wind
    if isinstance(comp_surface_wind, ImportError):
        comp_surface_wind = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW24 method comp_surface_wind: " + str(
                comp_surface_wind))))
    else:
        comp_surface_wind = comp_surface_wind
    # save method is available in all object
    save = save

    def __init__(self, W3=0.003, H2=0.003, 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, ["W3", "H2", "Zs"])
            # Overwrite default value with init_dict content
            if "W3" in list(init_dict.keys()):
                W3 = init_dict["W3"]
            if "H2" in list(init_dict.keys()):
                H2 = init_dict["H2"]
            if "Zs" in list(init_dict.keys()):
                Zs = init_dict["Zs"]
        # Initialisation by argument
        self.W3 = W3
        self.H2 = H2
        # Call SlotWind init
        super(SlotW24, self).__init__(Zs=Zs)
        # The class is frozen (in SlotWind init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        SlotW24_str = ""
        # Get the properties inherited from SlotWind
        SlotW24_str += super(SlotW24, self).__str__()
        SlotW24_str += "W3 = " + str(self.W3) + linesep
        SlotW24_str += "H2 = " + str(self.H2) + linesep
        return SlotW24_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from SlotWind
        if not super(SlotW24, self).__eq__(other):
            return False
        if other.W3 != self.W3:
            return False
        if other.H2 != self.H2:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from SlotWind
        SlotW24_dict = super(SlotW24, self).as_dict()
        SlotW24_dict["W3"] = self.W3
        SlotW24_dict["H2"] = self.H2
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        SlotW24_dict["__class__"] = "SlotW24"
        return SlotW24_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.W3 = None
        self.H2 = None
        # Set to None the properties inherited from SlotWind
        super(SlotW24, self)._set_None()

    def _get_W3(self):
        """getter of W3"""
        return self._W3

    def _set_W3(self, value):
        """setter of W3"""
        check_var("W3", value, "float", Vmin=0)
        self._W3 = value

    # Teeth width
    # Type : float, min = 0
    W3 = property(fget=_get_W3, fset=_set_W3, doc=u"""Teeth width""")

    def _get_H2(self):
        """getter of H2"""
        return self._H2

    def _set_H2(self, value):
        """setter of H2"""
        check_var("H2", value, "float", Vmin=0)
        self._H2 = value

    # Slot height
    # Type : float, min = 0
    H2 = property(fget=_get_H2, fset=_set_H2, doc=u"""Slot height""")
Ejemplo n.º 3
0
class OutputMultiOpti(OutputMulti):
    """Optimization results"""

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Output.OutputMultiOpti.add_evaluation
    if isinstance(add_evaluation, ImportError):
        add_evaluation = property(fget=lambda x: raise_(
            ImportError("Can't use OutputMultiOpti method add_evaluation: " +
                        str(add_evaluation))))
    else:
        add_evaluation = add_evaluation
    # cf Methods.Output.OutputMultiOpti.plot_pareto
    if isinstance(plot_pareto, ImportError):
        plot_pareto = property(fget=lambda x: raise_(
            ImportError("Can't use OutputMultiOpti method plot_pareto: " + str(
                plot_pareto))))
    else:
        plot_pareto = plot_pareto
    # cf Methods.Output.OutputMultiOpti.plot_generation
    if isinstance(plot_generation, ImportError):
        plot_generation = property(fget=lambda x: raise_(
            ImportError("Can't use OutputMultiOpti method plot_generation: " +
                        str(plot_generation))))
    else:
        plot_generation = plot_generation
    # cf Methods.Output.OutputMultiOpti.get_pareto
    if isinstance(get_pareto, ImportError):
        get_pareto = property(fget=lambda x: raise_(
            ImportError("Can't use OutputMultiOpti method get_pareto: " + str(
                get_pareto))))
    else:
        get_pareto = get_pareto
    # cf Methods.Output.OutputMultiOpti.plot_pareto_design_space
    if isinstance(plot_pareto_design_space, ImportError):
        plot_pareto_design_space = property(fget=lambda x: raise_(
            ImportError(
                "Can't use OutputMultiOpti method plot_pareto_design_space: " +
                str(plot_pareto_design_space))))
    else:
        plot_pareto_design_space = plot_pareto_design_space
    # cf Methods.Output.OutputMultiOpti.plot_generation_design_space
    if isinstance(plot_generation_design_space, ImportError):
        plot_generation_design_space = property(fget=lambda x: raise_(
            ImportError(
                "Can't use OutputMultiOpti method plot_generation_design_space: "
                + str(plot_generation_design_space))))
    else:
        plot_generation_design_space = plot_generation_design_space
    # save method is available in all object
    save = save

    def __init__(
        self,
        fitness=[],
        constraint=[],
        ngen=[],
        fitness_names=[],
        output_ref=-1,
        outputs=list(),
        is_valid=[],
        design_var=[],
        design_var_names=[],
        init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

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

        if output_ref == -1:
            output_ref = Output()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "fitness",
                    "constraint",
                    "ngen",
                    "fitness_names",
                    "output_ref",
                    "outputs",
                    "is_valid",
                    "design_var",
                    "design_var_names",
                ],
            )
            # Overwrite default value with init_dict content
            if "fitness" in list(init_dict.keys()):
                fitness = init_dict["fitness"]
            if "constraint" in list(init_dict.keys()):
                constraint = init_dict["constraint"]
            if "ngen" in list(init_dict.keys()):
                ngen = init_dict["ngen"]
            if "fitness_names" in list(init_dict.keys()):
                fitness_names = init_dict["fitness_names"]
            if "output_ref" in list(init_dict.keys()):
                output_ref = init_dict["output_ref"]
            if "outputs" in list(init_dict.keys()):
                outputs = init_dict["outputs"]
            if "is_valid" in list(init_dict.keys()):
                is_valid = init_dict["is_valid"]
            if "design_var" in list(init_dict.keys()):
                design_var = init_dict["design_var"]
            if "design_var_names" in list(init_dict.keys()):
                design_var_names = init_dict["design_var_names"]
        # Initialisation by argument
        self.fitness = fitness
        self.constraint = constraint
        self.ngen = ngen
        self.fitness_names = fitness_names
        # Call OutputMulti init
        super(OutputMultiOpti, self).__init__(
            output_ref=output_ref,
            outputs=outputs,
            is_valid=is_valid,
            design_var=design_var,
            design_var_names=design_var_names,
        )
        # The class is frozen (in OutputMulti init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        OutputMultiOpti_str = ""
        # Get the properties inherited from OutputMulti
        OutputMultiOpti_str += super(OutputMultiOpti, self).__str__()
        OutputMultiOpti_str += (
            "fitness = " + linesep +
            str(self.fitness).replace(linesep, linesep + "\t") + linesep)
        OutputMultiOpti_str += (
            "constraint = " + linesep +
            str(self.constraint).replace(linesep, linesep + "\t") + linesep)
        OutputMultiOpti_str += (
            "ngen = " + linesep +
            str(self.ngen).replace(linesep, linesep + "\t") + linesep)
        OutputMultiOpti_str += (
            "fitness_names = " + linesep +
            str(self.fitness_names).replace(linesep, linesep + "\t") + linesep)
        return OutputMultiOpti_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from OutputMulti
        if not super(OutputMultiOpti, self).__eq__(other):
            return False
        if other.fitness != self.fitness:
            return False
        if other.constraint != self.constraint:
            return False
        if other.ngen != self.ngen:
            return False
        if other.fitness_names != self.fitness_names:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from OutputMulti
        OutputMultiOpti_dict = super(OutputMultiOpti, self).as_dict()
        OutputMultiOpti_dict["fitness"] = self.fitness
        OutputMultiOpti_dict["constraint"] = self.constraint
        OutputMultiOpti_dict["ngen"] = self.ngen
        OutputMultiOpti_dict["fitness_names"] = self.fitness_names
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        OutputMultiOpti_dict["__class__"] = "OutputMultiOpti"
        return OutputMultiOpti_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.fitness = None
        self.constraint = None
        self.ngen = None
        self.fitness_names = None
        # Set to None the properties inherited from OutputMulti
        super(OutputMultiOpti, self)._set_None()

    def _get_fitness(self):
        """getter of fitness"""
        return self._fitness

    def _set_fitness(self, value):
        """setter of fitness"""
        check_var("fitness", value, "list")
        self._fitness = value

    # List of the corresponding output objective values
    # Type : list
    fitness = property(
        fget=_get_fitness,
        fset=_set_fitness,
        doc=u"""List of the corresponding output objective values""",
    )

    def _get_constraint(self):
        """getter of constraint"""
        return self._constraint

    def _set_constraint(self, value):
        """setter of constraint"""
        check_var("constraint", value, "list")
        self._constraint = value

    # List of the corresponding output constraint values
    # Type : list
    constraint = property(
        fget=_get_constraint,
        fset=_set_constraint,
        doc=u"""List of the corresponding output constraint values""",
    )

    def _get_ngen(self):
        """getter of ngen"""
        return self._ngen

    def _set_ngen(self, value):
        """setter of ngen"""
        check_var("ngen", value, "list")
        self._ngen = value

    # Number of generation of the indiv
    # Type : list
    ngen = property(fget=_get_ngen,
                    fset=_set_ngen,
                    doc=u"""Number of generation of the indiv""")

    def _get_fitness_names(self):
        """getter of fitness_names"""
        return self._fitness_names

    def _set_fitness_names(self, value):
        """setter of fitness_names"""
        check_var("fitness_names", value, "list")
        self._fitness_names = value

    # Names of the objectives functions
    # Type : list
    fitness_names = property(
        fget=_get_fitness_names,
        fset=_set_fitness_names,
        doc=u"""Names of the objectives functions""",
    )
Ejemplo n.º 4
0
class Magnet(FrozenClass):
    """abstract class of magnets"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Machine.Magnet.comp_angle_opening
    if isinstance(comp_angle_opening, ImportError):
        comp_angle_opening = property(fget=lambda x: raise_(
            ImportError("Can't use Magnet method comp_angle_opening: " + str(
                comp_angle_opening))))
    else:
        comp_angle_opening = comp_angle_opening
    # cf Methods.Machine.Magnet.comp_height
    if isinstance(comp_height, ImportError):
        comp_height = property(fget=lambda x: raise_(
            ImportError("Can't use Magnet method comp_height: " + str(
                comp_height))))
    else:
        comp_height = comp_height
    # cf Methods.Machine.Magnet.comp_mass
    if isinstance(comp_mass, ImportError):
        comp_mass = property(fget=lambda x: raise_(
            ImportError("Can't use Magnet method comp_mass: " + str(comp_mass))
        ))
    else:
        comp_mass = comp_mass
    # cf Methods.Machine.Magnet.comp_ratio_opening
    if isinstance(comp_ratio_opening, ImportError):
        comp_ratio_opening = property(fget=lambda x: raise_(
            ImportError("Can't use Magnet method comp_ratio_opening: " + str(
                comp_ratio_opening))))
    else:
        comp_ratio_opening = comp_ratio_opening
    # cf Methods.Machine.Magnet.comp_surface
    if isinstance(comp_surface, ImportError):
        comp_surface = property(fget=lambda x: raise_(
            ImportError("Can't use Magnet method comp_surface: " + str(
                comp_surface))))
    else:
        comp_surface = comp_surface
    # cf Methods.Machine.Magnet.comp_volume
    if isinstance(comp_volume, ImportError):
        comp_volume = property(fget=lambda x: raise_(
            ImportError("Can't use Magnet method comp_volume: " + str(
                comp_volume))))
    else:
        comp_volume = comp_volume
    # cf Methods.Machine.Magnet.is_outwards
    if isinstance(is_outwards, ImportError):
        is_outwards = property(fget=lambda x: raise_(
            ImportError("Can't use Magnet method is_outwards: " + str(
                is_outwards))))
    else:
        is_outwards = is_outwards
    # cf Methods.Machine.Magnet.plot
    if isinstance(plot, ImportError):
        plot = property(fget=lambda x: raise_(
            ImportError("Can't use Magnet method plot: " + str(plot))))
    else:
        plot = plot
    # save method is available in all object
    save = save

    def __init__(self,
                 mat_type=-1,
                 type_magnetization=0,
                 Lmag=0.95,
                 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,
                            ["mat_type", "type_magnetization", "Lmag"])
            # Overwrite default value with init_dict content
            if "mat_type" in list(init_dict.keys()):
                mat_type = init_dict["mat_type"]
            if "type_magnetization" in list(init_dict.keys()):
                type_magnetization = init_dict["type_magnetization"]
            if "Lmag" in list(init_dict.keys()):
                Lmag = init_dict["Lmag"]
        # Initialisation by argument
        self.parent = None
        # 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.type_magnetization = type_magnetization
        self.Lmag = Lmag

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

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        Magnet_str = ""
        if self.parent is None:
            Magnet_str += "parent = None " + linesep
        else:
            Magnet_str += "parent = " + str(type(
                self.parent)) + " object" + linesep
        if self.mat_type is not None:
            tmp = self.mat_type.__str__().replace(linesep,
                                                  linesep + "\t").rstrip("\t")
            Magnet_str += "mat_type = " + tmp
        else:
            Magnet_str += "mat_type = None" + linesep + linesep
        Magnet_str += "type_magnetization = " + str(
            self.type_magnetization) + linesep
        Magnet_str += "Lmag = " + str(self.Lmag) + linesep
        return Magnet_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False
        if other.mat_type != self.mat_type:
            return False
        if other.type_magnetization != self.type_magnetization:
            return False
        if other.Lmag != self.Lmag:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        Magnet_dict = dict()
        if self.mat_type is None:
            Magnet_dict["mat_type"] = None
        else:
            Magnet_dict["mat_type"] = self.mat_type.as_dict()
        Magnet_dict["type_magnetization"] = self.type_magnetization
        Magnet_dict["Lmag"] = self.Lmag
        # The class name is added to the dict fordeserialisation purpose
        Magnet_dict["__class__"] = "Magnet"
        return Magnet_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        if self.mat_type is not None:
            self.mat_type._set_None()
        self.type_magnetization = None
        self.Lmag = None

    def _get_mat_type(self):
        """getter of mat_type"""
        return self._mat_type

    def _set_mat_type(self, value):
        """setter of mat_type"""
        check_var("mat_type", value, "Material")
        self._mat_type = value

        if self._mat_type is not None:
            self._mat_type.parent = self

    # The Magnet material
    # Type : Material
    mat_type = property(fget=_get_mat_type,
                        fset=_set_mat_type,
                        doc=u"""The Magnet material""")

    def _get_type_magnetization(self):
        """getter of type_magnetization"""
        return self._type_magnetization

    def _set_type_magnetization(self, value):
        """setter of type_magnetization"""
        check_var("type_magnetization", value, "int", Vmin=0, Vmax=5)
        self._type_magnetization = value

    # Permanent magnet magnetization type: 0 for radial, 1 for parallel, 2 for Hallbach
    # Type : int, min = 0, max = 5
    type_magnetization = property(
        fget=_get_type_magnetization,
        fset=_set_type_magnetization,
        doc=
        u"""Permanent magnet magnetization type: 0 for radial, 1 for parallel, 2 for Hallbach""",
    )

    def _get_Lmag(self):
        """getter of Lmag"""
        return self._Lmag

    def _set_Lmag(self, value):
        """setter of Lmag"""
        check_var("Lmag", value, "float", Vmin=0)
        self._Lmag = value

    # Magnet axial length
    # Type : float, min = 0
    Lmag = property(fget=_get_Lmag,
                    fset=_set_Lmag,
                    doc=u"""Magnet axial length""")
Ejemplo n.º 5
0
class Circle(Surface):
    """Circle define by  the center of circle(point_ref), the label and the radius"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Geometry.Circle.check
    if isinstance(check, ImportError):
        check = property(fget=lambda x: raise_(
            ImportError("Can't use Circle method check: " + str(check))))
    else:
        check = check
    # cf Methods.Geometry.Circle.comp_length
    if isinstance(comp_length, ImportError):
        comp_length = property(fget=lambda x: raise_(
            ImportError("Can't use Circle method comp_length: " + str(
                comp_length))))
    else:
        comp_length = comp_length
    # cf Methods.Geometry.Circle.comp_surface
    if isinstance(comp_surface, ImportError):
        comp_surface = property(fget=lambda x: raise_(
            ImportError("Can't use Circle method comp_surface: " + str(
                comp_surface))))
    else:
        comp_surface = comp_surface
    # cf Methods.Geometry.Circle.discretize
    if isinstance(discretize, ImportError):
        discretize = property(fget=lambda x: raise_(
            ImportError("Can't use Circle method discretize: " + str(discretize
                                                                     ))))
    else:
        discretize = discretize
    # cf Methods.Geometry.Circle.get_lines
    if isinstance(get_lines, ImportError):
        get_lines = property(fget=lambda x: raise_(
            ImportError("Can't use Circle method get_lines: " + str(get_lines))
        ))
    else:
        get_lines = get_lines
    # cf Methods.Geometry.Circle.get_patch
    if isinstance(get_patch, ImportError):
        get_patch = property(fget=lambda x: raise_(
            ImportError("Can't use Circle method get_patch: " + str(get_patch))
        ))
    else:
        get_patch = get_patch
    # cf Methods.Geometry.Circle.rotate
    if isinstance(rotate, ImportError):
        rotate = property(fget=lambda x: raise_(
            ImportError("Can't use Circle method rotate: " + str(rotate))))
    else:
        rotate = rotate
    # cf Methods.Geometry.Circle.translate
    if isinstance(translate, ImportError):
        translate = property(fget=lambda x: raise_(
            ImportError("Can't use Circle method translate: " + str(translate))
        ))
    else:
        translate = translate
    # save method is available in all object
    save = save

    def __init__(self,
                 radius=1,
                 center=0,
                 line_label="",
                 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,
                ["radius", "center", "line_label", "point_ref", "label"])
            # Overwrite default value with init_dict content
            if "radius" in list(init_dict.keys()):
                radius = init_dict["radius"]
            if "center" in list(init_dict.keys()):
                center = init_dict["center"]
            if "line_label" in list(init_dict.keys()):
                line_label = init_dict["line_label"]
            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
        self.radius = radius
        self.center = center
        self.line_label = line_label
        # Call Surface init
        super(Circle, self).__init__(point_ref=point_ref, label=label)
        # The class is frozen (in Surface init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        Circle_str = ""
        # Get the properties inherited from Surface
        Circle_str += super(Circle, self).__str__()
        Circle_str += "radius = " + str(self.radius) + linesep
        Circle_str += "center = " + str(self.center) + linesep
        Circle_str += 'line_label = "' + str(self.line_label) + '"' + linesep
        return Circle_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from Surface
        if not super(Circle, self).__eq__(other):
            return False
        if other.radius != self.radius:
            return False
        if other.center != self.center:
            return False
        if other.line_label != self.line_label:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from Surface
        Circle_dict = super(Circle, self).as_dict()
        Circle_dict["radius"] = self.radius
        Circle_dict["center"] = self.center
        Circle_dict["line_label"] = self.line_label
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        Circle_dict["__class__"] = "Circle"
        return Circle_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.radius = None
        self.center = None
        self.line_label = None
        # Set to None the properties inherited from Surface
        super(Circle, self)._set_None()

    def _get_radius(self):
        """getter of radius"""
        return self._radius

    def _set_radius(self, value):
        """setter of radius"""
        check_var("radius", value, "float", Vmin=0)
        self._radius = value

    # Radius of the circle
    # Type : float, min = 0
    radius = property(fget=_get_radius,
                      fset=_set_radius,
                      doc=u"""Radius of the circle""")

    def _get_center(self):
        """getter of center"""
        return self._center

    def _set_center(self, value):
        """setter of center"""
        check_var("center", value, "complex")
        self._center = value

    # center of the Circle
    # Type : complex
    center = property(fget=_get_center,
                      fset=_set_center,
                      doc=u"""center of the Circle""")

    def _get_line_label(self):
        """getter of line_label"""
        return self._line_label

    def _set_line_label(self, value):
        """setter of line_label"""
        check_var("line_label", value, "str")
        self._line_label = value

    # Label to set to the lines
    # Type : str
    line_label = property(fget=_get_line_label,
                          fset=_set_line_label,
                          doc=u"""Label to set to the lines""")
Ejemplo n.º 6
0
class SlotW22(SlotWind):
    """semi-closed orthoradial without fillet without wedge"""

    VERSION = 1
    IS_SYMMETRICAL = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Slot.SlotW22.build_geometry
    if isinstance(build_geometry, ImportError):
        build_geometry = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW22 method build_geometry: " + str(
                build_geometry))))
    else:
        build_geometry = build_geometry
    # cf Methods.Slot.SlotW22.build_geometry_wind
    if isinstance(build_geometry_wind, ImportError):
        build_geometry_wind = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW22 method build_geometry_wind: " + str(
                build_geometry_wind))))
    else:
        build_geometry_wind = build_geometry_wind
    # cf Methods.Slot.SlotW22.check
    if isinstance(check, ImportError):
        check = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW22 method check: " + str(check))))
    else:
        check = check
    # cf Methods.Slot.SlotW22.comp_angle_opening
    if isinstance(comp_angle_opening, ImportError):
        comp_angle_opening = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW22 method comp_angle_opening: " + str(
                comp_angle_opening))))
    else:
        comp_angle_opening = comp_angle_opening
    # cf Methods.Slot.SlotW22.comp_height
    if isinstance(comp_height, ImportError):
        comp_height = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW22 method comp_height: " + str(
                comp_height))))
    else:
        comp_height = comp_height
    # cf Methods.Slot.SlotW22.comp_height_wind
    if isinstance(comp_height_wind, ImportError):
        comp_height_wind = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW22 method comp_height_wind: " + str(
                comp_height_wind))))
    else:
        comp_height_wind = comp_height_wind
    # cf Methods.Slot.SlotW22.comp_surface
    if isinstance(comp_surface, ImportError):
        comp_surface = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW22 method comp_surface: " + str(
                comp_surface))))
    else:
        comp_surface = comp_surface
    # cf Methods.Slot.SlotW22.comp_surface_wind
    if isinstance(comp_surface_wind, ImportError):
        comp_surface_wind = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW22 method comp_surface_wind: " + str(
                comp_surface_wind))))
    else:
        comp_surface_wind = comp_surface_wind
    # save method is available in all object
    save = save

    def __init__(self,
                 W0=0.043633,
                 H0=0.006,
                 H2=0.04,
                 W2=0.08725,
                 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", "H2", "W2", "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 "H2" in list(init_dict.keys()):
                H2 = init_dict["H2"]
            if "W2" in list(init_dict.keys()):
                W2 = init_dict["W2"]
            if "Zs" in list(init_dict.keys()):
                Zs = init_dict["Zs"]
        # Initialisation by argument
        self.W0 = W0
        self.H0 = H0
        self.H2 = H2
        self.W2 = W2
        # Call SlotWind init
        super(SlotW22, self).__init__(Zs=Zs)
        # The class is frozen (in SlotWind init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        SlotW22_str = ""
        # Get the properties inherited from SlotWind
        SlotW22_str += super(SlotW22, self).__str__()
        SlotW22_str += "W0 = " + str(self.W0) + linesep
        SlotW22_str += "H0 = " + str(self.H0) + linesep
        SlotW22_str += "H2 = " + str(self.H2) + linesep
        SlotW22_str += "W2 = " + str(self.W2) + linesep
        return SlotW22_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from SlotWind
        if not super(SlotW22, self).__eq__(other):
            return False
        if other.W0 != self.W0:
            return False
        if other.H0 != self.H0:
            return False
        if other.H2 != self.H2:
            return False
        if other.W2 != self.W2:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from SlotWind
        SlotW22_dict = super(SlotW22, self).as_dict()
        SlotW22_dict["W0"] = self.W0
        SlotW22_dict["H0"] = self.H0
        SlotW22_dict["H2"] = self.H2
        SlotW22_dict["W2"] = self.W2
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        SlotW22_dict["__class__"] = "SlotW22"
        return SlotW22_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.W0 = None
        self.H0 = None
        self.H2 = None
        self.W2 = None
        # Set to None the properties inherited from SlotWind
        super(SlotW22, self)._set_None()

    def _get_W0(self):
        """getter of W0"""
        return self._W0

    def _set_W0(self, value):
        """setter of W0"""
        check_var("W0", value, "float", Vmin=0)
        self._W0 = value

    # Slot isthmus orthoradial angular width.
    # Type : float, min = 0
    W0 = property(fget=_get_W0,
                  fset=_set_W0,
                  doc=u"""Slot isthmus orthoradial angular width.""")

    def _get_H0(self):
        """getter of H0"""
        return self._H0

    def _set_H0(self, value):
        """setter of H0"""
        check_var("H0", value, "float", Vmin=0)
        self._H0 = value

    # Slot isthmus radial height.
    # Type : float, min = 0
    H0 = property(fget=_get_H0,
                  fset=_set_H0,
                  doc=u"""Slot isthmus radial height.""")

    def _get_H2(self):
        """getter of H2"""
        return self._H2

    def _set_H2(self, value):
        """setter of H2"""
        check_var("H2", value, "float", Vmin=0)
        self._H2 = value

    # Slot radial height below wedge
    # Type : float, min = 0
    H2 = property(fget=_get_H2,
                  fset=_set_H2,
                  doc=u"""Slot radial height below wedge """)

    def _get_W2(self):
        """getter of W2"""
        return self._W2

    def _set_W2(self, value):
        """setter of W2"""
        check_var("W2", value, "float", Vmin=0)
        self._W2 = value

    # Angle between slot edges
    # Type : float, min = 0
    W2 = property(fget=_get_W2,
                  fset=_set_W2,
                  doc=u"""Angle between slot edges""")
Ejemplo n.º 7
0
class SlotW13(SlotWind):
    """Open Rectangular or trapezoidal slot with wedge"""

    VERSION = 1
    IS_SYMMETRICAL = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Slot.SlotW13._comp_point_coordinate
    if isinstance(_comp_point_coordinate, ImportError):
        _comp_point_coordinate = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW13 method _comp_point_coordinate: " +
                        str(_comp_point_coordinate))))
    else:
        _comp_point_coordinate = _comp_point_coordinate
    # cf Methods.Slot.SlotW13.build_geometry
    if isinstance(build_geometry, ImportError):
        build_geometry = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW13 method build_geometry: " + str(
                build_geometry))))
    else:
        build_geometry = build_geometry
    # cf Methods.Slot.SlotW13.build_geometry_wind
    if isinstance(build_geometry_wind, ImportError):
        build_geometry_wind = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW13 method build_geometry_wind: " + str(
                build_geometry_wind))))
    else:
        build_geometry_wind = build_geometry_wind
    # cf Methods.Slot.SlotW13.check
    if isinstance(check, ImportError):
        check = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW13 method check: " + str(check))))
    else:
        check = check
    # cf Methods.Slot.SlotW13.comp_angle_opening
    if isinstance(comp_angle_opening, ImportError):
        comp_angle_opening = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW13 method comp_angle_opening: " + str(
                comp_angle_opening))))
    else:
        comp_angle_opening = comp_angle_opening
    # cf Methods.Slot.SlotW13.comp_height
    if isinstance(comp_height, ImportError):
        comp_height = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW13 method comp_height: " + str(
                comp_height))))
    else:
        comp_height = comp_height
    # cf Methods.Slot.SlotW13.comp_height_wind
    if isinstance(comp_height_wind, ImportError):
        comp_height_wind = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW13 method comp_height_wind: " + str(
                comp_height_wind))))
    else:
        comp_height_wind = comp_height_wind
    # cf Methods.Slot.SlotW13.comp_surface
    if isinstance(comp_surface, ImportError):
        comp_surface = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW13 method comp_surface: " + str(
                comp_surface))))
    else:
        comp_surface = comp_surface
    # cf Methods.Slot.SlotW13.comp_surface_wind
    if isinstance(comp_surface_wind, ImportError):
        comp_surface_wind = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW13 method comp_surface_wind: " + str(
                comp_surface_wind))))
    else:
        comp_surface_wind = comp_surface_wind
    # save method is available in all object
    save = save

    def __init__(
        self,
        W0=0.0122,
        H0=0.001,
        H1=0.0015,
        W1=0.014,
        H2=0.0325,
        W2=0.0122,
        W3=0.0122,
        H1_is_rad=False,
        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", "H1", "W1", "H2", "W2", "W3", "H1_is_rad", "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 "H1" in list(init_dict.keys()):
                H1 = init_dict["H1"]
            if "W1" in list(init_dict.keys()):
                W1 = init_dict["W1"]
            if "H2" in list(init_dict.keys()):
                H2 = init_dict["H2"]
            if "W2" in list(init_dict.keys()):
                W2 = init_dict["W2"]
            if "W3" in list(init_dict.keys()):
                W3 = init_dict["W3"]
            if "H1_is_rad" in list(init_dict.keys()):
                H1_is_rad = init_dict["H1_is_rad"]
            if "Zs" in list(init_dict.keys()):
                Zs = init_dict["Zs"]
        # Initialisation by argument
        self.W0 = W0
        self.H0 = H0
        self.H1 = H1
        self.W1 = W1
        self.H2 = H2
        self.W2 = W2
        self.W3 = W3
        self.H1_is_rad = H1_is_rad
        # Call SlotWind init
        super(SlotW13, self).__init__(Zs=Zs)
        # The class is frozen (in SlotWind init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        SlotW13_str = ""
        # Get the properties inherited from SlotWind
        SlotW13_str += super(SlotW13, self).__str__()
        SlotW13_str += "W0 = " + str(self.W0) + linesep
        SlotW13_str += "H0 = " + str(self.H0) + linesep
        SlotW13_str += "H1 = " + str(self.H1) + linesep
        SlotW13_str += "W1 = " + str(self.W1) + linesep
        SlotW13_str += "H2 = " + str(self.H2) + linesep
        SlotW13_str += "W2 = " + str(self.W2) + linesep
        SlotW13_str += "W3 = " + str(self.W3) + linesep
        SlotW13_str += "H1_is_rad = " + str(self.H1_is_rad) + linesep
        return SlotW13_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from SlotWind
        if not super(SlotW13, self).__eq__(other):
            return False
        if other.W0 != self.W0:
            return False
        if other.H0 != self.H0:
            return False
        if other.H1 != self.H1:
            return False
        if other.W1 != self.W1:
            return False
        if other.H2 != self.H2:
            return False
        if other.W2 != self.W2:
            return False
        if other.W3 != self.W3:
            return False
        if other.H1_is_rad != self.H1_is_rad:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from SlotWind
        SlotW13_dict = super(SlotW13, self).as_dict()
        SlotW13_dict["W0"] = self.W0
        SlotW13_dict["H0"] = self.H0
        SlotW13_dict["H1"] = self.H1
        SlotW13_dict["W1"] = self.W1
        SlotW13_dict["H2"] = self.H2
        SlotW13_dict["W2"] = self.W2
        SlotW13_dict["W3"] = self.W3
        SlotW13_dict["H1_is_rad"] = self.H1_is_rad
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        SlotW13_dict["__class__"] = "SlotW13"
        return SlotW13_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.W0 = None
        self.H0 = None
        self.H1 = None
        self.W1 = None
        self.H2 = None
        self.W2 = None
        self.W3 = None
        self.H1_is_rad = None
        # Set to None the properties inherited from SlotWind
        super(SlotW13, self)._set_None()

    def _get_W0(self):
        """getter of W0"""
        return self._W0

    def _set_W0(self, value):
        """setter of W0"""
        check_var("W0", value, "float", Vmin=0)
        self._W0 = value

    # Slot isthmus width.
    # Type : float, min = 0
    W0 = property(fget=_get_W0, fset=_set_W0, doc=u"""Slot isthmus width.""")

    def _get_H0(self):
        """getter of H0"""
        return self._H0

    def _set_H0(self, value):
        """setter of H0"""
        check_var("H0", value, "float", Vmin=0)
        self._H0 = value

    # Slot isthmus height.
    # Type : float, min = 0
    H0 = property(fget=_get_H0, fset=_set_H0, doc=u"""Slot isthmus height.""")

    def _get_H1(self):
        """getter of H1"""
        return self._H1

    def _set_H1(self, value):
        """setter of H1"""
        check_var("H1", value, "float", Vmin=0)
        self._H1 = value

    # Slot wedge radial height or wedge angle .
    # Type : float, min = 0
    H1 = property(
        fget=_get_H1,
        fset=_set_H1,
        doc=u"""Slot wedge radial height or wedge angle .""",
    )

    def _get_W1(self):
        """getter of W1"""
        return self._W1

    def _set_W1(self, value):
        """setter of W1"""
        check_var("W1", value, "float", Vmin=0)
        self._W1 = value

    # Slot wedge width.
    # Type : float, min = 0
    W1 = property(fget=_get_W1, fset=_set_W1, doc=u"""Slot wedge width.""")

    def _get_H2(self):
        """getter of H2"""
        return self._H2

    def _set_H2(self, value):
        """setter of H2"""
        check_var("H2", value, "float", Vmin=0)
        self._H2 = value

    # Slot height below wedge
    # Type : float, min = 0
    H2 = property(fget=_get_H2,
                  fset=_set_H2,
                  doc=u"""Slot height below wedge """)

    def _get_W2(self):
        """getter of W2"""
        return self._W2

    def _set_W2(self, value):
        """setter of W2"""
        check_var("W2", value, "float", Vmin=0)
        self._W2 = value

    # Slot width below wedge
    # Type : float, min = 0
    W2 = property(fget=_get_W2,
                  fset=_set_W2,
                  doc=u"""Slot width below wedge """)

    def _get_W3(self):
        """getter of W3"""
        return self._W3

    def _set_W3(self, value):
        """setter of W3"""
        check_var("W3", value, "float", Vmin=0)
        self._W3 = value

    # Slot bottom width.
    # Type : float, min = 0
    W3 = property(fget=_get_W3, fset=_set_W3, doc=u"""Slot bottom width.""")

    def _get_H1_is_rad(self):
        """getter of H1_is_rad"""
        return self._H1_is_rad

    def _set_H1_is_rad(self, value):
        """setter of H1_is_rad"""
        check_var("H1_is_rad", value, "bool")
        self._H1_is_rad = value

    # H1 unit, 0 for m, 1 for rad
    # Type : bool
    H1_is_rad = property(fget=_get_H1_is_rad,
                         fset=_set_H1_is_rad,
                         doc=u"""H1 unit, 0 for m, 1 for rad""")
Ejemplo n.º 8
0
class Hole(FrozenClass):
    """Holes for lamination (abstract)"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Slot.Hole.comp_radius
    if isinstance(comp_radius, ImportError):
        comp_radius = property(fget=lambda x: raise_(
            ImportError("Can't use Hole method comp_radius: " + str(comp_radius
                                                                    ))))
    else:
        comp_radius = comp_radius
    # cf Methods.Slot.Hole.comp_surface
    if isinstance(comp_surface, ImportError):
        comp_surface = property(fget=lambda x: raise_(
            ImportError("Can't use Hole method comp_surface: " + str(
                comp_surface))))
    else:
        comp_surface = comp_surface
    # cf Methods.Slot.Hole.get_is_stator
    if isinstance(get_is_stator, ImportError):
        get_is_stator = property(fget=lambda x: raise_(
            ImportError("Can't use Hole method get_is_stator: " + str(
                get_is_stator))))
    else:
        get_is_stator = get_is_stator
    # cf Methods.Slot.Hole.get_Rbo
    if isinstance(get_Rbo, ImportError):
        get_Rbo = property(fget=lambda x: raise_(
            ImportError("Can't use Hole method get_Rbo: " + str(get_Rbo))))
    else:
        get_Rbo = get_Rbo
    # cf Methods.Slot.Hole.has_magnet
    if isinstance(has_magnet, ImportError):
        has_magnet = property(fget=lambda x: raise_(
            ImportError("Can't use Hole method has_magnet: " + str(has_magnet))
        ))
    else:
        has_magnet = has_magnet
    # cf Methods.Slot.Hole.plot
    if isinstance(plot, ImportError):
        plot = property(fget=lambda x: raise_(
            ImportError("Can't use Hole method plot: " + str(plot))))
    else:
        plot = plot
    # save method is available in all object
    save = save

    def __init__(self, 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 mat_void == -1:
            mat_void = Material()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(init_dict, ["Zh", "mat_void"])
            # Overwrite default value with init_dict content
            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.parent = None
        self.Zh = Zh
        # mat_void can be None, a Material object or a dict
        if isinstance(mat_void, dict):
            self.mat_void = Material(init_dict=mat_void)
        else:
            self.mat_void = mat_void

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

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        Hole_str = ""
        if self.parent is None:
            Hole_str += "parent = None " + linesep
        else:
            Hole_str += "parent = " + str(type(
                self.parent)) + " object" + linesep
        Hole_str += "Zh = " + str(self.Zh) + linesep
        if self.mat_void is not None:
            tmp = self.mat_void.__str__().replace(linesep,
                                                  linesep + "\t").rstrip("\t")
            Hole_str += "mat_void = " + tmp
        else:
            Hole_str += "mat_void = None" + linesep + linesep
        return Hole_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False
        if other.Zh != self.Zh:
            return False
        if other.mat_void != self.mat_void:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        Hole_dict = dict()
        Hole_dict["Zh"] = self.Zh
        if self.mat_void is None:
            Hole_dict["mat_void"] = None
        else:
            Hole_dict["mat_void"] = self.mat_void.as_dict()
        # The class name is added to the dict fordeserialisation purpose
        Hole_dict["__class__"] = "Hole"
        return Hole_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.Zh = None
        if self.mat_void is not None:
            self.mat_void._set_None()

    def _get_Zh(self):
        """getter of Zh"""
        return self._Zh

    def _set_Zh(self, value):
        """setter of Zh"""
        check_var("Zh", value, "int", Vmin=0, Vmax=1000)
        self._Zh = value

    # Number of Hole around the circumference
    # Type : int, min = 0, max = 1000
    Zh = property(fget=_get_Zh,
                  fset=_set_Zh,
                  doc=u"""Number of Hole around the circumference""")

    def _get_mat_void(self):
        """getter of mat_void"""
        return self._mat_void

    def _set_mat_void(self, value):
        """setter of mat_void"""
        check_var("mat_void", value, "Material")
        self._mat_void = value

        if self._mat_void is not None:
            self._mat_void.parent = self

    # Material of the void part of the hole (Air in general)
    # Type : Material
    mat_void = property(
        fget=_get_mat_void,
        fset=_set_mat_void,
        doc=u"""Material of the void part of the hole (Air in general)""",
    )
Ejemplo n.º 9
0
class LamSlotMag(LamSlot):
    """Lamination with Slot for Magnets"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Machine.LamSlotMag.build_geometry
    if isinstance(build_geometry, ImportError):
        build_geometry = property(
            fget=lambda x: raise_(
                ImportError(
                    "Can't use LamSlotMag method build_geometry: " + str(build_geometry)
                )
            )
        )
    else:
        build_geometry = build_geometry
    # cf Methods.Machine.LamSlotMag.check
    if isinstance(check, ImportError):
        check = property(
            fget=lambda x: raise_(
                ImportError("Can't use LamSlotMag method check: " + str(check))
            )
        )
    else:
        check = check
    # cf Methods.Machine.LamSlotMag.comp_masses
    if isinstance(comp_masses, ImportError):
        comp_masses = property(
            fget=lambda x: raise_(
                ImportError(
                    "Can't use LamSlotMag method comp_masses: " + str(comp_masses)
                )
            )
        )
    else:
        comp_masses = comp_masses
    # cf Methods.Machine.LamSlotMag.comp_radius_mec
    if isinstance(comp_radius_mec, ImportError):
        comp_radius_mec = property(
            fget=lambda x: raise_(
                ImportError(
                    "Can't use LamSlotMag method comp_radius_mec: "
                    + str(comp_radius_mec)
                )
            )
        )
    else:
        comp_radius_mec = comp_radius_mec
    # cf Methods.Machine.LamSlotMag.comp_surfaces
    if isinstance(comp_surfaces, ImportError):
        comp_surfaces = property(
            fget=lambda x: raise_(
                ImportError(
                    "Can't use LamSlotMag method comp_surfaces: " + str(comp_surfaces)
                )
            )
        )
    else:
        comp_surfaces = comp_surfaces
    # cf Methods.Machine.LamSlotMag.comp_volumes
    if isinstance(comp_volumes, ImportError):
        comp_volumes = property(
            fget=lambda x: raise_(
                ImportError(
                    "Can't use LamSlotMag method comp_volumes: " + str(comp_volumes)
                )
            )
        )
    else:
        comp_volumes = comp_volumes
    # cf Methods.Machine.LamSlotMag.plot
    if isinstance(plot, ImportError):
        plot = property(
            fget=lambda x: raise_(
                ImportError("Can't use LamSlotMag method plot: " + str(plot))
            )
        )
    else:
        plot = plot
    # save method is available in all object
    save = save

    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
        # Call LamSlot init
        super(LamSlotMag, self).__init__(
            slot=slot,
            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,
        )
        # The class is frozen (in LamSlot init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        LamSlotMag_str = ""
        # Get the properties inherited from LamSlot
        LamSlotMag_str += super(LamSlotMag, self).__str__()
        return LamSlotMag_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from LamSlot
        if not super(LamSlotMag, self).__eq__(other):
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from LamSlot
        LamSlotMag_dict = super(LamSlotMag, self).as_dict()
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        LamSlotMag_dict["__class__"] = "LamSlotMag"
        return LamSlotMag_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        # Set to None the properties inherited from LamSlot
        super(LamSlotMag, self)._set_None()
Ejemplo n.º 10
0
class MachineSync(Machine):
    """Abstract class for synchronous machine"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Machine.MachineSync.is_synchronous
    if isinstance(is_synchronous, ImportError):
        is_synchronous = property(
            fget=lambda x: raise_(
                ImportError(
                    "Can't use MachineSync method is_synchronous: "
                    + str(is_synchronous)
                )
            )
        )
    else:
        is_synchronous = is_synchronous
    # cf Methods.Machine.MachineSync.comp_initial_angle
    if isinstance(comp_initial_angle, ImportError):
        comp_initial_angle = property(
            fget=lambda x: raise_(
                ImportError(
                    "Can't use MachineSync method comp_initial_angle: "
                    + str(comp_initial_angle)
                )
            )
        )
    else:
        comp_initial_angle = comp_initial_angle
    # save method is available in all object
    save = save

    def __init__(
        self,
        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, ["frame", "shaft", "name", "desc", "type_machine"]
            )
            # Overwrite default value with init_dict content
            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
        # Call Machine init
        super(MachineSync, self).__init__(
            frame=frame, shaft=shaft, name=name, desc=desc, type_machine=type_machine
        )
        # The class is frozen (in Machine init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        MachineSync_str = ""
        # Get the properties inherited from Machine
        MachineSync_str += super(MachineSync, self).__str__()
        return MachineSync_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from Machine
        if not super(MachineSync, self).__eq__(other):
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from Machine
        MachineSync_dict = super(MachineSync, self).as_dict()
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        MachineSync_dict["__class__"] = "MachineSync"
        return MachineSync_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        # Set to None the properties inherited from Machine
        super(MachineSync, self)._set_None()
Ejemplo n.º 11
0
class HoleM52(HoleMag):
    """V shape slot for buried magnet"""

    VERSION = 1
    IS_SYMMETRICAL = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Slot.HoleM52.build_geometry
    if isinstance(build_geometry, ImportError):
        build_geometry = property(fget=lambda x: raise_(
            ImportError("Can't use HoleM52 method build_geometry: " + str(
                build_geometry))))
    else:
        build_geometry = build_geometry
    # cf Methods.Slot.HoleM52.check
    if isinstance(check, ImportError):
        check = property(fget=lambda x: raise_(
            ImportError("Can't use HoleM52 method check: " + str(check))))
    else:
        check = check
    # cf Methods.Slot.HoleM52.comp_alpha
    if isinstance(comp_alpha, ImportError):
        comp_alpha = property(fget=lambda x: raise_(
            ImportError("Can't use HoleM52 method comp_alpha: " + str(
                comp_alpha))))
    else:
        comp_alpha = comp_alpha
    # cf Methods.Slot.HoleM52.comp_mass_magnets
    if isinstance(comp_mass_magnets, ImportError):
        comp_mass_magnets = property(fget=lambda x: raise_(
            ImportError("Can't use HoleM52 method comp_mass_magnets: " + str(
                comp_mass_magnets))))
    else:
        comp_mass_magnets = comp_mass_magnets
    # cf Methods.Slot.HoleM52.comp_radius
    if isinstance(comp_radius, ImportError):
        comp_radius = property(fget=lambda x: raise_(
            ImportError("Can't use HoleM52 method comp_radius: " + str(
                comp_radius))))
    else:
        comp_radius = comp_radius
    # cf Methods.Slot.HoleM52.comp_surface
    if isinstance(comp_surface, ImportError):
        comp_surface = property(fget=lambda x: raise_(
            ImportError("Can't use HoleM52 method comp_surface: " + str(
                comp_surface))))
    else:
        comp_surface = comp_surface
    # cf Methods.Slot.HoleM52.comp_surface_magnets
    if isinstance(comp_surface_magnets, ImportError):
        comp_surface_magnets = property(fget=lambda x: raise_(
            ImportError("Can't use HoleM52 method comp_surface_magnets: " +
                        str(comp_surface_magnets))))
    else:
        comp_surface_magnets = comp_surface_magnets
    # cf Methods.Slot.HoleM52.comp_volume_magnets
    if isinstance(comp_volume_magnets, ImportError):
        comp_volume_magnets = property(fget=lambda x: raise_(
            ImportError("Can't use HoleM52 method comp_volume_magnets: " + str(
                comp_volume_magnets))))
    else:
        comp_volume_magnets = comp_volume_magnets
    # cf Methods.Slot.HoleM52.comp_W1
    if isinstance(comp_W1, ImportError):
        comp_W1 = property(fget=lambda x: raise_(
            ImportError("Can't use HoleM52 method comp_W1: " + str(comp_W1))))
    else:
        comp_W1 = comp_W1
    # cf Methods.Slot.HoleM52.get_height_magnet
    if isinstance(get_height_magnet, ImportError):
        get_height_magnet = property(fget=lambda x: raise_(
            ImportError("Can't use HoleM52 method get_height_magnet: " + str(
                get_height_magnet))))
    else:
        get_height_magnet = get_height_magnet
    # cf Methods.Slot.HoleM52.remove_magnet
    if isinstance(remove_magnet, ImportError):
        remove_magnet = property(fget=lambda x: raise_(
            ImportError("Can't use HoleM52 method remove_magnet: " + str(
                remove_magnet))))
    else:
        remove_magnet = remove_magnet
    # save method is available in all object
    save = save

    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)
        # The class is frozen (in HoleMag init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        HoleM52_str = ""
        # Get the properties inherited from HoleMag
        HoleM52_str += super(HoleM52, self).__str__()
        HoleM52_str += "H0 = " + str(self.H0) + linesep
        HoleM52_str += "W0 = " + str(self.W0) + linesep
        HoleM52_str += "H1 = " + str(self.H1) + linesep
        HoleM52_str += "W3 = " + str(self.W3) + linesep
        HoleM52_str += "H2 = " + str(self.H2) + linesep
        if self.magnet_0 is not None:
            tmp = self.magnet_0.__str__().replace(linesep,
                                                  linesep + "\t").rstrip("\t")
            HoleM52_str += "magnet_0 = " + tmp
        else:
            HoleM52_str += "magnet_0 = None" + linesep + linesep
        return HoleM52_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from HoleMag
        if not super(HoleM52, self).__eq__(other):
            return False
        if other.H0 != self.H0:
            return False
        if other.W0 != self.W0:
            return False
        if other.H1 != self.H1:
            return False
        if other.W3 != self.W3:
            return False
        if other.H2 != self.H2:
            return False
        if other.magnet_0 != self.magnet_0:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from HoleMag
        HoleM52_dict = super(HoleM52, self).as_dict()
        HoleM52_dict["H0"] = self.H0
        HoleM52_dict["W0"] = self.W0
        HoleM52_dict["H1"] = self.H1
        HoleM52_dict["W3"] = self.W3
        HoleM52_dict["H2"] = self.H2
        if self.magnet_0 is None:
            HoleM52_dict["magnet_0"] = None
        else:
            HoleM52_dict["magnet_0"] = self.magnet_0.as_dict()
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        HoleM52_dict["__class__"] = "HoleM52"
        return HoleM52_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.H0 = None
        self.W0 = None
        self.H1 = None
        self.W3 = None
        self.H2 = None
        if self.magnet_0 is not None:
            self.magnet_0._set_None()
        # Set to None the properties inherited from HoleMag
        super(HoleM52, self)._set_None()

    def _get_H0(self):
        """getter of H0"""
        return self._H0

    def _set_H0(self, value):
        """setter of H0"""
        check_var("H0", value, "float", Vmin=0)
        self._H0 = value

    # Slot depth
    # Type : float, min = 0
    H0 = property(fget=_get_H0, fset=_set_H0, doc=u"""Slot depth""")

    def _get_W0(self):
        """getter of W0"""
        return self._W0

    def _set_W0(self, value):
        """setter of W0"""
        check_var("W0", value, "float", Vmin=0)
        self._W0 = value

    # Magnet width
    # Type : float, min = 0
    W0 = property(fget=_get_W0, fset=_set_W0, doc=u"""Magnet width""")

    def _get_H1(self):
        """getter of H1"""
        return self._H1

    def _set_H1(self, value):
        """setter of H1"""
        check_var("H1", value, "float", Vmin=0)
        self._H1 = value

    # Magnet height
    # Type : float, min = 0
    H1 = property(fget=_get_H1, fset=_set_H1, doc=u"""Magnet height""")

    def _get_W3(self):
        """getter of W3"""
        return self._W3

    def _set_W3(self, value):
        """setter of W3"""
        check_var("W3", value, "float", Vmin=0)
        self._W3 = value

    # Tooth width
    # Type : float, min = 0
    W3 = property(fget=_get_W3, fset=_set_W3, doc=u"""Tooth width""")

    def _get_H2(self):
        """getter of H2"""
        return self._H2

    def _set_H2(self, value):
        """setter of H2"""
        check_var("H2", value, "float", Vmin=0)
        self._H2 = value

    # Additional depth for the magnet
    # Type : float, min = 0
    H2 = property(fget=_get_H2,
                  fset=_set_H2,
                  doc=u"""Additional depth for the magnet""")

    def _get_magnet_0(self):
        """getter of magnet_0"""
        return self._magnet_0

    def _set_magnet_0(self, value):
        """setter of magnet_0"""
        check_var("magnet_0", value, "Magnet")
        self._magnet_0 = value

        if self._magnet_0 is not None:
            self._magnet_0.parent = self

    # Magnet of the hole
    # Type : Magnet
    magnet_0 = property(fget=_get_magnet_0,
                        fset=_set_magnet_0,
                        doc=u"""Magnet of the hole""")
Ejemplo n.º 12
0
class WindingCW2LR(Winding):
    """double layer non-overlapping "concentrated" tooth winding "all teeth wound", radial coil superposition"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Machine.WindingCW2LR.comp_connection_mat
    if isinstance(comp_connection_mat, ImportError):
        comp_connection_mat = property(
            fget=lambda x: raise_(
                ImportError(
                    "Can't use WindingCW2LR method comp_connection_mat: "
                    + str(comp_connection_mat)
                )
            )
        )
    else:
        comp_connection_mat = comp_connection_mat
    # cf Methods.Machine.WindingCW2LR.get_dim_wind
    if isinstance(get_dim_wind, ImportError):
        get_dim_wind = property(
            fget=lambda x: raise_(
                ImportError(
                    "Can't use WindingCW2LR method get_dim_wind: " + str(get_dim_wind)
                )
            )
        )
    else:
        get_dim_wind = get_dim_wind
    # save method is available in all object
    save = save

    def __init__(
        self,
        is_reverse_wind=False,
        Nslot_shift_wind=0,
        qs=3,
        Ntcoil=7,
        Npcpp=2,
        type_connection=0,
        p=3,
        Lewout=0.015,
        conductor=-1,
        init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

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

        if conductor == -1:
            conductor = Conductor()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "is_reverse_wind",
                    "Nslot_shift_wind",
                    "qs",
                    "Ntcoil",
                    "Npcpp",
                    "type_connection",
                    "p",
                    "Lewout",
                    "conductor",
                ],
            )
            # Overwrite default value with init_dict content
            if "is_reverse_wind" in list(init_dict.keys()):
                is_reverse_wind = init_dict["is_reverse_wind"]
            if "Nslot_shift_wind" in list(init_dict.keys()):
                Nslot_shift_wind = init_dict["Nslot_shift_wind"]
            if "qs" in list(init_dict.keys()):
                qs = init_dict["qs"]
            if "Ntcoil" in list(init_dict.keys()):
                Ntcoil = init_dict["Ntcoil"]
            if "Npcpp" in list(init_dict.keys()):
                Npcpp = init_dict["Npcpp"]
            if "type_connection" in list(init_dict.keys()):
                type_connection = init_dict["type_connection"]
            if "p" in list(init_dict.keys()):
                p = init_dict["p"]
            if "Lewout" in list(init_dict.keys()):
                Lewout = init_dict["Lewout"]
            if "conductor" in list(init_dict.keys()):
                conductor = init_dict["conductor"]
        # Initialisation by argument
        # Call Winding init
        super(WindingCW2LR, 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,
        )
        # The class is frozen (in Winding init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        WindingCW2LR_str = ""
        # Get the properties inherited from Winding
        WindingCW2LR_str += super(WindingCW2LR, self).__str__()
        return WindingCW2LR_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from Winding
        if not super(WindingCW2LR, self).__eq__(other):
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from Winding
        WindingCW2LR_dict = super(WindingCW2LR, self).as_dict()
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        WindingCW2LR_dict["__class__"] = "WindingCW2LR"
        return WindingCW2LR_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        # Set to None the properties inherited from Winding
        super(WindingCW2LR, self)._set_None()
Ejemplo n.º 13
0
class ImportMatrixXls(ImportMatrix):
    """Import the data from an xls file"""

    VERSION = 1

    # cf Methods.Import.ImportMatrixXls.get_data
    if isinstance(get_data, ImportError):
        get_data = property(fget=lambda x: raise_(
            ImportError("Can't use ImportMatrixXls method get_data: " + str(
                get_data))))
    else:
        get_data = get_data
    # save method is available in all object
    save = save

    def __init__(
        self,
        file_path="",
        sheet="",
        skiprows=0,
        usecols=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,
                ["file_path", "sheet", "skiprows", "usecols", "is_transpose"])
            # Overwrite default value with init_dict content
            if "file_path" in list(init_dict.keys()):
                file_path = init_dict["file_path"]
            if "sheet" in list(init_dict.keys()):
                sheet = init_dict["sheet"]
            if "skiprows" in list(init_dict.keys()):
                skiprows = init_dict["skiprows"]
            if "usecols" in list(init_dict.keys()):
                usecols = init_dict["usecols"]
            if "is_transpose" in list(init_dict.keys()):
                is_transpose = init_dict["is_transpose"]
        # Initialisation by argument
        self.file_path = file_path
        self.sheet = sheet
        self.skiprows = skiprows
        self.usecols = usecols
        # Call ImportMatrix init
        super(ImportMatrixXls, self).__init__(is_transpose=is_transpose)
        # The class is frozen (in ImportMatrix init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        ImportMatrixXls_str = ""
        # Get the properties inherited from ImportMatrix
        ImportMatrixXls_str += super(ImportMatrixXls, self).__str__()
        ImportMatrixXls_str += 'file_path = "' + str(
            self.file_path) + '"' + linesep
        ImportMatrixXls_str += 'sheet = "' + str(self.sheet) + '"' + linesep
        ImportMatrixXls_str += "skiprows = " + str(self.skiprows) + linesep
        ImportMatrixXls_str += 'usecols = "' + str(
            self.usecols) + '"' + linesep
        return ImportMatrixXls_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from ImportMatrix
        if not super(ImportMatrixXls, self).__eq__(other):
            return False
        if other.file_path != self.file_path:
            return False
        if other.sheet != self.sheet:
            return False
        if other.skiprows != self.skiprows:
            return False
        if other.usecols != self.usecols:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from ImportMatrix
        ImportMatrixXls_dict = super(ImportMatrixXls, self).as_dict()
        ImportMatrixXls_dict["file_path"] = self.file_path
        ImportMatrixXls_dict["sheet"] = self.sheet
        ImportMatrixXls_dict["skiprows"] = self.skiprows
        ImportMatrixXls_dict["usecols"] = self.usecols
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        ImportMatrixXls_dict["__class__"] = "ImportMatrixXls"
        return ImportMatrixXls_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.file_path = None
        self.sheet = None
        self.skiprows = None
        self.usecols = None
        # Set to None the properties inherited from ImportMatrix
        super(ImportMatrixXls, self)._set_None()

    def _get_file_path(self):
        """getter of file_path"""
        return self._file_path

    def _set_file_path(self, value):
        """setter of file_path"""
        check_var("file_path", value, "str")
        self._file_path = value

    # Path of the file to load
    # Type : str
    file_path = property(fget=_get_file_path,
                         fset=_set_file_path,
                         doc=u"""Path of the file to load""")

    def _get_sheet(self):
        """getter of sheet"""
        return self._sheet

    def _set_sheet(self, value):
        """setter of sheet"""
        check_var("sheet", value, "str")
        self._sheet = value

    # Name of the sheet to load
    # Type : str
    sheet = property(fget=_get_sheet,
                     fset=_set_sheet,
                     doc=u"""Name of the sheet to load""")

    def _get_skiprows(self):
        """getter of skiprows"""
        return self._skiprows

    def _set_skiprows(self, value):
        """setter of skiprows"""
        check_var("skiprows", value, "int", Vmin=0)
        self._skiprows = value

    # To skip some rows in the file (header)
    # Type : int, min = 0
    skiprows = property(
        fget=_get_skiprows,
        fset=_set_skiprows,
        doc=u"""To skip some rows in the file (header)""",
    )

    def _get_usecols(self):
        """getter of usecols"""
        return self._usecols

    def _set_usecols(self, value):
        """setter of usecols"""
        check_var("usecols", value, "str")
        self._usecols = value

    # To select the range of column to use
    # Type : str
    usecols = property(
        fget=_get_usecols,
        fset=_set_usecols,
        doc=u"""To select the range of column to use""",
    )
Ejemplo n.º 14
0
class CondType22(Conductor):
    """conductor with only surface definition without specifc shape nor isolation"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Machine.CondType22.comp_surface_active
    if isinstance(comp_surface_active, ImportError):
        comp_surface_active = property(
            fget=lambda x: raise_(
                ImportError(
                    "Can't use CondType22 method comp_surface_active: "
                    + str(comp_surface_active)
                )
            )
        )
    else:
        comp_surface_active = comp_surface_active
    # cf Methods.Machine.CondType22.comp_surface
    if isinstance(comp_surface, ImportError):
        comp_surface = property(
            fget=lambda x: raise_(
                ImportError(
                    "Can't use CondType22 method comp_surface: " + str(comp_surface)
                )
            )
        )
    else:
        comp_surface = comp_surface
    # save method is available in all object
    save = save

    def __init__(self, Sbar=0.01, cond_mat=-1, ins_mat=-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 cond_mat == -1:
            cond_mat = Material()
        if ins_mat == -1:
            ins_mat = Material()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(init_dict, ["Sbar", "cond_mat", "ins_mat"])
            # Overwrite default value with init_dict content
            if "Sbar" in list(init_dict.keys()):
                Sbar = init_dict["Sbar"]
            if "cond_mat" in list(init_dict.keys()):
                cond_mat = init_dict["cond_mat"]
            if "ins_mat" in list(init_dict.keys()):
                ins_mat = init_dict["ins_mat"]
        # Initialisation by argument
        self.Sbar = Sbar
        # Call Conductor init
        super(CondType22, self).__init__(cond_mat=cond_mat, ins_mat=ins_mat)
        # The class is frozen (in Conductor init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        CondType22_str = ""
        # Get the properties inherited from Conductor
        CondType22_str += super(CondType22, self).__str__()
        CondType22_str += "Sbar = " + str(self.Sbar) + linesep
        return CondType22_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from Conductor
        if not super(CondType22, self).__eq__(other):
            return False
        if other.Sbar != self.Sbar:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from Conductor
        CondType22_dict = super(CondType22, self).as_dict()
        CondType22_dict["Sbar"] = self.Sbar
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        CondType22_dict["__class__"] = "CondType22"
        return CondType22_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.Sbar = None
        # Set to None the properties inherited from Conductor
        super(CondType22, self)._set_None()

    def _get_Sbar(self):
        """getter of Sbar"""
        return self._Sbar

    def _set_Sbar(self, value):
        """setter of Sbar"""
        check_var("Sbar", value, "float", Vmin=0)
        self._Sbar = value

    # Surface of the Slot
    # Type : float, min = 0
    Sbar = property(fget=_get_Sbar, fset=_set_Sbar, doc=u"""Surface of the Slot""")
Ejemplo n.º 15
0
class Magnetics(FrozenClass):
    """Magnetic module abstract object"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Simulation.Magnetics.run
    if isinstance(run, ImportError):
        run = property(
            fget=lambda x: raise_(
                ImportError("Can't use Magnetics method run: " + str(run))
            )
        )
    else:
        run = run
    # cf Methods.Simulation.Magnetics.comp_time_angle
    if isinstance(comp_time_angle, ImportError):
        comp_time_angle = property(
            fget=lambda x: raise_(
                ImportError(
                    "Can't use Magnetics method comp_time_angle: "
                    + str(comp_time_angle)
                )
            )
        )
    else:
        comp_time_angle = comp_time_angle
    # cf Methods.Simulation.Magnetics.comp_emf
    if isinstance(comp_emf, ImportError):
        comp_emf = property(
            fget=lambda x: raise_(
                ImportError("Can't use Magnetics method comp_emf: " + str(comp_emf))
            )
        )
    else:
        comp_emf = comp_emf
    # save method is available in all object
    save = save

    def __init__(
        self,
        is_remove_slotS=False,
        is_remove_slotR=False,
        is_remove_vent=False,
        is_mmfs=True,
        is_mmfr=True,
        is_stator_linear_BH=0,
        is_rotor_linear_BH=0,
        is_symmetry_t=False,
        sym_t=1,
        is_antiper_t=False,
        is_symmetry_a=False,
        sym_a=1,
        is_antiper_a=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,
                [
                    "is_remove_slotS",
                    "is_remove_slotR",
                    "is_remove_vent",
                    "is_mmfs",
                    "is_mmfr",
                    "is_stator_linear_BH",
                    "is_rotor_linear_BH",
                    "is_symmetry_t",
                    "sym_t",
                    "is_antiper_t",
                    "is_symmetry_a",
                    "sym_a",
                    "is_antiper_a",
                ],
            )
            # Overwrite default value with init_dict content
            if "is_remove_slotS" in list(init_dict.keys()):
                is_remove_slotS = init_dict["is_remove_slotS"]
            if "is_remove_slotR" in list(init_dict.keys()):
                is_remove_slotR = init_dict["is_remove_slotR"]
            if "is_remove_vent" in list(init_dict.keys()):
                is_remove_vent = init_dict["is_remove_vent"]
            if "is_mmfs" in list(init_dict.keys()):
                is_mmfs = init_dict["is_mmfs"]
            if "is_mmfr" in list(init_dict.keys()):
                is_mmfr = init_dict["is_mmfr"]
            if "is_stator_linear_BH" in list(init_dict.keys()):
                is_stator_linear_BH = init_dict["is_stator_linear_BH"]
            if "is_rotor_linear_BH" in list(init_dict.keys()):
                is_rotor_linear_BH = init_dict["is_rotor_linear_BH"]
            if "is_symmetry_t" in list(init_dict.keys()):
                is_symmetry_t = init_dict["is_symmetry_t"]
            if "sym_t" in list(init_dict.keys()):
                sym_t = init_dict["sym_t"]
            if "is_antiper_t" in list(init_dict.keys()):
                is_antiper_t = init_dict["is_antiper_t"]
            if "is_symmetry_a" in list(init_dict.keys()):
                is_symmetry_a = init_dict["is_symmetry_a"]
            if "sym_a" in list(init_dict.keys()):
                sym_a = init_dict["sym_a"]
            if "is_antiper_a" in list(init_dict.keys()):
                is_antiper_a = init_dict["is_antiper_a"]
        # Initialisation by argument
        self.parent = None
        self.is_remove_slotS = is_remove_slotS
        self.is_remove_slotR = is_remove_slotR
        self.is_remove_vent = is_remove_vent
        self.is_mmfs = is_mmfs
        self.is_mmfr = is_mmfr
        self.is_stator_linear_BH = is_stator_linear_BH
        self.is_rotor_linear_BH = is_rotor_linear_BH
        self.is_symmetry_t = is_symmetry_t
        self.sym_t = sym_t
        self.is_antiper_t = is_antiper_t
        self.is_symmetry_a = is_symmetry_a
        self.sym_a = sym_a
        self.is_antiper_a = is_antiper_a

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

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        Magnetics_str = ""
        if self.parent is None:
            Magnetics_str += "parent = None " + linesep
        else:
            Magnetics_str += "parent = " + str(type(self.parent)) + " object" + linesep
        Magnetics_str += "is_remove_slotS = " + str(self.is_remove_slotS) + linesep
        Magnetics_str += "is_remove_slotR = " + str(self.is_remove_slotR) + linesep
        Magnetics_str += "is_remove_vent = " + str(self.is_remove_vent) + linesep
        Magnetics_str += "is_mmfs = " + str(self.is_mmfs) + linesep
        Magnetics_str += "is_mmfr = " + str(self.is_mmfr) + linesep
        Magnetics_str += (
            "is_stator_linear_BH = " + str(self.is_stator_linear_BH) + linesep
        )
        Magnetics_str += (
            "is_rotor_linear_BH = " + str(self.is_rotor_linear_BH) + linesep
        )
        Magnetics_str += "is_symmetry_t = " + str(self.is_symmetry_t) + linesep
        Magnetics_str += "sym_t = " + str(self.sym_t) + linesep
        Magnetics_str += "is_antiper_t = " + str(self.is_antiper_t) + linesep
        Magnetics_str += "is_symmetry_a = " + str(self.is_symmetry_a) + linesep
        Magnetics_str += "sym_a = " + str(self.sym_a) + linesep
        Magnetics_str += "is_antiper_a = " + str(self.is_antiper_a) + linesep
        return Magnetics_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False
        if other.is_remove_slotS != self.is_remove_slotS:
            return False
        if other.is_remove_slotR != self.is_remove_slotR:
            return False
        if other.is_remove_vent != self.is_remove_vent:
            return False
        if other.is_mmfs != self.is_mmfs:
            return False
        if other.is_mmfr != self.is_mmfr:
            return False
        if other.is_stator_linear_BH != self.is_stator_linear_BH:
            return False
        if other.is_rotor_linear_BH != self.is_rotor_linear_BH:
            return False
        if other.is_symmetry_t != self.is_symmetry_t:
            return False
        if other.sym_t != self.sym_t:
            return False
        if other.is_antiper_t != self.is_antiper_t:
            return False
        if other.is_symmetry_a != self.is_symmetry_a:
            return False
        if other.sym_a != self.sym_a:
            return False
        if other.is_antiper_a != self.is_antiper_a:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        Magnetics_dict = dict()
        Magnetics_dict["is_remove_slotS"] = self.is_remove_slotS
        Magnetics_dict["is_remove_slotR"] = self.is_remove_slotR
        Magnetics_dict["is_remove_vent"] = self.is_remove_vent
        Magnetics_dict["is_mmfs"] = self.is_mmfs
        Magnetics_dict["is_mmfr"] = self.is_mmfr
        Magnetics_dict["is_stator_linear_BH"] = self.is_stator_linear_BH
        Magnetics_dict["is_rotor_linear_BH"] = self.is_rotor_linear_BH
        Magnetics_dict["is_symmetry_t"] = self.is_symmetry_t
        Magnetics_dict["sym_t"] = self.sym_t
        Magnetics_dict["is_antiper_t"] = self.is_antiper_t
        Magnetics_dict["is_symmetry_a"] = self.is_symmetry_a
        Magnetics_dict["sym_a"] = self.sym_a
        Magnetics_dict["is_antiper_a"] = self.is_antiper_a
        # The class name is added to the dict fordeserialisation purpose
        Magnetics_dict["__class__"] = "Magnetics"
        return Magnetics_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.is_remove_slotS = None
        self.is_remove_slotR = None
        self.is_remove_vent = None
        self.is_mmfs = None
        self.is_mmfr = None
        self.is_stator_linear_BH = None
        self.is_rotor_linear_BH = None
        self.is_symmetry_t = None
        self.sym_t = None
        self.is_antiper_t = None
        self.is_symmetry_a = None
        self.sym_a = None
        self.is_antiper_a = None

    def _get_is_remove_slotS(self):
        """getter of is_remove_slotS"""
        return self._is_remove_slotS

    def _set_is_remove_slotS(self, value):
        """setter of is_remove_slotS"""
        check_var("is_remove_slotS", value, "bool")
        self._is_remove_slotS = value

    # 1 to artificially remove stator slotting effects in permeance mmf calculations
    # Type : bool
    is_remove_slotS = property(
        fget=_get_is_remove_slotS,
        fset=_set_is_remove_slotS,
        doc=u"""1 to artificially remove stator slotting effects in permeance mmf calculations""",
    )

    def _get_is_remove_slotR(self):
        """getter of is_remove_slotR"""
        return self._is_remove_slotR

    def _set_is_remove_slotR(self, value):
        """setter of is_remove_slotR"""
        check_var("is_remove_slotR", value, "bool")
        self._is_remove_slotR = value

    # 1 to artificially remove rotor slotting effects in permeance mmf calculations
    # Type : bool
    is_remove_slotR = property(
        fget=_get_is_remove_slotR,
        fset=_set_is_remove_slotR,
        doc=u"""1 to artificially remove rotor slotting effects in permeance mmf calculations""",
    )

    def _get_is_remove_vent(self):
        """getter of is_remove_vent"""
        return self._is_remove_vent

    def _set_is_remove_vent(self, value):
        """setter of is_remove_vent"""
        check_var("is_remove_vent", value, "bool")
        self._is_remove_vent = value

    # 1 to artificially remove the ventilations duct
    # Type : bool
    is_remove_vent = property(
        fget=_get_is_remove_vent,
        fset=_set_is_remove_vent,
        doc=u"""1 to artificially remove the ventilations duct""",
    )

    def _get_is_mmfs(self):
        """getter of is_mmfs"""
        return self._is_mmfs

    def _set_is_mmfs(self, value):
        """setter of is_mmfs"""
        check_var("is_mmfs", value, "bool")
        self._is_mmfs = value

    # 1 to compute the stator magnetomotive force / stator armature magnetic field
    # Type : bool
    is_mmfs = property(
        fget=_get_is_mmfs,
        fset=_set_is_mmfs,
        doc=u"""1 to compute the stator magnetomotive force / stator armature magnetic field""",
    )

    def _get_is_mmfr(self):
        """getter of is_mmfr"""
        return self._is_mmfr

    def _set_is_mmfr(self, value):
        """setter of is_mmfr"""
        check_var("is_mmfr", value, "bool")
        self._is_mmfr = value

    # 1 to compute the rotor magnetomotive force / rotor magnetic field
    # Type : bool
    is_mmfr = property(
        fget=_get_is_mmfr,
        fset=_set_is_mmfr,
        doc=u"""1 to compute the rotor magnetomotive force / rotor magnetic field""",
    )

    def _get_is_stator_linear_BH(self):
        """getter of is_stator_linear_BH"""
        return self._is_stator_linear_BH

    def _set_is_stator_linear_BH(self, value):
        """setter of is_stator_linear_BH"""
        check_var("is_stator_linear_BH", value, "int", Vmin=0, Vmax=2)
        self._is_stator_linear_BH = value

    # 0 to use the B(H) curve, 1 to use linear B(H) curve according to mur_lin, 2 to enforce infinite permeability (mur_lin =100000)
    # Type : int, min = 0, max = 2
    is_stator_linear_BH = property(
        fget=_get_is_stator_linear_BH,
        fset=_set_is_stator_linear_BH,
        doc=u"""0 to use the B(H) curve, 1 to use linear B(H) curve according to mur_lin, 2 to enforce infinite permeability (mur_lin =100000)""",
    )

    def _get_is_rotor_linear_BH(self):
        """getter of is_rotor_linear_BH"""
        return self._is_rotor_linear_BH

    def _set_is_rotor_linear_BH(self, value):
        """setter of is_rotor_linear_BH"""
        check_var("is_rotor_linear_BH", value, "int", Vmin=0, Vmax=2)
        self._is_rotor_linear_BH = value

    # 0 to use the B(H) curve, 1 to use linear B(H) curve according to mur_lin, 2 to enforce infinite permeability (mur_lin =100000)
    # Type : int, min = 0, max = 2
    is_rotor_linear_BH = property(
        fget=_get_is_rotor_linear_BH,
        fset=_set_is_rotor_linear_BH,
        doc=u"""0 to use the B(H) curve, 1 to use linear B(H) curve according to mur_lin, 2 to enforce infinite permeability (mur_lin =100000)""",
    )

    def _get_is_symmetry_t(self):
        """getter of is_symmetry_t"""
        return self._is_symmetry_t

    def _set_is_symmetry_t(self, value):
        """setter of is_symmetry_t"""
        check_var("is_symmetry_t", value, "bool")
        self._is_symmetry_t = value

    # 0 Compute on the complete time vector, 1 compute according to sym_t and is_antiper_t
    # Type : bool
    is_symmetry_t = property(
        fget=_get_is_symmetry_t,
        fset=_set_is_symmetry_t,
        doc=u"""0 Compute on the complete time vector, 1 compute according to sym_t and is_antiper_t""",
    )

    def _get_sym_t(self):
        """getter of sym_t"""
        return self._sym_t

    def _set_sym_t(self, value):
        """setter of sym_t"""
        check_var("sym_t", value, "int", Vmin=1)
        self._sym_t = value

    # Number of symmetry for the time vector
    # Type : int, min = 1
    sym_t = property(
        fget=_get_sym_t,
        fset=_set_sym_t,
        doc=u"""Number of symmetry for the time vector""",
    )

    def _get_is_antiper_t(self):
        """getter of is_antiper_t"""
        return self._is_antiper_t

    def _set_is_antiper_t(self, value):
        """setter of is_antiper_t"""
        check_var("is_antiper_t", value, "bool")
        self._is_antiper_t = value

    # To add an antiperiodicity to the time vector
    # Type : bool
    is_antiper_t = property(
        fget=_get_is_antiper_t,
        fset=_set_is_antiper_t,
        doc=u"""To add an antiperiodicity to the time vector""",
    )

    def _get_is_symmetry_a(self):
        """getter of is_symmetry_a"""
        return self._is_symmetry_a

    def _set_is_symmetry_a(self, value):
        """setter of is_symmetry_a"""
        check_var("is_symmetry_a", value, "bool")
        self._is_symmetry_a = value

    # 0 Compute on the complete machine, 1 compute according to sym_a and is_antiper_a
    # Type : bool
    is_symmetry_a = property(
        fget=_get_is_symmetry_a,
        fset=_set_is_symmetry_a,
        doc=u"""0 Compute on the complete machine, 1 compute according to sym_a and is_antiper_a""",
    )

    def _get_sym_a(self):
        """getter of sym_a"""
        return self._sym_a

    def _set_sym_a(self, value):
        """setter of sym_a"""
        check_var("sym_a", value, "int", Vmin=1)
        self._sym_a = value

    # Number of symmetry for the angle vector
    # Type : int, min = 1
    sym_a = property(
        fget=_get_sym_a,
        fset=_set_sym_a,
        doc=u"""Number of symmetry for the angle vector""",
    )

    def _get_is_antiper_a(self):
        """getter of is_antiper_a"""
        return self._is_antiper_a

    def _set_is_antiper_a(self, value):
        """setter of is_antiper_a"""
        check_var("is_antiper_a", value, "bool")
        self._is_antiper_a = value

    # To add an antiperiodicity to the angle vector
    # Type : bool
    is_antiper_a = property(
        fget=_get_is_antiper_a,
        fset=_set_is_antiper_a,
        doc=u"""To add an antiperiodicity to the angle vector""",
    )
Ejemplo n.º 16
0
class MatMagnetics(FrozenClass):
    """magnetic material properties"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Material.MatMagnetics.get_BH
    if isinstance(get_BH, ImportError):
        get_BH = property(
            fget=lambda x: raise_(
                ImportError("Can't use MatMagnetics method get_BH: " + str(get_BH))
            )
        )
    else:
        get_BH = get_BH
    # cf Methods.Material.MatMagnetics.plot_BH
    if isinstance(plot_BH, ImportError):
        plot_BH = property(
            fget=lambda x: raise_(
                ImportError("Can't use MatMagnetics method plot_BH: " + str(plot_BH))
            )
        )
    else:
        plot_BH = plot_BH
    # save method is available in all object
    save = save

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

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        MatMagnetics_str = ""
        if self.parent is None:
            MatMagnetics_str += "parent = None " + linesep
        else:
            MatMagnetics_str += (
                "parent = " + str(type(self.parent)) + " object" + linesep
            )
        MatMagnetics_str += "mur_lin = " + str(self.mur_lin) + linesep
        MatMagnetics_str += "Hc = " + str(self.Hc) + linesep
        MatMagnetics_str += "Brm20 = " + str(self.Brm20) + linesep
        MatMagnetics_str += "alpha_Br = " + str(self.alpha_Br) + linesep
        MatMagnetics_str += "Wlam = " + str(self.Wlam) + linesep
        if self.BH_curve is not None:
            tmp = self.BH_curve.__str__().replace(linesep, linesep + "\t").rstrip("\t")
            MatMagnetics_str += "BH_curve = " + tmp
        else:
            MatMagnetics_str += "BH_curve = None" + linesep + linesep
        return MatMagnetics_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False
        if other.mur_lin != self.mur_lin:
            return False
        if other.Hc != self.Hc:
            return False
        if other.Brm20 != self.Brm20:
            return False
        if other.alpha_Br != self.alpha_Br:
            return False
        if other.Wlam != self.Wlam:
            return False
        if other.BH_curve != self.BH_curve:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        MatMagnetics_dict = dict()
        MatMagnetics_dict["mur_lin"] = self.mur_lin
        MatMagnetics_dict["Hc"] = self.Hc
        MatMagnetics_dict["Brm20"] = self.Brm20
        MatMagnetics_dict["alpha_Br"] = self.alpha_Br
        MatMagnetics_dict["Wlam"] = self.Wlam
        if self.BH_curve is None:
            MatMagnetics_dict["BH_curve"] = None
        else:
            MatMagnetics_dict["BH_curve"] = self.BH_curve.as_dict()
        # The class name is added to the dict fordeserialisation purpose
        MatMagnetics_dict["__class__"] = "MatMagnetics"
        return MatMagnetics_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.mur_lin = None
        self.Hc = None
        self.Brm20 = None
        self.alpha_Br = None
        self.Wlam = None
        if self.BH_curve is not None:
            self.BH_curve._set_None()

    def _get_mur_lin(self):
        """getter of mur_lin"""
        return self._mur_lin

    def _set_mur_lin(self, value):
        """setter of mur_lin"""
        check_var("mur_lin", value, "float", Vmin=0)
        self._mur_lin = value

    # Relative magnetic permeability
    # Type : float, min = 0
    mur_lin = property(
        fget=_get_mur_lin, fset=_set_mur_lin, doc=u"""Relative magnetic permeability"""
    )

    def _get_Hc(self):
        """getter of Hc"""
        return self._Hc

    def _set_Hc(self, value):
        """setter of Hc"""
        check_var("Hc", value, "float", Vmin=0)
        self._Hc = value

    # Coercitivity field
    # Type : float, min = 0
    Hc = property(fget=_get_Hc, fset=_set_Hc, doc=u"""Coercitivity field""")

    def _get_Brm20(self):
        """getter of Brm20"""
        return self._Brm20

    def _set_Brm20(self, value):
        """setter of Brm20"""
        check_var("Brm20", value, "float")
        self._Brm20 = value

    # magnet remanence induction at 20degC
    # Type : float
    Brm20 = property(
        fget=_get_Brm20,
        fset=_set_Brm20,
        doc=u"""magnet remanence induction at 20degC""",
    )

    def _get_alpha_Br(self):
        """getter of alpha_Br"""
        return self._alpha_Br

    def _set_alpha_Br(self, value):
        """setter of alpha_Br"""
        check_var("alpha_Br", value, "float")
        self._alpha_Br = value

    # temperature coefficient for remanent flux density /degC compared to 20degC
    # Type : float
    alpha_Br = property(
        fget=_get_alpha_Br,
        fset=_set_alpha_Br,
        doc=u"""temperature coefficient for remanent flux density /degC compared to 20degC""",
    )

    def _get_Wlam(self):
        """getter of Wlam"""
        return self._Wlam

    def _set_Wlam(self, value):
        """setter of Wlam"""
        check_var("Wlam", value, "float", Vmin=0)
        self._Wlam = value

    # lamination sheet width without insulation [m] (0 == not laminated)
    # Type : float, min = 0
    Wlam = property(
        fget=_get_Wlam,
        fset=_set_Wlam,
        doc=u"""lamination sheet width without insulation [m] (0 == not laminated)""",
    )

    def _get_BH_curve(self):
        """getter of BH_curve"""
        return self._BH_curve

    def _set_BH_curve(self, value):
        """setter of BH_curve"""
        check_var("BH_curve", value, "ImportMatrix")
        self._BH_curve = value

        if self._BH_curve is not None:
            self._BH_curve.parent = self

    # nonlinear B(H) curve (two columns matrix, H and B(H))
    # Type : ImportMatrix
    BH_curve = property(
        fget=_get_BH_curve,
        fset=_set_BH_curve,
        doc=u"""nonlinear B(H) curve (two columns matrix, H and B(H))""",
    )
Ejemplo n.º 17
0
class OptiProblem(FrozenClass):
    """Multi-objectives optimization problem with some constraints"""

    VERSION = 1

    # cf Methods.Optimization.OptiProblem.eval_pb
    if isinstance(eval_pb, ImportError):
        eval_pb = property(fget=lambda x: raise_(
            ImportError("Can't use OptiProblem method eval_pb: " + str(eval_pb)
                        )))
    else:
        eval_pb = eval_pb
    # save method is available in all object
    save = save

    def __init__(
            self,
            output=-1,
            design_var=dict(),
            obj_func=dict(),
            eval_func=None,
            constraint=dict(),
            init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

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

        if output == -1:
            output = Output()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "output", "design_var", "obj_func", "eval_func",
                    "constraint"
                ],
            )
            # Overwrite default value with init_dict content
            if "output" in list(init_dict.keys()):
                output = init_dict["output"]
            if "design_var" in list(init_dict.keys()):
                design_var = init_dict["design_var"]
            if "obj_func" in list(init_dict.keys()):
                obj_func = init_dict["obj_func"]
            if "eval_func" in list(init_dict.keys()):
                eval_func = init_dict["eval_func"]
            if "constraint" in list(init_dict.keys()):
                constraint = init_dict["constraint"]
        # Initialisation by argument
        self.parent = None
        # output can be None, a Output object or a dict
        if isinstance(output, dict):
            self.output = Output(init_dict=output)
        else:
            self.output = output
        # design_var can be None or a dict of OptiDesignVar object
        self.design_var = dict()
        if type(design_var) is dict:
            for key, obj in design_var.items():
                if isinstance(obj, dict):
                    self.design_var[key] = OptiDesignVar(init_dict=obj)
                else:
                    self.design_var[key] = obj
        elif design_var is None:
            self.design_var = dict()
        else:
            self.design_var = design_var  # Should raise an error
        # obj_func can be None or a dict of OptiObjFunc object
        self.obj_func = dict()
        if type(obj_func) is dict:
            for key, obj in obj_func.items():
                if isinstance(obj, dict):
                    self.obj_func[key] = OptiObjFunc(init_dict=obj)
                else:
                    self.obj_func[key] = obj
        elif obj_func is None:
            self.obj_func = dict()
        else:
            self.obj_func = obj_func  # Should raise an error
        self.eval_func = eval_func
        # constraint can be None or a dict of OptiConstraint object
        self.constraint = dict()
        if type(constraint) is dict:
            for key, obj in constraint.items():
                if isinstance(obj, dict):
                    self.constraint[key] = OptiConstraint(init_dict=obj)
                else:
                    self.constraint[key] = obj
        elif constraint is None:
            self.constraint = dict()
        else:
            self.constraint = constraint  # Should raise an error

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

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        OptiProblem_str = ""
        if self.parent is None:
            OptiProblem_str += "parent = None " + linesep
        else:
            OptiProblem_str += ("parent = " + str(type(self.parent)) +
                                " object" + linesep)
        if self.output is not None:
            tmp = self.output.__str__().replace(linesep,
                                                linesep + "\t").rstrip("\t")
            OptiProblem_str += "output = " + tmp
        else:
            OptiProblem_str += "output = None" + linesep + linesep
        if len(self.design_var) == 0:
            OptiProblem_str += "design_var = dict()" + linesep
        for key, obj in self.design_var.items():
            tmp = (self.design_var[key].__str__().replace(
                linesep, linesep + "\t") + linesep)
            OptiProblem_str += "design_var[" + key + "] =" + tmp + linesep + linesep
        if len(self.obj_func) == 0:
            OptiProblem_str += "obj_func = dict()" + linesep
        for key, obj in self.obj_func.items():
            tmp = (
                self.obj_func[key].__str__().replace(linesep, linesep + "\t") +
                linesep)
            OptiProblem_str += "obj_func[" + key + "] =" + tmp + linesep + linesep
        if self._eval_func[1] is None:
            OptiProblem_str += "eval_func = " + str(self._eval_func[1])
        else:
            OptiProblem_str += ("eval_func = " + linesep +
                                str(self._eval_func[1]) + linesep + linesep)
        if len(self.constraint) == 0:
            OptiProblem_str += "constraint = dict()" + linesep
        for key, obj in self.constraint.items():
            tmp = (self.constraint[key].__str__().replace(
                linesep, linesep + "\t") + linesep)
            OptiProblem_str += "constraint[" + key + "] =" + tmp + linesep + linesep
        return OptiProblem_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False
        if other.output != self.output:
            return False
        if other.design_var != self.design_var:
            return False
        if other.obj_func != self.obj_func:
            return False
        if other.eval_func != self.eval_func:
            return False
        if other.constraint != self.constraint:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        OptiProblem_dict = dict()
        if self.output is None:
            OptiProblem_dict["output"] = None
        else:
            OptiProblem_dict["output"] = self.output.as_dict()
        OptiProblem_dict["design_var"] = dict()
        for key, obj in self.design_var.items():
            OptiProblem_dict["design_var"][key] = obj.as_dict()
        OptiProblem_dict["obj_func"] = dict()
        for key, obj in self.obj_func.items():
            OptiProblem_dict["obj_func"][key] = obj.as_dict()
        if self.eval_func is None:
            OptiProblem_dict["eval_func"] = None
        else:
            OptiProblem_dict["eval_func"] = [
                dumps(self._eval_func[0]).decode("ISO-8859-2"),
                self._eval_func[1],
            ]
        OptiProblem_dict["constraint"] = dict()
        for key, obj in self.constraint.items():
            OptiProblem_dict["constraint"][key] = obj.as_dict()
        # The class name is added to the dict fordeserialisation purpose
        OptiProblem_dict["__class__"] = "OptiProblem"
        return OptiProblem_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        if self.output is not None:
            self.output._set_None()
        for key, obj in self.design_var.items():
            obj._set_None()
        for key, obj in self.obj_func.items():
            obj._set_None()
        self.eval_func = None
        for key, obj in self.constraint.items():
            obj._set_None()

    def _get_output(self):
        """getter of output"""
        return self._output

    def _set_output(self, value):
        """setter of output"""
        check_var("output", value, "Output")
        self._output = value

        if self._output is not None:
            self._output.parent = self

    # Default output to define the default simulation.
    # Type : Output
    output = property(
        fget=_get_output,
        fset=_set_output,
        doc=u"""Default output to define the default simulation. """,
    )

    def _get_design_var(self):
        """getter of design_var"""
        for key, obj in self._design_var.items():
            if obj is not None:
                obj.parent = self
        return self._design_var

    def _set_design_var(self, value):
        """setter of design_var"""
        check_var("design_var", value, "{OptiDesignVar}")
        self._design_var = value

    # Dict of design variables
    # Type : {OptiDesignVar}
    design_var = property(fget=_get_design_var,
                          fset=_set_design_var,
                          doc=u"""Dict of design variables""")

    def _get_obj_func(self):
        """getter of obj_func"""
        for key, obj in self._obj_func.items():
            if obj is not None:
                obj.parent = self
        return self._obj_func

    def _set_obj_func(self, value):
        """setter of obj_func"""
        check_var("obj_func", value, "{OptiObjFunc}")
        self._obj_func = value

    # Dict of objective functions
    # Type : {OptiObjFunc}
    obj_func = property(fget=_get_obj_func,
                        fset=_set_obj_func,
                        doc=u"""Dict of objective functions""")

    def _get_eval_func(self):
        """getter of eval_func"""
        return self._eval_func[0]

    def _set_eval_func(self, value):
        """setter of eval_func"""
        try:
            check_var("eval_func", value, "list")
        except CheckTypeError:
            check_var("eval_func", value, "function")
        if isinstance(value, list):  # Load function from saved dict
            self._eval_func = [loads(value[0].encode("ISO-8859-2")), value[1]]
        elif value is None:
            self._eval_func = [None, None]
        elif callable(value):
            self._eval_func = [value, getsource(value)]
        else:
            raise TypeError(
                "Expected function or list from a saved file, got: " +
                str(type(value)))

    # Function to evaluate before computing obj function and constraints
    # Type : function
    eval_func = property(
        fget=_get_eval_func,
        fset=_set_eval_func,
        doc=
        u"""Function to evaluate before computing obj function and constraints""",
    )

    def _get_constraint(self):
        """getter of constraint"""
        for key, obj in self._constraint.items():
            if obj is not None:
                obj.parent = self
        return self._constraint

    def _set_constraint(self, value):
        """setter of constraint"""
        check_var("constraint", value, "{OptiConstraint}")
        self._constraint = value

    # Dict containing the constraints
    # Type : {OptiConstraint}
    constraint = property(
        fget=_get_constraint,
        fset=_set_constraint,
        doc=u"""Dict containing the constraints """,
    )
Ejemplo n.º 18
0
class MagFEMM(Magnetics):
    """Magnetic module: Finite Element model with FEMM"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Simulation.MagFEMM.comp_flux_airgap
    if isinstance(comp_flux_airgap, ImportError):
        comp_flux_airgap = property(fget=lambda x: raise_(
            ImportError("Can't use MagFEMM method comp_flux_airgap: " + str(
                comp_flux_airgap))))
    else:
        comp_flux_airgap = comp_flux_airgap
    # cf Methods.Simulation.MagFEMM.get_path_save
    if isinstance(get_path_save, ImportError):
        get_path_save = property(fget=lambda x: raise_(
            ImportError("Can't use MagFEMM method get_path_save: " + str(
                get_path_save))))
    else:
        get_path_save = get_path_save
    # cf Methods.Simulation.MagFEMM.solve_FEMM
    if isinstance(solve_FEMM, ImportError):
        solve_FEMM = property(fget=lambda x: raise_(
            ImportError("Can't use MagFEMM method solve_FEMM: " + str(
                solve_FEMM))))
    else:
        solve_FEMM = solve_FEMM
    # cf Methods.Simulation.MagFEMM.get_meshsolution
    if isinstance(get_meshsolution, ImportError):
        get_meshsolution = property(fget=lambda x: raise_(
            ImportError("Can't use MagFEMM method get_meshsolution: " + str(
                get_meshsolution))))
    else:
        get_meshsolution = get_meshsolution
    # cf Methods.Simulation.MagFEMM.get_path_save_fem
    if isinstance(get_path_save_fem, ImportError):
        get_path_save_fem = property(fget=lambda x: raise_(
            ImportError("Can't use MagFEMM method get_path_save_fem: " + str(
                get_path_save_fem))))
    else:
        get_path_save_fem = get_path_save_fem
    # save method is available in all object
    save = save

    def __init__(
        self,
        Kmesh_fineness=1,
        Kgeo_fineness=1,
        type_calc_leakage=0,
        file_name="",
        FEMM_dict={},
        angle_stator=0,
        is_get_mesh=False,
        is_save_FEA=False,
        is_sliding_band=True,
        transform_list=[],
        is_remove_slotS=False,
        is_remove_slotR=False,
        is_remove_vent=False,
        is_mmfs=True,
        is_mmfr=True,
        is_stator_linear_BH=0,
        is_rotor_linear_BH=0,
        is_symmetry_t=False,
        sym_t=1,
        is_antiper_t=False,
        is_symmetry_a=False,
        sym_a=1,
        is_antiper_a=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,
                [
                    "Kmesh_fineness",
                    "Kgeo_fineness",
                    "type_calc_leakage",
                    "file_name",
                    "FEMM_dict",
                    "angle_stator",
                    "is_get_mesh",
                    "is_save_FEA",
                    "is_sliding_band",
                    "transform_list",
                    "is_remove_slotS",
                    "is_remove_slotR",
                    "is_remove_vent",
                    "is_mmfs",
                    "is_mmfr",
                    "is_stator_linear_BH",
                    "is_rotor_linear_BH",
                    "is_symmetry_t",
                    "sym_t",
                    "is_antiper_t",
                    "is_symmetry_a",
                    "sym_a",
                    "is_antiper_a",
                ],
            )
            # Overwrite default value with init_dict content
            if "Kmesh_fineness" in list(init_dict.keys()):
                Kmesh_fineness = init_dict["Kmesh_fineness"]
            if "Kgeo_fineness" in list(init_dict.keys()):
                Kgeo_fineness = init_dict["Kgeo_fineness"]
            if "type_calc_leakage" in list(init_dict.keys()):
                type_calc_leakage = init_dict["type_calc_leakage"]
            if "file_name" in list(init_dict.keys()):
                file_name = init_dict["file_name"]
            if "FEMM_dict" in list(init_dict.keys()):
                FEMM_dict = init_dict["FEMM_dict"]
            if "angle_stator" in list(init_dict.keys()):
                angle_stator = init_dict["angle_stator"]
            if "is_get_mesh" in list(init_dict.keys()):
                is_get_mesh = init_dict["is_get_mesh"]
            if "is_save_FEA" in list(init_dict.keys()):
                is_save_FEA = init_dict["is_save_FEA"]
            if "is_sliding_band" in list(init_dict.keys()):
                is_sliding_band = init_dict["is_sliding_band"]
            if "transform_list" in list(init_dict.keys()):
                transform_list = init_dict["transform_list"]
            if "is_remove_slotS" in list(init_dict.keys()):
                is_remove_slotS = init_dict["is_remove_slotS"]
            if "is_remove_slotR" in list(init_dict.keys()):
                is_remove_slotR = init_dict["is_remove_slotR"]
            if "is_remove_vent" in list(init_dict.keys()):
                is_remove_vent = init_dict["is_remove_vent"]
            if "is_mmfs" in list(init_dict.keys()):
                is_mmfs = init_dict["is_mmfs"]
            if "is_mmfr" in list(init_dict.keys()):
                is_mmfr = init_dict["is_mmfr"]
            if "is_stator_linear_BH" in list(init_dict.keys()):
                is_stator_linear_BH = init_dict["is_stator_linear_BH"]
            if "is_rotor_linear_BH" in list(init_dict.keys()):
                is_rotor_linear_BH = init_dict["is_rotor_linear_BH"]
            if "is_symmetry_t" in list(init_dict.keys()):
                is_symmetry_t = init_dict["is_symmetry_t"]
            if "sym_t" in list(init_dict.keys()):
                sym_t = init_dict["sym_t"]
            if "is_antiper_t" in list(init_dict.keys()):
                is_antiper_t = init_dict["is_antiper_t"]
            if "is_symmetry_a" in list(init_dict.keys()):
                is_symmetry_a = init_dict["is_symmetry_a"]
            if "sym_a" in list(init_dict.keys()):
                sym_a = init_dict["sym_a"]
            if "is_antiper_a" in list(init_dict.keys()):
                is_antiper_a = init_dict["is_antiper_a"]
        # Initialisation by argument
        self.Kmesh_fineness = Kmesh_fineness
        self.Kgeo_fineness = Kgeo_fineness
        self.type_calc_leakage = type_calc_leakage
        self.file_name = file_name
        self.FEMM_dict = FEMM_dict
        self.angle_stator = angle_stator
        self.is_get_mesh = is_get_mesh
        self.is_save_FEA = is_save_FEA
        self.is_sliding_band = is_sliding_band
        self.transform_list = transform_list
        # Call Magnetics init
        super(MagFEMM, self).__init__(
            is_remove_slotS=is_remove_slotS,
            is_remove_slotR=is_remove_slotR,
            is_remove_vent=is_remove_vent,
            is_mmfs=is_mmfs,
            is_mmfr=is_mmfr,
            is_stator_linear_BH=is_stator_linear_BH,
            is_rotor_linear_BH=is_rotor_linear_BH,
            is_symmetry_t=is_symmetry_t,
            sym_t=sym_t,
            is_antiper_t=is_antiper_t,
            is_symmetry_a=is_symmetry_a,
            sym_a=sym_a,
            is_antiper_a=is_antiper_a,
        )
        # The class is frozen (in Magnetics init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        MagFEMM_str = ""
        # Get the properties inherited from Magnetics
        MagFEMM_str += super(MagFEMM, self).__str__()
        MagFEMM_str += "Kmesh_fineness = " + str(self.Kmesh_fineness) + linesep
        MagFEMM_str += "Kgeo_fineness = " + str(self.Kgeo_fineness) + linesep
        MagFEMM_str += "type_calc_leakage = " + str(
            self.type_calc_leakage) + linesep
        MagFEMM_str += 'file_name = "' + str(self.file_name) + '"' + linesep
        MagFEMM_str += "FEMM_dict = " + str(self.FEMM_dict) + linesep
        MagFEMM_str += "angle_stator = " + str(self.angle_stator) + linesep
        MagFEMM_str += "is_get_mesh = " + str(self.is_get_mesh) + linesep
        MagFEMM_str += "is_save_FEA = " + str(self.is_save_FEA) + linesep
        MagFEMM_str += "is_sliding_band = " + str(
            self.is_sliding_band) + linesep
        MagFEMM_str += ("transform_list = " + linesep + str(
            self.transform_list).replace(linesep, linesep + "\t") + linesep)
        return MagFEMM_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from Magnetics
        if not super(MagFEMM, self).__eq__(other):
            return False
        if other.Kmesh_fineness != self.Kmesh_fineness:
            return False
        if other.Kgeo_fineness != self.Kgeo_fineness:
            return False
        if other.type_calc_leakage != self.type_calc_leakage:
            return False
        if other.file_name != self.file_name:
            return False
        if other.FEMM_dict != self.FEMM_dict:
            return False
        if other.angle_stator != self.angle_stator:
            return False
        if other.is_get_mesh != self.is_get_mesh:
            return False
        if other.is_save_FEA != self.is_save_FEA:
            return False
        if other.is_sliding_band != self.is_sliding_band:
            return False
        if other.transform_list != self.transform_list:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from Magnetics
        MagFEMM_dict = super(MagFEMM, self).as_dict()
        MagFEMM_dict["Kmesh_fineness"] = self.Kmesh_fineness
        MagFEMM_dict["Kgeo_fineness"] = self.Kgeo_fineness
        MagFEMM_dict["type_calc_leakage"] = self.type_calc_leakage
        MagFEMM_dict["file_name"] = self.file_name
        MagFEMM_dict["FEMM_dict"] = self.FEMM_dict
        MagFEMM_dict["angle_stator"] = self.angle_stator
        MagFEMM_dict["is_get_mesh"] = self.is_get_mesh
        MagFEMM_dict["is_save_FEA"] = self.is_save_FEA
        MagFEMM_dict["is_sliding_band"] = self.is_sliding_band
        MagFEMM_dict["transform_list"] = self.transform_list
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        MagFEMM_dict["__class__"] = "MagFEMM"
        return MagFEMM_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.Kmesh_fineness = None
        self.Kgeo_fineness = None
        self.type_calc_leakage = None
        self.file_name = None
        self.FEMM_dict = None
        self.angle_stator = None
        self.is_get_mesh = None
        self.is_save_FEA = None
        self.is_sliding_band = None
        self.transform_list = None
        # Set to None the properties inherited from Magnetics
        super(MagFEMM, self)._set_None()

    def _get_Kmesh_fineness(self):
        """getter of Kmesh_fineness"""
        return self._Kmesh_fineness

    def _set_Kmesh_fineness(self, value):
        """setter of Kmesh_fineness"""
        check_var("Kmesh_fineness", value, "float")
        self._Kmesh_fineness = value

    # global coefficient to adjust mesh fineness in FEMM (1 : default , > 1 : finner , < 1 : less fine)
    # Type : float
    Kmesh_fineness = property(
        fget=_get_Kmesh_fineness,
        fset=_set_Kmesh_fineness,
        doc=
        u"""global coefficient to adjust mesh fineness in FEMM (1 : default , > 1 : finner , < 1 : less fine)""",
    )

    def _get_Kgeo_fineness(self):
        """getter of Kgeo_fineness"""
        return self._Kgeo_fineness

    def _set_Kgeo_fineness(self, value):
        """setter of Kgeo_fineness"""
        check_var("Kgeo_fineness", value, "float")
        self._Kgeo_fineness = value

    # global coefficient to adjust geometry fineness in FEMM (1 : default , > 1 : finner , < 1 : less fine)
    # Type : float
    Kgeo_fineness = property(
        fget=_get_Kgeo_fineness,
        fset=_set_Kgeo_fineness,
        doc=
        u"""global coefficient to adjust geometry fineness in FEMM (1 : default , > 1 : finner , < 1 : less fine)""",
    )

    def _get_type_calc_leakage(self):
        """getter of type_calc_leakage"""
        return self._type_calc_leakage

    def _set_type_calc_leakage(self, value):
        """setter of type_calc_leakage"""
        check_var("type_calc_leakage", value, "int", Vmin=0, Vmax=1)
        self._type_calc_leakage = value

    # 0 no leakage calculation /  1 calculation using single slot
    # Type : int, min = 0, max = 1
    type_calc_leakage = property(
        fget=_get_type_calc_leakage,
        fset=_set_type_calc_leakage,
        doc=u"""0 no leakage calculation /  1 calculation using single slot """,
    )

    def _get_file_name(self):
        """getter of file_name"""
        return self._file_name

    def _set_file_name(self, value):
        """setter of file_name"""
        check_var("file_name", value, "str")
        self._file_name = value

    # Name of the file to save the FEMM model
    # Type : str
    file_name = property(
        fget=_get_file_name,
        fset=_set_file_name,
        doc=u"""Name of the file to save the FEMM model""",
    )

    def _get_FEMM_dict(self):
        """getter of FEMM_dict"""
        return self._FEMM_dict

    def _set_FEMM_dict(self, value):
        """setter of FEMM_dict"""
        check_var("FEMM_dict", value, "dict")
        self._FEMM_dict = value

    # To enforce user-defined values for FEMM main parameters
    # Type : dict
    FEMM_dict = property(
        fget=_get_FEMM_dict,
        fset=_set_FEMM_dict,
        doc=u"""To enforce user-defined values for FEMM main parameters """,
    )

    def _get_angle_stator(self):
        """getter of angle_stator"""
        return self._angle_stator

    def _set_angle_stator(self, value):
        """setter of angle_stator"""
        check_var("angle_stator", value, "float")
        self._angle_stator = value

    # Angular position shift of the stator
    # Type : float
    angle_stator = property(
        fget=_get_angle_stator,
        fset=_set_angle_stator,
        doc=u"""Angular position shift of the stator""",
    )

    def _get_is_get_mesh(self):
        """getter of is_get_mesh"""
        return self._is_get_mesh

    def _set_is_get_mesh(self, value):
        """setter of is_get_mesh"""
        check_var("is_get_mesh", value, "bool")
        self._is_get_mesh = value

    # To save FEA mesh for latter post-procesing
    # Type : bool
    is_get_mesh = property(
        fget=_get_is_get_mesh,
        fset=_set_is_get_mesh,
        doc=u"""To save FEA mesh for latter post-procesing """,
    )

    def _get_is_save_FEA(self):
        """getter of is_save_FEA"""
        return self._is_save_FEA

    def _set_is_save_FEA(self, value):
        """setter of is_save_FEA"""
        check_var("is_save_FEA", value, "bool")
        self._is_save_FEA = value

    # To save FEA mesh and solution in .dat file
    # Type : bool
    is_save_FEA = property(
        fget=_get_is_save_FEA,
        fset=_set_is_save_FEA,
        doc=u"""To save FEA mesh and solution in .dat file""",
    )

    def _get_is_sliding_band(self):
        """getter of is_sliding_band"""
        return self._is_sliding_band

    def _set_is_sliding_band(self, value):
        """setter of is_sliding_band"""
        check_var("is_sliding_band", value, "bool")
        self._is_sliding_band = value

    # 0 to desactivate the sliding band
    # Type : bool
    is_sliding_band = property(
        fget=_get_is_sliding_band,
        fset=_set_is_sliding_band,
        doc=u"""0 to desactivate the sliding band""",
    )

    def _get_transform_list(self):
        """getter of transform_list"""
        return self._transform_list

    def _set_transform_list(self, value):
        """setter of transform_list"""
        check_var("transform_list", value, "list")
        self._transform_list = value

    # List of dictionnary to apply transformation on the machine surfaces. Key: label (to select the surface), type (rotate or translate), value (alpha or delta)
    # Type : list
    transform_list = property(
        fget=_get_transform_list,
        fset=_set_transform_list,
        doc=
        u"""List of dictionnary to apply transformation on the machine surfaces. Key: label (to select the surface), type (rotate or translate), value (alpha or delta)""",
    )
Ejemplo n.º 19
0
class Arc2(Arc):
    """An arc between two points (defined by the begin  point and a center and angle)"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Geometry.Arc2.check
    if isinstance(check, ImportError):
        check = property(fget=lambda x: raise_(
            ImportError("Can't use Arc2 method check: " + str(check))))
    else:
        check = check
    # cf Methods.Geometry.Arc2.comp_length
    if isinstance(comp_length, ImportError):
        comp_length = property(fget=lambda x: raise_(
            ImportError("Can't use Arc2 method comp_length: " + str(comp_length
                                                                    ))))
    else:
        comp_length = comp_length
    # cf Methods.Geometry.Arc2.comp_radius
    if isinstance(comp_radius, ImportError):
        comp_radius = property(fget=lambda x: raise_(
            ImportError("Can't use Arc2 method comp_radius: " + str(comp_radius
                                                                    ))))
    else:
        comp_radius = comp_radius
    # cf Methods.Geometry.Arc2.discretize
    if isinstance(discretize, ImportError):
        discretize = property(fget=lambda x: raise_(
            ImportError("Can't use Arc2 method discretize: " + str(discretize))
        ))
    else:
        discretize = discretize
    # cf Methods.Geometry.Arc2.get_angle
    if isinstance(get_angle, ImportError):
        get_angle = property(fget=lambda x: raise_(
            ImportError("Can't use Arc2 method get_angle: " + str(get_angle))))
    else:
        get_angle = get_angle
    # cf Methods.Geometry.Arc2.get_begin
    if isinstance(get_begin, ImportError):
        get_begin = property(fget=lambda x: raise_(
            ImportError("Can't use Arc2 method get_begin: " + str(get_begin))))
    else:
        get_begin = get_begin
    # cf Methods.Geometry.Arc2.get_center
    if isinstance(get_center, ImportError):
        get_center = property(fget=lambda x: raise_(
            ImportError("Can't use Arc2 method get_center: " + str(get_center))
        ))
    else:
        get_center = get_center
    # cf Methods.Geometry.Arc2.get_end
    if isinstance(get_end, ImportError):
        get_end = property(fget=lambda x: raise_(
            ImportError("Can't use Arc2 method get_end: " + str(get_end))))
    else:
        get_end = get_end
    # cf Methods.Geometry.Arc2.get_middle
    if isinstance(get_middle, ImportError):
        get_middle = property(fget=lambda x: raise_(
            ImportError("Can't use Arc2 method get_middle: " + str(get_middle))
        ))
    else:
        get_middle = get_middle
    # cf Methods.Geometry.Arc2.reverse
    if isinstance(reverse, ImportError):
        reverse = property(fget=lambda x: raise_(
            ImportError("Can't use Arc2 method reverse: " + str(reverse))))
    else:
        reverse = reverse
    # cf Methods.Geometry.Arc2.rotate
    if isinstance(rotate, ImportError):
        rotate = property(fget=lambda x: raise_(
            ImportError("Can't use Arc2 method rotate: " + str(rotate))))
    else:
        rotate = rotate
    # cf Methods.Geometry.Arc2.split_half
    if isinstance(split_half, ImportError):
        split_half = property(fget=lambda x: raise_(
            ImportError("Can't use Arc2 method split_half: " + str(split_half))
        ))
    else:
        split_half = split_half
    # cf Methods.Geometry.Arc2.translate
    if isinstance(translate, ImportError):
        translate = property(fget=lambda x: raise_(
            ImportError("Can't use Arc2 method translate: " + str(translate))))
    else:
        translate = translate
    # save method is available in all object
    save = save

    def __init__(self,
                 begin=0,
                 center=0,
                 angle=1.57079633,
                 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, ["begin", "center", "angle", "label"])
            # Overwrite default value with init_dict content
            if "begin" in list(init_dict.keys()):
                begin = init_dict["begin"]
            if "center" in list(init_dict.keys()):
                center = init_dict["center"]
            if "angle" in list(init_dict.keys()):
                angle = init_dict["angle"]
            if "label" in list(init_dict.keys()):
                label = init_dict["label"]
        # Initialisation by argument
        self.begin = begin
        self.center = center
        self.angle = angle
        # Call Arc init
        super(Arc2, self).__init__(label=label)
        # The class is frozen (in Arc init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        Arc2_str = ""
        # Get the properties inherited from Arc
        Arc2_str += super(Arc2, self).__str__()
        Arc2_str += "begin = " + str(self.begin) + linesep
        Arc2_str += "center = " + str(self.center) + linesep
        Arc2_str += "angle = " + str(self.angle) + linesep
        return Arc2_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from Arc
        if not super(Arc2, self).__eq__(other):
            return False
        if other.begin != self.begin:
            return False
        if other.center != self.center:
            return False
        if other.angle != self.angle:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from Arc
        Arc2_dict = super(Arc2, self).as_dict()
        Arc2_dict["begin"] = self.begin
        Arc2_dict["center"] = self.center
        Arc2_dict["angle"] = self.angle
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        Arc2_dict["__class__"] = "Arc2"
        return Arc2_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.begin = None
        self.center = None
        self.angle = None
        # Set to None the properties inherited from Arc
        super(Arc2, self)._set_None()

    def _get_begin(self):
        """getter of begin"""
        return self._begin

    def _set_begin(self, value):
        """setter of begin"""
        check_var("begin", value, "complex")
        self._begin = value

    # begin point of the arc
    # Type : complex
    begin = property(fget=_get_begin,
                     fset=_set_begin,
                     doc=u"""begin point of the arc""")

    def _get_center(self):
        """getter of center"""
        return self._center

    def _set_center(self, value):
        """setter of center"""
        check_var("center", value, "complex")
        self._center = value

    # center of the arc
    # Type : complex
    center = property(fget=_get_center,
                      fset=_set_center,
                      doc=u"""center of the arc""")

    def _get_angle(self):
        """getter of angle"""
        return self._angle

    def _set_angle(self, value):
        """setter of angle"""
        check_var("angle",
                  value,
                  "float",
                  Vmin=-6.2831853071796,
                  Vmax=6.2831853071796)
        self._angle = value

    # opening angle of the arc
    # Type : float, min = -6.2831853071796, max = 6.2831853071796
    angle = property(fget=_get_angle,
                     fset=_set_angle,
                     doc=u"""opening angle of the arc""")
Ejemplo n.º 20
0
class Simu1(Simulation):
    """Five sequential weak coupling multi physics simulation"""

    VERSION = 1

    # cf Methods.Simulation.Simu1.run
    if isinstance(run, ImportError):
        run = property(
            fget=lambda x: raise_(
                ImportError("Can't use Simu1 method run: " + str(run))
            )
        )
    else:
        run = run
    # save method is available in all object
    save = save

    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)
        # The class is frozen (in Simulation init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        Simu1_str = ""
        # Get the properties inherited from Simulation
        Simu1_str += super(Simu1, self).__str__()
        if self.mag is not None:
            tmp = self.mag.__str__().replace(linesep, linesep + "\t").rstrip("\t")
            Simu1_str += "mag = " + tmp
        else:
            Simu1_str += "mag = None" + linesep + linesep
        if self.struct is not None:
            tmp = self.struct.__str__().replace(linesep, linesep + "\t").rstrip("\t")
            Simu1_str += "struct = " + tmp
        else:
            Simu1_str += "struct = None" + linesep + linesep
        return Simu1_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from Simulation
        if not super(Simu1, self).__eq__(other):
            return False
        if other.mag != self.mag:
            return False
        if other.struct != self.struct:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from Simulation
        Simu1_dict = super(Simu1, self).as_dict()
        if self.mag is None:
            Simu1_dict["mag"] = None
        else:
            Simu1_dict["mag"] = self.mag.as_dict()
        if self.struct is None:
            Simu1_dict["struct"] = None
        else:
            Simu1_dict["struct"] = self.struct.as_dict()
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        Simu1_dict["__class__"] = "Simu1"
        return Simu1_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        if self.mag is not None:
            self.mag._set_None()
        if self.struct is not None:
            self.struct._set_None()
        # Set to None the properties inherited from Simulation
        super(Simu1, self)._set_None()

    def _get_mag(self):
        """getter of mag"""
        return self._mag

    def _set_mag(self, value):
        """setter of mag"""
        check_var("mag", value, "Magnetics")
        self._mag = value

        if self._mag is not None:
            self._mag.parent = self

    # Magnetic module
    # Type : Magnetics
    mag = property(fget=_get_mag, fset=_set_mag, doc=u"""Magnetic module""")

    def _get_struct(self):
        """getter of struct"""
        return self._struct

    def _set_struct(self, value):
        """setter of struct"""
        check_var("struct", value, "Structural")
        self._struct = value

        if self._struct is not None:
            self._struct.parent = self

    # Structural module
    # Type : Structural
    struct = property(fget=_get_struct, fset=_set_struct, doc=u"""Structural module""")
Ejemplo n.º 21
0
class Output(FrozenClass):
    """Main Output object: gather all the outputs of all the modules"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Output.Output.getter.get_BH_stator
    if isinstance(get_BH_stator, ImportError):
        get_BH_stator = property(fget=lambda x: raise_(
            ImportError("Can't use Output method get_BH_stator: " + str(
                get_BH_stator))))
    else:
        get_BH_stator = get_BH_stator
    # cf Methods.Output.Output.getter.get_BH_rotor
    if isinstance(get_BH_rotor, ImportError):
        get_BH_rotor = property(fget=lambda x: raise_(
            ImportError("Can't use Output method get_BH_rotor: " + str(
                get_BH_rotor))))
    else:
        get_BH_rotor = get_BH_rotor
    # cf Methods.Output.Output.getter.get_path_result
    if isinstance(get_path_result, ImportError):
        get_path_result = property(fget=lambda x: raise_(
            ImportError("Can't use Output method get_path_result: " + str(
                get_path_result))))
    else:
        get_path_result = get_path_result
    # cf Methods.Output.Output.getter.get_angle_rotor
    if isinstance(get_angle_rotor, ImportError):
        get_angle_rotor = property(fget=lambda x: raise_(
            ImportError("Can't use Output method get_angle_rotor: " + str(
                get_angle_rotor))))
    else:
        get_angle_rotor = get_angle_rotor
    # cf Methods.Output.Output.plot.Magnetic.plot_B_space
    if isinstance(plot_B_space, ImportError):
        plot_B_space = property(fget=lambda x: raise_(
            ImportError("Can't use Output method plot_B_space: " + str(
                plot_B_space))))
    else:
        plot_B_space = plot_B_space
    # cf Methods.Output.Output.plot.Structural.plot_force_space
    if isinstance(plot_force_space, ImportError):
        plot_force_space = property(fget=lambda x: raise_(
            ImportError("Can't use Output method plot_force_space: " + str(
                plot_force_space))))
    else:
        plot_force_space = plot_force_space
    # cf Methods.Output.Output.plot.Magnetic.plot_mesh_field
    if isinstance(plot_mesh_field, ImportError):
        plot_mesh_field = property(fget=lambda x: raise_(
            ImportError("Can't use Output method plot_mesh_field: " + str(
                plot_mesh_field))))
    else:
        plot_mesh_field = plot_mesh_field
    # cf Methods.Output.Output.plot.Magnetic.plot_mesh
    if isinstance(plot_mesh, ImportError):
        plot_mesh = property(fget=lambda x: raise_(
            ImportError("Can't use Output method plot_mesh: " + str(plot_mesh))
        ))
    else:
        plot_mesh = plot_mesh
    # save method is available in all object
    save = save

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

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        Output_str = ""
        if self.parent is None:
            Output_str += "parent = None " + linesep
        else:
            Output_str += "parent = " + str(type(
                self.parent)) + " object" + linesep
        if self.simu is not None:
            tmp = self.simu.__str__().replace(linesep,
                                              linesep + "\t").rstrip("\t")
            Output_str += "simu = " + tmp
        else:
            Output_str += "simu = None" + linesep + linesep
        Output_str += 'path_res = "' + str(self.path_res) + '"' + linesep
        if self.geo is not None:
            tmp = self.geo.__str__().replace(linesep,
                                             linesep + "\t").rstrip("\t")
            Output_str += "geo = " + tmp
        else:
            Output_str += "geo = None" + linesep + linesep
        if self.elec is not None:
            tmp = self.elec.__str__().replace(linesep,
                                              linesep + "\t").rstrip("\t")
            Output_str += "elec = " + tmp
        else:
            Output_str += "elec = None" + linesep + linesep
        if self.mag is not None:
            tmp = self.mag.__str__().replace(linesep,
                                             linesep + "\t").rstrip("\t")
            Output_str += "mag = " + tmp
        else:
            Output_str += "mag = None" + linesep + linesep
        if self.struct is not None:
            tmp = self.struct.__str__().replace(linesep,
                                                linesep + "\t").rstrip("\t")
            Output_str += "struct = " + tmp
        else:
            Output_str += "struct = None" + linesep + linesep
        if self.post is not None:
            tmp = self.post.__str__().replace(linesep,
                                              linesep + "\t").rstrip("\t")
            Output_str += "post = " + tmp
        else:
            Output_str += "post = None" + linesep + linesep
        return Output_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False
        if other.simu != self.simu:
            return False
        if other.path_res != self.path_res:
            return False
        if other.geo != self.geo:
            return False
        if other.elec != self.elec:
            return False
        if other.mag != self.mag:
            return False
        if other.struct != self.struct:
            return False
        if other.post != self.post:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        Output_dict = dict()
        if self.simu is None:
            Output_dict["simu"] = None
        else:
            Output_dict["simu"] = self.simu.as_dict()
        Output_dict["path_res"] = self.path_res
        if self.geo is None:
            Output_dict["geo"] = None
        else:
            Output_dict["geo"] = self.geo.as_dict()
        if self.elec is None:
            Output_dict["elec"] = None
        else:
            Output_dict["elec"] = self.elec.as_dict()
        if self.mag is None:
            Output_dict["mag"] = None
        else:
            Output_dict["mag"] = self.mag.as_dict()
        if self.struct is None:
            Output_dict["struct"] = None
        else:
            Output_dict["struct"] = self.struct.as_dict()
        if self.post is None:
            Output_dict["post"] = None
        else:
            Output_dict["post"] = self.post.as_dict()
        # The class name is added to the dict fordeserialisation purpose
        Output_dict["__class__"] = "Output"
        return Output_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        if self.simu is not None:
            self.simu._set_None()
        self.path_res = None
        if self.geo is not None:
            self.geo._set_None()
        if self.elec is not None:
            self.elec._set_None()
        if self.mag is not None:
            self.mag._set_None()
        if self.struct is not None:
            self.struct._set_None()
        if self.post is not None:
            self.post._set_None()

    def _get_simu(self):
        """getter of simu"""
        return self._simu

    def _set_simu(self, value):
        """setter of simu"""
        check_var("simu", value, "Simulation")
        self._simu = value

        if self._simu is not None:
            self._simu.parent = self

    # Simulation object that generated the Output
    # Type : Simulation
    simu = property(
        fget=_get_simu,
        fset=_set_simu,
        doc=u"""Simulation object that generated the Output""",
    )

    def _get_path_res(self):
        """getter of path_res"""
        return self._path_res

    def _set_path_res(self, value):
        """setter of path_res"""
        check_var("path_res", value, "str")
        self._path_res = value

    # Path to the folder to same the results
    # Type : str
    path_res = property(
        fget=_get_path_res,
        fset=_set_path_res,
        doc=u"""Path to the folder to same the results""",
    )

    def _get_geo(self):
        """getter of geo"""
        return self._geo

    def _set_geo(self, value):
        """setter of geo"""
        check_var("geo", value, "OutGeo")
        self._geo = value

        if self._geo is not None:
            self._geo.parent = self

    # Geometry output
    # Type : OutGeo
    geo = property(fget=_get_geo, fset=_set_geo, doc=u"""Geometry output""")

    def _get_elec(self):
        """getter of elec"""
        return self._elec

    def _set_elec(self, value):
        """setter of elec"""
        check_var("elec", value, "OutElec")
        self._elec = value

        if self._elec is not None:
            self._elec.parent = self

    # Electrical module output
    # Type : OutElec
    elec = property(fget=_get_elec,
                    fset=_set_elec,
                    doc=u"""Electrical module output""")

    def _get_mag(self):
        """getter of mag"""
        return self._mag

    def _set_mag(self, value):
        """setter of mag"""
        check_var("mag", value, "OutMag")
        self._mag = value

        if self._mag is not None:
            self._mag.parent = self

    # Magnetic module output
    # Type : OutMag
    mag = property(fget=_get_mag,
                   fset=_set_mag,
                   doc=u"""Magnetic module output""")

    def _get_struct(self):
        """getter of struct"""
        return self._struct

    def _set_struct(self, value):
        """setter of struct"""
        check_var("struct", value, "OutStruct")
        self._struct = value

        if self._struct is not None:
            self._struct.parent = self

    # Structural module output
    # Type : OutStruct
    struct = property(fget=_get_struct,
                      fset=_set_struct,
                      doc=u"""Structural module output""")

    def _get_post(self):
        """getter of post"""
        return self._post

    def _set_post(self, value):
        """setter of post"""
        check_var("post", value, "OutPost")
        self._post = value

        if self._post is not None:
            self._post.parent = self

    # Post-Processing settings
    # Type : OutPost
    post = property(fget=_get_post,
                    fset=_set_post,
                    doc=u"""Post-Processing settings""")
Ejemplo n.º 22
0
class Surface(FrozenClass):
    """SurfLine define by list of lines that delimit it, label and point reference."""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Geometry.Surface.comp_mesh_dict
    if isinstance(comp_mesh_dict, ImportError):
        comp_mesh_dict = property(
            fget=lambda x: raise_(
                ImportError(
                    "Can't use Surface method comp_mesh_dict: " + str(comp_mesh_dict)
                )
            )
        )
    else:
        comp_mesh_dict = comp_mesh_dict
    # cf Methods.Geometry.Surface.draw_FEMM
    if isinstance(draw_FEMM, ImportError):
        draw_FEMM = property(
            fget=lambda x: raise_(
                ImportError("Can't use Surface method draw_FEMM: " + str(draw_FEMM))
            )
        )
    else:
        draw_FEMM = draw_FEMM
    # cf Methods.Geometry.Surface.plot
    if isinstance(plot, ImportError):
        plot = property(
            fget=lambda x: raise_(
                ImportError("Can't use Surface method plot: " + str(plot))
            )
        )
    else:
        plot = plot
    # save method is available in all object
    save = save

    def __init__(self, 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, ["point_ref", "label"])
            # Overwrite default value with init_dict content
            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
        self.parent = None
        self.point_ref = point_ref
        self.label = label

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

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        Surface_str = ""
        if self.parent is None:
            Surface_str += "parent = None " + linesep
        else:
            Surface_str += "parent = " + str(type(self.parent)) + " object" + linesep
        Surface_str += "point_ref = " + str(self.point_ref) + linesep
        Surface_str += 'label = "' + str(self.label) + '"' + linesep
        return Surface_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False
        if other.point_ref != self.point_ref:
            return False
        if other.label != self.label:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        Surface_dict = dict()
        Surface_dict["point_ref"] = self.point_ref
        Surface_dict["label"] = self.label
        # The class name is added to the dict fordeserialisation purpose
        Surface_dict["__class__"] = "Surface"
        return Surface_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.point_ref = None
        self.label = None

    def _get_point_ref(self):
        """getter of point_ref"""
        return self._point_ref

    def _set_point_ref(self, value):
        """setter of point_ref"""
        check_var("point_ref", value, "complex")
        self._point_ref = value

    # Center of symmetry
    # Type : complex
    point_ref = property(
        fget=_get_point_ref, fset=_set_point_ref, doc=u"""Center of symmetry"""
    )

    def _get_label(self):
        """getter of label"""
        return self._label

    def _set_label(self, value):
        """setter of label"""
        check_var("label", value, "str")
        self._label = value

    # Label of the surface
    # Type : str
    label = property(fget=_get_label, fset=_set_label, doc=u"""Label of the surface""")
Ejemplo n.º 23
0
class MachineSIPMSM(MachineSync):
    """Inset and Surface Permanent Magnet Synchronous Machine"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Machine.MachineSIPMSM.check
    if isinstance(check, ImportError):
        check = property(
            fget=lambda x: raise_(
                ImportError("Can't use MachineSIPMSM method check: " + str(check))
            )
        )
    else:
        check = check
    # cf Methods.Machine.MachineSIPMSM.get_machine_type
    if isinstance(get_machine_type, ImportError):
        get_machine_type = property(
            fget=lambda x: raise_(
                ImportError(
                    "Can't use MachineSIPMSM method get_machine_type: "
                    + str(get_machine_type)
                )
            )
        )
    else:
        get_machine_type = get_machine_type
    # save method is available in all object
    save = save

    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
        )
        # The class is frozen (in MachineSync init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        MachineSIPMSM_str = ""
        # Get the properties inherited from MachineSync
        MachineSIPMSM_str += super(MachineSIPMSM, self).__str__()
        if self.rotor is not None:
            tmp = self.rotor.__str__().replace(linesep, linesep + "\t").rstrip("\t")
            MachineSIPMSM_str += "rotor = " + tmp
        else:
            MachineSIPMSM_str += "rotor = None" + linesep + linesep
        if self.stator is not None:
            tmp = self.stator.__str__().replace(linesep, linesep + "\t").rstrip("\t")
            MachineSIPMSM_str += "stator = " + tmp
        else:
            MachineSIPMSM_str += "stator = None" + linesep + linesep
        return MachineSIPMSM_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from MachineSync
        if not super(MachineSIPMSM, self).__eq__(other):
            return False
        if other.rotor != self.rotor:
            return False
        if other.stator != self.stator:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from MachineSync
        MachineSIPMSM_dict = super(MachineSIPMSM, self).as_dict()
        if self.rotor is None:
            MachineSIPMSM_dict["rotor"] = None
        else:
            MachineSIPMSM_dict["rotor"] = self.rotor.as_dict()
        if self.stator is None:
            MachineSIPMSM_dict["stator"] = None
        else:
            MachineSIPMSM_dict["stator"] = self.stator.as_dict()
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        MachineSIPMSM_dict["__class__"] = "MachineSIPMSM"
        return MachineSIPMSM_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        if self.rotor is not None:
            self.rotor._set_None()
        if self.stator is not None:
            self.stator._set_None()
        # Set to None the properties inherited from MachineSync
        super(MachineSIPMSM, self)._set_None()

    def _get_rotor(self):
        """getter of rotor"""
        return self._rotor

    def _set_rotor(self, value):
        """setter of rotor"""
        check_var("rotor", value, "LamSlotMag")
        self._rotor = value

        if self._rotor is not None:
            self._rotor.parent = self

    # Machine's Rotor
    # Type : LamSlotMag
    rotor = property(fget=_get_rotor, fset=_set_rotor, doc=u"""Machine's Rotor""")

    def _get_stator(self):
        """getter of stator"""
        return self._stator

    def _set_stator(self, value):
        """setter of stator"""
        check_var("stator", value, "LamSlotWind")
        self._stator = value

        if self._stator is not None:
            self._stator.parent = self

    # Machine's Stator
    # Type : LamSlotWind
    stator = property(fget=_get_stator, fset=_set_stator, doc=u"""Machine's Stator""")
Ejemplo n.º 24
0
class LamSquirrelCage(LamSlotWind):
    """squirrel cages lamination"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Machine.LamSquirrelCage.build_geometry
    if isinstance(build_geometry, ImportError):
        build_geometry = property(fget=lambda x: raise_(
            ImportError("Can't use LamSquirrelCage method build_geometry: " +
                        str(build_geometry))))
    else:
        build_geometry = build_geometry
    # cf Methods.Machine.LamSquirrelCage.check
    if isinstance(check, ImportError):
        check = property(fget=lambda x: raise_(
            ImportError("Can't use LamSquirrelCage method check: " + str(check)
                        )))
    else:
        check = check
    # cf Methods.Machine.LamSquirrelCage.comp_length_ring
    if isinstance(comp_length_ring, ImportError):
        comp_length_ring = property(fget=lambda x: raise_(
            ImportError("Can't use LamSquirrelCage method comp_length_ring: " +
                        str(comp_length_ring))))
    else:
        comp_length_ring = comp_length_ring
    # cf Methods.Machine.LamSquirrelCage.plot
    if isinstance(plot, ImportError):
        plot = property(fget=lambda x: raise_(
            ImportError("Can't use LamSquirrelCage method plot: " + str(plot)))
                        )
    else:
        plot = plot
    # save method is available in all object
    save = save

    def __init__(
            self,
            Hscr=0.03,
            Lscr=0.015,
            ring_mat=-1,
            Ksfill=None,
            winding=-1,
            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 ring_mat == -1:
            ring_mat = Material()
        if winding == -1:
            winding = Winding()
        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,
                [
                    "Hscr",
                    "Lscr",
                    "ring_mat",
                    "Ksfill",
                    "winding",
                    "slot",
                    "L1",
                    "mat_type",
                    "Nrvd",
                    "Wrvd",
                    "Kf1",
                    "is_internal",
                    "Rint",
                    "Rext",
                    "is_stator",
                    "axial_vent",
                    "notch",
                ],
            )
            # Overwrite default value with init_dict content
            if "Hscr" in list(init_dict.keys()):
                Hscr = init_dict["Hscr"]
            if "Lscr" in list(init_dict.keys()):
                Lscr = init_dict["Lscr"]
            if "ring_mat" in list(init_dict.keys()):
                ring_mat = init_dict["ring_mat"]
            if "Ksfill" in list(init_dict.keys()):
                Ksfill = init_dict["Ksfill"]
            if "winding" in list(init_dict.keys()):
                winding = init_dict["winding"]
            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
        self.Hscr = Hscr
        self.Lscr = Lscr
        # ring_mat can be None, a Material object or a dict
        if isinstance(ring_mat, dict):
            self.ring_mat = Material(init_dict=ring_mat)
        else:
            self.ring_mat = ring_mat
        # Call LamSlotWind init
        super(LamSquirrelCage, self).__init__(
            Ksfill=Ksfill,
            winding=winding,
            slot=slot,
            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,
        )
        # The class is frozen (in LamSlotWind init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        LamSquirrelCage_str = ""
        # Get the properties inherited from LamSlotWind
        LamSquirrelCage_str += super(LamSquirrelCage, self).__str__()
        LamSquirrelCage_str += "Hscr = " + str(self.Hscr) + linesep
        LamSquirrelCage_str += "Lscr = " + str(self.Lscr) + linesep
        if self.ring_mat is not None:
            tmp = self.ring_mat.__str__().replace(linesep,
                                                  linesep + "\t").rstrip("\t")
            LamSquirrelCage_str += "ring_mat = " + tmp
        else:
            LamSquirrelCage_str += "ring_mat = None" + linesep + linesep
        return LamSquirrelCage_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from LamSlotWind
        if not super(LamSquirrelCage, self).__eq__(other):
            return False
        if other.Hscr != self.Hscr:
            return False
        if other.Lscr != self.Lscr:
            return False
        if other.ring_mat != self.ring_mat:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from LamSlotWind
        LamSquirrelCage_dict = super(LamSquirrelCage, self).as_dict()
        LamSquirrelCage_dict["Hscr"] = self.Hscr
        LamSquirrelCage_dict["Lscr"] = self.Lscr
        if self.ring_mat is None:
            LamSquirrelCage_dict["ring_mat"] = None
        else:
            LamSquirrelCage_dict["ring_mat"] = self.ring_mat.as_dict()
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        LamSquirrelCage_dict["__class__"] = "LamSquirrelCage"
        return LamSquirrelCage_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.Hscr = None
        self.Lscr = None
        if self.ring_mat is not None:
            self.ring_mat._set_None()
        # Set to None the properties inherited from LamSlotWind
        super(LamSquirrelCage, self)._set_None()

    def _get_Hscr(self):
        """getter of Hscr"""
        return self._Hscr

    def _set_Hscr(self, value):
        """setter of Hscr"""
        check_var("Hscr", value, "float", Vmin=0)
        self._Hscr = value

    # short circuit ring section radial height [m]
    # Type : float, min = 0
    Hscr = property(
        fget=_get_Hscr,
        fset=_set_Hscr,
        doc=u"""short circuit ring section radial height [m]""",
    )

    def _get_Lscr(self):
        """getter of Lscr"""
        return self._Lscr

    def _set_Lscr(self, value):
        """setter of Lscr"""
        check_var("Lscr", value, "float", Vmin=0)
        self._Lscr = value

    # short circuit ring section axial length
    # Type : float, min = 0
    Lscr = property(
        fget=_get_Lscr,
        fset=_set_Lscr,
        doc=u"""short circuit ring section axial length""",
    )

    def _get_ring_mat(self):
        """getter of ring_mat"""
        return self._ring_mat

    def _set_ring_mat(self, value):
        """setter of ring_mat"""
        check_var("ring_mat", value, "Material")
        self._ring_mat = value

        if self._ring_mat is not None:
            self._ring_mat.parent = self

    # Material of the Rotor short circuit ring
    # Type : Material
    ring_mat = property(
        fget=_get_ring_mat,
        fset=_set_ring_mat,
        doc=u"""Material of the Rotor short circuit ring""",
    )
Ejemplo n.º 25
0
class Force(FrozenClass):
    """Forces module abstract object"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Simulation.Force.comp_force
    if isinstance(comp_force, ImportError):
        comp_force = property(fget=lambda x: raise_(
            ImportError("Can't use Force method comp_force: " + str(comp_force)
                        )))
    else:
        comp_force = comp_force
    # cf Methods.Simulation.Force.comp_force_nodal
    if isinstance(comp_force_nodal, ImportError):
        comp_force_nodal = property(fget=lambda x: raise_(
            ImportError("Can't use Force method comp_force_nodal: " + str(
                comp_force_nodal))))
    else:
        comp_force_nodal = comp_force_nodal
    # save method is available in all object
    save = save

    def __init__(self, is_comp_nodal_force=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, ["is_comp_nodal_force"])
            # Overwrite default value with init_dict content
            if "is_comp_nodal_force" in list(init_dict.keys()):
                is_comp_nodal_force = init_dict["is_comp_nodal_force"]
        # Initialisation by argument
        self.parent = None
        self.is_comp_nodal_force = is_comp_nodal_force

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

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        Force_str = ""
        if self.parent is None:
            Force_str += "parent = None " + linesep
        else:
            Force_str += "parent = " + str(type(
                self.parent)) + " object" + linesep
        Force_str += "is_comp_nodal_force = " + str(
            self.is_comp_nodal_force) + linesep
        return Force_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False
        if other.is_comp_nodal_force != self.is_comp_nodal_force:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        Force_dict = dict()
        Force_dict["is_comp_nodal_force"] = self.is_comp_nodal_force
        # The class name is added to the dict fordeserialisation purpose
        Force_dict["__class__"] = "Force"
        return Force_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.is_comp_nodal_force = None

    def _get_is_comp_nodal_force(self):
        """getter of is_comp_nodal_force"""
        return self._is_comp_nodal_force

    def _set_is_comp_nodal_force(self, value):
        """setter of is_comp_nodal_force"""
        check_var("is_comp_nodal_force", value, "bool")
        self._is_comp_nodal_force = value

    # 1 to compute lumped tooth forces
    # Type : bool
    is_comp_nodal_force = property(
        fget=_get_is_comp_nodal_force,
        fset=_set_is_comp_nodal_force,
        doc=u"""1 to compute lumped tooth forces""",
    )
Ejemplo n.º 26
0
class NodeMat(Node):
    """Class to define nodes coordinates and getter."""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Mesh.NodeMat.get_coord
    if isinstance(get_coord, ImportError):
        get_coord = property(fget=lambda x: raise_(
            ImportError("Can't use NodeMat method get_coord: " + str(get_coord)
                        )))
    else:
        get_coord = get_coord
    # cf Methods.Mesh.NodeMat.get_tag
    if isinstance(get_tag, ImportError):
        get_tag = property(fget=lambda x: raise_(
            ImportError("Can't use NodeMat method get_tag: " + str(get_tag))))
    else:
        get_tag = get_tag
    # cf Methods.Mesh.NodeMat.get_group
    if isinstance(get_group, ImportError):
        get_group = property(fget=lambda x: raise_(
            ImportError("Can't use NodeMat method get_group: " + str(get_group)
                        )))
    else:
        get_group = get_group
    # cf Methods.Mesh.NodeMat.add_node
    if isinstance(add_node, ImportError):
        add_node = property(fget=lambda x: raise_(
            ImportError("Can't use NodeMat method add_node: " + str(add_node)))
                            )
    else:
        add_node = add_node
    # cf Methods.Mesh.NodeMat.is_exist
    if isinstance(is_exist, ImportError):
        is_exist = property(fget=lambda x: raise_(
            ImportError("Can't use NodeMat method is_exist: " + str(is_exist)))
                            )
    else:
        is_exist = is_exist
    # save method is available in all object
    save = save

    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__()
        # The class is frozen (in Node init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        NodeMat_str = ""
        # Get the properties inherited from Node
        NodeMat_str += super(NodeMat, self).__str__()
        NodeMat_str += ("coordinate = " + linesep +
                        str(self.coordinate).replace(linesep, linesep + "\t") +
                        linesep + linesep)
        NodeMat_str += "nb_node = " + str(self.nb_node) + linesep
        NodeMat_str += ("tag = " + linesep +
                        str(self.tag).replace(linesep, linesep + "\t") +
                        linesep + linesep)
        NodeMat_str += "delta = " + str(self.delta) + linesep
        return NodeMat_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from Node
        if not super(NodeMat, self).__eq__(other):
            return False
        if not array_equal(other.coordinate, self.coordinate):
            return False
        if other.nb_node != self.nb_node:
            return False
        if not array_equal(other.tag, self.tag):
            return False
        if other.delta != self.delta:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from Node
        NodeMat_dict = super(NodeMat, self).as_dict()
        if self.coordinate is None:
            NodeMat_dict["coordinate"] = None
        else:
            NodeMat_dict["coordinate"] = self.coordinate.tolist()
        NodeMat_dict["nb_node"] = self.nb_node
        if self.tag is None:
            NodeMat_dict["tag"] = None
        else:
            NodeMat_dict["tag"] = self.tag.tolist()
        NodeMat_dict["delta"] = self.delta
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        NodeMat_dict["__class__"] = "NodeMat"
        return NodeMat_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.coordinate = None
        self.nb_node = None
        self.tag = None
        self.delta = None
        # Set to None the properties inherited from Node
        super(NodeMat, self)._set_None()

    def _get_coordinate(self):
        """getter of coordinate"""
        return self._coordinate

    def _set_coordinate(self, value):
        """setter of coordinate"""
        if type(value) is list:
            try:
                value = array(value)
            except:
                pass
        check_var("coordinate", value, "ndarray")
        self._coordinate = value

    # Nodes coordinates
    # Type : ndarray
    coordinate = property(fget=_get_coordinate,
                          fset=_set_coordinate,
                          doc=u"""Nodes coordinates""")

    def _get_nb_node(self):
        """getter of nb_node"""
        return self._nb_node

    def _set_nb_node(self, value):
        """setter of nb_node"""
        check_var("nb_node", value, "int")
        self._nb_node = value

    # Total number of nodes
    # Type : int
    nb_node = property(fget=_get_nb_node,
                       fset=_set_nb_node,
                       doc=u"""Total number of nodes""")

    def _get_tag(self):
        """getter of tag"""
        return self._tag

    def _set_tag(self, value):
        """setter of tag"""
        if type(value) is list:
            try:
                value = array(value)
            except:
                pass
        check_var("tag", value, "ndarray")
        self._tag = value

    # Node tags
    # Type : ndarray
    tag = property(fget=_get_tag, fset=_set_tag, doc=u"""Node tags""")

    def _get_delta(self):
        """getter of delta"""
        return self._delta

    def _set_delta(self, value):
        """setter of delta"""
        check_var("delta", value, "float")
        self._delta = value

    # Sensibility for node searching
    # Type : float
    delta = property(fget=_get_delta,
                     fset=_set_delta,
                     doc=u"""Sensibility for node searching""")
Ejemplo n.º 27
0
class MagnetType11(MagnetPolar):
    """single magnet with polar shape"""

    VERSION = 1
    IS_FLAT_BOT = 0
    IS_FLAT_TOP = 0

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Machine.MagnetType11._comp_point_coordinate
    if isinstance(_comp_point_coordinate, ImportError):
        _comp_point_coordinate = property(fget=lambda x: raise_(
            ImportError(
                "Can't use MagnetType11 method _comp_point_coordinate: " + str(
                    _comp_point_coordinate))))
    else:
        _comp_point_coordinate = _comp_point_coordinate
    # cf Methods.Machine.MagnetType11.build_geometry
    if isinstance(build_geometry, ImportError):
        build_geometry = property(fget=lambda x: raise_(
            ImportError("Can't use MagnetType11 method build_geometry: " + str(
                build_geometry))))
    else:
        build_geometry = build_geometry
    # cf Methods.Machine.MagnetType11.comp_height
    if isinstance(comp_height, ImportError):
        comp_height = property(fget=lambda x: raise_(
            ImportError("Can't use MagnetType11 method comp_height: " + str(
                comp_height))))
    else:
        comp_height = comp_height
    # cf Methods.Machine.MagnetType11.comp_surface
    if isinstance(comp_surface, ImportError):
        comp_surface = property(fget=lambda x: raise_(
            ImportError("Can't use MagnetType11 method comp_surface: " + str(
                comp_surface))))
    else:
        comp_surface = comp_surface
    # save method is available in all object
    save = save

    def __init__(
        self,
        Wmag=0.002,
        Hmag=0.001,
        mat_type=-1,
        type_magnetization=0,
        Lmag=0.95,
        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,
                ["Wmag", "Hmag", "mat_type", "type_magnetization", "Lmag"])
            # Overwrite default value with init_dict content
            if "Wmag" in list(init_dict.keys()):
                Wmag = init_dict["Wmag"]
            if "Hmag" in list(init_dict.keys()):
                Hmag = init_dict["Hmag"]
            if "mat_type" in list(init_dict.keys()):
                mat_type = init_dict["mat_type"]
            if "type_magnetization" in list(init_dict.keys()):
                type_magnetization = init_dict["type_magnetization"]
            if "Lmag" in list(init_dict.keys()):
                Lmag = init_dict["Lmag"]
        # Initialisation by argument
        self.Wmag = Wmag
        self.Hmag = Hmag
        # Call MagnetPolar init
        super(MagnetType11,
              self).__init__(mat_type=mat_type,
                             type_magnetization=type_magnetization,
                             Lmag=Lmag)
        # The class is frozen (in MagnetPolar init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        MagnetType11_str = ""
        # Get the properties inherited from MagnetPolar
        MagnetType11_str += super(MagnetType11, self).__str__()
        MagnetType11_str += "Wmag = " + str(self.Wmag) + linesep
        MagnetType11_str += "Hmag = " + str(self.Hmag) + linesep
        return MagnetType11_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from MagnetPolar
        if not super(MagnetType11, self).__eq__(other):
            return False
        if other.Wmag != self.Wmag:
            return False
        if other.Hmag != self.Hmag:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from MagnetPolar
        MagnetType11_dict = super(MagnetType11, self).as_dict()
        MagnetType11_dict["Wmag"] = self.Wmag
        MagnetType11_dict["Hmag"] = self.Hmag
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        MagnetType11_dict["__class__"] = "MagnetType11"
        return MagnetType11_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.Wmag = None
        self.Hmag = None
        # Set to None the properties inherited from MagnetPolar
        super(MagnetType11, self)._set_None()

    def _get_Wmag(self):
        """getter of Wmag"""
        return self._Wmag

    def _set_Wmag(self, value):
        """setter of Wmag"""
        check_var("Wmag", value, "float", Vmin=0)
        self._Wmag = value

    # magnet bottom width [rad]
    # Type : float, min = 0
    Wmag = property(fget=_get_Wmag,
                    fset=_set_Wmag,
                    doc=u"""magnet bottom width [rad]""")

    def _get_Hmag(self):
        """getter of Hmag"""
        return self._Hmag

    def _set_Hmag(self, value):
        """setter of Hmag"""
        check_var("Hmag", value, "float", Vmin=0)
        self._Hmag = value

    # magnet radial height [m]
    # Type : float, min = 0
    Hmag = property(fget=_get_Hmag,
                    fset=_set_Hmag,
                    doc=u"""magnet radial height [m]""")
Ejemplo n.º 28
0
class SlotW60(SlotWind):

    VERSION = 1
    IS_SYMMETRICAL = 0

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Slot.SlotW60._comp_point_coordinate
    if isinstance(_comp_point_coordinate, ImportError):
        _comp_point_coordinate = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW60 method _comp_point_coordinate: " +
                        str(_comp_point_coordinate))))
    else:
        _comp_point_coordinate = _comp_point_coordinate
    # cf Methods.Slot.SlotW60.build_geometry
    if isinstance(build_geometry, ImportError):
        build_geometry = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW60 method build_geometry: " + str(
                build_geometry))))
    else:
        build_geometry = build_geometry
    # cf Methods.Slot.SlotW60.build_geometry_wind
    if isinstance(build_geometry_wind, ImportError):
        build_geometry_wind = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW60 method build_geometry_wind: " + str(
                build_geometry_wind))))
    else:
        build_geometry_wind = build_geometry_wind
    # cf Methods.Slot.SlotW60.check
    if isinstance(check, ImportError):
        check = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW60 method check: " + str(check))))
    else:
        check = check
    # cf Methods.Slot.SlotW60.comp_angle_opening
    if isinstance(comp_angle_opening, ImportError):
        comp_angle_opening = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW60 method comp_angle_opening: " + str(
                comp_angle_opening))))
    else:
        comp_angle_opening = comp_angle_opening
    # cf Methods.Slot.SlotW60.comp_height
    if isinstance(comp_height, ImportError):
        comp_height = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW60 method comp_height: " + str(
                comp_height))))
    else:
        comp_height = comp_height
    # cf Methods.Slot.SlotW60.comp_height_wind
    if isinstance(comp_height_wind, ImportError):
        comp_height_wind = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW60 method comp_height_wind: " + str(
                comp_height_wind))))
    else:
        comp_height_wind = comp_height_wind
    # cf Methods.Slot.SlotW60.comp_surface
    if isinstance(comp_surface, ImportError):
        comp_surface = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW60 method comp_surface: " + str(
                comp_surface))))
    else:
        comp_surface = comp_surface
    # cf Methods.Slot.SlotW60.comp_surface_wind
    if isinstance(comp_surface_wind, ImportError):
        comp_surface_wind = property(fget=lambda x: raise_(
            ImportError("Can't use SlotW60 method comp_surface_wind: " + str(
                comp_surface_wind))))
    else:
        comp_surface_wind = comp_surface_wind
    # save method is available in all object
    save = save

    def __init__(
        self,
        W1=0.02,
        W2=0.03,
        H1=0.05,
        H2=0.15,
        R1=0.03,
        H3=0,
        H4=0,
        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,
                ["W1", "W2", "H1", "H2", "R1", "H3", "H4", "W3", "Zs"])
            # Overwrite default value with init_dict content
            if "W1" in list(init_dict.keys()):
                W1 = init_dict["W1"]
            if "W2" in list(init_dict.keys()):
                W2 = init_dict["W2"]
            if "H1" in list(init_dict.keys()):
                H1 = init_dict["H1"]
            if "H2" in list(init_dict.keys()):
                H2 = init_dict["H2"]
            if "R1" in list(init_dict.keys()):
                R1 = init_dict["R1"]
            if "H3" in list(init_dict.keys()):
                H3 = init_dict["H3"]
            if "H4" in list(init_dict.keys()):
                H4 = init_dict["H4"]
            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.W1 = W1
        self.W2 = W2
        self.H1 = H1
        self.H2 = H2
        self.R1 = R1
        self.H3 = H3
        self.H4 = H4
        self.W3 = W3
        # Call SlotWind init
        super(SlotW60, self).__init__(Zs=Zs)
        # The class is frozen (in SlotWind init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        SlotW60_str = ""
        # Get the properties inherited from SlotWind
        SlotW60_str += super(SlotW60, self).__str__()
        SlotW60_str += "W1 = " + str(self.W1) + linesep
        SlotW60_str += "W2 = " + str(self.W2) + linesep
        SlotW60_str += "H1 = " + str(self.H1) + linesep
        SlotW60_str += "H2 = " + str(self.H2) + linesep
        SlotW60_str += "R1 = " + str(self.R1) + linesep
        SlotW60_str += "H3 = " + str(self.H3) + linesep
        SlotW60_str += "H4 = " + str(self.H4) + linesep
        SlotW60_str += "W3 = " + str(self.W3) + linesep
        return SlotW60_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from SlotWind
        if not super(SlotW60, self).__eq__(other):
            return False
        if other.W1 != self.W1:
            return False
        if other.W2 != self.W2:
            return False
        if other.H1 != self.H1:
            return False
        if other.H2 != self.H2:
            return False
        if other.R1 != self.R1:
            return False
        if other.H3 != self.H3:
            return False
        if other.H4 != self.H4:
            return False
        if other.W3 != self.W3:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from SlotWind
        SlotW60_dict = super(SlotW60, self).as_dict()
        SlotW60_dict["W1"] = self.W1
        SlotW60_dict["W2"] = self.W2
        SlotW60_dict["H1"] = self.H1
        SlotW60_dict["H2"] = self.H2
        SlotW60_dict["R1"] = self.R1
        SlotW60_dict["H3"] = self.H3
        SlotW60_dict["H4"] = self.H4
        SlotW60_dict["W3"] = self.W3
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        SlotW60_dict["__class__"] = "SlotW60"
        return SlotW60_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.W1 = None
        self.W2 = None
        self.H1 = None
        self.H2 = None
        self.R1 = None
        self.H3 = None
        self.H4 = None
        self.W3 = None
        # Set to None the properties inherited from SlotWind
        super(SlotW60, self)._set_None()

    def _get_W1(self):
        """getter of W1"""
        return self._W1

    def _set_W1(self, value):
        """setter of W1"""
        check_var("W1", value, "float", Vmin=0)
        self._W1 = value

    # Pole top width
    # Type : float, min = 0
    W1 = property(fget=_get_W1, fset=_set_W1, doc=u"""Pole top width""")

    def _get_W2(self):
        """getter of W2"""
        return self._W2

    def _set_W2(self, value):
        """setter of W2"""
        check_var("W2", value, "float", Vmin=0)
        self._W2 = value

    # Pole bottom width
    # Type : float, min = 0
    W2 = property(fget=_get_W2, fset=_set_W2, doc=u"""Pole bottom width""")

    def _get_H1(self):
        """getter of H1"""
        return self._H1

    def _set_H1(self, value):
        """setter of H1"""
        check_var("H1", value, "float", Vmin=0)
        self._H1 = value

    # Pole top height
    # Type : float, min = 0
    H1 = property(fget=_get_H1, fset=_set_H1, doc=u"""Pole top height""")

    def _get_H2(self):
        """getter of H2"""
        return self._H2

    def _set_H2(self, value):
        """setter of H2"""
        check_var("H2", value, "float", Vmin=0)
        self._H2 = value

    # Pole bottom height
    # Type : float, min = 0
    H2 = property(fget=_get_H2, fset=_set_H2, doc=u"""Pole bottom height""")

    def _get_R1(self):
        """getter of R1"""
        return self._R1

    def _set_R1(self, value):
        """setter of R1"""
        check_var("R1", value, "float", Vmin=0)
        self._R1 = value

    # Pole top radius
    # Type : float, min = 0
    R1 = property(fget=_get_R1, fset=_set_R1, doc=u"""Pole top radius""")

    def _get_H3(self):
        """getter of H3"""
        return self._H3

    def _set_H3(self, value):
        """setter of H3"""
        check_var("H3", value, "float", Vmin=0)
        self._H3 = value

    # Top Distance Ploe-coil
    # Type : float, min = 0
    H3 = property(fget=_get_H3,
                  fset=_set_H3,
                  doc=u"""Top Distance Ploe-coil """)

    def _get_H4(self):
        """getter of H4"""
        return self._H4

    def _set_H4(self, value):
        """setter of H4"""
        check_var("H4", value, "float", Vmin=0)
        self._H4 = value

    # Bottom Distance Ploe-coil
    # Type : float, min = 0
    H4 = property(fget=_get_H4,
                  fset=_set_H4,
                  doc=u"""Bottom Distance Ploe-coil """)

    def _get_W3(self):
        """getter of W3"""
        return self._W3

    def _set_W3(self, value):
        """setter of W3"""
        check_var("W3", value, "float", Vmin=0)
        self._W3 = value

    # Edge Distance Ploe-coil
    # Type : float, min = 0
    W3 = property(fget=_get_W3,
                  fset=_set_W3,
                  doc=u"""Edge Distance Ploe-coil """)
Ejemplo n.º 29
0
class Slot19(Slot):
    """trapezoidal slot with rounded bottom"""

    VERSION = 1
    IS_SYMMETRICAL = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Slot.Slot19._comp_point_coordinate
    if isinstance(_comp_point_coordinate, ImportError):
        _comp_point_coordinate = property(fget=lambda x: raise_(
            ImportError("Can't use Slot19 method _comp_point_coordinate: " +
                        str(_comp_point_coordinate))))
    else:
        _comp_point_coordinate = _comp_point_coordinate
    # cf Methods.Slot.Slot19.build_geometry
    if isinstance(build_geometry, ImportError):
        build_geometry = property(fget=lambda x: raise_(
            ImportError("Can't use Slot19 method build_geometry: " + str(
                build_geometry))))
    else:
        build_geometry = build_geometry
    # cf Methods.Slot.Slot19.check
    if isinstance(check, ImportError):
        check = property(fget=lambda x: raise_(
            ImportError("Can't use Slot19 method check: " + str(check))))
    else:
        check = check
    # cf Methods.Slot.Slot19.comp_angle_opening
    if isinstance(comp_angle_opening, ImportError):
        comp_angle_opening = property(fget=lambda x: raise_(
            ImportError("Can't use Slot19 method comp_angle_opening: " + str(
                comp_angle_opening))))
    else:
        comp_angle_opening = comp_angle_opening
    # cf Methods.Slot.Slot19.comp_angle_bottom
    if isinstance(comp_angle_bottom, ImportError):
        comp_angle_bottom = property(fget=lambda x: raise_(
            ImportError("Can't use Slot19 method comp_angle_bottom: " + str(
                comp_angle_bottom))))
    else:
        comp_angle_bottom = comp_angle_bottom
    # cf Methods.Slot.Slot19.comp_height
    if isinstance(comp_height, ImportError):
        comp_height = property(fget=lambda x: raise_(
            ImportError("Can't use Slot19 method comp_height: " + str(
                comp_height))))
    else:
        comp_height = comp_height
    # cf Methods.Slot.Slot19.comp_surface
    if isinstance(comp_surface, ImportError):
        comp_surface = property(fget=lambda x: raise_(
            ImportError("Can't use Slot19 method comp_surface: " + str(
                comp_surface))))
    else:
        comp_surface = comp_surface
    # save method is available in all object
    save = save

    def __init__(self,
                 W0=0.013,
                 H0=0.02,
                 W1=0.01,
                 Wx_is_rad=False,
                 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", "W1", "Wx_is_rad", "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 "W1" in list(init_dict.keys()):
                W1 = init_dict["W1"]
            if "Wx_is_rad" in list(init_dict.keys()):
                Wx_is_rad = init_dict["Wx_is_rad"]
            if "Zs" in list(init_dict.keys()):
                Zs = init_dict["Zs"]
        # Initialisation by argument
        self.W0 = W0
        self.H0 = H0
        self.W1 = W1
        self.Wx_is_rad = Wx_is_rad
        # Call Slot init
        super(Slot19, self).__init__(Zs=Zs)
        # The class is frozen (in Slot init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        Slot19_str = ""
        # Get the properties inherited from Slot
        Slot19_str += super(Slot19, self).__str__()
        Slot19_str += "W0 = " + str(self.W0) + linesep
        Slot19_str += "H0 = " + str(self.H0) + linesep
        Slot19_str += "W1 = " + str(self.W1) + linesep
        Slot19_str += "Wx_is_rad = " + str(self.Wx_is_rad) + linesep
        return Slot19_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from Slot
        if not super(Slot19, self).__eq__(other):
            return False
        if other.W0 != self.W0:
            return False
        if other.H0 != self.H0:
            return False
        if other.W1 != self.W1:
            return False
        if other.Wx_is_rad != self.Wx_is_rad:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from Slot
        Slot19_dict = super(Slot19, self).as_dict()
        Slot19_dict["W0"] = self.W0
        Slot19_dict["H0"] = self.H0
        Slot19_dict["W1"] = self.W1
        Slot19_dict["Wx_is_rad"] = self.Wx_is_rad
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        Slot19_dict["__class__"] = "Slot19"
        return Slot19_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.W0 = None
        self.H0 = None
        self.W1 = None
        self.Wx_is_rad = None
        # Set to None the properties inherited from Slot
        super(Slot19, self)._set_None()

    def _get_W0(self):
        """getter of W0"""
        return self._W0

    def _set_W0(self, value):
        """setter of W0"""
        check_var("W0", value, "float", Vmin=0)
        self._W0 = value

    # Slot top width
    # Type : float, min = 0
    W0 = property(fget=_get_W0, fset=_set_W0, doc=u"""Slot top width""")

    def _get_H0(self):
        """getter of H0"""
        return self._H0

    def _set_H0(self, value):
        """setter of H0"""
        check_var("H0", value, "float", Vmin=0)
        self._H0 = value

    # Slot height
    # Type : float, min = 0
    H0 = property(fget=_get_H0, fset=_set_H0, doc=u"""Slot height""")

    def _get_W1(self):
        """getter of W1"""
        return self._W1

    def _set_W1(self, value):
        """setter of W1"""
        check_var("W1", value, "float", Vmin=0)
        self._W1 = value

    # Slot bottom width.
    # Type : float, min = 0
    W1 = property(fget=_get_W1, fset=_set_W1, doc=u"""Slot bottom width.""")

    def _get_Wx_is_rad(self):
        """getter of Wx_is_rad"""
        return self._Wx_is_rad

    def _set_Wx_is_rad(self, value):
        """setter of Wx_is_rad"""
        check_var("Wx_is_rad", value, "bool")
        self._Wx_is_rad = value

    # Wx unit, 0 for m, 1 for rad
    # Type : bool
    Wx_is_rad = property(fget=_get_Wx_is_rad,
                         fset=_set_Wx_is_rad,
                         doc=u"""Wx unit, 0 for m, 1 for rad""")
Ejemplo n.º 30
0
class SlotMPolar(SlotMag):
    """Polar bottomed SlotMag"""

    VERSION = 1
    IS_SYMMETRICAL = 1
    IS_INSET = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Slot.SlotMPolar.build_geometry
    if isinstance(build_geometry, ImportError):
        build_geometry = property(fget=lambda x: raise_(
            ImportError("Can't use SlotMPolar method build_geometry: " + str(
                build_geometry))))
    else:
        build_geometry = build_geometry
    # cf Methods.Slot.SlotMPolar.comp_angle_opening
    if isinstance(comp_angle_opening, ImportError):
        comp_angle_opening = property(fget=lambda x: raise_(
            ImportError("Can't use SlotMPolar method comp_angle_opening: " +
                        str(comp_angle_opening))))
    else:
        comp_angle_opening = comp_angle_opening
    # cf Methods.Slot.SlotMPolar.comp_angle_opening_magnet
    if isinstance(comp_angle_opening_magnet, ImportError):
        comp_angle_opening_magnet = property(fget=lambda x: raise_(
            ImportError(
                "Can't use SlotMPolar method comp_angle_opening_magnet: " +
                str(comp_angle_opening_magnet))))
    else:
        comp_angle_opening_magnet = comp_angle_opening_magnet
    # cf Methods.Slot.SlotMPolar.comp_height
    if isinstance(comp_height, ImportError):
        comp_height = property(fget=lambda x: raise_(
            ImportError("Can't use SlotMPolar method comp_height: " + str(
                comp_height))))
    else:
        comp_height = comp_height
    # cf Methods.Slot.SlotMPolar.comp_surface
    if isinstance(comp_surface, ImportError):
        comp_surface = property(fget=lambda x: raise_(
            ImportError("Can't use SlotMPolar method comp_surface: " + str(
                comp_surface))))
    else:
        comp_surface = comp_surface
    # cf Methods.Slot.SlotMPolar.get_point_bottom
    if isinstance(get_point_bottom, ImportError):
        get_point_bottom = property(fget=lambda x: raise_(
            ImportError("Can't use SlotMPolar method get_point_bottom: " + str(
                get_point_bottom))))
    else:
        get_point_bottom = get_point_bottom
    # save method is available in all object
    save = save

    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)
        # The class is frozen (in SlotMag init), for now it's impossible to
        # add new properties

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        SlotMPolar_str = ""
        # Get the properties inherited from SlotMag
        SlotMPolar_str += super(SlotMPolar, self).__str__()
        SlotMPolar_str += "W0 = " + str(self.W0) + linesep
        SlotMPolar_str += "H0 = " + str(self.H0) + linesep
        if len(self.magnet) == 0:
            SlotMPolar_str += "magnet = []" + linesep
        for ii in range(len(self.magnet)):
            tmp = self.magnet[ii].__str__().replace(linesep,
                                                    linesep + "\t") + linesep
            SlotMPolar_str += "magnet[" + str(
                ii) + "] =" + tmp + linesep + linesep
        return SlotMPolar_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False

        # Check the properties inherited from SlotMag
        if not super(SlotMPolar, self).__eq__(other):
            return False
        if other.W0 != self.W0:
            return False
        if other.H0 != self.H0:
            return False
        if other.magnet != self.magnet:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        # Get the properties inherited from SlotMag
        SlotMPolar_dict = super(SlotMPolar, self).as_dict()
        SlotMPolar_dict["W0"] = self.W0
        SlotMPolar_dict["H0"] = self.H0
        SlotMPolar_dict["magnet"] = list()
        for obj in self.magnet:
            SlotMPolar_dict["magnet"].append(obj.as_dict())
        # The class name is added to the dict fordeserialisation purpose
        # Overwrite the mother class name
        SlotMPolar_dict["__class__"] = "SlotMPolar"
        return SlotMPolar_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        self.W0 = None
        self.H0 = None
        for obj in self.magnet:
            obj._set_None()
        # Set to None the properties inherited from SlotMag
        super(SlotMPolar, self)._set_None()

    def _get_W0(self):
        """getter of W0"""
        return self._W0

    def _set_W0(self, value):
        """setter of W0"""
        check_var("W0", value, "float", Vmin=0)
        self._W0 = value

    # Slot isthmus width.
    # Type : float, min = 0
    W0 = property(fget=_get_W0, fset=_set_W0, doc=u"""Slot isthmus width.""")

    def _get_H0(self):
        """getter of H0"""
        return self._H0

    def _set_H0(self, value):
        """setter of H0"""
        check_var("H0", value, "float", Vmin=0)
        self._H0 = value

    # Slot isthmus height
    # Type : float, min = 0
    H0 = property(fget=_get_H0, fset=_set_H0, doc=u"""Slot isthmus height""")

    def _get_magnet(self):
        """getter of magnet"""
        for obj in self._magnet:
            if obj is not None:
                obj.parent = self
        return self._magnet

    def _set_magnet(self, value):
        """setter of magnet"""
        check_var("magnet", value, "[MagnetPolar]")
        self._magnet = value

        for obj in self._magnet:
            if obj is not None:
                obj.parent = self

    # List of magnet
    # Type : [MagnetPolar]
    magnet = property(fget=_get_magnet,
                      fset=_set_magnet,
                      doc=u"""List of magnet""")