{ "cells": [ { "cell_type": "markdown", "id": "355ccb57", "metadata": {}, "source": [ "# Motor creation and export\n", "\n", "This example uses PyAEDT to create a RMxprt project and export it to Maxwell 2D.\n", "It shows how to create an ASSM (Adjust-Speed Synchronous Machine) in RMxprt\n", "and how to access rotor and stator settings.\n", "It then exports the model to a Maxwell 2D design\n", "and the RMxprt settings to a JSON file to be reused.\n", "\n", "Keywords: **RMxprt**, **Maxwell 2D**" ] }, { "cell_type": "markdown", "id": "2a614558", "metadata": {}, "source": [ "## Perform imports and define constants\n", "\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "6bd51830", "metadata": {}, "outputs": [], "source": [ "import os\n", "import tempfile\n", "import time" ] }, { "cell_type": "code", "execution_count": null, "id": "294b0198", "metadata": {}, "outputs": [], "source": [ "import ansys.aedt.core" ] }, { "cell_type": "markdown", "id": "0b4d33a0", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "c99d8e8d", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2024.2\"\n", "NUM_CORES = 4\n", "NG_MODE = False # Open AEDT UI when it is launched." ] }, { "cell_type": "markdown", "id": "bf5a2e55", "metadata": {}, "source": [ "## Create temporary directory\n", "\n", "Create a temporary directory where downloaded data or\n", "dumped data can be stored.\n", "If you'd like to retrieve the project data for subsequent use,\n", "the temporary folder name is given by ``temp_folder.name``." ] }, { "cell_type": "code", "execution_count": null, "id": "4f7aeba4", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")" ] }, { "cell_type": "markdown", "id": "ae1c7cb4", "metadata": {}, "source": [ "## Launch AEDT and RMxprt\n", "\n", "Launch AEDT and RMxprt after first setting up the project name.\n", "This example uses ASSM (Adjust-Speed Synchronous Machine) as the solution type." ] }, { "cell_type": "code", "execution_count": null, "id": "6d7dd4d9", "metadata": {}, "outputs": [], "source": [ "project_name = os.path.join(temp_folder.name, \"ASSM.aedt\")\n", "rmxprt = ansys.aedt.core.Rmxprt(\n", " version=AEDT_VERSION,\n", " new_desktop=True,\n", " close_on_exit=True,\n", " solution_type=\"ASSM\",\n", " project=project_name,\n", " non_graphical=NG_MODE,\n", ")" ] }, { "cell_type": "markdown", "id": "1e1c1ed3", "metadata": {}, "source": [ "## Define global machine settings" ] }, { "cell_type": "code", "execution_count": null, "id": "167ac4e0", "metadata": {}, "outputs": [], "source": [ "rmxprt.general[\"Number of Poles\"] = 4\n", "rmxprt.general[\"Rotor Position\"] = \"Inner Rotor\"\n", "rmxprt.general[\"Frictional Loss\"] = \"12W\"\n", "rmxprt.general[\"Windage Loss\"] = \"0W\"\n", "rmxprt.general[\"Reference Speed\"] = \"1500rpm\"\n", "rmxprt.general[\"Control Type\"] = \"DC\"\n", "rmxprt.general[\"Circuit Type\"] = \"Y3\"" ] }, { "cell_type": "markdown", "id": "46e97d14", "metadata": {}, "source": [ "## Define circuit settings" ] }, { "cell_type": "code", "execution_count": null, "id": "aad21c6d", "metadata": {}, "outputs": [], "source": [ "rmxprt.circuit[\"Trigger Pulse Width\"] = \"120deg\"\n", "rmxprt.circuit[\"Transistor Drop\"] = \"2V\"\n", "rmxprt.circuit[\"Diode Drop\"] = \"2V\"" ] }, { "cell_type": "markdown", "id": "8fc827fe", "metadata": {}, "source": [ "## Define stator\n", "\n", "Define stator and slot and winding settings." ] }, { "cell_type": "code", "execution_count": null, "id": "f5543c17", "metadata": {}, "outputs": [], "source": [ "rmxprt.stator[\"Outer Diameter\"] = \"122mm\"\n", "rmxprt.stator[\"Inner Diameter\"] = \"75mm\"\n", "rmxprt.stator[\"Length\"] = \"65mm\"\n", "rmxprt.stator[\"Stacking Factor\"] = 0.95\n", "rmxprt.stator[\"Steel Type\"] = \"steel_1008\"\n", "rmxprt.stator[\"Number of Slots\"] = 24\n", "rmxprt.stator[\"Slot Type\"] = 2" ] }, { "cell_type": "code", "execution_count": null, "id": "c4a6d66f", "metadata": {}, "outputs": [], "source": [ "rmxprt.stator.properties.children[\"Slot\"].props[\"Auto Design\"] = False\n", "rmxprt.stator.properties.children[\"Slot\"].props[\"Hs0\"] = \"0.5mm\"\n", "rmxprt.stator.properties.children[\"Slot\"].props[\"Hs1\"] = \"1.2mm\"\n", "rmxprt.stator.properties.children[\"Slot\"].props[\"Hs2\"] = \"8.2mm\"\n", "rmxprt.stator.properties.children[\"Slot\"].props[\"Bs0\"] = \"2.5mm\"\n", "rmxprt.stator.properties.children[\"Slot\"].props[\"Bs1\"] = \"5.6mm\"\n", "rmxprt.stator.properties.children[\"Slot\"].props[\"Bs2\"] = \"7.6mm\"" ] }, { "cell_type": "code", "execution_count": null, "id": "ef632590", "metadata": {}, "outputs": [], "source": [ "rmxprt.stator.properties.children[\"Winding\"].props[\"Winding Layers\"] = 2\n", "rmxprt.stator.properties.children[\"Winding\"].props[\"Parallel Branches\"] = 1\n", "rmxprt.stator.properties.children[\"Winding\"].props[\"Conductors per Slot\"] = 52\n", "rmxprt.stator.properties.children[\"Winding\"].props[\"Coil Pitch\"] = 5\n", "rmxprt.stator.properties.children[\"Winding\"].props[\"Number of Strands\"] = 1" ] }, { "cell_type": "markdown", "id": "f2b7c9ca", "metadata": {}, "source": [ "## Define rotor\n", "\n", "Define rotor and pole settings." ] }, { "cell_type": "code", "execution_count": null, "id": "17467ec4", "metadata": {}, "outputs": [], "source": [ "rmxprt.rotor[\"Outer Diameter\"] = \"74mm\"\n", "rmxprt.rotor[\"Inner Diameter\"] = \"26mm\"\n", "rmxprt.rotor[\"Length\"] = \"65mm\"\n", "rmxprt.rotor[\"Stacking Factor\"] = 0.95\n", "rmxprt.rotor[\"Steel Type\"] = \"steel_1008\"\n", "rmxprt.rotor[\"Pole Type\"] = 1" ] }, { "cell_type": "code", "execution_count": null, "id": "ee548320", "metadata": {}, "outputs": [], "source": [ "rmxprt.rotor.properties.children[\"Pole\"].props[\"Embrace\"] = 0.7\n", "rmxprt.rotor.properties.children[\"Pole\"].props[\"Offset\"] = \"0mm\"\n", "rmxprt.rotor.properties.children[\"Pole\"].props[\"Magnet Type\"] = [\n", " \"Material:=\",\n", " \"Alnico9\",\n", "]\n", "rmxprt.rotor.properties.children[\"Pole\"].props[\"Magnet Thickness\"] = \"3.5mm\"" ] }, { "cell_type": "markdown", "id": "f6813176", "metadata": {}, "source": [ "## Create setup\n", "\n", "Create a setup and define the main settings." ] }, { "cell_type": "code", "execution_count": null, "id": "59cf332d", "metadata": {}, "outputs": [], "source": [ "setup = rmxprt.create_setup()\n", "setup.props[\"RatedVoltage\"] = \"220V\"\n", "setup.props[\"RatedOutputPower\"] = \"550W\"\n", "setup.props[\"RatedSpeed\"] = \"1500rpm\"\n", "setup.props[\"OperatingTemperature\"] = \"75cel\"" ] }, { "cell_type": "markdown", "id": "19d45bde", "metadata": {}, "source": [ "## Analyze setup." ] }, { "cell_type": "code", "execution_count": null, "id": "7e55e353", "metadata": {}, "outputs": [], "source": [ "setup.analyze(cores=NUM_CORES)" ] }, { "cell_type": "markdown", "id": "60326f72", "metadata": {}, "source": [ "## Export to Maxwell\n", "\n", "After the project is solved, you can export it to either Maxwell 2D or Maxwell 3D." ] }, { "cell_type": "code", "execution_count": null, "id": "932c1a05", "metadata": {}, "outputs": [], "source": [ "m2d = rmxprt.create_maxwell_design(setup_name=setup.name, maxwell_2d=True)\n", "m2d.plot(\n", " show=False,\n", " output_file=os.path.join(temp_folder.name, \"Image.jpg\"),\n", " plot_air_objects=True,\n", ")" ] }, { "cell_type": "markdown", "id": "ae6fd929", "metadata": {}, "source": [ "## Export RMxprt settings\n", "\n", "Export all RMxprt settings to a JSON file to reuse it for another\n", "project with the the import function." ] }, { "cell_type": "code", "execution_count": null, "id": "0e775c07", "metadata": {}, "outputs": [], "source": [ "config = rmxprt.export_configuration(os.path.join(temp_folder.name, \"assm.json\"))\n", "rmxprt2 = ansys.aedt.core.Rmxprt(\n", " project=\"assm_test2\",\n", " solution_type=rmxprt.solution_type,\n", " design=\"from_configuration\",\n", ")\n", "rmxprt2.import_configuration(config)" ] }, { "cell_type": "markdown", "id": "7465595e", "metadata": {}, "source": [ "## Save project\n", "\n", "Save the project containing the Maxwell design." ] }, { "cell_type": "code", "execution_count": null, "id": "f796fd8c", "metadata": {}, "outputs": [], "source": [ "m2d.save_project(file_name=project_name)" ] }, { "cell_type": "markdown", "id": "e2e77e93", "metadata": {}, "source": [ "## Release AEDT and clean up temporary directory\n", "\n", "Release AEDT and remove both the project and temporary directory." ] }, { "cell_type": "code", "execution_count": null, "id": "b590c91a", "metadata": {}, "outputs": [], "source": [ "m2d.release_desktop()\n", "time.sleep(3)\n", "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }