From 56c6e725ab6009b2ce2105a0c734c5f486818c5e Mon Sep 17 00:00:00 2001 From: Jonathan Velasco Date: Thu, 6 Mar 2025 15:47:19 +0200 Subject: [PATCH 1/2] [refactor][upgrade] LF running without errors 2024R2 to 2025R1 --- .../low_frequency/general/eddy_current.py | 2 +- .../low_frequency/general/electrostatic.py | 2 +- .../low_frequency/general/external_circuit.py | 2 +- examples/low_frequency/general/resistance.py | 2 +- .../general/twin_builder/dynamic_rom.py | 2 +- .../general/twin_builder/lti_rom_sml.py | 2 +- .../general/twin_builder/rc_circuit.py | 2 +- .../general/twin_builder/rectifier.py | 2 +- .../general/twin_builder/static_rom.py | 2 +- .../multiphysics/maxwell_icepak.py | 19 +++++++++++-------- .../low_frequency/team_problem/bath_plate.py | 2 +- 11 files changed, 21 insertions(+), 18 deletions(-) diff --git a/examples/low_frequency/general/eddy_current.py b/examples/low_frequency/general/eddy_current.py index 94184957c..741fee201 100644 --- a/examples/low_frequency/general/eddy_current.py +++ b/examples/low_frequency/general/eddy_current.py @@ -16,7 +16,7 @@ # Define constants. -AEDT_VERSION = "2024.2" +AEDT_VERSION = "2025.1" NUM_CORES = 4 NG_MODE = False # Open AEDT UI when it is launched. diff --git a/examples/low_frequency/general/electrostatic.py b/examples/low_frequency/general/electrostatic.py index 598008ffb..a77c04ead 100644 --- a/examples/low_frequency/general/electrostatic.py +++ b/examples/low_frequency/general/electrostatic.py @@ -19,7 +19,7 @@ # Define constants. -AEDT_VERSION = "2024.2" +AEDT_VERSION = "2025.1" NUM_CORES = 4 NG_MODE = False diff --git a/examples/low_frequency/general/external_circuit.py b/examples/low_frequency/general/external_circuit.py index 53c731ddf..6e79d2024 100644 --- a/examples/low_frequency/general/external_circuit.py +++ b/examples/low_frequency/general/external_circuit.py @@ -14,7 +14,7 @@ # Define constants. -AEDT_VERSION = "2024.2" +AEDT_VERSION = "2025.1" NUM_CORES = 4 NG_MODE = False # Open AEDT UI when it is launched. diff --git a/examples/low_frequency/general/resistance.py b/examples/low_frequency/general/resistance.py index 6023cef0c..7968e5392 100644 --- a/examples/low_frequency/general/resistance.py +++ b/examples/low_frequency/general/resistance.py @@ -18,7 +18,7 @@ # Define constants. -AEDT_VERSION = "2024.2" +AEDT_VERSION = "2025.1" NG_MODE = False NUM_CORES = 4 diff --git a/examples/low_frequency/general/twin_builder/dynamic_rom.py b/examples/low_frequency/general/twin_builder/dynamic_rom.py index 2f8ffc901..afa5baa09 100644 --- a/examples/low_frequency/general/twin_builder/dynamic_rom.py +++ b/examples/low_frequency/general/twin_builder/dynamic_rom.py @@ -22,7 +22,7 @@ # Define constants. -AEDT_VERSION = "2024.2" +AEDT_VERSION = "2025.1" NUM_CORES = 4 NG_MODE = False # Open AEDT UI when it is launched. diff --git a/examples/low_frequency/general/twin_builder/lti_rom_sml.py b/examples/low_frequency/general/twin_builder/lti_rom_sml.py index 9d1c12a7c..9d7ccd0d7 100644 --- a/examples/low_frequency/general/twin_builder/lti_rom_sml.py +++ b/examples/low_frequency/general/twin_builder/lti_rom_sml.py @@ -21,7 +21,7 @@ # Define constants -AEDT_VERSION = "2024.2" +AEDT_VERSION = "2025.1" NUM_CORES = 4 NG_MODE = False # Open AEDT UI when it is launched. diff --git a/examples/low_frequency/general/twin_builder/rc_circuit.py b/examples/low_frequency/general/twin_builder/rc_circuit.py index a369e0a1e..e64ad3024 100644 --- a/examples/low_frequency/general/twin_builder/rc_circuit.py +++ b/examples/low_frequency/general/twin_builder/rc_circuit.py @@ -17,7 +17,7 @@ # Define constants. -AEDT_VERSION = "2024.2" +AEDT_VERSION = "2025.1" NUM_CORES = 4 NG_MODE = False # Open AEDT UI when it is launched. diff --git a/examples/low_frequency/general/twin_builder/rectifier.py b/examples/low_frequency/general/twin_builder/rectifier.py index 508a1792e..cba971c88 100644 --- a/examples/low_frequency/general/twin_builder/rectifier.py +++ b/examples/low_frequency/general/twin_builder/rectifier.py @@ -20,7 +20,7 @@ # Define constants. -AEDT_VERSION = "2024.2" +AEDT_VERSION = "2025.1" NUM_CORES = 4 NG_MODE = False # Open AEDT UI when it is launched. diff --git a/examples/low_frequency/general/twin_builder/static_rom.py b/examples/low_frequency/general/twin_builder/static_rom.py index 4dec1fcec..314d803b0 100644 --- a/examples/low_frequency/general/twin_builder/static_rom.py +++ b/examples/low_frequency/general/twin_builder/static_rom.py @@ -20,7 +20,7 @@ # Define constants. -AEDT_VERSION = "2024.2" +AEDT_VERSION = "2025.1" NUM_CORES = 4 NG_MODE = False # Open AEDT UI when it is launched. diff --git a/examples/low_frequency/multiphysics/maxwell_icepak.py b/examples/low_frequency/multiphysics/maxwell_icepak.py index 8211eab68..b098cb5eb 100644 --- a/examples/low_frequency/multiphysics/maxwell_icepak.py +++ b/examples/low_frequency/multiphysics/maxwell_icepak.py @@ -24,7 +24,7 @@ # Define constants. -AEDT_VERSION = "2024.2" +AEDT_VERSION = "2025.1" NG_MODE = False # Open AEDT UI when it is launched. # ## Create temporary directory @@ -180,7 +180,10 @@ # ### Create the simulation setup # -# The simulation frequency is 150 kHz. You can query and modify the properties of the simulation setup using ``setup.props``. The "PercentError" establishes the minimum allowed change in energy due to the change in mesh size and ensure a small global solution error. +# The simulation frequency is 150 kHz. You can query and modify the properties +# of the simulation setup using ``setup.props``. The "PercentError" establishes +# the minimum allowed change in energy due to the change in mesh size and ensure +# a small global solution error. setup = m3d.create_setup(name="Setup1") setup.props["Frequency"] = "150kHz" @@ -194,13 +197,13 @@ # ## Postprocessing # -# The DC resistance of the coil can be calculated analyticially. The following cell compares the known -# DC resistance with the simulated coil -# resistance. +# The DC resistance of the coil can be calculated analytically. +# The following cell compares the known DC resistance +# with the simulated coil resistance. # -# The values can be displayed in the AEDT "Message Manager". The Ohmic loss in -# coil is calculated and displayed so we can see the change when Joule -# heating is considered. +# The values can be displayed in the AEDT "Message Manager". +# The Ohmic loss in coil is calculated and displayed so we can +# see the change when Joule heating is considered. # + report = m3d.post.create_report(expressions="Matrix1.R(Winding1,Winding1)") diff --git a/examples/low_frequency/team_problem/bath_plate.py b/examples/low_frequency/team_problem/bath_plate.py index b0bb16d0d..9e57d700d 100644 --- a/examples/low_frequency/team_problem/bath_plate.py +++ b/examples/low_frequency/team_problem/bath_plate.py @@ -19,7 +19,7 @@ # Define constants. -AEDT_VERSION = "2024.2" +AEDT_VERSION = "2025.1" NUM_CORES = 4 NG_MODE = False # Open AEDT UI when it is launched. From b2ebf63f9f585d9ab43ba7c79804c51b9f0acd32 Mon Sep 17 00:00:00 2001 From: Jonathan Velasco Date: Thu, 6 Mar 2025 16:30:49 +0200 Subject: [PATCH 2/2] [docs][maxwell_icepak.py] Correct Documentation --- .../multiphysics/maxwell_icepak.py | 112 ++++++++++-------- 1 file changed, 64 insertions(+), 48 deletions(-) diff --git a/examples/low_frequency/multiphysics/maxwell_icepak.py b/examples/low_frequency/multiphysics/maxwell_icepak.py index b098cb5eb..a421dc07d 100644 --- a/examples/low_frequency/multiphysics/maxwell_icepak.py +++ b/examples/low_frequency/multiphysics/maxwell_icepak.py @@ -7,51 +7,53 @@ # Coil resistance and ohmic loss are analyzed again in Maxwell. Results are printed in AEDT Message Manager. # # Keywords: **Multiphysics**, **Maxwell**, **Icepak**, **Wireless Charging**. + +# ## Prerequisites # -# ## Perform imports and define constants -# -# Perform required imports. +# ### Perform imports -# + import os import tempfile import time -import ansys.aedt.core +import ansys.aedt.core # Interface to Ansys Electronics Desktop from ansys.aedt.core.generic.constants import AXIS -# - - -# Define constants. +# ### Define constants +# +# Constants help ensure consistency and avoid repetition throughout the example. AEDT_VERSION = "2025.1" NG_MODE = False # Open AEDT UI when it is launched. -# ## Create temporary directory +# ### 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 +# > **Note:** The final cell in this example removes the temporary folder and +# > all contents. 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") -# ## Launch application +# ### Launch application # # The syntax for different applications in AEDT differ # only in the name of the class. This example demonstrates the use of the -# ``Maxwell3d`` class. +# ``Maxwell3d`` and ``Icepak`` classes. # # > **Note:** An AEDT _Project_ is created when the ``Maxwell3d`` class is instantiated. An instance of -# > the ``Icepak`` class will be used to insert and simulate an Icepak design and demonstrate +# > the ``Icepak`` class will be used later to insert and simulate an +# > Icepak design to demonstrate # > the coupled electrical-thermal workflow. # + -project_name = os.path.join(temp_folder.name, "Maxwell-Icepak-2way-Coupling") maxwell_design_name = "1 Maxwell" icepak_design_name = "2 Icepak" +project_name = os.path.join(temp_folder.name, "Maxwell-Icepak-2way-Coupling") + m3d = ansys.aedt.core.Maxwell3d( project=project_name, design=maxwell_design_name, @@ -61,13 +63,9 @@ ) # - -# ### Units -# The default units are "mm". Model units can be queried or changed using the -# property ``m3d.modeler.model_units``. - -print(f'Model units are "{m3d.modeler.model_units}"') - -# ## Set up model +# ## Model Preparation +# +# ### Build the model # # Create the coil, coil terminal, core, and surrounding air region. The coil and core # are created by drawing a rectangle and sweeping it about the z-axis. @@ -97,16 +95,21 @@ region = m3d.modeler.create_region(pad_percent=[20, 20, 20, 20, 500, 100]) # - -# ### Restore view +# #### Restore view # # If you are using PyAEDT with an interactive desktop, you may want to fit the visible view to fit the model. -# PyAEDT uses the direct access to the native API for this command using the property `m3d.odesktop`. +# PyAEDT allows direct access to the native API for this command using the property `m3d.odesktop`. # # Uncomment and run the following cell if you are running PyAEDT interactively and would like to automatically fit the # window to the model. +# +# > **Note:** Native API calls do not allow for introspection or follow PIP +# > syntax guidelines. Full documentation for the native API is available in +# > the built-in AEDT [help](https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/Electronics/v242/en//Subsystems/Maxwell/Subsystems/Maxwell%20Scripting/Maxwell%20Scripting.htm). # + # desktop=m3d.odesktop.RestoreWindow() # Fit the active view +# desktop = m3d.post.still_focus_oneditor() # - # ### Create and assign material @@ -137,6 +140,8 @@ m3d.assign_material(core.name, "ferrite") # - +# ### Define the source +# # The coil carries 0.5 A and 20 turns. # + @@ -150,7 +155,7 @@ # ### Assign mesh operations # -# Mesh "seeding" is used to retain solution accuracy and accelerate the auto-adaptive mesh refinement. +# Mesh "seeding" is used to accelerate the auto-adaptive mesh refinement. m3d.mesh.assign_length_mesh( ["Core"], maximum_length=15, maximum_elements=None, name="Inside_Core" @@ -163,7 +168,7 @@ # # The impact of Joule heating on conductivity can be considered # by adding a "thermal modifier" to the ``cu_litz`` material definition. -# In this example, conductivity increases by 0.393% per $\Delta$K. The temperature of the objects is set to the default value ($22^0$ C). +# In this example, conductivity increases by 0.393% per $\Delta^o$C. The temperature of the objects is set to the default value ($22^o$C). cu_resistivity_temp_coefficient = 0.00393 cu_litz.conductivity.add_thermal_modifier_free_form( @@ -171,19 +176,19 @@ ) m3d.modeler.set_objects_temperature(["Coil"], ambient_temperature=22) -# ### Assign matrix +# ### Assign the matrix calculation to the winding # # The resistance and inductance calculations for the coil are enabled by -# adding the matrix assignment. +# adding the matrix assignment to the winding. m3d.assign_matrix(["Winding1"], matrix_name="Matrix1") # ### Create the simulation setup # -# The simulation frequency is 150 kHz. You can query and modify the properties -# of the simulation setup using ``setup.props``. The "PercentError" establishes -# the minimum allowed change in energy due to the change in mesh size and ensure -# a small global solution error. +# The simulation frequency is 150 kHz. +# You can query and modify the properties of the simulation setup using ``setup.props``. +# The "PercentError" establishes the minimum allowed change in energy due to the change in mesh size +# and ensure a small global solution error. setup = m3d.create_setup(name="Setup1") setup.props["Frequency"] = "150kHz" @@ -191,19 +196,23 @@ setup.props["PercentError"] = 0.5 setup.props["MinimumConvergedPasses"] = 2 -# ## Run the Maxwell 3D analysis +# ### Run the Maxwell 3D analysis +# +# The following command runs the 3D finite element analysis in Maxwell. m3d.analyze_setup("Setup1") # ## Postprocessing # -# The DC resistance of the coil can be calculated analytically. -# The following cell compares the known DC resistance -# with the simulated coil resistance. +# ### DC resistance +# +# The DC resistance of the coil can be calculated analyticially. The following cell compares the known +# DC resistance with the simulated coil +# resistance. # -# The values can be displayed in the AEDT "Message Manager". -# The Ohmic loss in coil is calculated and displayed so we can -# see the change when Joule heating is considered. +# The values can be displayed in the AEDT "Message Manager". The Ohmic loss in +# coil is calculated and displayed so we can see the change when Joule +# heating is considered. # + report = m3d.post.create_report(expressions="Matrix1.R(Winding1,Winding1)") @@ -213,9 +222,11 @@ report_loss = m3d.post.create_report(expressions="StrandedLossAC") solution_loss = report_loss.get_solution_data() em_loss = solution_loss.data_magnitude()[0] +# - + +# ### Analytic calculation of DC resistance # + -# Analytical calculation of the DC resistance of the coil cu_cond = float(cu_litz.conductivity.value) # Average radius of a coil turn = 125 mm @@ -242,7 +253,7 @@ ) # - -# ## Insert Icepak design +# ## Create the thermal model # # The following commands insert an Icepak design into the AEDT project, copies the solid objects from Maxwell 3D, and modifies the region dimensions so they're suitable # for thermal convection analysis. @@ -260,7 +271,7 @@ ) # - -# ## Map coil losses +# ### Map coil losses # # Map ohmic losses from Maxwell 3D to the Icepak design. @@ -285,7 +296,9 @@ temp_monitor = ipk.assign_point_monitor([70, 0, 0], monitor_name="PointMonitor1") -# Set up Icepak solution +# ### Set up Icepak solution +# +# Icepak solution settings are modified by updating the ``props`` associated with the solution setup. solution_setup = ipk.create_setup() solution_setup.props["Convergence Criteria - Max Iterations"] = 50 @@ -298,7 +311,7 @@ solution_setup.props["Convergence Criteria - Flow"] = 0.0005 solution_setup.props["Flow Iteration Per Radiation Iteration"] = "5" -# ## Add two-way coupling and solve the project +# ### Add two-way coupling # # The temperature update from Icepak to Maxwell 3D is activated using the method ``assign_2way_coupling()``. The Ohmic # loss in Maxwell will change due to the temperature increase, which in turn will change the results @@ -308,6 +321,9 @@ # The full electro-thermal analysis is run by calling the ``analyze_setup()`` method. ipk.assign_2way_coupling() + +# ### Run Icepak analysis + ipk.analyze_setup(name=solution_setup.name) # ## Postprocess @@ -338,7 +354,7 @@ m3d.logger.info("*******Coil temperature = {:.2f}deg C".format(temp)) # - -# ### Get new resistance from Maxwell 3D +# ### Get updated resistance from Maxwell 3D # # The temperature of the coil increases, and consequently the coil resistance increases. @@ -367,17 +383,17 @@ ) # - -# ### Save project +# ### Save the project ipk.save_project() ipk.release_desktop() time.sleep(3) # Allow AEDT to shut down before cleaning the temporary project folder. -# ## Clean up +# ### 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. +# can retrieve those project files. The following cell +# removes all temporary files, including the project folder. temp_folder.cleanup()