|
1 | | -# %% [markdown] |
2 | 1 | # # Busbar Joule Heating Analysis with Maxwell 3D |
3 | 2 | # |
4 | 3 | # Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates. |
|
28 | 27 | # - Skin depth effects on current distribution |
29 | 28 | # |
30 | 29 | # This example demonstrates the complete electromagnetic analysis workflow for conductor systems. |
| 30 | +# |
| 31 | +# Keywords: **Maxwell 3D**, **Eddy Current**, **Joule Heating**, **Skin Effect** |
31 | 32 |
|
32 | | -# %% [markdown] |
33 | | -# ## 1. Perform Required Imports |
34 | | -# Import all necessary modules for the Maxwell 3D busbar analysis. |
| 33 | +# ## Prerequisites |
| 34 | +# |
| 35 | +# ### Perform imports |
35 | 36 |
|
36 | | -# %% |
| 37 | +# + |
37 | 38 | import math |
38 | 39 | import os |
39 | 40 | import tempfile |
40 | 41 | import time |
41 | 42 |
|
42 | 43 | from ansys.aedt.core import Maxwell3d |
| 44 | +# - |
43 | 45 |
|
44 | | -# %% [markdown] |
45 | | -# ## 2. Set Analysis Parameters |
| 46 | +# ### Define constants |
46 | 47 | # Define geometric dimensions and electrical parameters for the busbar system. |
47 | 48 |
|
48 | | -# %% |
49 | 49 | AEDT_VERSION = "2025.2" |
50 | 50 | NG_MODE = False |
51 | 51 | PROJECT_NAME = "Busbar_JouleHeating_Simple.aedt" |
|
68 | 68 | print(f"Input currents: {I1}A + {I2}A = {I1+I2}A total") |
69 | 69 | print(f"Frequency: {FREQ} Hz") |
70 | 70 |
|
71 | | -# %% [markdown] |
72 | | -# ## 3. Initialize Maxwell 3D |
73 | | -# Start Maxwell 3D with eddy current solution type and set model units. |
| 71 | +# ### Create temporary directory |
| 72 | +# |
| 73 | +# Create a temporary working directory. |
| 74 | +# The name of the working folder is stored in ``temp_folder.name``. |
| 75 | +# |
| 76 | +# > **Note:** The final cell in the notebook cleans up the temporary folder. If you want to |
| 77 | +# > retrieve the AEDT project and data, do so before executing the final cell in the notebook. |
74 | 78 |
|
75 | | -# %% |
76 | | -tmpdir = tempfile.TemporaryDirectory(suffix=".ansys") |
77 | | -project_path = os.path.join(tmpdir.name, PROJECT_NAME) |
| 79 | +temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") |
| 80 | +project_path = os.path.join(temp_folder.name, PROJECT_NAME) |
| 81 | + |
| 82 | +# ### Launch application |
| 83 | +# |
| 84 | +# Start Maxwell 3D with eddy current solution type and set model units. |
78 | 85 |
|
79 | 86 | m3d = Maxwell3d( |
80 | 87 | project=project_path, |
|
87 | 94 | m3d.modeler.model_units = "mm" |
88 | 95 | print("Maxwell 3D initialized") |
89 | 96 |
|
90 | | -# %% [markdown] |
91 | | -# ## 4. Create Busbar Geometry |
| 97 | +# ## Model Preparation |
| 98 | +# |
92 | 99 | # Create the main busbar conductor and terminal tabs, then unite them into a single object. |
93 | 100 |
|
94 | | -# %% |
| 101 | +# ### Create 3D model |
| 102 | +# |
95 | 103 | print("\nCreating Geometry") |
96 | 104 |
|
97 | 105 | # Main busbar |
|
123 | 131 | conductor.name = "CompleteBusbar" |
124 | 132 | print(f"Created united conductor with {len(conductor.faces)} faces") |
125 | 133 |
|
126 | | -# %% [markdown] |
127 | | -# ## 5. Define Current Excitations |
| 134 | +# ### Assign boundary conditions |
| 135 | +# |
128 | 136 | # Select terminal faces and assign current excitations following Kirchhoff's current law. |
129 | 137 |
|
130 | | -# %% |
| 138 | +# + |
131 | 139 | print("\nSelecting Terminal Faces") |
132 | 140 |
|
133 | 141 | # Sort faces by x-coordinate to identify input and output terminals |
|
167 | 175 | print(f"Output Current: {-(I1 + I2)}A") |
168 | 176 | print(f"Current balance: {I1 + I2 + (-(I1 + I2))} = 0A") |
169 | 177 |
|
170 | | -# %% [markdown] |
171 | | -# ## 6. Create Air Region |
172 | | -# Define the air region that provides boundary conditions for the electromagnetic field solution. |
173 | | - |
174 | | -# %% |
175 | 178 | print("\nCreating Air Region") |
176 | 179 |
|
177 | 180 | air = m3d.modeler.create_air_region( |
178 | 181 | x_pos=0, y_pos=50, z_pos=100, x_neg=0, y_neg=50, z_neg=100 |
179 | 182 | ) |
180 | 183 | print("Air region created with 50% padding") |
| 184 | +# - |
181 | 185 |
|
182 | | -# %% [markdown] |
183 | | -# ## 7. Configure Analysis Setup |
| 186 | +# ### Define solution setup |
| 187 | +# |
184 | 188 | # Set up the eddy current analysis with frequency, convergence criteria, and mesh settings. |
185 | 189 |
|
186 | | -# %% |
| 190 | +# + |
187 | 191 | print("\n Setting Up Analysis ") |
188 | 192 |
|
189 | 193 | setup = m3d.create_setup("EddyCurrentSetup") |
|
201 | 205 | name="ConductorMesh", |
202 | 206 | ) |
203 | 207 | print("Mesh operation assigned") |
| 208 | +# - |
204 | 209 |
|
205 | | -# %% [markdown] |
206 | | -# ## 8. Run Analysis |
| 210 | +# ### Run analysis |
| 211 | +# |
207 | 212 | # Execute the finite element solver with automatic adaptive mesh refinement. |
208 | 213 |
|
209 | | -# %% |
210 | 214 | print("\n Running Analysis ") |
211 | 215 | print("Starting solver... (this may take a few minutes)") |
212 | 216 |
|
|
217 | 221 | m3d.analyze_setup(setup.name) |
218 | 222 | print("Analysis completed") |
219 | 223 |
|
220 | | -# %% [markdown] |
221 | | -# ## 9. Extract Solution Data |
| 224 | +# ## Postprocess |
| 225 | +# |
222 | 226 | # Get Ohmic loss (Joule heating) results from the electromagnetic field solution. |
223 | 227 |
|
224 | | -# %% |
| 228 | +# ### Evaluate loss |
| 229 | +# |
| 230 | +# + |
225 | 231 | print("\n--- Extracting Results ---") |
226 | 232 |
|
227 | 233 | setup_sweep = f"{setup.name} : LastAdaptive" |
|
237 | 243 |
|
238 | 244 | total_loss = solution_data.data_magnitude()[0] |
239 | 245 | print(f"\nOhmic Loss (Joule heating): {total_loss:.6f} W") |
| 246 | +# - |
240 | 247 |
|
241 | | -# %% [markdown] |
242 | | -# ## 10. Create Field Visualizations |
| 248 | +# ### Visualize fields |
| 249 | +# |
243 | 250 | # Generate 3D field plots showing current density, electric field, and power loss distributions. |
244 | 251 |
|
245 | | -# %% |
| 252 | +# + |
246 | 253 | print("\n Creating Field Plots ") |
247 | 254 |
|
248 | 255 | j_plot = m3d.post.create_fieldplot_surface( |
|
262 | 269 | ) |
263 | 270 | print("Joule heating distribution plot created") |
264 | 271 |
|
265 | | -# %% [markdown] |
266 | | -# ## 11. Calculate Engineering Metrics |
| 272 | +# Calculate engineering metrics |
267 | 273 | # Compute key parameters including resistance, loss density, skin depth, and current density. |
268 | 274 |
|
269 | | -# %% |
270 | 275 | print("\nANALYSIS RESULTS") |
271 | 276 |
|
272 | 277 | # Basic electrical parameters |
|
315 | 320 | print("Current density magnitude (|J|): Shows current distribution") |
316 | 321 | print("Electric field magnitude (|E|): Shows electric field intensity") |
317 | 322 | print("Joule heating distribution: Shows power loss density") |
| 323 | +# - |
318 | 324 |
|
319 | | -# %% [markdown] |
320 | | -# ## 12. Save Project and Release Resources |
321 | | -# Save the analysis project and clean up AEDT resources. |
| 325 | +# ## Finish |
| 326 | +# |
| 327 | +# ### Save the project |
322 | 328 |
|
323 | | -# %% |
324 | 329 | print(f"\n--- Saving Project ---") |
325 | 330 | m3d.save_project(project_path) |
326 | 331 | print(f"Project saved to: {project_path}") |
327 | 332 |
|
328 | 333 | m3d.release_desktop(close_projects=True, close_desktop=True) |
329 | | -time.sleep(2) |
| 334 | +# Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory. |
| 335 | +time.sleep(3) |
| 336 | + |
| 337 | +# ### Clean up |
| 338 | +# |
| 339 | +# All project files are saved in the folder ``temp_folder.name``. |
| 340 | +# If you've run this example as a Jupyter notebook, you |
| 341 | +# can retrieve those project files. The following cell |
| 342 | +# removes all temporary files, including the project folder. |
330 | 343 |
|
331 | | -# %% [markdown] |
332 | | -# ## 13. Conclusion |
| 344 | +temp_folder.cleanup() |
| 345 | + |
| 346 | +# ## Conclusion |
333 | 347 | # This example demonstrated the complete workflow for busbar Joule heating analysis using Maxwell 3D |
334 | 348 | # and PyAEDT. The analysis captured frequency-dependent phenomena including skin effect, current |
335 | 349 | # redistribution, and AC losses. Key outputs included power loss calculations, field visualizations, |
|
339 | 353 | # Joule heating due to AC resistance and skin effect |
340 | 354 | # Non-uniform current density due to skin effect |
341 | 355 | # Relationship between frequency, skin depth, and power loss |
342 | | - |
343 | | -# %% |
|
0 commit comments