From cde34eb402546c76a038e7b28300201aee3d49d7 Mon Sep 17 00:00:00 2001 From: Garima Chaturvedi Date: Mon, 25 Aug 2025 12:15:02 +0530 Subject: [PATCH 1/8] first-draft --- .../general/busbar__joule_heating.py | 255 ++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 examples/low_frequency/general/busbar__joule_heating.py diff --git a/examples/low_frequency/general/busbar__joule_heating.py b/examples/low_frequency/general/busbar__joule_heating.py new file mode 100644 index 000000000..6f9e6a0df --- /dev/null +++ b/examples/low_frequency/general/busbar__joule_heating.py @@ -0,0 +1,255 @@ +# Copyright (C) 2025 ANSYS, Inc. and/or its affiliates. +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# %% [markdown] +# # Maxwell 3D: Multi-Terminal Busbar Joule Heating Analysis +# +# This comprehensive example demonstrates electromagnetic analysis of a multi-terminal copper busbar +# system using ANSYS Maxwell 3D and PyAEDT. The analysis covers current distribution, electromagnetic +# fields, and Joule heating in AC power distribution systems. +# +# ## Problem Overview +# +# We analyze a copper busbar system with the following configuration: +# - **Main Busbar**: 100mm × 10mm × 5mm rectangular conductor +# - **Input Terminals**: Two parallel 2mm × 5mm × 5mm copper tabs +# - **Output Terminal**: Single 2mm × 5mm × 5mm copper tab +# - **Current Configuration**: 100A + 100A input, 200A output +# - **Frequency**: 50Hz AC industrial power frequency +# +# ## Engineering Applications +# - **Power Distribution**: Electrical panel and switchgear design +# - **Thermal Management**: Heat dissipation and cooling system design +# - **Current Rating**: Safe operating current determination +# - **EMI/EMC Analysis**: Electromagnetic interference assessment +# - **Material Optimization**: Conductor sizing and configuration + +# %% [markdown] +# ## Theoretical Background +# +# ### Maxwell's Equations for Eddy Current Analysis +# +# The analysis is based on Maxwell's equations in the frequency domain for conducting materials: +# +# - **Faraday's Law**: ∇ × **E** = -jω**B** +# - **Ampère's Law**: ∇ × **H** = **J** + jω**D** +# - **Current Density**: **J** = σ**E** (Ohm's Law) +# - **Constitutive Relations**: **B** = μ**H**, **D** = ε**E** +# +# ### Joule Heating Physics +# +# **Power Dissipation**: P = ∫ **J**·**E** dV = ∫ σ|**E**|² dV +# +# Where: +# - **J** = Current density vector (A/m²) +# - **E** = Electric field vector (V/m) +# - σ = Electrical conductivity (S/m) +# - ω = Angular frequency = 2πf +# +# ### Skin Effect +# +# At AC frequencies, current concentrates near conductor surfaces with skin depth: +# +# **δ = √(2/(ωμσ))** +# +# For copper at 50Hz: δ ≈ 9.3mm, indicating significant skin effect in our geometry. + +# %% [markdown] +# ### 1. Import Required Libraries and Initialize Maxwell 3D +# +# Import PyAEDT and initialize Maxwell 3D with eddy current solver for AC electromagnetic analysis. + +# %% +from ansys.aedt.core import Maxwell3d + +# Initialize Maxwell 3D with eddy current solution type +m3d = Maxwell3d( + version="2025.1", + design="Busbar_JouleHeating", + solution_type="EddyCurrent" +) + +# %% [markdown] +# ### 2. Geometry Creation and Material Assignment +# +# Create the 3D busbar geometry with multiple terminals representing a realistic power distribution scenario. +# +# #### Geometry Specifications: +# - **Main Busbar**: Central current-carrying conductor +# - **Input Tabs**: Two parallel connection points for incoming current +# - **Output Tab**: Single connection point for outgoing current +# - **Material**: High-conductivity copper (σ ≈ 5.8 × 10⁷ S/m) + +# %% +# Create main busbar conductor +busbar = m3d.modeler.create_box([0, 0, 0], [100, 10, 5], "Busbar") +m3d.assign_material(busbar, "copper") + +# Create input terminals (parallel configuration) +tab1 = m3d.modeler.create_box([-2, 0, 0], [2, 5, 5], "InputTab1") +tab2 = m3d.modeler.create_box([-2, 5, 0], [2, 5, 5], "InputTab2") +m3d.assign_material(tab1, "copper") +m3d.assign_material(tab2, "copper") + +# Create output terminal +tab_out = m3d.modeler.create_box([100, 2.5, 0], [2, 5, 5], "OutputTab") +m3d.assign_material(tab_out, "copper") + +# %% [markdown] +# ### 3. Current Excitation and Boundary Conditions +# +# Apply AC current excitations to simulate realistic power distribution scenarios. +# +# #### Current Configuration: +# - **Input Currents**: 100A @ 0° phase (each input tab) +# - **Output Current**: 200A @ 180° phase (current conservation) +# - **Frequency**: 50Hz industrial power frequency +# +# This configuration represents a parallel input, single output power distribution system. + +# %% +# Apply current excitation to input terminals +m3d.assign_current(tab1.faces[0].id, amplitude=100, phase=0) +m3d.assign_current(tab2.faces[0].id, amplitude=100, phase=0) + +# Apply return current to output terminal +m3d.assign_current(tab_out.faces[0].id, amplitude=-200, phase=0) + +# %% [markdown] +# ### 4. Analysis Setup and Solver Configuration +# +# Configure the eddy current solver for accurate electromagnetic field calculation at power frequency. +# +# #### Solver Parameters: +# - **Solution Type**: Eddy Current (frequency domain) +# - **Frequency**: 50Hz (where skin effect becomes significant) +# - **Solver**: Iterative matrix solver optimized for electromagnetic problems + +# %% +# Create analysis setup +setup = m3d.create_setup("Setup1") +setup.props["Frequency"] = "50Hz" + +# %% [markdown] +# ### 5. Electromagnetic Field Solution +# +# Execute the finite element analysis to solve Maxwell's equations throughout the conductor domain. +# +# #### Computational Process: +# 1. **Mesh Generation**: Automatic adaptive mesh refinement +# 2. **Matrix Assembly**: Finite element system matrix construction +# 3. **Iterative Solution**: Conjugate gradient solver for large sparse systems +# 4. **Field Calculation**: Electric and magnetic field computation +# 5. **Convergence Check**: Solution accuracy verification + +# %% +# Solve the electromagnetic problem +m3d.analyze() + +# %% [markdown] +# ### 6. Field Visualization and Post-Processing +# +# Generate field plots to visualize electromagnetic phenomena and current distribution patterns. +# +# #### Visualization Results: +# - **Electric Field Magnitude**: Shows regions of high electric stress and potential gradients +# - **Current Density**: Reveals current flow patterns and skin effect distribution +# +# These visualizations are critical for: +# - Understanding current crowding effects +# - Identifying hot spots for thermal management +# - Optimizing conductor geometry + +# %% +# Create electric field magnitude plot +m3d.post.create_fieldplot_surface(busbar, "Mag_E") + +# Create current density plot +m3d.post.create_fieldplot_surface(busbar, "J") + +# %% [markdown] +# ### 7. Joule Heating Loss Calculation +# +# Calculate and quantify the resistive power losses (Joule heating) in the conductor system. +# +# #### Power Loss Physics: +# - **Ohmic Loss**: P = ∫ σ|E|² dV over conductor volume +# - **Units**: Power dissipated in watts (W) +# - **Engineering Significance**: Critical for thermal design and cooling requirements +# +# The calculated losses provide essential data for: +# - Temperature rise prediction +# - Cooling system sizing +# - Current derating calculations + +# %% +# Create ohmic loss report +report_name = "OhmicLossReport" +m3d.post.create_report( + expressions="Ohmic_Loss", + report_category="EddyCurrent", + plotname=report_name +) +data = m3d.post.get_report_data(report_name) + +# Extract and display results with engineering context +if data and data.data_magnitude(): + total_loss = data.data_magnitude()[0] + loss_per_amp_squared = total_loss / (200**2) # Loss per A² + loss_density = total_loss / (100 * 10 * 5) # Loss per unit volume (W/mm³) + + print(f"=== JOULE HEATING ANALYSIS RESULTS ===") + print(f"Total Joule Heating Loss: {total_loss:.3f} W") + print(f"Loss per unit current²: {loss_per_amp_squared*1e6:.3f} μW/A²") + print(f"Loss density: {loss_density:.6f} W/mm³") + print(f"Equivalent resistance: {total_loss/(200**2):.6f} Ω") +else: + print("Warning: No Ohmic Loss data found in simulation results.") + +# %% [markdown] +# ### 8. Project Save and Resource Management +# +# Save the complete analysis for future reference and properly release computational resources. + +# %% +# Save project with all results +m3d.save_project("Busbar_JouleHeating.aedt") + +# Release computational resources +m3d.release_desktop(True, True) + +# %% [markdown] +# ## Results Analysis +# +# ### Key Findings +# +# 1. **Current Distribution**: The dual-input configuration creates non-uniform current density +# 2. **Skin Effect**: At 50Hz, current concentration near surfaces increases resistance +# 3. **Joule Heating**: Power losses are concentrated at connection points and current transitions +# 4. **Field Concentration**: Electric field peaks occur at geometric discontinuities +# +# ## Conclusion +# +# This Maxwell 3D analysis successfully demonstrates: +# +# 1. **Comprehensive Modeling**: Multi-terminal busbar with realistic geometry and excitation +# 2. **Physics-Based Results**: Accurate electromagnetic field and loss calculations +# 3. **Engineering Applications**: Practical design insights for power systems +# 4. **Professional Workflow**: Industry-standard simulation methodology +# +# The calculated Joule heating provides essential data for thermal design, current rating, +# and safety assessment of electrical power distribution systems. This workflow can be +# extended for parametric studies, optimization, and coupled thermal analysis. +# +# This analysis demonstrates the power of PyAEDT for electromagnetic engineering and +# provides a solid foundation for advanced busbar design applications. From fb494dc867207cb2f151ccb9f098ec2b6866a616 Mon Sep 17 00:00:00 2001 From: Garima Chaturvedi Date: Mon, 1 Sep 2025 15:05:00 +0530 Subject: [PATCH 2/8] ADD: Implement Maxwell 3D multi-terminal busbar Joule heating analysis example --- .../magnetic/busbar_joule_heating.py | 256 ++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 examples/low_frequency/magnetic/busbar_joule_heating.py diff --git a/examples/low_frequency/magnetic/busbar_joule_heating.py b/examples/low_frequency/magnetic/busbar_joule_heating.py new file mode 100644 index 000000000..fa8893e5f --- /dev/null +++ b/examples/low_frequency/magnetic/busbar_joule_heating.py @@ -0,0 +1,256 @@ +# %% +# Copyright (C) 2025 ANSYS, Inc. and/or its affiliates. +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# %% [markdown] +# # Maxwell 3D: Multi-Terminal Busbar Joule Heating Analysis +# +# This comprehensive example demonstrates electromagnetic analysis of a multi-terminal copper busbar +# system using ANSYS Maxwell 3D and PyAEDT. The analysis covers current distribution, electromagnetic +# fields, and Joule heating in AC power distribution systems. +# +# ## Problem Overview +# +# We analyze a copper busbar system with the following configuration: +# - **Main Busbar**: 100mm × 10mm × 5mm rectangular conductor +# - **Input Terminals**: Two parallel 2mm × 5mm × 5mm copper tabs +# - **Output Terminal**: Single 2mm × 5mm × 5mm copper tab +# - **Current Configuration**: 100A + 100A input, 200A output +# - **Frequency**: 50Hz AC industrial power frequency +# +# ## Engineering Applications +# - **Power Distribution**: Electrical panel and switchgear design +# - **Thermal Management**: Heat dissipation and cooling system design +# - **Current Rating**: Safe operating current determination +# - **EMI/EMC Analysis**: Electromagnetic interference assessment +# - **Material Optimization**: Conductor sizing and configuration + +# %% [markdown] +# ## Theoretical Background +# +# ### Maxwell's Equations for Eddy Current Analysis +# +# The analysis is based on Maxwell's equations in the frequency domain for conducting materials: +# +# - **Faraday's Law**: ∇ × **E** = -jω**B** +# - **Ampère's Law**: ∇ × **H** = **J** + jω**D** +# - **Current Density**: **J** = σ**E** (Ohm's Law) +# - **Constitutive Relations**: **B** = μ**H**, **D** = ε**E** +# +# ### Joule Heating Physics +# +# **Power Dissipation**: P = ∫ **J**·**E** dV = ∫ σ|**E**|² dV +# +# Where: +# - **J** = Current density vector (A/m²) +# - **E** = Electric field vector (V/m) +# - σ = Electrical conductivity (S/m) +# - ω = Angular frequency = 2πf +# +# ### Skin Effect +# +# At AC frequencies, current concentrates near conductor surfaces with skin depth: +# +# **δ = √(2/(ωμσ))** +# +# For copper at 50Hz: δ ≈ 9.3mm, indicating significant skin effect in our geometry. + +# %% [markdown] +# ### 1. Import Required Libraries and Initialize Maxwell 3D +# +# Import PyAEDT and initialize Maxwell 3D with eddy current solver for AC electromagnetic analysis. + +# %% +from ansys.aedt.core import Maxwell3d + +# Initialize Maxwell 3D with eddy current solution type +m3d = Maxwell3d( + version="2025.1", + design="Busbar_JouleHeating", + solution_type="EddyCurrent" +) + +# %% [markdown] +# ### 2. Geometry Creation and Material Assignment +# +# Create the 3D busbar geometry with multiple terminals representing a realistic power distribution scenario. +# +# #### Geometry Specifications: +# - **Main Busbar**: Central current-carrying conductor +# - **Input Tabs**: Two parallel connection points for incoming current +# - **Output Tab**: Single connection point for outgoing current +# - **Material**: High-conductivity copper (σ ≈ 5.8 × 10⁷ S/m) + +# %% +# Create main busbar conductor +busbar = m3d.modeler.create_box([0, 0, 0], [100, 10, 5], "Busbar") +m3d.assign_material(busbar, "copper") + +# Create input terminals (parallel configuration) +tab1 = m3d.modeler.create_box([-2, 0, 0], [2, 5, 5], "InputTab1") +tab2 = m3d.modeler.create_box([-2, 5, 0], [2, 5, 5], "InputTab2") +m3d.assign_material(tab1, "copper") +m3d.assign_material(tab2, "copper") + +# Create output terminal +tab_out = m3d.modeler.create_box([100, 2.5, 0], [2, 5, 5], "OutputTab") +m3d.assign_material(tab_out, "copper") + +# %% [markdown] +# ### 3. Current Excitation and Boundary Conditions +# +# Apply AC current excitations to simulate realistic power distribution scenarios. +# +# #### Current Configuration: +# - **Input Currents**: 100A @ 0° phase (each input tab) +# - **Output Current**: 200A @ 180° phase (current conservation) +# - **Frequency**: 50Hz industrial power frequency +# +# This configuration represents a parallel input, single output power distribution system. + +# %% +# Apply current excitation to input terminals +m3d.assign_current(tab1.faces[0].id, amplitude=100, phase=0) +m3d.assign_current(tab2.faces[0].id, amplitude=100, phase=0) + +# Apply return current to output terminal +m3d.assign_current(tab_out.faces[0].id, amplitude=-200, phase=0) + +# %% [markdown] +# ### 4. Analysis Setup and Solver Configuration +# +# Configure the eddy current solver for accurate electromagnetic field calculation at power frequency. +# +# #### Solver Parameters: +# - **Solution Type**: Eddy Current (frequency domain) +# - **Frequency**: 50Hz (where skin effect becomes significant) +# - **Solver**: Iterative matrix solver optimized for electromagnetic problems + +# %% +# Create analysis setup +setup = m3d.create_setup("Setup1") +setup.props["Frequency"] = "50Hz" + +# %% [markdown] +# ### 5. Electromagnetic Field Solution +# +# Execute the finite element analysis to solve Maxwell's equations throughout the conductor domain. +# +# #### Computational Process: +# 1. **Mesh Generation**: Automatic adaptive mesh refinement +# 2. **Matrix Assembly**: Finite element system matrix construction +# 3. **Iterative Solution**: Conjugate gradient solver for large sparse systems +# 4. **Field Calculation**: Electric and magnetic field computation +# 5. **Convergence Check**: Solution accuracy verification + +# %% +# Solve the electromagnetic problem +m3d.analyze() + +# %% [markdown] +# ### 6. Field Visualization and Post-Processing +# +# Generate field plots to visualize electromagnetic phenomena and current distribution patterns. +# +# #### Visualization Results: +# - **Electric Field Magnitude**: Shows regions of high electric stress and potential gradients +# - **Current Density**: Reveals current flow patterns and skin effect distribution +# +# These visualizations are critical for: +# - Understanding current crowding effects +# - Identifying hot spots for thermal management +# - Optimizing conductor geometry + +# %% +# Create electric field magnitude plot +m3d.post.create_fieldplot_surface(busbar, "Mag_E") + +# Create current density plot +m3d.post.create_fieldplot_surface(busbar, "J") + +# %% [markdown] +# ### 7. Joule Heating Loss Calculation +# +# Calculate and quantify the resistive power losses (Joule heating) in the conductor system. +# +# #### Power Loss Physics: +# - **Ohmic Loss**: P = ∫ σ|E|² dV over conductor volume +# - **Units**: Power dissipated in watts (W) +# - **Engineering Significance**: Critical for thermal design and cooling requirements +# +# The calculated losses provide essential data for: +# - Temperature rise prediction +# - Cooling system sizing +# - Current derating calculations + +# %% +# Create ohmic loss report +report_name = "OhmicLossReport" +m3d.post.create_report( + expressions="Ohmic_Loss", + report_category="EddyCurrent", + plotname=report_name +) +data = m3d.post.get_report_data(report_name) + +# Extract and display results with engineering context +if data and data.data_magnitude(): + total_loss = data.data_magnitude()[0] + loss_per_amp_squared = total_loss / (200**2) # Loss per A² + loss_density = total_loss / (100 * 10 * 5) # Loss per unit volume (W/mm³) + + print(f"=== JOULE HEATING ANALYSIS RESULTS ===") + print(f"Total Joule Heating Loss: {total_loss:.3f} W") + print(f"Loss per unit current²: {loss_per_amp_squared*1e6:.3f} μW/A²") + print(f"Loss density: {loss_density:.6f} W/mm³") + print(f"Equivalent resistance: {total_loss/(200**2):.6f} Ω") +else: + print("Warning: No Ohmic Loss data found in simulation results.") + +# %% [markdown] +# ### 8. Project Save and Resource Management +# +# Save the complete analysis for future reference and properly release computational resources. + +# %% +# Save project with all results +m3d.save_project("Busbar_JouleHeating.aedt") + +# Release computational resources +m3d.release_desktop(True, True) + +# %% [markdown] +# ## Results Analysis +# +# ### Key Findings +# +# 1. **Current Distribution**: The dual-input configuration creates non-uniform current density +# 2. **Skin Effect**: At 50Hz, current concentration near surfaces increases resistance +# 3. **Joule Heating**: Power losses are concentrated at connection points and current transitions +# 4. **Field Concentration**: Electric field peaks occur at geometric discontinuities +# +# ## Conclusion +# +# This Maxwell 3D analysis successfully demonstrates: +# +# 1. **Comprehensive Modeling**: Multi-terminal busbar with realistic geometry and excitation +# 2. **Physics-Based Results**: Accurate electromagnetic field and loss calculations +# 3. **Engineering Applications**: Practical design insights for power systems +# 4. **Professional Workflow**: Industry-standard simulation methodology +# +# The calculated Joule heating provides essential data for thermal design, current rating, +# and safety assessment of electrical power distribution systems. This workflow can be +# extended for parametric studies, optimization, and coupled thermal analysis. +# +# This analysis demonstrates the power of PyAEDT for electromagnetic engineering and +# provides a solid foundation for advanced busbar design applications. From 95c57b02fd63aab095182d5a5a3eadf39f0b78d3 Mon Sep 17 00:00:00 2001 From: Garima Chaturvedi Date: Mon, 22 Sep 2025 14:42:21 +0530 Subject: [PATCH 3/8] Created busbar joule heating example --- .vscode/settings.json | 7 + .../magnetic/busbar_joule_heating.py | 485 +++++++++++------- 2 files changed, 293 insertions(+), 199 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..92d87fad0 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.testing.pytestArgs": [ + "examples" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} \ No newline at end of file diff --git a/examples/low_frequency/magnetic/busbar_joule_heating.py b/examples/low_frequency/magnetic/busbar_joule_heating.py index fa8893e5f..2e56efc62 100644 --- a/examples/low_frequency/magnetic/busbar_joule_heating.py +++ b/examples/low_frequency/magnetic/busbar_joule_heating.py @@ -1,256 +1,343 @@ -# %% -# Copyright (C) 2025 ANSYS, Inc. and/or its affiliates. -# SPDX-License-Identifier: MIT -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. - # %% [markdown] -# # Maxwell 3D: Multi-Terminal Busbar Joule Heating Analysis -# -# This comprehensive example demonstrates electromagnetic analysis of a multi-terminal copper busbar -# system using ANSYS Maxwell 3D and PyAEDT. The analysis covers current distribution, electromagnetic -# fields, and Joule heating in AC power distribution systems. -# -# ## Problem Overview -# -# We analyze a copper busbar system with the following configuration: -# - **Main Busbar**: 100mm × 10mm × 5mm rectangular conductor -# - **Input Terminals**: Two parallel 2mm × 5mm × 5mm copper tabs -# - **Output Terminal**: Single 2mm × 5mm × 5mm copper tab -# - **Current Configuration**: 100A + 100A input, 200A output -# - **Frequency**: 50Hz AC industrial power frequency -# -# ## Engineering Applications -# - **Power Distribution**: Electrical panel and switchgear design -# - **Thermal Management**: Heat dissipation and cooling system design -# - **Current Rating**: Safe operating current determination -# - **EMI/EMC Analysis**: Electromagnetic interference assessment -# - **Material Optimization**: Conductor sizing and configuration - -# %% [markdown] -# ## Theoretical Background -# -# ### Maxwell's Equations for Eddy Current Analysis -# -# The analysis is based on Maxwell's equations in the frequency domain for conducting materials: +# # Busbar Joule Heating Analysis with Maxwell 3D # -# - **Faraday's Law**: ∇ × **E** = -jω**B** -# - **Ampère's Law**: ∇ × **H** = **J** + jω**D** -# - **Current Density**: **J** = σ**E** (Ohm's Law) -# - **Constitutive Relations**: **B** = μ**H**, **D** = ε**E** +# Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates. +# SPDX-License-Identifier: MIT # -# ### Joule Heating Physics +# ## Overview # -# **Power Dissipation**: P = ∫ **J**·**E** dV = ∫ σ|**E**|² dV +# 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: # -# Where: -# - **J** = Current density vector (A/m²) -# - **E** = Electric field vector (V/m) -# - σ = Electrical conductivity (S/m) -# - ω = Angular frequency = 2πf +# - 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 # -# ### Skin Effect +# ## Core Concepts and Principles # -# At AC frequencies, current concentrates near conductor surfaces with skin depth: +# **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. # -# **δ = √(2/(ωμσ))** +# 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 # -# For copper at 50Hz: δ ≈ 9.3mm, indicating significant skin effect in our geometry. +# This example demonstrates the complete electromagnetic analysis workflow for conductor systems. # %% [markdown] -# ### 1. Import Required Libraries and Initialize Maxwell 3D -# -# Import PyAEDT and initialize Maxwell 3D with eddy current solver for AC electromagnetic analysis. +# ## 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 -# Initialize Maxwell 3D with eddy current solution type +# %% [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( - version="2025.1", + project=project_path, + version=AEDT_VERSION, design="Busbar_JouleHeating", - solution_type="EddyCurrent" + solution_type="Eddy Current", + new_desktop=True, + non_graphical=NG_MODE, ) +m3d.modeler.model_units = "mm" +print("Maxwell 3D initialized") # %% [markdown] -# ### 2. Geometry Creation and Material Assignment -# -# Create the 3D busbar geometry with multiple terminals representing a realistic power distribution scenario. -# -# #### Geometry Specifications: -# - **Main Busbar**: Central current-carrying conductor -# - **Input Tabs**: Two parallel connection points for incoming current -# - **Output Tab**: Single connection point for outgoing current -# - **Material**: High-conductivity copper (σ ≈ 5.8 × 10⁷ S/m) +# ## 4. Create Busbar Geometry +# Create the main busbar conductor and terminal tabs, then unite them into a single object. # %% -# Create main busbar conductor -busbar = m3d.modeler.create_box([0, 0, 0], [100, 10, 5], "Busbar") +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") -# Create input terminals (parallel configuration) -tab1 = m3d.modeler.create_box([-2, 0, 0], [2, 5, 5], "InputTab1") -tab2 = m3d.modeler.create_box([-2, 5, 0], [2, 5, 5], "InputTab2") -m3d.assign_material(tab1, "copper") -m3d.assign_material(tab2, "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") -# Create output terminal -tab_out = m3d.modeler.create_box([100, 2.5, 0], [2, 5, 5], "OutputTab") -m3d.assign_material(tab_out, "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] -# ### 3. Current Excitation and Boundary Conditions -# -# Apply AC current excitations to simulate realistic power distribution scenarios. -# -# #### Current Configuration: -# - **Input Currents**: 100A @ 0° phase (each input tab) -# - **Output Current**: 200A @ 180° phase (current conservation) -# - **Frequency**: 50Hz industrial power frequency -# -# This configuration represents a parallel input, single output power distribution system. +# ## 5. Define Current Excitations +# Select terminal faces and assign current excitations following Kirchhoff's current law. # %% -# Apply current excitation to input terminals -m3d.assign_current(tab1.faces[0].id, amplitude=100, phase=0) -m3d.assign_current(tab2.faces[0].id, amplitude=100, phase=0) +print("\nSelecting Terminal Faces") -# Apply return current to output terminal -m3d.assign_current(tab_out.faces[0].id, amplitude=-200, phase=0) +# 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] -# ### 4. Analysis Setup and Solver Configuration -# -# Configure the eddy current solver for accurate electromagnetic field calculation at power frequency. -# -# #### Solver Parameters: -# - **Solution Type**: Eddy Current (frequency domain) -# - **Frequency**: 50Hz (where skin effect becomes significant) -# - **Solver**: Iterative matrix solver optimized for electromagnetic problems +# ## 6. Create Air Region +# Define the air region that provides boundary conditions for the electromagnetic field solution. # %% -# Create analysis setup -setup = m3d.create_setup("Setup1") -setup.props["Frequency"] = "50Hz" +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] -# ### 5. Electromagnetic Field Solution -# -# Execute the finite element analysis to solve Maxwell's equations throughout the conductor domain. -# -# #### Computational Process: -# 1. **Mesh Generation**: Automatic adaptive mesh refinement -# 2. **Matrix Assembly**: Finite element system matrix construction -# 3. **Iterative Solution**: Conjugate gradient solver for large sparse systems -# 4. **Field Calculation**: Electric and magnetic field computation -# 5. **Convergence Check**: Solution accuracy verification +# ## 7. Configure Analysis Setup +# Set up the eddy current analysis with frequency, convergence criteria, and mesh settings. # %% -# Solve the electromagnetic problem -m3d.analyze() +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] -# ### 6. Field Visualization and Post-Processing -# -# Generate field plots to visualize electromagnetic phenomena and current distribution patterns. -# -# #### Visualization Results: -# - **Electric Field Magnitude**: Shows regions of high electric stress and potential gradients -# - **Current Density**: Reveals current flow patterns and skin effect distribution -# -# These visualizations are critical for: -# - Understanding current crowding effects -# - Identifying hot spots for thermal management -# - Optimizing conductor geometry +# ## 8. Run Analysis +# Execute the finite element solver with automatic adaptive mesh refinement. # %% -# Create electric field magnitude plot -m3d.post.create_fieldplot_surface(busbar, "Mag_E") +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'}") -# Create current density plot -m3d.post.create_fieldplot_surface(busbar, "J") +# Solve +m3d.analyze_setup(setup.name) +print("Analysis completed") # %% [markdown] -# ### 7. Joule Heating Loss Calculation -# -# Calculate and quantify the resistive power losses (Joule heating) in the conductor system. -# -# #### Power Loss Physics: -# - **Ohmic Loss**: P = ∫ σ|E|² dV over conductor volume -# - **Units**: Power dissipated in watts (W) -# - **Engineering Significance**: Critical for thermal design and cooling requirements -# -# The calculated losses provide essential data for: -# - Temperature rise prediction -# - Cooling system sizing -# - Current derating calculations +# ## 9. Extract Solution Data +# Get Ohmic loss (Joule heating) results from the electromagnetic field solution. # %% -# Create ohmic loss report -report_name = "OhmicLossReport" -m3d.post.create_report( - expressions="Ohmic_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", - plotname=report_name + 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", ) -data = m3d.post.get_report_data(report_name) - -# Extract and display results with engineering context -if data and data.data_magnitude(): - total_loss = data.data_magnitude()[0] - loss_per_amp_squared = total_loss / (200**2) # Loss per A² - loss_density = total_loss / (100 * 10 * 5) # Loss per unit volume (W/mm³) - - print(f"=== JOULE HEATING ANALYSIS RESULTS ===") - print(f"Total Joule Heating Loss: {total_loss:.3f} W") - print(f"Loss per unit current²: {loss_per_amp_squared*1e6:.3f} μW/A²") - print(f"Loss density: {loss_density:.6f} W/mm³") - print(f"Equivalent resistance: {total_loss/(200**2):.6f} Ω") +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("Warning: No Ohmic Loss data found in simulation results.") + 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] -# ### 8. Project Save and Resource Management -# -# Save the complete analysis for future reference and properly release computational resources. +# ## 12. Save Project and Release Resources +# Save the analysis project and clean up AEDT resources. # %% -# Save project with all results -m3d.save_project("Busbar_JouleHeating.aedt") +print(f"\n--- Saving Project ---") +m3d.save_project(project_path) +print(f"Project saved to: {project_path}") -# Release computational resources -m3d.release_desktop(True, True) +m3d.release_desktop(close_projects=True, close_desktop=True) +time.sleep(2) # %% [markdown] -# ## Results Analysis -# -# ### Key Findings -# -# 1. **Current Distribution**: The dual-input configuration creates non-uniform current density -# 2. **Skin Effect**: At 50Hz, current concentration near surfaces increases resistance -# 3. **Joule Heating**: Power losses are concentrated at connection points and current transitions -# 4. **Field Concentration**: Electric field peaks occur at geometric discontinuities -# -# ## Conclusion -# -# This Maxwell 3D analysis successfully demonstrates: -# -# 1. **Comprehensive Modeling**: Multi-terminal busbar with realistic geometry and excitation -# 2. **Physics-Based Results**: Accurate electromagnetic field and loss calculations -# 3. **Engineering Applications**: Practical design insights for power systems -# 4. **Professional Workflow**: Industry-standard simulation methodology -# -# The calculated Joule heating provides essential data for thermal design, current rating, -# and safety assessment of electrical power distribution systems. This workflow can be -# extended for parametric studies, optimization, and coupled thermal analysis. -# -# This analysis demonstrates the power of PyAEDT for electromagnetic engineering and -# provides a solid foundation for advanced busbar design applications. +# ## 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 + +# %% From 0605f8f207c14bd678f4d24d08a2a72ad181ed09 Mon Sep 17 00:00:00 2001 From: Garima Chaturvedi Date: Thu, 25 Sep 2025 13:42:08 +0530 Subject: [PATCH 4/8] DELETE: Remove busbar Joule heating example script and add .vscode to .gitignore --- .gitignore | 1 + .vscode/settings.json | 7 - .../general/busbar__joule_heating.py | 255 ------------------ 3 files changed, 1 insertion(+), 262 deletions(-) delete mode 100644 .vscode/settings.json delete mode 100644 examples/low_frequency/general/busbar__joule_heating.py diff --git a/.gitignore b/.gitignore index 6567db02e..8b14c1599 100644 --- a/.gitignore +++ b/.gitignore @@ -114,3 +114,4 @@ venv.bak/ # Generated example src/ansys/pyaedt/examples/simple_example.py +.vscode/ diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 92d87fad0..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "python.testing.pytestArgs": [ - "examples" - ], - "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true -} \ No newline at end of file diff --git a/examples/low_frequency/general/busbar__joule_heating.py b/examples/low_frequency/general/busbar__joule_heating.py deleted file mode 100644 index 6f9e6a0df..000000000 --- a/examples/low_frequency/general/busbar__joule_heating.py +++ /dev/null @@ -1,255 +0,0 @@ -# Copyright (C) 2025 ANSYS, Inc. and/or its affiliates. -# SPDX-License-Identifier: MIT -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. - -# %% [markdown] -# # Maxwell 3D: Multi-Terminal Busbar Joule Heating Analysis -# -# This comprehensive example demonstrates electromagnetic analysis of a multi-terminal copper busbar -# system using ANSYS Maxwell 3D and PyAEDT. The analysis covers current distribution, electromagnetic -# fields, and Joule heating in AC power distribution systems. -# -# ## Problem Overview -# -# We analyze a copper busbar system with the following configuration: -# - **Main Busbar**: 100mm × 10mm × 5mm rectangular conductor -# - **Input Terminals**: Two parallel 2mm × 5mm × 5mm copper tabs -# - **Output Terminal**: Single 2mm × 5mm × 5mm copper tab -# - **Current Configuration**: 100A + 100A input, 200A output -# - **Frequency**: 50Hz AC industrial power frequency -# -# ## Engineering Applications -# - **Power Distribution**: Electrical panel and switchgear design -# - **Thermal Management**: Heat dissipation and cooling system design -# - **Current Rating**: Safe operating current determination -# - **EMI/EMC Analysis**: Electromagnetic interference assessment -# - **Material Optimization**: Conductor sizing and configuration - -# %% [markdown] -# ## Theoretical Background -# -# ### Maxwell's Equations for Eddy Current Analysis -# -# The analysis is based on Maxwell's equations in the frequency domain for conducting materials: -# -# - **Faraday's Law**: ∇ × **E** = -jω**B** -# - **Ampère's Law**: ∇ × **H** = **J** + jω**D** -# - **Current Density**: **J** = σ**E** (Ohm's Law) -# - **Constitutive Relations**: **B** = μ**H**, **D** = ε**E** -# -# ### Joule Heating Physics -# -# **Power Dissipation**: P = ∫ **J**·**E** dV = ∫ σ|**E**|² dV -# -# Where: -# - **J** = Current density vector (A/m²) -# - **E** = Electric field vector (V/m) -# - σ = Electrical conductivity (S/m) -# - ω = Angular frequency = 2πf -# -# ### Skin Effect -# -# At AC frequencies, current concentrates near conductor surfaces with skin depth: -# -# **δ = √(2/(ωμσ))** -# -# For copper at 50Hz: δ ≈ 9.3mm, indicating significant skin effect in our geometry. - -# %% [markdown] -# ### 1. Import Required Libraries and Initialize Maxwell 3D -# -# Import PyAEDT and initialize Maxwell 3D with eddy current solver for AC electromagnetic analysis. - -# %% -from ansys.aedt.core import Maxwell3d - -# Initialize Maxwell 3D with eddy current solution type -m3d = Maxwell3d( - version="2025.1", - design="Busbar_JouleHeating", - solution_type="EddyCurrent" -) - -# %% [markdown] -# ### 2. Geometry Creation and Material Assignment -# -# Create the 3D busbar geometry with multiple terminals representing a realistic power distribution scenario. -# -# #### Geometry Specifications: -# - **Main Busbar**: Central current-carrying conductor -# - **Input Tabs**: Two parallel connection points for incoming current -# - **Output Tab**: Single connection point for outgoing current -# - **Material**: High-conductivity copper (σ ≈ 5.8 × 10⁷ S/m) - -# %% -# Create main busbar conductor -busbar = m3d.modeler.create_box([0, 0, 0], [100, 10, 5], "Busbar") -m3d.assign_material(busbar, "copper") - -# Create input terminals (parallel configuration) -tab1 = m3d.modeler.create_box([-2, 0, 0], [2, 5, 5], "InputTab1") -tab2 = m3d.modeler.create_box([-2, 5, 0], [2, 5, 5], "InputTab2") -m3d.assign_material(tab1, "copper") -m3d.assign_material(tab2, "copper") - -# Create output terminal -tab_out = m3d.modeler.create_box([100, 2.5, 0], [2, 5, 5], "OutputTab") -m3d.assign_material(tab_out, "copper") - -# %% [markdown] -# ### 3. Current Excitation and Boundary Conditions -# -# Apply AC current excitations to simulate realistic power distribution scenarios. -# -# #### Current Configuration: -# - **Input Currents**: 100A @ 0° phase (each input tab) -# - **Output Current**: 200A @ 180° phase (current conservation) -# - **Frequency**: 50Hz industrial power frequency -# -# This configuration represents a parallel input, single output power distribution system. - -# %% -# Apply current excitation to input terminals -m3d.assign_current(tab1.faces[0].id, amplitude=100, phase=0) -m3d.assign_current(tab2.faces[0].id, amplitude=100, phase=0) - -# Apply return current to output terminal -m3d.assign_current(tab_out.faces[0].id, amplitude=-200, phase=0) - -# %% [markdown] -# ### 4. Analysis Setup and Solver Configuration -# -# Configure the eddy current solver for accurate electromagnetic field calculation at power frequency. -# -# #### Solver Parameters: -# - **Solution Type**: Eddy Current (frequency domain) -# - **Frequency**: 50Hz (where skin effect becomes significant) -# - **Solver**: Iterative matrix solver optimized for electromagnetic problems - -# %% -# Create analysis setup -setup = m3d.create_setup("Setup1") -setup.props["Frequency"] = "50Hz" - -# %% [markdown] -# ### 5. Electromagnetic Field Solution -# -# Execute the finite element analysis to solve Maxwell's equations throughout the conductor domain. -# -# #### Computational Process: -# 1. **Mesh Generation**: Automatic adaptive mesh refinement -# 2. **Matrix Assembly**: Finite element system matrix construction -# 3. **Iterative Solution**: Conjugate gradient solver for large sparse systems -# 4. **Field Calculation**: Electric and magnetic field computation -# 5. **Convergence Check**: Solution accuracy verification - -# %% -# Solve the electromagnetic problem -m3d.analyze() - -# %% [markdown] -# ### 6. Field Visualization and Post-Processing -# -# Generate field plots to visualize electromagnetic phenomena and current distribution patterns. -# -# #### Visualization Results: -# - **Electric Field Magnitude**: Shows regions of high electric stress and potential gradients -# - **Current Density**: Reveals current flow patterns and skin effect distribution -# -# These visualizations are critical for: -# - Understanding current crowding effects -# - Identifying hot spots for thermal management -# - Optimizing conductor geometry - -# %% -# Create electric field magnitude plot -m3d.post.create_fieldplot_surface(busbar, "Mag_E") - -# Create current density plot -m3d.post.create_fieldplot_surface(busbar, "J") - -# %% [markdown] -# ### 7. Joule Heating Loss Calculation -# -# Calculate and quantify the resistive power losses (Joule heating) in the conductor system. -# -# #### Power Loss Physics: -# - **Ohmic Loss**: P = ∫ σ|E|² dV over conductor volume -# - **Units**: Power dissipated in watts (W) -# - **Engineering Significance**: Critical for thermal design and cooling requirements -# -# The calculated losses provide essential data for: -# - Temperature rise prediction -# - Cooling system sizing -# - Current derating calculations - -# %% -# Create ohmic loss report -report_name = "OhmicLossReport" -m3d.post.create_report( - expressions="Ohmic_Loss", - report_category="EddyCurrent", - plotname=report_name -) -data = m3d.post.get_report_data(report_name) - -# Extract and display results with engineering context -if data and data.data_magnitude(): - total_loss = data.data_magnitude()[0] - loss_per_amp_squared = total_loss / (200**2) # Loss per A² - loss_density = total_loss / (100 * 10 * 5) # Loss per unit volume (W/mm³) - - print(f"=== JOULE HEATING ANALYSIS RESULTS ===") - print(f"Total Joule Heating Loss: {total_loss:.3f} W") - print(f"Loss per unit current²: {loss_per_amp_squared*1e6:.3f} μW/A²") - print(f"Loss density: {loss_density:.6f} W/mm³") - print(f"Equivalent resistance: {total_loss/(200**2):.6f} Ω") -else: - print("Warning: No Ohmic Loss data found in simulation results.") - -# %% [markdown] -# ### 8. Project Save and Resource Management -# -# Save the complete analysis for future reference and properly release computational resources. - -# %% -# Save project with all results -m3d.save_project("Busbar_JouleHeating.aedt") - -# Release computational resources -m3d.release_desktop(True, True) - -# %% [markdown] -# ## Results Analysis -# -# ### Key Findings -# -# 1. **Current Distribution**: The dual-input configuration creates non-uniform current density -# 2. **Skin Effect**: At 50Hz, current concentration near surfaces increases resistance -# 3. **Joule Heating**: Power losses are concentrated at connection points and current transitions -# 4. **Field Concentration**: Electric field peaks occur at geometric discontinuities -# -# ## Conclusion -# -# This Maxwell 3D analysis successfully demonstrates: -# -# 1. **Comprehensive Modeling**: Multi-terminal busbar with realistic geometry and excitation -# 2. **Physics-Based Results**: Accurate electromagnetic field and loss calculations -# 3. **Engineering Applications**: Practical design insights for power systems -# 4. **Professional Workflow**: Industry-standard simulation methodology -# -# The calculated Joule heating provides essential data for thermal design, current rating, -# and safety assessment of electrical power distribution systems. This workflow can be -# extended for parametric studies, optimization, and coupled thermal analysis. -# -# This analysis demonstrates the power of PyAEDT for electromagnetic engineering and -# provides a solid foundation for advanced busbar design applications. From 417fb702b9ad4f3c5f7786bdfd8a33fb3bf70030 Mon Sep 17 00:00:00 2001 From: Garima Chaturvedi Date: Wed, 8 Oct 2025 00:15:35 +0530 Subject: [PATCH 5/8] Convert busbar_joule_heating.py to template format - Changed cell markers from # %% to # + and # - - Updated tmpdir to temp_folder for consistency - Reorganized sections to match template structure - Added temp_folder.cleanup() at end - Preserved all functionality and analysis content --- .../magnetic/busbar_joule_heating.py | 110 ++++++++++-------- 1 file changed, 61 insertions(+), 49 deletions(-) diff --git a/examples/low_frequency/magnetic/busbar_joule_heating.py b/examples/low_frequency/magnetic/busbar_joule_heating.py index 2e56efc62..030b49a56 100644 --- a/examples/low_frequency/magnetic/busbar_joule_heating.py +++ b/examples/low_frequency/magnetic/busbar_joule_heating.py @@ -1,4 +1,3 @@ -# %% [markdown] # # Busbar Joule Heating Analysis with Maxwell 3D # # Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates. @@ -28,24 +27,25 @@ # - 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** -# %% [markdown] -# ## 1. Perform Required Imports -# Import all necessary modules for the Maxwell 3D busbar analysis. +# ## Prerequisites +# +# ### Perform imports -# %% +# + import math import os import tempfile import time from ansys.aedt.core import Maxwell3d +# - -# %% [markdown] -# ## 2. Set Analysis Parameters +# ### 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" @@ -68,13 +68,20 @@ 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. +# ### 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. -# %% -tmpdir = tempfile.TemporaryDirectory(suffix=".ansys") -project_path = os.path.join(tmpdir.name, PROJECT_NAME) +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, @@ -87,11 +94,12 @@ m3d.modeler.model_units = "mm" print("Maxwell 3D initialized") -# %% [markdown] -# ## 4. Create Busbar Geometry +# ## 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 @@ -123,11 +131,11 @@ conductor.name = "CompleteBusbar" print(f"Created united conductor with {len(conductor.faces)} faces") -# %% [markdown] -# ## 5. Define Current Excitations +# ### 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 @@ -167,23 +175,19 @@ 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 +# ### 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") @@ -201,12 +205,12 @@ name="ConductorMesh", ) print("Mesh operation assigned") +# - -# %% [markdown] -# ## 8. Run Analysis +# ### 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)") @@ -217,11 +221,13 @@ m3d.analyze_setup(setup.name) print("Analysis completed") -# %% [markdown] -# ## 9. Extract Solution Data +# ## Postprocess +# # Get Ohmic loss (Joule heating) results from the electromagnetic field solution. -# %% +# ### Evaluate loss +# +# + print("\n--- Extracting Results ---") setup_sweep = f"{setup.name} : LastAdaptive" @@ -237,12 +243,13 @@ total_loss = solution_data.data_magnitude()[0] print(f"\nOhmic Loss (Joule heating): {total_loss:.6f} W") +# - -# %% [markdown] -# ## 10. Create Field Visualizations +# ### 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( @@ -262,11 +269,9 @@ ) print("Joule heating distribution plot created") -# %% [markdown] -# ## 11. Calculate Engineering Metrics +# Calculate engineering metrics # Compute key parameters including resistance, loss density, skin depth, and current density. -# %% print("\nANALYSIS RESULTS") # Basic electrical parameters @@ -315,21 +320,30 @@ 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. +# ## 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) -time.sleep(2) +# 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. -# %% [markdown] -# ## 13. Conclusion +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, @@ -339,5 +353,3 @@ # 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 - -# %% From 4d6b38fddf894dbaf40e02ebc31b628319cba908 Mon Sep 17 00:00:00 2001 From: Garima Chaturvedi Date: Fri, 10 Oct 2025 12:02:11 +0530 Subject: [PATCH 6/8] Remove wpt(wireless_power_transfer) and .gitignore files --- .gitignore | 117 -------------- .../general/wpt(wireless_power_transfer) | 150 ++++++++++++++++++ 2 files changed, 150 insertions(+), 117 deletions(-) delete mode 100644 .gitignore create mode 100644 examples/low_frequency/general/wpt(wireless_power_transfer) diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 8b14c1599..000000000 --- a/.gitignore +++ /dev/null @@ -1,117 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] - -# C extensions -*.so - -# Distribution / packaging -bin/ -build/ -develop-eggs/ -dist/ -eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -*.egg-info/ -.installed.cfg -*.egg - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -.tox/ -.coverage -.cov -.cache -nosetests.xml -coverage.xml - -# Translations -*.mo - -# Mr Developer -.mr.developer.cfg -.project -.pydevproject - -# Rope -.ropeproject - -# Django stuff: -*.log -*.pot - -# Sphinx documentation -doc/_build/ -doc/source/api/ -log.txt - -python/dcp.egg-info/ -build/ -bin/ -dist -.vs/ -/*.bat -*.whl -*.tar.gz -*.log -*.log.* -*.err -*.err.* -dev_env -*.egg-info -conan_imports_manifest.txt -conanbuildinfo.txt -conaninfo.txt -graph_info.json -*.exp -*.lib -*_env/ -test_run/ - -.pytest_cache/ -test_results.xml -freeze/freeze_log.txt -docs/schema/* -*.pdb -core.* -content.txt -replaced_content.txt -[Oo]bj/ - -# REP specific -*.tmp -*.csproj.orig -csharp/NuGet.Config -csharp/Directory.*.props -.idea -one_build_project.txt -*.orig -.DS_Store -test_results-*.xml -.coverage.* -.DS_Store -.DS_Store - -# Ipython notebook checkpoints -.ipynb_checkpoints - -# Environments -.env -.venv -env/ -venv*/ -/venv/ -ENV/ -env.bak/ -venv.bak/ - -# Generated example -src/ansys/pyaedt/examples/simple_example.py -.vscode/ diff --git a/examples/low_frequency/general/wpt(wireless_power_transfer) b/examples/low_frequency/general/wpt(wireless_power_transfer) new file mode 100644 index 000000000..a705c1d1a --- /dev/null +++ b/examples/low_frequency/general/wpt(wireless_power_transfer) @@ -0,0 +1,150 @@ +import os +import tempfile +import time +import numpy as np +from ansys.aedt.core import Maxwell3d +from ansys.aedt.core.generic.constants import Axis + +# ---------- PARAMETERS ---------- +AEDT_VERSION = "2025.2" +NG_MODE = False +PROJECT_NAME = "WPT_Transient_Final.aedt" + +frequency_hz = 200e3 +amps_primary = 1.0 +load_resistance = 10.0 +sim_time = 5e-5 +time_steps = 1001 + +coil_radius = 20.0 # mm +coil_wire_diam = 4.0 # mm (height of cylinder) +coil_separation = 15.0 # mm between coil centers + +project_dir = tempfile.TemporaryDirectory(suffix=".ansys") +project_path = os.path.join(project_dir.name, PROJECT_NAME) + +m3d = Maxwell3d( + project=project_path, + version=AEDT_VERSION, + design="WPT_Transient", + solution_type="Transient", + new_desktop=True, + non_graphical=NG_MODE, +) +m3d.modeler.model_units = "mm" + +existing = m3d.modeler.object_names +for name in ("Load_Tab", "R_Load", "PrimaryWinding", "SecondaryWinding", "Prim_Coil", "Sec_Coil"): + if name in existing: + m3d.modeler.delete(name) + + +prim_center = [0, 0, 0] +sec_center = [0, 0, coil_separation] + +prim = m3d.modeler.create_cylinder( + orientation=Axis.Z, + origin=prim_center, + radius=coil_radius, + height=coil_wire_diam, + name="Coil_Primary", + material="copper", +) + +sec = m3d.modeler.create_cylinder( + orientation=Axis.Z, + origin=sec_center, + radius=coil_radius, + height=coil_wire_diam, + name="Coil_Secondary", + material="copper", +) + + +region = m3d.modeler.create_region(name="Region", extent=60) # creates region around model + +prim_faces = [f for f in prim.faces] +sec_faces = [f for f in sec.faces] + +prim_top_face = max(prim_faces, key=lambda f: f.center[2]) +sec_top_face = max(sec_faces, key=lambda f: f.center[2]) + + +load_tab_origin = [coil_radius + 10.0, 1.0, coil_separation - coil_wire_diam / 2] +load_tab = m3d.modeler.create_box( + origin=load_tab_origin, + sizes=[2.0, 2.0, coil_wire_diam], + name="Load_Tab", +) +m3d.assign_material(load_tab, "copper") + +load_tab_obj = m3d.modeler["Load_Tab"] +load_tab_faces = [f for f in load_tab_obj.faces] +load_face = max(load_tab_faces, key=lambda f: abs(f.normal[0])) + +m3d.assign_resistive_sheet( + assignment=load_face, + resistance=f"{load_resistance}ohm", + name="R_Load", +) + +prim_coil = m3d.assign_coil(assignment=[prim_top_face], conductors_number=1, name="Prim_Coil") +sec_coil = m3d.assign_coil( assignment=[sec_top_face], conductors_number=1, name="Sec_Coil") + +prim_coil_name = prim_coil.name if hasattr(prim_coil, "name") else str(prim_coil) +sec_coil_name = sec_coil.name if hasattr(sec_coil, "name") else str(sec_coil) + + +current_expr = f"{amps_primary}*sin(2*PI*{frequency_hz}*Time)" + +# Get object names as strings +prim_obj_name = "Coil_Primary" # or prim.name +sec_obj_name = "Coil_Secondary" # or sec.name + +# Assign windings to objects, not faces +prim_winding = m3d.assign_winding( + assignment=[prim_obj_name], # Object name, not face + winding_type="Current", + is_solid=True, + current=current_expr, + resistance=0, + name="PrimaryWinding", +) + +sec_winding = m3d.assign_winding( + assignment=[sec_obj_name], # Object name, not face + winding_type="Current", + is_solid=True, + current="0A", # Add unit + resistance=load_resistance, # Set to load_resistance, not 0 + name="SecondaryWinding", +) + + +m3d.add_winding_coils(assignment=prim_winding.name, coils=[prim_coil_name]) +m3d.add_winding_coils(assignment=sec_winding.name, coils=[sec_coil_name]) + + +m3d.mesh.assign_length_mesh(assignment=["Coil_Primary", "Coil_Secondary", "Load_Tab"], maximum_length=2.0, name="CoilMesh") + + +valid = m3d.validate_simple() +print("Validation result:", valid) + +if not valid: + print("Validation FAILED. Inspect Message Manager. Exiting script before solve.") +else: + setup = m3d.create_setup("TransientSetup") + setup.props["Time Step"] = f"{sim_time/time_steps}s" + setup.props["Stop Time"] = f"{sim_time}s" + setup.props["Adaptive"] = False + + m3d.save_project(project_path) + print("Starting transient solve...") + m3d.analyze_setup(setup.name) + print("Solve requested. Check AEDT Message Manager for progress and results.") + + + +print("Project saved at:", project_path) + From 36222a83bdfbad22fbba10a5b9a963ba4ddc350f Mon Sep 17 00:00:00 2001 From: Garima Chaturvedi Date: Fri, 10 Oct 2025 12:06:09 +0530 Subject: [PATCH 7/8] Remove wpt(wireless_power_transfer) from Git tracking - work in progress file --- .../general/wpt(wireless_power_transfer) | 150 ------------------ 1 file changed, 150 deletions(-) delete mode 100644 examples/low_frequency/general/wpt(wireless_power_transfer) diff --git a/examples/low_frequency/general/wpt(wireless_power_transfer) b/examples/low_frequency/general/wpt(wireless_power_transfer) deleted file mode 100644 index a705c1d1a..000000000 --- a/examples/low_frequency/general/wpt(wireless_power_transfer) +++ /dev/null @@ -1,150 +0,0 @@ -import os -import tempfile -import time -import numpy as np -from ansys.aedt.core import Maxwell3d -from ansys.aedt.core.generic.constants import Axis - -# ---------- PARAMETERS ---------- -AEDT_VERSION = "2025.2" -NG_MODE = False -PROJECT_NAME = "WPT_Transient_Final.aedt" - -frequency_hz = 200e3 -amps_primary = 1.0 -load_resistance = 10.0 -sim_time = 5e-5 -time_steps = 1001 - -coil_radius = 20.0 # mm -coil_wire_diam = 4.0 # mm (height of cylinder) -coil_separation = 15.0 # mm between coil centers - -project_dir = tempfile.TemporaryDirectory(suffix=".ansys") -project_path = os.path.join(project_dir.name, PROJECT_NAME) - -m3d = Maxwell3d( - project=project_path, - version=AEDT_VERSION, - design="WPT_Transient", - solution_type="Transient", - new_desktop=True, - non_graphical=NG_MODE, -) -m3d.modeler.model_units = "mm" - -existing = m3d.modeler.object_names -for name in ("Load_Tab", "R_Load", "PrimaryWinding", "SecondaryWinding", "Prim_Coil", "Sec_Coil"): - if name in existing: - m3d.modeler.delete(name) - - -prim_center = [0, 0, 0] -sec_center = [0, 0, coil_separation] - -prim = m3d.modeler.create_cylinder( - orientation=Axis.Z, - origin=prim_center, - radius=coil_radius, - height=coil_wire_diam, - name="Coil_Primary", - material="copper", -) - -sec = m3d.modeler.create_cylinder( - orientation=Axis.Z, - origin=sec_center, - radius=coil_radius, - height=coil_wire_diam, - name="Coil_Secondary", - material="copper", -) - - -region = m3d.modeler.create_region(name="Region", extent=60) # creates region around model - -prim_faces = [f for f in prim.faces] -sec_faces = [f for f in sec.faces] - -prim_top_face = max(prim_faces, key=lambda f: f.center[2]) -sec_top_face = max(sec_faces, key=lambda f: f.center[2]) - - -load_tab_origin = [coil_radius + 10.0, 1.0, coil_separation - coil_wire_diam / 2] -load_tab = m3d.modeler.create_box( - origin=load_tab_origin, - sizes=[2.0, 2.0, coil_wire_diam], - name="Load_Tab", -) -m3d.assign_material(load_tab, "copper") - -load_tab_obj = m3d.modeler["Load_Tab"] -load_tab_faces = [f for f in load_tab_obj.faces] -load_face = max(load_tab_faces, key=lambda f: abs(f.normal[0])) - -m3d.assign_resistive_sheet( - assignment=load_face, - resistance=f"{load_resistance}ohm", - name="R_Load", -) - -prim_coil = m3d.assign_coil(assignment=[prim_top_face], conductors_number=1, name="Prim_Coil") -sec_coil = m3d.assign_coil( assignment=[sec_top_face], conductors_number=1, name="Sec_Coil") - -prim_coil_name = prim_coil.name if hasattr(prim_coil, "name") else str(prim_coil) -sec_coil_name = sec_coil.name if hasattr(sec_coil, "name") else str(sec_coil) - - -current_expr = f"{amps_primary}*sin(2*PI*{frequency_hz}*Time)" - -# Get object names as strings -prim_obj_name = "Coil_Primary" # or prim.name -sec_obj_name = "Coil_Secondary" # or sec.name - -# Assign windings to objects, not faces -prim_winding = m3d.assign_winding( - assignment=[prim_obj_name], # Object name, not face - winding_type="Current", - is_solid=True, - current=current_expr, - resistance=0, - name="PrimaryWinding", -) - -sec_winding = m3d.assign_winding( - assignment=[sec_obj_name], # Object name, not face - winding_type="Current", - is_solid=True, - current="0A", # Add unit - resistance=load_resistance, # Set to load_resistance, not 0 - name="SecondaryWinding", -) - - -m3d.add_winding_coils(assignment=prim_winding.name, coils=[prim_coil_name]) -m3d.add_winding_coils(assignment=sec_winding.name, coils=[sec_coil_name]) - - -m3d.mesh.assign_length_mesh(assignment=["Coil_Primary", "Coil_Secondary", "Load_Tab"], maximum_length=2.0, name="CoilMesh") - - -valid = m3d.validate_simple() -print("Validation result:", valid) - -if not valid: - print("Validation FAILED. Inspect Message Manager. Exiting script before solve.") -else: - setup = m3d.create_setup("TransientSetup") - setup.props["Time Step"] = f"{sim_time/time_steps}s" - setup.props["Stop Time"] = f"{sim_time}s" - setup.props["Adaptive"] = False - - m3d.save_project(project_path) - print("Starting transient solve...") - m3d.analyze_setup(setup.name) - print("Solve requested. Check AEDT Message Manager for progress and results.") - - - -print("Project saved at:", project_path) - From 085b541f82e9fc3286f7ef67f796c48121963eb2 Mon Sep 17 00:00:00 2001 From: Garima Chaturvedi Date: Sun, 19 Oct 2025 15:39:13 +0530 Subject: [PATCH 8/8] Fixed example alligned it with the template , also refactored the print statements --- .../magnetic/busbar_joule_heating.py | 149 ++++++++++++++---- 1 file changed, 118 insertions(+), 31 deletions(-) diff --git a/examples/low_frequency/magnetic/busbar_joule_heating.py b/examples/low_frequency/magnetic/busbar_joule_heating.py index 030b49a56..8cff8bca2 100644 --- a/examples/low_frequency/magnetic/busbar_joule_heating.py +++ b/examples/low_frequency/magnetic/busbar_joule_heating.py @@ -1,10 +1,19 @@ +<<<<<<< Updated upstream # # Busbar Joule Heating Analysis with Maxwell 3D +======= +# # Busbar Joule Heating Analysis +>>>>>>> Stashed changes # -# Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates. -# SPDX-License-Identifier: MIT +# This example demonstrates how to set up and solve a busbar Joule heating analysis using PyAEDT. +# The analysis captures frequency-dependent phenomena including skin effect, current redistribution, +# and AC losses in power electronics systems. # -# ## Overview +# 1. Import packages and instantiate the application. +# 2. Create busbar geometry with input/output terminals and assign materials. +# 3. Set up current excitations following Kirchhoff's laws and configure analysis. +# 4. Run eddy current analysis and extract engineering results. # +<<<<<<< Updated upstream # 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 @@ -29,6 +38,9 @@ # This example demonstrates the complete electromagnetic analysis workflow for conductor systems. # # Keywords: **Maxwell 3D**, **Eddy Current**, **Joule Heating**, **Skin Effect** +======= +# Keywords: **Busbar**, **Joule heating**, **Eddy current**, **Skin effect** +>>>>>>> Stashed changes # ## Prerequisites # @@ -40,6 +52,7 @@ import tempfile import time +<<<<<<< Updated upstream from ansys.aedt.core import Maxwell3d # - @@ -49,6 +62,17 @@ AEDT_VERSION = "2025.2" NG_MODE = False PROJECT_NAME = "Busbar_JouleHeating_Simple.aedt" +======= +import ansys.aedt.core # Interface to Ansys Electronics Desktop +# - + +# ### Define constants +# Constants help ensure consistency and avoid repetition throughout the example. + +AEDT_VERSION = "2025.1" +NUM_CORES = 4 +NG_MODE = False # Open AEDT UI when it is launched. +>>>>>>> Stashed changes # Geometry parameters (mm) BUSBAR_L = 100.0 @@ -63,11 +87,15 @@ 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. +<<<<<<< Updated upstream # ### Create temporary directory # # Create a temporary working directory. @@ -82,26 +110,41 @@ # ### Launch application # # Start Maxwell 3D with eddy current solution type and set model units. +======= +temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") -m3d = Maxwell3d( - project=project_path, - version=AEDT_VERSION, - design="Busbar_JouleHeating", +# ### Launch application +# +# Launch Maxwell 3D for eddy current analysis of the busbar system. +>>>>>>> Stashed changes + +project_name = os.path.join(temp_folder.name, "busbar_joule_heating.aedt") +m3d = ansys.aedt.core.Maxwell3d( + project=project_name, + design="BusbarJouleHeating", solution_type="Eddy Current", - new_desktop=True, + version=AEDT_VERSION, non_graphical=NG_MODE, + new_desktop=True, ) m3d.modeler.model_units = "mm" -print("Maxwell 3D initialized") # ## Model Preparation # +<<<<<<< Updated upstream # Create the main busbar conductor and terminal tabs, then unite them into a single object. # ### Create 3D model # print("\nCreating Geometry") +======= +# Create the busbar geometry, assign materials and boundary conditions, +# and configure the electromagnetic analysis setup. +>>>>>>> Stashed changes +# ### Create 3D model +# +# Build the busbar geometry including main conductor and terminal tabs. # Main busbar busbar = m3d.modeler.create_box( origin=[0, 0, 0], sizes=[BUSBAR_L, BUSBAR_W, BUSBAR_H], name="MainBusbar" @@ -129,14 +172,17 @@ 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 # +<<<<<<< Updated upstream # Select terminal faces and assign current excitations following Kirchhoff's current law. # + print("\nSelecting Terminal Faces") +======= +# Set up current excitations on terminal faces following Kirchhoff's current law. +>>>>>>> Stashed changes # Sort faces by x-coordinate to identify input and output terminals faces_sorted = sorted(conductor.faces, key=lambda f: f.center[0]) @@ -152,10 +198,7 @@ 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( @@ -175,6 +218,7 @@ print(f"Output Current: {-(I1 + I2)}A") print(f"Current balance: {I1 + I2 + (-(I1 + I2))} = 0A") +<<<<<<< Updated upstream print("\nCreating Air Region") air = m3d.modeler.create_air_region( @@ -189,6 +233,16 @@ # + print("\n Setting Up Analysis ") +======= +# Create air region for boundary conditions +air = m3d.modeler.create_air_region( + x_pos=0, y_pos=50, z_pos=100, x_neg=0, y_neg=50, z_neg=100 +) + +# ### Define solution setup +# +# Configure eddy current analysis with frequency and convergence settings. +>>>>>>> Stashed changes setup = m3d.create_setup("EddyCurrentSetup") setup.props["Frequency"] = f"{FREQ}Hz" @@ -197,13 +251,13 @@ setup.props["MinimumPasses"] = 2 setup.props["PercentRefinement"] = 30 -print(f"Analysis setup created for {FREQ} Hz") - +# Assign mesh for skin effect resolution mesh = m3d.mesh.assign_length_mesh( assignment=conductor.name, maximum_length=3.0, # 3mm elements for skin effect resolution name="ConductorMesh", ) +<<<<<<< Updated upstream print("Mesh operation assigned") # - @@ -213,35 +267,42 @@ 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'}") +# ### Run analysis +# +# Execute the eddy current solver. +>>>>>>> Stashed changes -# Solve +validation = m3d.validate_simple() m3d.analyze_setup(setup.name) -print("Analysis completed") # ## Postprocess # +<<<<<<< Updated upstream # Get Ohmic loss (Joule heating) results from the electromagnetic field solution. # ### Evaluate loss # # + print("\n--- Extracting Results ---") +======= +# Extract and visualize the electromagnetic field results and calculate +# engineering metrics for the busbar Joule heating analysis. -setup_sweep = f"{setup.name} : LastAdaptive" - -quantities_ec = m3d.post.available_report_quantities(report_category="EddyCurrent") -print(f"Available quantities: {quantities_ec}") +# ### Evaluate loss +# +# Extract Ohmic loss (Joule heating) from the field solution. +>>>>>>> Stashed changes +setup_sweep = f"{setup.name} : LastAdaptive" solution_data = m3d.post.get_solution_data( expressions=["SolidLoss"], report_category="EddyCurrent", setup_sweep_name=setup_sweep, ) - total_loss = solution_data.data_magnitude()[0] +<<<<<<< Updated upstream print(f"\nOhmic Loss (Joule heating): {total_loss:.6f} W") # - @@ -251,27 +312,37 @@ # + print("\n Creating Field Plots ") +======= +print(f"Ohmic Loss (Joule heating): {total_loss:.6f} W") + +# ### Visualize fields +# +# Create field plots to visualize current density, electric field, and power loss distributions. +>>>>>>> Stashed changes 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") +<<<<<<< Updated upstream # Calculate engineering metrics # Compute key parameters including resistance, loss density, skin depth, and current density. +======= +# ### Calculate engineering metrics +# +# Compute key electrical parameters including resistance, loss density, and skin depth. +>>>>>>> Stashed changes print("\nANALYSIS RESULTS") # Basic electrical parameters @@ -326,6 +397,7 @@ # # ### Save the project +<<<<<<< Updated upstream print(f"\n--- Saving Project ---") m3d.save_project(project_path) print(f"Project saved to: {project_path}") @@ -353,3 +425,18 @@ # 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 +======= +m3d.save_project() +m3d.release_desktop() +# 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() +>>>>>>> Stashed changes