-
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
Open
gchaturve
wants to merge
10
commits into
main
Choose a base branch
from
example/busbar_joule_heating
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cde34eb
first-draft
gchaturve fb494dc
ADD: Implement Maxwell 3D multi-terminal busbar Joule heating analysi…
gchaturve 95c57b0
Created busbar joule heating example
gchaturve 0605f8f
DELETE: Remove busbar Joule heating example script and add .vscode to…
gchaturve 43dc1fe
Merge branch 'main' into example/busbar_joule_heating
gchaturve 59d57f3
Merge branch 'main' into example/busbar_joule_heating
gchaturve 417fb70
Convert busbar_joule_heating.py to template format
gchaturve 4d6b38f
Remove wpt(wireless_power_transfer) and .gitignore files
gchaturve 36222a8
Remove wpt(wireless_power_transfer) from Git tracking - work in progr…
gchaturve 085b541
Fixed example alligned it with the template , also refactored the pri…
gchaturve File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/ | ||
355 changes: 355 additions & 0 deletions
355
examples/low_frequency/magnetic/busbar_joule_heating.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,355 @@ | ||
| # # 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. | ||
| # | ||
| # Keywords: **Maxwell 3D**, **Eddy Current**, **Joule Heating**, **Skin Effect** | ||
|
|
||
| # ## Prerequisites | ||
| # | ||
| # ### Perform imports | ||
|
|
||
| # + | ||
| import math | ||
| import os | ||
| import tempfile | ||
| import time | ||
|
|
||
| from ansys.aedt.core import Maxwell3d | ||
| # - | ||
|
|
||
| # ### Define constants | ||
| # 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") | ||
|
|
||
| # ### Create temporary directory | ||
| # | ||
| # Create a temporary working directory. | ||
| # The name of the working folder is stored in ``temp_folder.name``. | ||
| # | ||
| # > **Note:** The final cell in the notebook cleans up the temporary folder. If you want to | ||
| # > retrieve the AEDT project and data, do so before executing the final cell in the notebook. | ||
|
|
||
| temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") | ||
| project_path = os.path.join(temp_folder.name, PROJECT_NAME) | ||
|
|
||
| # ### Launch application | ||
| # | ||
| # Start Maxwell 3D with eddy current solution type and set model units. | ||
|
|
||
| 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") | ||
|
|
||
| # ## Model Preparation | ||
| # | ||
| # Create the main busbar conductor and terminal tabs, then unite them into a single object. | ||
|
|
||
| # ### Create 3D model | ||
| # | ||
| 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") | ||
|
|
||
| # ### Assign boundary conditions | ||
| # | ||
| # 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") | ||
|
|
||
| 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") | ||
| # - | ||
|
|
||
| # ### Define solution 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") | ||
| # - | ||
|
|
||
| # ### 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") | ||
|
|
||
| # ## Postprocess | ||
| # | ||
| # Get Ohmic loss (Joule heating) results from the electromagnetic field solution. | ||
|
|
||
| # ### Evaluate loss | ||
| # | ||
| # + | ||
| 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") | ||
| # - | ||
|
|
||
| # ### Visualize fields | ||
| # | ||
| # 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") | ||
|
|
||
| # 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") | ||
| # - | ||
|
|
||
| # ## Finish | ||
| # | ||
| # ### Save the project | ||
|
|
||
| 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) | ||
| # Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory. | ||
| time.sleep(3) | ||
|
|
||
| # ### Clean up | ||
| # | ||
| # All project files are saved in the folder ``temp_folder.name``. | ||
| # If you've run this example as a Jupyter notebook, you | ||
| # can retrieve those project files. The following cell | ||
| # removes all temporary files, including the project folder. | ||
|
|
||
| temp_folder.cleanup() | ||
|
|
||
| # ## 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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