예제 #1
0
class unittest_plot_mesh_field(TestCase):
    """unittest to get elements containing specific node(s)"""
    def setUp(self):

        self.simu = Simulation()
        self.out = Output(simu=self.simu)
        self.mesh = Mesh()
        self.mesh.element["Triangle3"] = ElementMat(nb_node_per_element=3)
        self.mesh.node = NodeMat()
        self.mesh.node.add_node(np.array([0, 0]))
        self.mesh.node.add_node(np.array([1, 0]))
        self.mesh.node.add_node(np.array([0, 1]))
        self.mesh.node.add_node(np.array([1, 1]))
        self.mesh.node.add_node(np.array([2, 0]))

        self.mesh.add_element(np.array([0, 1, 2]), "Triangle3", group=int(3))
        self.mesh.add_element(np.array([1, 2, 3]), "Triangle3", group=int(3))
        self.mesh.add_element(np.array([4, 1, 3]), "Triangle3", group=int(2))

    def test_Mesh_ElementMat_NodeMat_3Tgl(self):

        field = np.array([1, 2, 3])
        self.out.plot_mesh_field(mesh=self.mesh,
                                 title="Permeability",
                                 field=field)
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_plot_mesh_field.png"))
예제 #2
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"],
        )
예제 #3
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_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].mu,
        )
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_CEFC_002_save_mag"))
예제 #4
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_field(
            mesh=out.mag.meshsolution[0].mesh,
            field=out.mag.meshsolution[0].solution.get_field("mu"),
            title="Permeability",
        )

        element_dict = ElementDict()
        element_dict.convert_element(
            out.mag.meshsolution[0].mesh.element)  # It works !