Пример #1
0
    def test_Magnetic_FEMM(self):
        """Test compute the Flux in FEMM and import the mesh.
        """

        out = Output(simu=simu)
        out.post.legend_name = "Slotless lamination"
        simu.run()

        out.plot_mesh(mesh=out.mag.meshsolution.mesh[0], title="FEA Mesh")

        # out.plot_mesh_field(meshsolution=out.mag.meshsolution, title="Permeability")
        out.plot_mesh_field(
            mesh=out.mag.meshsolution.mesh[0],
            title="Permeability",
            field=out.mag.meshsolution.solution[0].face["mu"],
        )
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_CEFC_002_save_mag"))

        # Test save with MeshSolution object in out
        out.save(save_path=save_path)

        load_path = join(save_path, "Output.json")
        # Test to load the Meshsolution object (inside the output):
        with open(load_path) as json_file:
            json_tmp = json.load(json_file)
            FEMM = Output(init_dict=json_tmp)

        # To test that the "mu" is still a ndarray after saving and loading
        out.plot_mesh_field(
            mesh=FEMM.mag.meshsolution.mesh[0],
            title="Permeability",
            field=FEMM.mag.meshsolution.solution[0].face["mu"],
        )
Пример #2
0
    def test_ecc_FEMM(self):
        """Figure 19: transfrom_list in FEMM for eccentricities
        """
        simu = Simu1(name="ICEM_2020", machine=SPMSM_015)
        simu.machine.name = "fig_19_Transform_list"

        # Modify stator Rext to get more convincing translation
        SPMSM_015.stator.Rext = SPMSM_015.stator.Rext * 0.9
        gap = SPMSM_015.comp_width_airgap_mec()

        # Definition of the enforced output of the electrical module
        Nr = ImportMatrixVal(value=ones(1) * 3000)
        Is = ImportMatrixVal(value=array([[0, 0, 0]]))
        time = ImportGenVectLin(start=0, stop=0, num=1, endpoint=True)
        angle = ImportGenVectLin(start=0,
                                 stop=2 * 2 * pi / 9,
                                 num=2043,
                                 endpoint=False)
        simu.input = InCurrent(
            Is=Is,
            Ir=None,  # No winding on the rotor
            Nr=Nr,
            angle_rotor=None,
            time=time,
            angle=angle,
            angle_rotor_initial=0,
        )

        # Definition of the magnetic simulation (is_mmfr=False => no flux from the magnets)
        simu.mag = MagFEMM(
            is_stator_linear_BH=0,
            is_rotor_linear_BH=0,
            is_sliding_band=False,  # Ecc => No sliding band
            is_symmetry_a=False,  # No sym
            is_mmfs=False,
            is_get_mesh=True,
            is_save_FEA=True,
            sym_a=1,
        )
        simu.struct = None

        # Set two transformations
        # First rotate 3rd Magnet
        transform_list = [{
            "type": "rotate",
            "value": 0.08,
            "label": "MagnetRotorRadial_S_R0_T0_S3"
        }]
        # Then Translate the rotor
        transform_list.append({
            "type": "translate",
            "value": gap * 0.75,
            "label": "Rotor"
        })
        simu.mag.transform_list = transform_list

        # Run the simulation
        out = Output(simu=simu)
        simu.run()

        # FEMM files (mesh and results) are available in Results folder
        copyfile(
            join(out.path_res, "Femm", "fig_19_Transform_list_model.ans"),
            join(save_path, "fig_19_Transform_list_model.ans"),
        )
        copyfile(
            join(out.path_res, "Femm", "fig_19_Transform_list_model.fem"),
            join(save_path, "fig_19_Transform_list_model.fem"),
        )
        # Plot, check, save
        out.plot_mesh(mesh=out.mag.meshsolution.mesh[0], title="FEMM Mesh")
        fig = plt.gcf()
        fig.savefig(join(save_path, "fig_19_transform_list.png"))
        fig.savefig(join(save_path, "fig_19_transform_list.svg"), format="svg")