.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\03-Maxwell\RMxprt.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_03-Maxwell_RMxprt.py: Rmxprt: Create and export motor ------------------------------- This example uses PyAEDT to create an Rmxprt project and export to Maxwell 2D Keywords: Rmxprt, Maxwell2D .. GENERATED FROM PYTHON SOURCE LINES 7-13 .. code-block:: Python import os.path import tempfile import ansys.aedt.core .. GENERATED FROM PYTHON SOURCE LINES 14-17 Set AEDT version ~~~~~~~~~~~~~~~~ Set AEDT version. .. GENERATED FROM PYTHON SOURCE LINES 17-21 .. code-block:: Python aedt_version = "2024.2" temp_dir = tempfile.TemporaryDirectory(suffix=".ansys") .. GENERATED FROM PYTHON SOURCE LINES 22-26 Launch AEDT and Rmxprt ~~~~~~~~~~~~~~~~~~~~~~ Launch AEDT and Rmxprt after first setting up the project name. As solution type we will use ASSM (Adjust-Speed Syncronous Machine). .. GENERATED FROM PYTHON SOURCE LINES 26-36 .. code-block:: Python app = ansys.aedt.core.Rmxprt( version=aedt_version, new_desktop=True, close_on_exit=True, solution_type="ASSM", project=os.path.join(temp_dir.name, "ASSM.aedt"), ) .. rst-class:: sphx-glr-script-out .. code-block:: none C:\actions-runner\_work\_tool\Python\3.10.9\x64\lib\subprocess.py:1072: ResourceWarning: subprocess 7600 is still running _warn("subprocess %s is still running" % self.pid, C:\actions-runner\_work\pyaedt\pyaedt\.venv\lib\site-packages\ansys\aedt\core\generic\settings.py:231: ResourceWarning: unclosed file <_io.TextIOWrapper name='D:\\Temp\\pyaedt_ansys_81252a54-e251-4230-b99f-ef1acafc5894.log' mode='a' encoding='cp1252'> self.__logger = val .. GENERATED FROM PYTHON SOURCE LINES 37-40 Define Machine settings ~~~~~~~~~~~~~~~~~~~~~~~ Define global machine settings. .. GENERATED FROM PYTHON SOURCE LINES 40-50 .. code-block:: Python app.general["Number of Poles"] = 4 app.general["Rotor Position"] = "Inner Rotor" app.general["Frictional Loss"] = "12W" app.general["Windage Loss"] = "0W" app.general["Reference Speed"] = "1500rpm" app.general["Control Type"] = "DC" app.general["Circuit Type"] = "Y3" .. GENERATED FROM PYTHON SOURCE LINES 51-54 Define circuit settings ~~~~~~~~~~~~~~~~~~~~~~~ Define circuit settings. .. GENERATED FROM PYTHON SOURCE LINES 54-60 .. code-block:: Python app.circuit["Trigger Pulse Width"] = "120deg" app.circuit["Transistor Drop"] = "2V" app.circuit["Diode Drop"] = "2V" .. GENERATED FROM PYTHON SOURCE LINES 61-64 Stator ~~~~~~ Define stator, slot and windings settings. .. GENERATED FROM PYTHON SOURCE LINES 64-87 .. code-block:: Python app.stator["Outer Diameter"] = "122mm" app.stator["Inner Diameter"] = "75mm" app.stator["Length"] = "65mm" app.stator["Stacking Factor"] = 0.95 app.stator["Steel Type"] = "steel_1008" app.stator["Number of Slots"] = 24 app.stator["Slot Type"] = 2 app.stator.properties.children["Slot"].props["Auto Design"] = False app.stator.properties.children["Slot"].props["Hs0"] = "0.5mm" app.stator.properties.children["Slot"].props["Hs1"] = "1.2mm" app.stator.properties.children["Slot"].props["Hs2"] = "8.2mm" app.stator.properties.children["Slot"].props["Bs0"] = "2.5mm" app.stator.properties.children["Slot"].props["Bs1"] = "5.6mm" app.stator.properties.children["Slot"].props["Bs2"] = "7.6mm" app.stator.properties.children["Winding"].props["Winding Layers"] = 2 app.stator.properties.children["Winding"].props["Parallel Branches"] = 1 app.stator.properties.children["Winding"].props["Conductors per Slot"] = 52 app.stator.properties.children["Winding"].props["Coil Pitch"] = 5 app.stator.properties.children["Winding"].props["Number of Strands"] = 1 .. GENERATED FROM PYTHON SOURCE LINES 88-91 Rotor ~~~~~ Define rotor and pole settings. .. GENERATED FROM PYTHON SOURCE LINES 91-104 .. code-block:: Python app.rotor["Outer Diameter"] = "74mm" app.rotor["Inner Diameter"] = "26mm" app.rotor["Length"] = "65mm" app.rotor["Stacking Factor"] = 0.95 app.rotor["Steel Type"] = "steel_1008" app.rotor["Pole Type"] = 1 app.rotor.properties.children["Pole"].props["Embrace"] = 0.7 app.rotor.properties.children["Pole"].props["Offset"] = 0 app.rotor.properties.children["Pole"].props["Magnet Type"] = ["Material:=", "Alnico9"] app.rotor.properties.children["Pole"].props["Magnet Thickness"] = "3.5mm" .. GENERATED FROM PYTHON SOURCE LINES 105-108 Setup ~~~~~ Create a setup and define main settings. .. GENERATED FROM PYTHON SOURCE LINES 108-118 .. code-block:: Python setup = app.create_setup() setup.props["RatedVoltage"] = "220V" setup.props["RatedOutputPower"] = "550W" setup.props["RatedSpeed"] = "1500rpm" setup.props["OperatingTemperature"] = "75cel" setup.analyze() .. GENERATED FROM PYTHON SOURCE LINES 119-122 Export to Maxwell ~~~~~~~~~~~~~~~~~ After the project is solved we can export in Maxwell 2D or Maxwell 3D. .. GENERATED FROM PYTHON SOURCE LINES 122-128 .. code-block:: Python m2d = app.create_maxwell_design(setup_name=setup.name, maxwell_2d=True) m2d.plot(show=False, output_file=os.path.join(temp_dir.name, "Image.jpg"), plot_air_objects=True) .. image-sg:: /examples/03-Maxwell/images/sphx_glr_RMxprt_001.png :alt: RMxprt :srcset: /examples/03-Maxwell/images/sphx_glr_RMxprt_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 129-133 Rmxprt settings export ~~~~~~~~~~~~~~~~~~~~~~ All Rmxprt settings can be exported in a json file and reused for another project with import function. .. GENERATED FROM PYTHON SOURCE LINES 133-140 .. code-block:: Python config = app.export_configuration(os.path.join(temp_dir.name, "assm.json")) app2 = ansys.aedt.core.Rmxprt(project="assm_test2",solution_type=app.solution_type, design="from_configuration") app2.import_configuration(config) .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 141-144 Save and Close Desktop ~~~~~~~~~~~~~~~~~~~~~~ Save and Close Desktop. .. GENERATED FROM PYTHON SOURCE LINES 144-149 .. code-block:: Python m2d.save_project(os.path.join(temp_dir.name, "Maxwell_project.aedt")) m2d.release_desktop() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 150-155 Cleanup ~~~~~~~ All project files are saved in the folder ``temp_dir.name``. If you've run this example as a Jupyter notebook you can retrieve those project files. The following cell removes all temporary files, including the project folder. .. GENERATED FROM PYTHON SOURCE LINES 155-156 .. code-block:: Python temp_dir.cleanup() .. rst-class:: sphx-glr-timing **Total running time of the script:** (1 minutes 31.268 seconds) .. _sphx_glr_download_examples_03-Maxwell_RMxprt.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: RMxprt.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: RMxprt.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: RMxprt.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_