{ "cells": [ { "cell_type": "markdown", "id": "93bcb95f", "metadata": {}, "source": [ "# 3-Phase Cable with Neutral\n", "\n", "This example uses PyAEDT to create a 3-phase cable with neutral\n", "and solve it using Maxwell 2D AC Magnetic (Eddy Current) solver.\n", "\n", "Keywords: **Maxwell 2D**, **cable**, **3-phase**, **field calculator**, **field plot**" ] }, { "cell_type": "markdown", "id": "243755f5", "metadata": {}, "source": [ "## Prerequisites\n", "\n", "### Perform imports" ] }, { "cell_type": "code", "execution_count": null, "id": "d05f28c5", "metadata": {}, "outputs": [], "source": [ "import os\n", "import tempfile\n", "import time\n", "\n", "import ansys.aedt.core # Interface to Ansys Electronics Desktop\n" ] }, { "cell_type": "markdown", "id": "af0ae8d2", "metadata": {}, "source": [ "### Define constants" ] }, { "cell_type": "code", "execution_count": null, "id": "1db12d1c", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2025.2\"\n", "NUM_CORES = 4\n", "NG_MODE = False # Open AEDT UI when it is launched." ] }, { "cell_type": "markdown", "id": "b6b317b6", "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": "13070386", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")" ] }, { "cell_type": "markdown", "id": "b061b7cd", "metadata": {}, "source": [ "## Launch AEDT and Maxwell 2D\n", "\n", "Create an instance of the ``Maxwell2d`` class named ``m2d`` by providing\n", "the project and design names, the version, and the graphical mode." ] }, { "cell_type": "code", "execution_count": null, "id": "4a05aeb9", "metadata": {}, "outputs": [], "source": [ "project_name = os.path.join(temp_folder.name, \"M2D_cable.aedt\")\n", "m2d = ansys.aedt.core.Maxwell2d(\n", " project=project_name,\n", " design=\"cable_maxwell_eddy\",\n", " solution_type=\"AC MagneticXY\",\n", " version=AEDT_VERSION,\n", " non_graphical=NG_MODE,\n", " new_desktop=True,\n", ")" ] }, { "cell_type": "markdown", "id": "ab02c3d6", "metadata": {}, "source": [ "## Define modeler units" ] }, { "cell_type": "code", "execution_count": null, "id": "425c0dfc", "metadata": {}, "outputs": [], "source": [ "m2d.modeler.model_units = \"mm\"" ] }, { "cell_type": "markdown", "id": "8cec4244", "metadata": {}, "source": [ "## Add materials\n", "\n", "Add XLPE material for insulation." ] }, { "cell_type": "code", "execution_count": null, "id": "001b784a", "metadata": {}, "outputs": [], "source": [ "xlpe = m2d.materials.add_material(\"XLPE\")\n", "xlpe.update()\n", "xlpe.conductivity = \"0\"\n", "xlpe.permittivity = \"2.3\"" ] }, { "cell_type": "markdown", "id": "3bed3f0d", "metadata": {}, "source": [ "## Create geometry of the cable and assign materials\n", "\n", "Create geometry of the 3-phase cable with neutral and assign materials." ] }, { "cell_type": "markdown", "id": "fe7b50f6", "metadata": {}, "source": [ "### Create the cable shield" ] }, { "cell_type": "code", "execution_count": null, "id": "79741bdc", "metadata": {}, "outputs": [], "source": [ "shield = m2d.modeler.create_circle(origin=[0, 0, 0], radius=8, name=\"Shield\")\n", "filler = m2d.modeler.create_circle(origin=[0, 0, 0], radius=7.5, name=\"Filler\")\n", "m2d.modeler.subtract(blank_list=shield.name, tool_list=filler.name)\n", "shield.material_name = \"aluminum\"\n", "filler.material_name = \"polyethylene\"\n", "filler.color = [143, 175, 143]\n", "filler.transparency = 0" ] }, { "cell_type": "markdown", "id": "c7bf8ccb", "metadata": {}, "source": [ "### Create the cable inner conductors" ] }, { "cell_type": "code", "execution_count": null, "id": "f02eb438", "metadata": {}, "outputs": [], "source": [ "phase_a = m2d.modeler.create_circle(origin=[5, 0, 0], radius=2.0575, material=\"copper\")\n", "cond = m2d.modeler.duplicate_around_axis(\n", " assignment=phase_a.name, axis=\"Z\", angle=120, clones=3\n", ")\n", "phase_b = m2d.modeler[cond[1][0]]\n", "phase_c = m2d.modeler[cond[1][1]]\n", "phase_a.name = \"PhaseA\"\n", "phase_a.color = [255, 0, 0]\n", "phase_a.transparency = 0\n", "phase_b.name = \"PhaseB\"\n", "phase_b.color = [0, 0, 255]\n", "phase_b.transparency = 0\n", "phase_c.name = \"PhaseC\"\n", "phase_c.color = [0, 255, 0]\n", "phase_c.transparency = 0" ] }, { "cell_type": "markdown", "id": "dee39ef5", "metadata": {}, "source": [ "### Create the cable inner conductor insulation" ] }, { "cell_type": "code", "execution_count": null, "id": "112c3f8c", "metadata": {}, "outputs": [], "source": [ "insul_a = m2d.modeler.create_circle(origin=[5, 0, 0], radius=2.25, material=\"XLPE\")\n", "insul_a.transparency = 0\n", "insul = m2d.modeler.duplicate_around_axis(\n", " assignment=insul_a.name, axis=\"Z\", angle=120, clones=3\n", ")\n", "insul_b = m2d.modeler[insul[1][0]]\n", "insul_c = m2d.modeler[insul[1][1]]\n", "insul_a.name = \"InsulA\"\n", "insul_b.name = \"InsulB\"\n", "insul_c.name = \"InsulC\"" ] }, { "cell_type": "markdown", "id": "6554af29", "metadata": {}, "source": [ "### Create the cable neutral wire and its insulation" ] }, { "cell_type": "code", "execution_count": null, "id": "6a9db488", "metadata": {}, "outputs": [], "source": [ "neu_ins = m2d.modeler.duplicate_along_line(\n", " assignment=[phase_a.name, insul_a.name], vector=[-5, 0, 0], clones=2\n", ")\n", "phase_n = m2d.modeler[neu_ins[1][0]]\n", "phase_n.name = \"PhaseN\"\n", "phase_n.color = [128, 64, 64]\n", "insul_n = m2d.modeler[neu_ins[1][1]]\n", "insul_n.name = \"InsulN\"\n", "\n", "m2d.modeler.subtract(blank_list=filler, tool_list=[insul_a, insul_b, insul_c, insul_n])\n", "m2d.modeler.subtract(blank_list=insul_a, tool_list=phase_a.name)\n", "m2d.modeler.subtract(blank_list=insul_b, tool_list=phase_b.name)\n", "m2d.modeler.subtract(blank_list=insul_c, tool_list=phase_c.name)\n", "m2d.modeler.subtract(blank_list=insul_n, tool_list=phase_n.name)" ] }, { "cell_type": "markdown", "id": "2e21c4ca", "metadata": {}, "source": [ "## Create region\n", "\n", "Create the air region and assign boundary condition to it." ] }, { "cell_type": "code", "execution_count": null, "id": "e5f2477d", "metadata": {}, "outputs": [], "source": [ "region = m2d.modeler.create_region(pad_value=200)\n", "m2d.assign_balloon(assignment=region.edges)\n", "\n", "m2d.modeler.fit_all()" ] }, { "cell_type": "markdown", "id": "a939a6fa", "metadata": {}, "source": [ "## Assign excitations\n", "\n", "Set electrical excitations for the conductive objects." ] }, { "cell_type": "code", "execution_count": null, "id": "58b30d01", "metadata": {}, "outputs": [], "source": [ "winding_a = m2d.assign_winding(assignment=phase_a.name, current=200, name=\"PhaseA\")\n", "winding_b = m2d.assign_winding(\n", " assignment=phase_b.name, current=200, phase=-120, name=\"PhaseB\"\n", ")\n", "winding_c = m2d.assign_winding(\n", " assignment=phase_c.name, current=200, phase=-240, name=\"PhaseC\"\n", ")\n", "winding_n = m2d.assign_winding(assignment=phase_n.name, current=0, name=\"PhaseN\")\n", "winding_s = m2d.assign_winding(assignment=shield.name, current=0, name=\"Shield\")" ] }, { "cell_type": "markdown", "id": "3a791473", "metadata": {}, "source": [ "## Assign matrix\n", "\n", "Set matrix for RL parameters calculation." ] }, { "cell_type": "code", "execution_count": null, "id": "260d6be6", "metadata": {}, "outputs": [], "source": [ "m2d.assign_matrix(\n", " assignment=[\"PhaseA\", \"PhaseB\", \"PhaseC\", \"PhaseN\", \"Shield\"], matrix_name=\"Matrix1\"\n", ")" ] }, { "cell_type": "markdown", "id": "2519be50", "metadata": {}, "source": [ "## Assign mesh operation\n", "\n", "Assign surface approximation mesh to all objects." ] }, { "cell_type": "code", "execution_count": null, "id": "3866f064", "metadata": {}, "outputs": [], "source": [ "m2d.mesh.assign_surface_mesh_manual(\n", " assignment=m2d.modeler.object_list, normal_dev=\"10deg\"\n", ")" ] }, { "cell_type": "markdown", "id": "48f6c75b", "metadata": {}, "source": [ "## Analysis setup\n", "\n", "Set analysis setup to run the simulation." ] }, { "cell_type": "code", "execution_count": null, "id": "4e08f724", "metadata": {}, "outputs": [], "source": [ "setup = m2d.create_setup()\n", "setup[\"MaximumPasses\"] = 15\n", "setup[\"PercentError\"] = 0.1\n", "setup[\"Frequency\"] = \"60Hz\"" ] }, { "cell_type": "markdown", "id": "dc4247b4", "metadata": {}, "source": [ "## Run the Maxwell 2D analysis\n", "\n", "The following command runs the 2D finite element analysis in Maxwell." ] }, { "cell_type": "code", "execution_count": null, "id": "54ed116d", "metadata": {}, "outputs": [], "source": [ "m2d.analyze_setup(name=setup.name)" ] }, { "cell_type": "markdown", "id": "8fefa97d", "metadata": {}, "source": [ "## Field plots\n", "\n", "### Plot the magnitude of magnetic flux density" ] }, { "cell_type": "code", "execution_count": null, "id": "c09fc784", "metadata": {}, "outputs": [], "source": [ "plot1 = m2d.post.create_fieldplot_surface(\n", " assignment=m2d.modeler.object_list, quantity=\"Mag_B\", plot_name=\"B\"\n", ")" ] }, { "cell_type": "markdown", "id": "897a8fd0", "metadata": {}, "source": [ "### Add the expression for the current density absolute value using the advanced field calculator" ] }, { "cell_type": "code", "execution_count": null, "id": "ae1b8a18", "metadata": {}, "outputs": [], "source": [ "j_abs = {\n", " \"name\": \"Jabs\",\n", " \"description\": \"Absolute value of the current density\",\n", " \"design_type\": [\"Maxwell 2D\"],\n", " \"fields_type\": [\"Fields\"],\n", " \"primary_sweep\": \"\",\n", " \"assignment\": \"\",\n", " \"assignment_type\": [\"\"],\n", " \"operations\": [\n", " \"Fundamental_Quantity('Jt')\",\n", " \"Operation('Smooth')\",\n", " \"Operation('ScalarZ')\",\n", " \"Scalar_Function(FuncValue='Phase')\",\n", " \"Operation('AtPhase')\",\n", " \"Operation('Abs')\",\n", " ],\n", " \"report\": [\"Field_2D\"],\n", "}\n", "m2d.post.fields_calculator.add_expression(j_abs, None)" ] }, { "cell_type": "markdown", "id": "fef1e5e8", "metadata": {}, "source": [ "### Plot the absolute value of the current density in the conductive objects" ] }, { "cell_type": "code", "execution_count": null, "id": "8fbdc8d5", "metadata": {}, "outputs": [], "source": [ "plot2 = m2d.post.create_fieldplot_surface(\n", " assignment=[phase_a, phase_b, phase_c],\n", " quantity=\"Jabs\",\n", " plot_name=\"Jabs_cond_3Phase\",\n", ")\n", "plot3 = m2d.post.create_fieldplot_surface(\n", " assignment=[shield, phase_n], quantity=\"Jabs\", plot_name=\"Jabs_shield_neutral\"\n", ")" ] }, { "cell_type": "markdown", "id": "8b9df4a4", "metadata": {}, "source": [ "## Release AEDT" ] }, { "cell_type": "code", "execution_count": null, "id": "566ecf8c", "metadata": {}, "outputs": [], "source": [ "m2d.save_project()\n", "m2d.release_desktop()\n", "# Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory.\n", "time.sleep(3)" ] }, { "cell_type": "markdown", "id": "e5f2d9f2", "metadata": {}, "source": [ "### Clean up" ] }, { "cell_type": "markdown", "id": "554c6a3c", "metadata": {}, "source": [ "All project files are saved in the folder ``temp_folder.name``.\n", "If you've run this example as a Jupyter notebook, you\n", "can retrieve those project files. The following cell\n", "removes all temporary files, including the project folder." ] }, { "cell_type": "code", "execution_count": null, "id": "f96d2ccd", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }