|
| 1 | +# # 3-Phase Cable with Neutral |
| 2 | +# |
| 3 | +# This example uses PyAEDT to create a 3-phase cable with neutral |
| 4 | +# and solve it using Maxwell 2D AC Magnetic (Eddy Current) solver. |
| 5 | +# |
| 6 | +# Keywords: **Maxwell 2D**, **cable**, **3-phase**, **field calculator**, **field plot** |
| 7 | + |
| 8 | +# ## Prerequisites |
| 9 | +# |
| 10 | +# ### Perform imports |
| 11 | + |
| 12 | +# + |
| 13 | +import os |
| 14 | +import tempfile |
| 15 | +import time |
| 16 | + |
| 17 | +import ansys.aedt.core # Interface to Ansys Electronics Desktop |
| 18 | + |
| 19 | +# - |
| 20 | + |
| 21 | +# ### Define constants |
| 22 | + |
| 23 | +AEDT_VERSION = "2025.2" |
| 24 | +NUM_CORES = 4 |
| 25 | +NG_MODE = False # Open AEDT UI when it is launched. |
| 26 | + |
| 27 | +# ### Create temporary directory |
| 28 | +# |
| 29 | +# Create a temporary directory where downloaded data or |
| 30 | +# dumped data can be stored. |
| 31 | +# If you'd like to retrieve the project data for subsequent use, |
| 32 | +# the temporary folder name is given by ``temp_folder.name``. |
| 33 | + |
| 34 | +temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") |
| 35 | + |
| 36 | +# ## Launch AEDT and Maxwell 2D |
| 37 | +# |
| 38 | +# Create an instance of the ``Maxwell2d`` class named ``m2d`` by providing |
| 39 | +# the project and design names, the version, and the graphical mode. |
| 40 | + |
| 41 | +project_name = os.path.join(temp_folder.name, "M2D_cable.aedt") |
| 42 | +m2d = ansys.aedt.core.Maxwell2d( |
| 43 | + project=project_name, |
| 44 | + design="cable_maxwell_eddy", |
| 45 | + solution_type="AC MagneticXY", |
| 46 | + version=AEDT_VERSION, |
| 47 | + non_graphical=NG_MODE, |
| 48 | + new_desktop=True, |
| 49 | +) |
| 50 | + |
| 51 | +# ## Define modeler units |
| 52 | + |
| 53 | +m2d.modeler.model_units = "mm" |
| 54 | + |
| 55 | +# ## Add materials |
| 56 | +# |
| 57 | +# Add XLPE material for insulation. |
| 58 | + |
| 59 | +xlpe = m2d.materials.add_material("XLPE") |
| 60 | +xlpe.update() |
| 61 | +xlpe.conductivity = "0" |
| 62 | +xlpe.permittivity = "2.3" |
| 63 | + |
| 64 | +# ## Create geometry of the cable and assign materials |
| 65 | +# |
| 66 | +# Create geometry of the 3-phase cable with neutral and assign materials. |
| 67 | + |
| 68 | +# ### Create the cable shield |
| 69 | + |
| 70 | +shield = m2d.modeler.create_circle(origin=[0, 0, 0], radius=8, name="Shield") |
| 71 | +filler = m2d.modeler.create_circle(origin=[0, 0, 0], radius=7.5, name="Filler") |
| 72 | +m2d.modeler.subtract(blank_list=shield.name, tool_list=filler.name) |
| 73 | +shield.material_name = "aluminum" |
| 74 | +filler.material_name = "polyethylene" |
| 75 | +filler.color = [143, 175, 143] |
| 76 | +filler.transparency = 0 |
| 77 | + |
| 78 | +# ### Create the cable inner conductors |
| 79 | + |
| 80 | +phase_a = m2d.modeler.create_circle(origin=[5, 0, 0], radius=2.0575, material="copper") |
| 81 | +cond = m2d.modeler.duplicate_around_axis( |
| 82 | + assignment=phase_a.name, axis="Z", angle=120, clones=3 |
| 83 | +) |
| 84 | +phase_b = m2d.modeler[cond[1][0]] |
| 85 | +phase_c = m2d.modeler[cond[1][1]] |
| 86 | +phase_a.name = "PhaseA" |
| 87 | +phase_a.color = [255, 0, 0] |
| 88 | +phase_a.transparency = 0 |
| 89 | +phase_b.name = "PhaseB" |
| 90 | +phase_b.color = [0, 0, 255] |
| 91 | +phase_b.transparency = 0 |
| 92 | +phase_c.name = "PhaseC" |
| 93 | +phase_c.color = [0, 255, 0] |
| 94 | +phase_c.transparency = 0 |
| 95 | + |
| 96 | +# ### Create the cable inner conductor insulation |
| 97 | + |
| 98 | +insul_a = m2d.modeler.create_circle(origin=[5, 0, 0], radius=2.25, material="XLPE") |
| 99 | +insul_a.transparency = 0 |
| 100 | +insul = m2d.modeler.duplicate_around_axis( |
| 101 | + assignment=insul_a.name, axis="Z", angle=120, clones=3 |
| 102 | +) |
| 103 | +insul_b = m2d.modeler[insul[1][0]] |
| 104 | +insul_c = m2d.modeler[insul[1][1]] |
| 105 | +insul_a.name = "InsulA" |
| 106 | +insul_b.name = "InsulB" |
| 107 | +insul_c.name = "InsulC" |
| 108 | + |
| 109 | +# ### Create the cable neutral wire and its insulation |
| 110 | + |
| 111 | +# + |
| 112 | +neu_ins = m2d.modeler.duplicate_along_line( |
| 113 | + assignment=[phase_a.name, insul_a.name], vector=[-5, 0, 0], clones=2 |
| 114 | +) |
| 115 | +phase_n = m2d.modeler[neu_ins[1][0]] |
| 116 | +phase_n.name = "PhaseN" |
| 117 | +phase_n.color = [128, 64, 64] |
| 118 | +insul_n = m2d.modeler[neu_ins[1][1]] |
| 119 | +insul_n.name = "InsulN" |
| 120 | + |
| 121 | +m2d.modeler.subtract(blank_list=filler, tool_list=[insul_a, insul_b, insul_c, insul_n]) |
| 122 | +m2d.modeler.subtract(blank_list=insul_a, tool_list=phase_a.name) |
| 123 | +m2d.modeler.subtract(blank_list=insul_b, tool_list=phase_b.name) |
| 124 | +m2d.modeler.subtract(blank_list=insul_c, tool_list=phase_c.name) |
| 125 | +m2d.modeler.subtract(blank_list=insul_n, tool_list=phase_n.name) |
| 126 | +# - |
| 127 | + |
| 128 | +# ## Create region |
| 129 | +# |
| 130 | +# Create the air region and assign boundary condition to it. |
| 131 | + |
| 132 | +# + |
| 133 | +region = m2d.modeler.create_region(pad_value=200) |
| 134 | +m2d.assign_balloon(assignment=region.edges) |
| 135 | + |
| 136 | +m2d.modeler.fit_all() |
| 137 | +# - |
| 138 | + |
| 139 | +# ## Assign excitations |
| 140 | +# |
| 141 | +# Set electrical excitations for the conductive objects. |
| 142 | + |
| 143 | +winding_a = m2d.assign_winding(assignment=phase_a.name, current=200, name="PhaseA") |
| 144 | +winding_b = m2d.assign_winding( |
| 145 | + assignment=phase_b.name, current=200, phase=-120, name="PhaseB" |
| 146 | +) |
| 147 | +winding_c = m2d.assign_winding( |
| 148 | + assignment=phase_c.name, current=200, phase=-240, name="PhaseC" |
| 149 | +) |
| 150 | +winding_n = m2d.assign_winding(assignment=phase_n.name, current=0, name="PhaseN") |
| 151 | +winding_s = m2d.assign_winding(assignment=shield.name, current=0, name="Shield") |
| 152 | + |
| 153 | +# ## Assign matrix |
| 154 | +# |
| 155 | +# Set matrix for RL parameters calculation. |
| 156 | + |
| 157 | +m2d.assign_matrix( |
| 158 | + assignment=["PhaseA", "PhaseB", "PhaseC", "PhaseN", "Shield"], matrix_name="Matrix1" |
| 159 | +) |
| 160 | + |
| 161 | +# ## Assign mesh operation |
| 162 | +# |
| 163 | +# Assign surface approximation mesh to all objects. |
| 164 | + |
| 165 | +m2d.mesh.assign_surface_mesh_manual( |
| 166 | + assignment=m2d.modeler.object_list, normal_dev="10deg" |
| 167 | +) |
| 168 | + |
| 169 | +# ## Analysis setup |
| 170 | +# |
| 171 | +# Set analysis setup to run the simulation. |
| 172 | + |
| 173 | +setup = m2d.create_setup() |
| 174 | +setup["MaximumPasses"] = 15 |
| 175 | +setup["PercentError"] = 0.1 |
| 176 | +setup["Frequency"] = "60Hz" |
| 177 | + |
| 178 | +# ## Run the Maxwell 2D analysis |
| 179 | +# |
| 180 | +# The following command runs the 2D finite element analysis in Maxwell. |
| 181 | + |
| 182 | +m2d.analyze_setup(name=setup.name) |
| 183 | + |
| 184 | +# ## Field plots |
| 185 | +# |
| 186 | +# ### Plot the magnitude of magnetic flux density |
| 187 | + |
| 188 | +plot1 = m2d.post.create_fieldplot_surface( |
| 189 | + assignment=m2d.modeler.object_list, quantity="Mag_B", plot_name="B" |
| 190 | +) |
| 191 | + |
| 192 | +# ### Add the expression for the current density absolute value using the advanced field calculator |
| 193 | + |
| 194 | +j_abs = { |
| 195 | + "name": "Jabs", |
| 196 | + "description": "Absolute value of the current density", |
| 197 | + "design_type": ["Maxwell 2D"], |
| 198 | + "fields_type": ["Fields"], |
| 199 | + "primary_sweep": "", |
| 200 | + "assignment": "", |
| 201 | + "assignment_type": [""], |
| 202 | + "operations": [ |
| 203 | + "Fundamental_Quantity('Jt')", |
| 204 | + "Operation('Smooth')", |
| 205 | + "Operation('ScalarZ')", |
| 206 | + "Scalar_Function(FuncValue='Phase')", |
| 207 | + "Operation('AtPhase')", |
| 208 | + "Operation('Abs')", |
| 209 | + ], |
| 210 | + "report": ["Field_2D"], |
| 211 | +} |
| 212 | +m2d.post.fields_calculator.add_expression(j_abs, None) |
| 213 | + |
| 214 | +# ### Plot the absolute value of the current density in the conductive objects |
| 215 | + |
| 216 | +plot2 = m2d.post.create_fieldplot_surface( |
| 217 | + assignment=[phase_a, phase_b, phase_c], |
| 218 | + quantity="Jabs", |
| 219 | + plot_name="Jabs_cond_3Phase", |
| 220 | +) |
| 221 | +plot3 = m2d.post.create_fieldplot_surface( |
| 222 | + assignment=[shield, phase_n], quantity="Jabs", plot_name="Jabs_shield_neutral" |
| 223 | +) |
| 224 | + |
| 225 | +# ## Release AEDT |
| 226 | + |
| 227 | +m2d.save_project() |
| 228 | +m2d.release_desktop() |
| 229 | +# Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory. |
| 230 | +time.sleep(3) |
| 231 | + |
| 232 | +# ### Clean up |
| 233 | + |
| 234 | +# All project files are saved in the folder ``temp_folder.name``. |
| 235 | +# If you've run this example as a Jupyter notebook, you |
| 236 | +# can retrieve those project files. The following cell |
| 237 | +# removes all temporary files, including the project folder. |
| 238 | + |
| 239 | +temp_folder.cleanup() |
0 commit comments