|
7 | 7 | # Coil resistance and ohmic loss are analyzed again in Maxwell. Results are printed in AEDT Message Manager.
|
8 | 8 | #
|
9 | 9 | # Keywords: **Multiphysics**, **Maxwell**, **Icepak**, **Wireless Charging**.
|
| 10 | + |
| 11 | +# ## Prerequisites |
10 | 12 | #
|
11 |
| -# ## Perform imports and define constants |
12 |
| -# |
13 |
| -# Perform required imports. |
| 13 | +# ### Perform imports |
14 | 14 |
|
15 |
| -# + |
16 | 15 | import os
|
17 | 16 | import tempfile
|
18 | 17 | import time
|
19 |
| - |
20 |
| -import ansys.aedt.core |
| 18 | +import ansys.aedt.core # Interface to Ansys Electronics Desktop |
21 | 19 | from ansys.aedt.core.generic.constants import AXIS
|
22 | 20 |
|
23 |
| -# - |
24 |
| - |
25 |
| -# Define constants. |
| 21 | +# ### Define constants |
| 22 | +# |
| 23 | +# Constants help ensure consistency and avoid repetition throughout the example. |
26 | 24 |
|
27 | 25 | AEDT_VERSION = "2024.2"
|
28 | 26 | NG_MODE = False # Open AEDT UI when it is launched.
|
29 | 27 |
|
30 |
| -# ## Create temporary directory |
| 28 | +# ### Create temporary directory |
31 | 29 | #
|
32 | 30 | # Create a temporary working directory.
|
33 | 31 | # The name of the working folder is stored in ``temp_folder.name``.
|
34 | 32 | #
|
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 |
36 | 35 | # > retrieve the AEDT project and data, do so before executing the final cell in the notebook.
|
37 | 36 |
|
38 | 37 | temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
|
39 | 38 |
|
40 |
| -# ## Launch application |
| 39 | +# ### Launch application |
41 | 40 | #
|
42 | 41 | # The syntax for different applications in AEDT differ
|
43 | 42 | # only in the name of the class. This example demonstrates the use of the
|
44 |
| -# ``Maxwell3d`` class. |
| 43 | +# ``Maxwell3d`` and ``Icepak`` classes. |
45 | 44 | #
|
46 | 45 | # > **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 |
48 | 48 | # > the coupled electrical-thermal workflow.
|
49 | 49 |
|
50 | 50 | # +
|
51 |
| -project_name = os.path.join(temp_folder.name, "Maxwell-Icepak-2way-Coupling") |
52 | 51 | maxwell_design_name = "1 Maxwell"
|
53 | 52 | icepak_design_name = "2 Icepak"
|
54 | 53 |
|
| 54 | +project_name = os.path.join(temp_folder.name, "Maxwell-Icepak-2way-Coupling") |
| 55 | + |
55 | 56 | m3d = ansys.aedt.core.Maxwell3d(
|
56 | 57 | project=project_name,
|
57 | 58 | design=maxwell_design_name,
|
|
61 | 62 | )
|
62 | 63 | # -
|
63 | 64 |
|
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 |
71 | 68 | #
|
72 | 69 | # Create the coil, coil terminal, core, and surrounding air region. The coil and core
|
73 | 70 | # are created by drawing a rectangle and sweeping it about the z-axis.
|
|
97 | 94 | region = m3d.modeler.create_region(pad_percent=[20, 20, 20, 20, 500, 100])
|
98 | 95 | # -
|
99 | 96 |
|
100 |
| -# ### Restore view |
| 97 | +# #### Restore view |
101 | 98 | #
|
102 | 99 | # 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`. |
104 | 101 | #
|
105 | 102 | # Uncomment and run the following cell if you are running PyAEDT interactively and would like to automatically fit the
|
106 | 103 | # 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). |
107 | 108 |
|
108 | 109 | # +
|
109 | 110 | # desktop=m3d.odesktop.RestoreWindow() # Fit the active view
|
| 111 | +# desktop = m3d.post.still_focus_oneditor() |
110 | 112 | # -
|
111 | 113 |
|
112 | 114 | # ### Create and assign material
|
|
137 | 139 | m3d.assign_material(core.name, "ferrite")
|
138 | 140 | # -
|
139 | 141 |
|
| 142 | +# ### Define the source |
| 143 | +# |
140 | 144 | # The coil carries 0.5 A and 20 turns.
|
141 | 145 |
|
142 | 146 | # +
|
|
150 | 154 |
|
151 | 155 | # ### Assign mesh operations
|
152 | 156 | #
|
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. |
154 | 158 |
|
155 | 159 | m3d.mesh.assign_length_mesh(
|
156 | 160 | ["Core"], maximum_length=15, maximum_elements=None, name="Inside_Core"
|
|
163 | 167 | #
|
164 | 168 | # The impact of Joule heating on conductivity can be considered
|
165 | 169 | # 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). |
167 | 171 |
|
168 | 172 | cu_resistivity_temp_coefficient = 0.00393
|
169 | 173 | cu_litz.conductivity.add_thermal_modifier_free_form(
|
170 | 174 | "1.0/(1.0+{}*(Temp-20))".format(cu_resistivity_temp_coefficient)
|
171 | 175 | )
|
172 | 176 | m3d.modeler.set_objects_temperature(["Coil"], ambient_temperature=22)
|
173 | 177 |
|
174 |
| -# ### Assign matrix |
| 178 | +# ### Assign the matrix calculation to the winding |
175 | 179 | #
|
176 | 180 | # The resistance and inductance calculations for the coil are enabled by
|
177 |
| -# adding the matrix assignment. |
| 181 | +# adding the matrix assignment to the winding. |
178 | 182 |
|
179 | 183 | m3d.assign_matrix(["Winding1"], matrix_name="Matrix1")
|
180 | 184 |
|
|
188 | 192 | setup.props["PercentError"] = 0.5
|
189 | 193 | setup.props["MinimumConvergedPasses"] = 2
|
190 | 194 |
|
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. |
192 | 198 |
|
193 | 199 | m3d.analyze_setup("Setup1")
|
194 | 200 |
|
195 | 201 | # ## Postprocessing
|
196 | 202 | #
|
| 203 | +# ### DC resistance |
| 204 | +# |
197 | 205 | # The DC resistance of the coil can be calculated analyticially. The following cell compares the known
|
198 | 206 | # DC resistance with the simulated coil
|
199 | 207 | # resistance.
|
|
210 | 218 | report_loss = m3d.post.create_report(expressions="StrandedLossAC")
|
211 | 219 | solution_loss = report_loss.get_solution_data()
|
212 | 220 | em_loss = solution_loss.data_magnitude()[0]
|
| 221 | +# - |
| 222 | + |
| 223 | +# ### Analyitic calculation of DC resistance |
213 | 224 |
|
214 | 225 | # +
|
215 |
| -# Analytical calculation of the DC resistance of the coil |
216 | 226 | cu_cond = float(cu_litz.conductivity.value)
|
217 | 227 |
|
218 | 228 | # Average radius of a coil turn = 125 mm
|
|
239 | 249 | )
|
240 | 250 | # -
|
241 | 251 |
|
242 |
| -# ## Insert Icepak design |
| 252 | +# ## Create the thermal model |
243 | 253 | #
|
244 | 254 | # 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
|
245 | 255 | # for thermal convection analysis.
|
|
257 | 267 | )
|
258 | 268 | # -
|
259 | 269 |
|
260 |
| -# ## Map coil losses |
| 270 | +# ### Map coil losses |
261 | 271 | #
|
262 | 272 | # Map ohmic losses from Maxwell 3D to the Icepak design.
|
263 | 273 |
|
|
282 | 292 |
|
283 | 293 | temp_monitor = ipk.assign_point_monitor([70, 0, 0], monitor_name="PointMonitor1")
|
284 | 294 |
|
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. |
286 | 298 |
|
287 | 299 | solution_setup = ipk.create_setup()
|
288 | 300 | solution_setup.props["Convergence Criteria - Max Iterations"] = 50
|
|
295 | 307 | solution_setup.props["Convergence Criteria - Flow"] = 0.0005
|
296 | 308 | solution_setup.props["Flow Iteration Per Radiation Iteration"] = "5"
|
297 | 309 |
|
298 |
| -# ## Add two-way coupling and solve the project |
| 310 | +# ### Add two-way coupling |
299 | 311 | #
|
300 | 312 | # The temperature update from Icepak to Maxwell 3D is activated using the method ``assign_2way_coupling()``. The Ohmic
|
301 | 313 | # loss in Maxwell will change due to the temperature increase, which in turn will change the results
|
|
305 | 317 | # The full electro-thermal analysis is run by calling the ``analyze_setup()`` method.
|
306 | 318 |
|
307 | 319 | ipk.assign_2way_coupling()
|
| 320 | + |
| 321 | +# ### Run Icepak analysis |
| 322 | + |
308 | 323 | ipk.analyze_setup(name=solution_setup.name)
|
309 | 324 |
|
310 | 325 | # ## Postprocess
|
|
335 | 350 | m3d.logger.info("*******Coil temperature = {:.2f}deg C".format(temp))
|
336 | 351 | # -
|
337 | 352 |
|
338 |
| -# ### Get new resistance from Maxwell 3D |
| 353 | +# ### Get updated resistance from Maxwell 3D |
339 | 354 | #
|
340 | 355 | # The temperature of the coil increases, and consequently the coil resistance increases.
|
341 | 356 |
|
|
364 | 379 | )
|
365 | 380 | # -
|
366 | 381 |
|
367 |
| -# ### Save project |
| 382 | +# ### Save the project |
368 | 383 |
|
369 | 384 | ipk.save_project()
|
370 | 385 | ipk.release_desktop()
|
371 | 386 | time.sleep(3) # Allow AEDT to shut down before cleaning the temporary project folder.
|
372 | 387 |
|
373 |
| -# ## Clean up |
| 388 | +# ### Clean up |
374 | 389 | #
|
375 | 390 | # All project files are saved in the folder ``temp_folder.name``.
|
376 | 391 | # 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. |
379 | 394 |
|
380 | 395 | temp_folder.cleanup()
|
0 commit comments