Skip to content

Commit 13bfeb1

Browse files
DOCS: Update template (#289)
1 parent a7ab125 commit 13bfeb1

File tree

6 files changed

+207
-136
lines changed

6 files changed

+207
-136
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ test_results-*.xml
106106
.env
107107
.venv
108108
env/
109-
venv/
109+
venv*/
110110
/venv/
111111
ENV/
112112
env.bak/

examples/aedt_general/report/automatic_report.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import ansys.aedt.core
2020
from IPython.display import Image
21+
# -
2122

2223
# Define constants.
2324

examples/low_frequency/multiphysics/maxwell_icepak.py

+54-39
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,52 @@
77
# Coil resistance and ohmic loss are analyzed again in Maxwell. Results are printed in AEDT Message Manager.
88
#
99
# Keywords: **Multiphysics**, **Maxwell**, **Icepak**, **Wireless Charging**.
10+
11+
# ## Prerequisites
1012
#
11-
# ## Perform imports and define constants
12-
#
13-
# Perform required imports.
13+
# ### Perform imports
1414

15-
# +
1615
import os
1716
import tempfile
1817
import time
19-
20-
import ansys.aedt.core
18+
import ansys.aedt.core # Interface to Ansys Electronics Desktop
2119
from ansys.aedt.core.generic.constants import AXIS
2220

23-
# -
24-
25-
# Define constants.
21+
# ### Define constants
22+
#
23+
# Constants help ensure consistency and avoid repetition throughout the example.
2624

2725
AEDT_VERSION = "2024.2"
2826
NG_MODE = False # Open AEDT UI when it is launched.
2927

30-
# ## Create temporary directory
28+
# ### Create temporary directory
3129
#
3230
# Create a temporary working directory.
3331
# The name of the working folder is stored in ``temp_folder.name``.
3432
#
35-
# > **Note:** The final cell in the notebook cleans up the temporary folder. If you want to
33+
# > **Note:** The final cell in this example removes the temporary folder and
34+
# > all contents. If you want to
3635
# > retrieve the AEDT project and data, do so before executing the final cell in the notebook.
3736

3837
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
3938

40-
# ## Launch application
39+
# ### Launch application
4140
#
4241
# The syntax for different applications in AEDT differ
4342
# only in the name of the class. This example demonstrates the use of the
44-
# ``Maxwell3d`` class.
43+
# ``Maxwell3d`` and ``Icepak`` classes.
4544
#
4645
# > **Note:** An AEDT _Project_ is created when the ``Maxwell3d`` class is instantiated. An instance of
47-
# > the ``Icepak`` class will be used to insert and simulate an Icepak design and demonstrate
46+
# > the ``Icepak`` class will be used later to insert and simulate an
47+
# > Icepak design to demonstrate
4848
# > the coupled electrical-thermal workflow.
4949

5050
# +
51-
project_name = os.path.join(temp_folder.name, "Maxwell-Icepak-2way-Coupling")
5251
maxwell_design_name = "1 Maxwell"
5352
icepak_design_name = "2 Icepak"
5453

54+
project_name = os.path.join(temp_folder.name, "Maxwell-Icepak-2way-Coupling")
55+
5556
m3d = ansys.aedt.core.Maxwell3d(
5657
project=project_name,
5758
design=maxwell_design_name,
@@ -61,13 +62,9 @@
6162
)
6263
# -
6364

64-
# ### Units
65-
# The default units are "mm". Model units can be queried or changed using the
66-
# property ``m3d.modeler.model_units``.
67-
68-
print(f'Model units are "{m3d.modeler.model_units}"')
69-
70-
# ## Set up model
65+
# ## Model Preparation
66+
#
67+
# ### Build the model
7168
#
7269
# Create the coil, coil terminal, core, and surrounding air region. The coil and core
7370
# are created by drawing a rectangle and sweeping it about the z-axis.
@@ -97,16 +94,21 @@
9794
region = m3d.modeler.create_region(pad_percent=[20, 20, 20, 20, 500, 100])
9895
# -
9996

100-
# ### Restore view
97+
# #### Restore view
10198
#
10299
# If you are using PyAEDT with an interactive desktop, you may want to fit the visible view to fit the model.
103-
# PyAEDT uses the direct access to the native API for this command using the property `m3d.odesktop`.
100+
# PyAEDT allows direct access to the native API for this command using the property `m3d.odesktop`.
104101
#
105102
# Uncomment and run the following cell if you are running PyAEDT interactively and would like to automatically fit the
106103
# window to the model.
104+
#
105+
# > **Note:** Native API calls do not allow for introspection or follow PIP
106+
# > syntax guidelines. Full documentation for the native API is available in
107+
# > 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).
107108

108109
# +
109110
# desktop=m3d.odesktop.RestoreWindow() # Fit the active view
111+
# desktop = m3d.post.still_focus_oneditor()
110112
# -
111113

112114
# ### Create and assign material
@@ -137,6 +139,8 @@
137139
m3d.assign_material(core.name, "ferrite")
138140
# -
139141

142+
# ### Define the source
143+
#
140144
# The coil carries 0.5 A and 20 turns.
141145

142146
# +
@@ -150,7 +154,7 @@
150154

151155
# ### Assign mesh operations
152156
#
153-
# Mesh "seeding" is used to retain solution accuracy and accelerate the auto-adaptive mesh refinement.
157+
# Mesh "seeding" is used to accelerate the auto-adaptive mesh refinement.
154158

155159
m3d.mesh.assign_length_mesh(
156160
["Core"], maximum_length=15, maximum_elements=None, name="Inside_Core"
@@ -163,18 +167,18 @@
163167
#
164168
# The impact of Joule heating on conductivity can be considered
165169
# by adding a "thermal modifier" to the ``cu_litz`` material definition.
166-
# 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).
170+
# 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).
167171

168172
cu_resistivity_temp_coefficient = 0.00393
169173
cu_litz.conductivity.add_thermal_modifier_free_form(
170174
"1.0/(1.0+{}*(Temp-20))".format(cu_resistivity_temp_coefficient)
171175
)
172176
m3d.modeler.set_objects_temperature(["Coil"], ambient_temperature=22)
173177

174-
# ### Assign matrix
178+
# ### Assign the matrix calculation to the winding
175179
#
176180
# The resistance and inductance calculations for the coil are enabled by
177-
# adding the matrix assignment.
181+
# adding the matrix assignment to the winding.
178182

179183
m3d.assign_matrix(["Winding1"], matrix_name="Matrix1")
180184

@@ -188,12 +192,16 @@
188192
setup.props["PercentError"] = 0.5
189193
setup.props["MinimumConvergedPasses"] = 2
190194

191-
# ## Run the Maxwell 3D analysis
195+
# ### Run the Maxwell 3D analysis
196+
#
197+
# The following command runs the 3D finite element analysis in Maxwell.
192198

193199
m3d.analyze_setup("Setup1")
194200

195201
# ## Postprocessing
196202
#
203+
# ### DC resistance
204+
#
197205
# The DC resistance of the coil can be calculated analyticially. The following cell compares the known
198206
# DC resistance with the simulated coil
199207
# resistance.
@@ -210,9 +218,11 @@
210218
report_loss = m3d.post.create_report(expressions="StrandedLossAC")
211219
solution_loss = report_loss.get_solution_data()
212220
em_loss = solution_loss.data_magnitude()[0]
221+
# -
222+
223+
# ### Analyitic calculation of DC resistance
213224

214225
# +
215-
# Analytical calculation of the DC resistance of the coil
216226
cu_cond = float(cu_litz.conductivity.value)
217227

218228
# Average radius of a coil turn = 125 mm
@@ -239,7 +249,7 @@
239249
)
240250
# -
241251

242-
# ## Insert Icepak design
252+
# ## Create the thermal model
243253
#
244254
# 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
245255
# for thermal convection analysis.
@@ -257,7 +267,7 @@
257267
)
258268
# -
259269

260-
# ## Map coil losses
270+
# ### Map coil losses
261271
#
262272
# Map ohmic losses from Maxwell 3D to the Icepak design.
263273

@@ -282,7 +292,9 @@
282292

283293
temp_monitor = ipk.assign_point_monitor([70, 0, 0], monitor_name="PointMonitor1")
284294

285-
# Set up Icepak solution
295+
# ### Set up Icepak solution
296+
#
297+
# Icepak solution settings are modified by updating the ``props`` associated with the solution setup.
286298

287299
solution_setup = ipk.create_setup()
288300
solution_setup.props["Convergence Criteria - Max Iterations"] = 50
@@ -295,7 +307,7 @@
295307
solution_setup.props["Convergence Criteria - Flow"] = 0.0005
296308
solution_setup.props["Flow Iteration Per Radiation Iteration"] = "5"
297309

298-
# ## Add two-way coupling and solve the project
310+
# ### Add two-way coupling
299311
#
300312
# The temperature update from Icepak to Maxwell 3D is activated using the method ``assign_2way_coupling()``. The Ohmic
301313
# loss in Maxwell will change due to the temperature increase, which in turn will change the results
@@ -305,6 +317,9 @@
305317
# The full electro-thermal analysis is run by calling the ``analyze_setup()`` method.
306318

307319
ipk.assign_2way_coupling()
320+
321+
# ### Run Icepak analysis
322+
308323
ipk.analyze_setup(name=solution_setup.name)
309324

310325
# ## Postprocess
@@ -335,7 +350,7 @@
335350
m3d.logger.info("*******Coil temperature = {:.2f}deg C".format(temp))
336351
# -
337352

338-
# ### Get new resistance from Maxwell 3D
353+
# ### Get updated resistance from Maxwell 3D
339354
#
340355
# The temperature of the coil increases, and consequently the coil resistance increases.
341356

@@ -364,17 +379,17 @@
364379
)
365380
# -
366381

367-
# ### Save project
382+
# ### Save the project
368383

369384
ipk.save_project()
370385
ipk.release_desktop()
371386
time.sleep(3) # Allow AEDT to shut down before cleaning the temporary project folder.
372387

373-
# ## Clean up
388+
# ### Clean up
374389
#
375390
# All project files are saved in the folder ``temp_folder.name``.
376391
# If you've run this example as a Jupyter notebook, you
377-
# can retrieve those project files. The following cell removes
378-
# all temporary files, including the project folder.
392+
# can retrieve those project files. The following cell
393+
# removes all temporary files, including the project folder.
379394

380395
temp_folder.cleanup()

0 commit comments

Comments
 (0)