-
Notifications
You must be signed in to change notification settings - Fork 3
Example/busbar joule heating #436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
cde34eb
fb494dc
95c57b0
0605f8f
43dc1fe
59d57f3
417fb70
4d6b38f
36222a8
085b541
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,3 +114,4 @@ venv.bak/ | |
|
|
||
| # Generated example | ||
| src/ansys/pyaedt/examples/simple_example.py | ||
| .vscode/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,343 @@ | ||
| # %% [markdown] | ||
|
||
| # # Busbar Joule Heating Analysis with Maxwell 3D | ||
| # | ||
| # Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates. | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # ## Overview | ||
| # | ||
| # This example demonstrates how to set up and solve a busbar Joule heating analysis using Maxwell 3D and PyAEDT. We will learn the complete workflow including: | ||
| # | ||
| # - Geometry creation and material assignment | ||
| # - Current excitation setup following Kirchhoff's laws | ||
| # - Mesh configuration for AC analysis | ||
| # - Eddy current analysis execution | ||
| # - Post-processing for field visualization | ||
| # - Engineering metrics extraction | ||
| # | ||
| # ## Core Concepts and Principles | ||
| # | ||
| # **Busbar Joule heating analysis** is critical in power electronics and electrical distribution systems. | ||
| # At AC frequencies, the **skin effect** causes non-uniform current distribution, which increases | ||
| # resistance and power losses. | ||
| # | ||
| # Maxwell 3D's eddy current solver captures these frequency-dependent phenomena, enabling accurate prediction of: | ||
| # - Power losses and current density distributions | ||
| # - Thermal loads for thermal management | ||
| # - AC resistance vs DC resistance | ||
| # - Skin depth effects on current distribution | ||
| # | ||
| # This example demonstrates the complete electromagnetic analysis workflow for conductor systems. | ||
|
|
||
| # %% [markdown] | ||
| # ## 1. Perform Required Imports | ||
| # Import all necessary modules for the Maxwell 3D busbar analysis. | ||
|
|
||
| # %% | ||
| import math | ||
| import os | ||
| import tempfile | ||
| import time | ||
|
|
||
| from ansys.aedt.core import Maxwell3d | ||
|
|
||
| # %% [markdown] | ||
| # ## 2. Set Analysis Parameters | ||
| # Define geometric dimensions and electrical parameters for the busbar system. | ||
|
|
||
| # %% | ||
| AEDT_VERSION = "2025.2" | ||
| NG_MODE = False | ||
| PROJECT_NAME = "Busbar_JouleHeating_Simple.aedt" | ||
|
|
||
| # Geometry parameters (mm) | ||
| BUSBAR_L = 100.0 | ||
| BUSBAR_W = 10.0 | ||
| BUSBAR_H = 5.0 | ||
| TAB_L = 5.0 | ||
| TAB_W = 3.0 | ||
| TAB_H = 3.0 | ||
|
|
||
| # Electrical parameters | ||
| I1 = 100.0 # Input current 1 (A) | ||
| I2 = 100.0 # Input current 2 (A) | ||
| FREQ = 50 # Frequency (Hz) | ||
|
|
||
| print("Maxwell 3D Busbar Joule Heating Analysis") | ||
| print(f"Busbar dimensions: {BUSBAR_L} x {BUSBAR_W} x {BUSBAR_H} mm") | ||
| print(f"Input currents: {I1}A + {I2}A = {I1+I2}A total") | ||
| print(f"Frequency: {FREQ} Hz") | ||
|
|
||
| # %% [markdown] | ||
| # ## 3. Initialize Maxwell 3D | ||
| # Start Maxwell 3D with eddy current solution type and set model units. | ||
|
|
||
| # %% | ||
| tmpdir = tempfile.TemporaryDirectory(suffix=".ansys") | ||
| project_path = os.path.join(tmpdir.name, PROJECT_NAME) | ||
|
|
||
| m3d = Maxwell3d( | ||
| project=project_path, | ||
| version=AEDT_VERSION, | ||
| design="Busbar_JouleHeating", | ||
| solution_type="Eddy Current", | ||
| new_desktop=True, | ||
| non_graphical=NG_MODE, | ||
| ) | ||
| m3d.modeler.model_units = "mm" | ||
| print("Maxwell 3D initialized") | ||
|
|
||
| # %% [markdown] | ||
| # ## 4. Create Busbar Geometry | ||
| # Create the main busbar conductor and terminal tabs, then unite them into a single object. | ||
|
|
||
| # %% | ||
| print("\nCreating Geometry") | ||
|
|
||
| # Main busbar | ||
| busbar = m3d.modeler.create_box( | ||
| origin=[0, 0, 0], sizes=[BUSBAR_L, BUSBAR_W, BUSBAR_H], name="MainBusbar" | ||
| ) | ||
| m3d.assign_material(busbar, "copper") | ||
|
|
||
| # Input tabs | ||
| input_tab1 = m3d.modeler.create_box( | ||
| origin=[-TAB_L, 1.0, 0.0], sizes=[TAB_L, TAB_W, BUSBAR_H], name="InputTab1" | ||
| ) | ||
| m3d.assign_material(input_tab1, "copper") | ||
|
|
||
| input_tab2 = m3d.modeler.create_box( | ||
| origin=[-TAB_L, 6.0, 0.0], sizes=[TAB_L, TAB_W, BUSBAR_H], name="InputTab2" | ||
| ) | ||
| m3d.assign_material(input_tab2, "copper") | ||
|
|
||
| # Output tab | ||
| output_tab = m3d.modeler.create_box( | ||
| origin=[BUSBAR_L, 3.0, 0.0], sizes=[TAB_L, 4.0, BUSBAR_H], name="OutputTab" | ||
| ) | ||
| m3d.assign_material(output_tab, "copper") | ||
|
|
||
| # Unite all parts | ||
| united = m3d.modeler.unite([busbar, input_tab1, input_tab2, output_tab]) | ||
| conductor = m3d.modeler[united] if isinstance(united, str) else united | ||
| conductor.name = "CompleteBusbar" | ||
| print(f"Created united conductor with {len(conductor.faces)} faces") | ||
|
|
||
| # %% [markdown] | ||
| # ## 5. Define Current Excitations | ||
| # Select terminal faces and assign current excitations following Kirchhoff's current law. | ||
|
|
||
| # %% | ||
| print("\nSelecting Terminal Faces") | ||
|
|
||
| # Sort faces by x-coordinate to identify input and output terminals | ||
| faces_sorted = sorted(conductor.faces, key=lambda f: f.center[0]) | ||
| left_x = faces_sorted[0].center[0] | ||
| right_x = faces_sorted[-1].center[0] | ||
|
|
||
| # Get faces at left and right ends | ||
| left_faces = [f for f in faces_sorted if abs(f.center[0] - left_x) < 1e-3] | ||
| right_faces = [f for f in faces_sorted if abs(f.center[0] - right_x) < 1e-3] | ||
|
|
||
| # Select terminal faces | ||
| input_face1 = left_faces[0].id | ||
| input_face2 = left_faces[1].id if len(left_faces) > 1 else left_faces[0].id | ||
| output_face = right_faces[0].id | ||
|
|
||
| print(f"Selected input faces: {input_face1}, {input_face2}") | ||
| print(f"Selected output face: {output_face}") | ||
|
|
||
| print("\nAssigning Current Excitations") | ||
|
|
||
| # Assign current excitations (following Kirchhoff's current law) | ||
| current1 = m3d.assign_current( | ||
| assignment=input_face1, amplitude=I1, phase=0, name="InputCurrent1" | ||
| ) | ||
|
|
||
| current2 = m3d.assign_current( | ||
| assignment=input_face2, amplitude=I2, phase=0, name="InputCurrent2" | ||
| ) | ||
|
|
||
| current3 = m3d.assign_current( | ||
| assignment=output_face, amplitude=-(I1 + I2), phase=0, name="OutputCurrent" | ||
| ) | ||
|
|
||
| print(f"Input Current 1: {I1}A") | ||
| print(f"Input Current 2: {I2}A") | ||
| print(f"Output Current: {-(I1 + I2)}A") | ||
| print(f"Current balance: {I1 + I2 + (-(I1 + I2))} = 0A") | ||
|
|
||
| # %% [markdown] | ||
| # ## 6. Create Air Region | ||
| # Define the air region that provides boundary conditions for the electromagnetic field solution. | ||
|
|
||
| # %% | ||
| print("\nCreating Air Region") | ||
|
|
||
| air = m3d.modeler.create_air_region( | ||
| x_pos=0, y_pos=50, z_pos=100, x_neg=0, y_neg=50, z_neg=100 | ||
| ) | ||
| print("Air region created with 50% padding") | ||
|
|
||
| # %% [markdown] | ||
| # ## 7. Configure Analysis Setup | ||
| # Set up the eddy current analysis with frequency, convergence criteria, and mesh settings. | ||
|
|
||
| # %% | ||
| print("\n Setting Up Analysis ") | ||
|
|
||
| setup = m3d.create_setup("EddyCurrentSetup") | ||
| setup.props["Frequency"] = f"{FREQ}Hz" | ||
| setup.props["PercentError"] = 2 | ||
| setup.props["MaximumPasses"] = 8 | ||
| setup.props["MinimumPasses"] = 2 | ||
| setup.props["PercentRefinement"] = 30 | ||
|
|
||
| print(f"Analysis setup created for {FREQ} Hz") | ||
|
|
||
| mesh = m3d.mesh.assign_length_mesh( | ||
| assignment=conductor.name, | ||
| maximum_length=3.0, # 3mm elements for skin effect resolution | ||
| name="ConductorMesh", | ||
| ) | ||
| print("Mesh operation assigned") | ||
|
|
||
| # %% [markdown] | ||
| # ## 8. Run Analysis | ||
| # Execute the finite element solver with automatic adaptive mesh refinement. | ||
|
|
||
| # %% | ||
| print("\n Running Analysis ") | ||
| print("Starting solver... (this may take a few minutes)") | ||
|
|
||
| validation = m3d.validate_simple() | ||
| print(f"Design validation: {'PASSED' if validation else 'WARNING'}") | ||
|
|
||
| # Solve | ||
| m3d.analyze_setup(setup.name) | ||
| print("Analysis completed") | ||
|
|
||
| # %% [markdown] | ||
| # ## 9. Extract Solution Data | ||
| # Get Ohmic loss (Joule heating) results from the electromagnetic field solution. | ||
|
|
||
| # %% | ||
| print("\n--- Extracting Results ---") | ||
|
|
||
| setup_sweep = f"{setup.name} : LastAdaptive" | ||
|
|
||
| quantities_ec = m3d.post.available_report_quantities(report_category="EddyCurrent") | ||
| print(f"Available quantities: {quantities_ec}") | ||
|
|
||
| solution_data = m3d.post.get_solution_data( | ||
| expressions=["SolidLoss"], | ||
| report_category="EddyCurrent", | ||
| setup_sweep_name=setup_sweep, | ||
| ) | ||
|
|
||
| total_loss = solution_data.data_magnitude()[0] | ||
| print(f"\nOhmic Loss (Joule heating): {total_loss:.6f} W") | ||
|
|
||
| # %% [markdown] | ||
| # ## 10. Create Field Visualizations | ||
| # Generate 3D field plots showing current density, electric field, and power loss distributions. | ||
|
|
||
| # %% | ||
| print("\n Creating Field Plots ") | ||
|
|
||
| j_plot = m3d.post.create_fieldplot_surface( | ||
| assignment=conductor.name, quantity="Mag_J", plot_name="Current_Density_Magnitude" | ||
| ) | ||
| print("Current density magnitude plot created") | ||
|
|
||
| e_plot = m3d.post.create_fieldplot_surface( | ||
| assignment=conductor.name, quantity="Mag_E", plot_name="Electric_Field_Magnitude" | ||
| ) | ||
| print("Electric field magnitude plot created") | ||
|
|
||
| joule_plot = m3d.post.create_fieldplot_volume( | ||
| assignment=conductor.name, | ||
| quantity="Ohmic_Loss", | ||
| plot_name="Joule_Heating_Distribution", | ||
| ) | ||
| print("Joule heating distribution plot created") | ||
|
|
||
| # %% [markdown] | ||
| # ## 11. Calculate Engineering Metrics | ||
| # Compute key parameters including resistance, loss density, skin depth, and current density. | ||
|
|
||
| # %% | ||
| print("\nANALYSIS RESULTS") | ||
|
|
||
| # Basic electrical parameters | ||
| total_current = I1 + I2 | ||
| busbar_volume = BUSBAR_L * BUSBAR_W * BUSBAR_H | ||
|
|
||
| # Ohmic Loss | ||
| print(f"Ohmic Loss (Joule heating): {total_loss:.6f} W") | ||
|
|
||
| # Loss density | ||
| loss_density = total_loss / busbar_volume | ||
| print(f"Loss density: {loss_density:.8f} W/mm³") | ||
|
|
||
| # Equivalent DC resistance | ||
| resistance = total_loss / (total_current**2) | ||
| resistance_micro = resistance * 1e6 | ||
| print(f"Equivalent DC resistance: {resistance_micro:.2f} µΩ") | ||
|
|
||
| # Skin depth calculation | ||
| mu0 = 4 * math.pi * 1e-7 | ||
| sigma_cu = 5.8e7 | ||
| omega = 2 * math.pi * FREQ | ||
| skin_depth_m = math.sqrt(2 / (omega * mu0 * sigma_cu)) | ||
| skin_depth_mm = skin_depth_m * 1000 | ||
| print(f"Skin depth at {FREQ} Hz: {skin_depth_mm:.3f} mm") | ||
|
|
||
| current_density = total_current / (BUSBAR_W * BUSBAR_H) | ||
| print(f"Average current density: {current_density:.2f} A/mm²") | ||
|
|
||
| power_per_amp_squared = total_loss / (total_current**2) | ||
| print(f"Power per A²: {power_per_amp_squared*1e6:.2f} µW/A²") | ||
|
|
||
| # Comparison with conductor thickness | ||
| if BUSBAR_H < 2 * skin_depth_mm: | ||
| print( | ||
| f"Note: Busbar thickness ({BUSBAR_H}mm) < 2×skin depth ({2*skin_depth_mm:.1f}mm)" | ||
| ) | ||
| print(f" Skin effect is significant - current distribution is non-uniform") | ||
| else: | ||
| print( | ||
| f"Note: Busbar thickness ({BUSBAR_H}mm) > 2×skin depth ({2*skin_depth_mm:.1f}mm)" | ||
| ) | ||
| print(f" Current flows mainly near surfaces due to skin effect") | ||
|
|
||
| print("\n--- Field Plot Information ---") | ||
| print("Current density magnitude (|J|): Shows current distribution") | ||
| print("Electric field magnitude (|E|): Shows electric field intensity") | ||
| print("Joule heating distribution: Shows power loss density") | ||
|
|
||
| # %% [markdown] | ||
| # ## 12. Save Project and Release Resources | ||
| # Save the analysis project and clean up AEDT resources. | ||
|
|
||
| # %% | ||
| print(f"\n--- Saving Project ---") | ||
| m3d.save_project(project_path) | ||
| print(f"Project saved to: {project_path}") | ||
|
|
||
| m3d.release_desktop(close_projects=True, close_desktop=True) | ||
| time.sleep(2) | ||
|
|
||
| # %% [markdown] | ||
| # ## 13. Conclusion | ||
| # This example demonstrated the complete workflow for busbar Joule heating analysis using Maxwell 3D | ||
| # and PyAEDT. The analysis captured frequency-dependent phenomena including skin effect, current | ||
| # redistribution, and AC losses. Key outputs included power loss calculations, field visualizations, | ||
| # and technical metrics essential for thermal management and design optimization. | ||
| # The example demonstrates: | ||
| # Eddy current distribution in a busbar at AC frequency | ||
| # Joule heating due to AC resistance and skin effect | ||
| # Non-uniform current density due to skin effect | ||
| # Relationship between frequency, skin depth, and power loss | ||
|
|
||
| # %% | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmalinve Ready for review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gchaturve: Great to have you contributing to the examples! Could you please take a look at the template we've tried to use for the examples? We still have not updated all the examples to match the template. That is an important task though.
The numbering of sections seems like a good idea, but the overall workflow should use at least H2 and H3 levels as was shown in the template: 1. Setup, 2. Solve, 3. Evaluate results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thankyou @Devin-Crawford I'll review the template and align my example with the required H2/H3 section levels (Setup, Solve and Evaluate Results)
I'll update it shortly to ensure it matches the structure and conventions shown in the template