Skip to content

Commit 5bb7409

Browse files
Devin-CrawfordSMoraisAnsysSamuelopez-ansys
authored
Update Icepak (#181)
* Update Icepak Make consistent with template. * Update examples/04-Icepak/icepak_graphic_card_example.py Co-authored-by: Sébastien Morais <146729917+SMoraisAnsys@users.noreply.github.com> * Fix farfield example --------- Co-authored-by: Sébastien Morais <146729917+SMoraisAnsys@users.noreply.github.com> Co-authored-by: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com> Co-authored-by: Samuelopez-ansys <samuel.lopez@ansys.com>
1 parent c7b0e11 commit 5bb7409

6 files changed

+157
-90
lines changed

examples/02-HFSS/HFSS_Dipole.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
# Generate 2D cutout plot. You can define the Theta scan
187187
# and Phi scan.
188188

189-
ffdata.plot_cut(
189+
ffdata.farfield_data.plot_cut(
190190
primary_sweep="theta",
191191
secondary_sweep_value=0,
192192
quantity="RealizedGain",

examples/04-Icepak/icepak_3d_components_example.py

+44-31
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@
77
# ## Import PyAEDT and download files
88
# Perform import of required classes from the ``pyaedt`` package and import the ``os`` package.
99

10-
# +
1110
import os
1211
import tempfile
1312

1413
from pyaedt import Icepak, downloads
15-
# -
1614

1715
# Set constant values
1816

1917
AEDT_VERSION = "2024.1"
18+
NG_MODE = False # Open Electronics UI when the application is launched.
2019

2120
# Download needed files in a temporary folder
2221

@@ -26,19 +25,13 @@
2625
)
2726

2827

29-
# ## Set non-graphical mode
30-
# Set non-graphical mode.
31-
# You can set ``non_graphical`` either to ``True`` or ``False``.
32-
33-
non_graphical = False
34-
3528
# ## Create heatsink
3629
# Create new empty project in non-graphical mode.
3730

3831
ipk = Icepak(
3932
project=os.path.join(temp_folder.name, "Heatsink.aedt"),
4033
version=AEDT_VERSION,
41-
non_graphical=non_graphical,
34+
non_graphical=NG_MODE,
4235
close_on_exit=True,
4336
new_desktop=True,
4437
)
@@ -50,18 +43,22 @@
5043

5144
# Define the heatsink using multiple boxes
5245

53-
hs_base = ipk.modeler.create_box(origin=[0, 0, 0], sizes=[37.5, 37.5, 2], name="HS_Base")
46+
hs_base = ipk.modeler.create_box(
47+
origin=[0, 0, 0], sizes=[37.5, 37.5, 2], name="HS_Base"
48+
)
5449
hs_base.material_name = "Al-Extruded"
5550
hs_fin = ipk.modeler.create_box(origin=[0, 0, 2], sizes=[37.5, 1, 18], name="HS_Fin1")
5651
hs_fin.material_name = "Al-Extruded"
5752
n_fins = 11
5853
hs_fins = hs_fin.duplicate_along_line(vector=[0, 3.65, 0], clones=n_fins)
5954

60-
ipk.plot(show=False, export_path=os.path.join(temp_folder.name, "Heatsink.jpg"))
55+
ipk.plot(show=False, output_file=os.path.join(temp_folder.name, "Heatsink.jpg"))
6156

6257
# Definition of a mesh region around the heatsink
6358

64-
mesh_region = ipk.mesh.assign_mesh_region(assignment=[hs_base.name, hs_fin.name] + hs_fins)
59+
mesh_region = ipk.mesh.assign_mesh_region(
60+
assignment=[hs_base.name, hs_fin.name] + hs_fins
61+
)
6562
mesh_region.manual_settings = True
6663
mesh_region.settings["MaxElementSizeX"] = "5mm"
6764
mesh_region.settings["MaxElementSizeY"] = "5mm"
@@ -87,40 +84,46 @@
8784
monitor_name="TopPoint",
8885
)
8986
ipk.monitor.assign_face_monitor(
90-
face_id=hs_base.bottom_face_z.id, monitor_quantity="Temperature", monitor_name="Bottom"
87+
face_id=hs_base.bottom_face_z.id,
88+
monitor_quantity="Temperature",
89+
monitor_name="Bottom",
9190
)
9291
ipk.monitor.assign_point_monitor_in_object(
93-
name=hs_middle_fin.name, monitor_quantity="Temperature", monitor_name="MiddleFinCenter"
92+
name=hs_middle_fin.name,
93+
monitor_quantity="Temperature",
94+
monitor_name="MiddleFinCenter",
9495
)
9596

9697
# Export the heatsink 3D component in a ``"componentLibrary"`` folder.
9798
# ``auxiliary_dict`` is set to true to export the monitor objects along with the .a3dcomp file.
9899

99100
os.mkdir(os.path.join(temp_folder.name, "componentLibrary"))
100101
ipk.modeler.create_3dcomponent(
101-
component_file=os.path.join(temp_folder.name, "componentLibrary", "Heatsink.a3dcomp"),
102+
component_file=os.path.join(
103+
temp_folder.name, "componentLibrary", "Heatsink.a3dcomp"
104+
),
102105
component_name="Heatsink",
103106
auxiliary_dict=True,
104107
)
105-
ipk.close_project(save_project=False)
108+
ipk.close_project(save=False)
106109

107110
# ## Create QFP
108111
# Open the previously downloaded project containing a QPF.
109112

110113
ipk = Icepak(project=qfp_temp_name)
111-
ipk.plot(show=False, export_path=os.path.join(temp_folder.name, "QFP2.jpg"))
114+
ipk.plot(show=False, output_file=os.path.join(temp_folder.name, "QFP2.jpg"))
112115

113116
# Create dataset for power dissipation.
114117

115118
x_datalist = [45, 53, 60, 70]
116119
y_datalist = [0.5, 3, 6, 9]
117120
ipk.create_dataset(
118-
dsname="PowerDissipationDataset",
119-
xlist=x_datalist,
120-
ylist=y_datalist,
121+
name="PowerDissipationDataset",
122+
x=x_datalist,
123+
y=y_datalist,
121124
is_project_dataset=False,
122-
xunit="cel",
123-
yunit="W",
125+
x_unit="cel",
126+
y_unit="W",
124127
)
125128

126129
# Assign source power condition to the die.
@@ -166,7 +169,9 @@
166169
# Download and open a project containing the electronic package.
167170

168171
ipk = Icepak(
169-
project=package_temp_name, version=AEDT_VERSION, non_graphical=non_graphical
172+
project=package_temp_name,
173+
version=AEDT_VERSION,
174+
non_graphical=NG_MODE,
170175
)
171176
ipk.plot(
172177
objects=[o for o in ipk.modeler.object_names if not o.startswith("DomainBox")],
@@ -201,10 +206,10 @@
201206
)
202207

203208
ipk.plot(
204-
objects=[o for o in ipk.modeler.object_names if not o.startswith("DomainBox")],
209+
assignment=[o for o in ipk.modeler.object_names if not o.startswith("DomainBox")],
205210
show=False,
206211
plot_air_objects=False,
207-
export_path=os.path.join(temp_folder.name, "electronic_package.jpg"),
212+
output_file=os.path.join(temp_folder.name, "electronic_package.jpg"),
208213
force_opacity_value=0.5,
209214
)
210215
# -
@@ -220,23 +225,31 @@
220225
y_pointing=[0, 1, 0],
221226
)
222227

223-
# Export of the whole assembly as 3d component and close project. First, a flattening
224-
# is needed because nested 3d components are not natively supported. Then it is possible
225-
# to export the whole package as 3d component. Here the auxiliary dictionary is needed
228+
# Export of the entire assembly as a 3D component and close the project. First, the nested
229+
# hierarchy must be flattned since nested 3d components are currently not supported. Subsequently,
230+
# the whole package can be exported as a 3D component. The auxiliary dictionary is needed
226231
# to export monitor objects, datasets and native components.
227232

228233
ipk.flatten_3d_components()
229234
ipk.modeler.create_3dcomponent(
230-
component_file=os.path.join(temp_folder.name, "componentLibrary", "PCBAssembly.a3dcomp"),
235+
component_file=os.path.join(
236+
temp_folder.name, "componentLibrary", "PCBAssembly.a3dcomp"
237+
),
231238
component_name="PCBAssembly",
232239
auxiliary_dict=True,
233240
included_cs=["Global", "HeatsinkCS", "PCB_Assembly"],
234241
reference_cs="PCB_Assembly",
235242
)
236243

237244
# ## Release AEDT
238-
#
239-
# Release AEDT and remove the temporary folder.
240245

241246
ipk.release_desktop(close_projects=True, close_desktop=True)
247+
248+
# ## Cleanup
249+
#
250+
# All project files are saved in the folder ``temp_dir.name``.
251+
# If you've run this example as a Jupyter notebook you
252+
# can retrieve those project files. The following cell
253+
# removes all temporary files, including the project folder.
254+
242255
temp_folder.cleanup()

examples/04-Icepak/icepak_csv_import.py

+39-26
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,36 @@
99
# Perform required imports including the operating system, regular expression, csv, Ansys PyAEDT
1010
# and its boundary objects.
1111

12+
# +
1213
import csv
1314
import os
1415
import tempfile
1516

16-
from IPython.display import Image
1717
import matplotlib as mpl
18+
import pyaedt
19+
from IPython.display import Image
1820
from matplotlib import cm
1921
from matplotlib import pyplot as plt
20-
import pyaedt
22+
23+
# -
2124

2225
# Set constant values
2326

2427
AEDT_VERSION = "2024.1"
28+
NG_MODE = False # Open Electronics UI when the application is launched.
2529

2630
# ## Download and open project
2731
#
2832
# Download the project and open it in non-graphical mode, using a temporary folder.
2933

30-
# +
3134
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
32-
35+
project_name = os.path.join(temp_folder.name, "Icepak_CSV_Import.aedt")
3336
ipk = pyaedt.Icepak(
34-
project=os.path.join(temp_folder.name, "Icepak_CSV_Import.aedt"),
37+
project=project_name,
3538
version=AEDT_VERSION,
3639
new_desktop=True,
37-
non_graphical=False,
40+
non_graphical=NG_MODE,
3841
)
39-
# -
4042

4143
# Create the PCB as a simple block.
4244

@@ -59,33 +61,33 @@
5961
#
6062
# The following table does not show the entire rows and data and only serves as a sample.
6163
#
62-
# +------------+------+--------+--------+------+-------+-------+------+------------------+-------+-----+-----+---------------+
64+
#
6365
# | block_type | name | xs | ys | zs | xd | yd | zd | matname | power | Rjb | Rjc | Monitor_point |
64-
# +============+======+========+========+======+=======+=======+======+==================+=======+=====+=====+===============+
66+
# |------------|------|--------|--------|------|-------|-------|------|------------------|-------|-----|-----|---------------|
6567
# | hollow | R8 | 31.75 | -20.32 | 0.40 | 15.24 | 2.54 | 2.54 | | 1 | | | 0 |
66-
# +------------+------+--------+--------+------+-------+-------+------+------------------+-------+-----+-----+---------------+
6768
# | solid | U1 | 16.55 | 10.20 | 0.40 | 10.16 | 20.32 | 5.08 | Ceramic_material | 0.2 | | | 1 |
68-
# +------------+------+--------+--------+------+-------+-------+------+------------------+-------+-----+-----+---------------+
69-
# | solid | U2 | -16.51 | 10.16 | 0.40 | 10.16 | 27.94 | 5.08 | Ceramic_material | 0.1 | | | 1 |
70-
# +------------+------+--------+--------+------+-------+-------+------+------------------+-------+-----+-----+---------------+
69+
# | solid | U2 | -51 | 10.16 | 0.40 | 10.16 | 27.94 | 5.08 | Ceramic_material | 0.1 | | | 1 |
7170
# | network | C180 | 47.62 | 19.05 | 0.40 | 3.81 | 2.54 | 2.43 | | 1.13 | 2 | 3 | 0 |
72-
# +------------+------+--------+--------+------+-------+-------+------+------------------+-------+-----+-----+---------------+
7371
# | network | C10 | 65.40 | -1.27 | 0.40 | 3.81 | 2.54 | 2.43 | | 0.562 | 2 | 3 | 0 |
74-
# +------------+------+--------+--------+------+-------+-------+------+------------------+-------+-----+-----+---------------+
7572
# | network | C20 | 113.03 | -0.63 | 0.40 | 2.54 | 3.81 | 2.43 | | 0.445 | 2 | 3 | 0 |
76-
# +------------+------+--------+--------+------+-------+-------+------+------------------+-------+-----+-----+---------------+
7773
#
7874
# In this step the code will loop over the csv file lines and creates the blocks.
7975
# It will create solid blocks and assign BCs.
8076
# Every row of the csv has information of a particular block.
8177

8278
# +
83-
filename = pyaedt.downloads.download_file("icepak", "blocks-list.csv", destination=temp_folder.name)
79+
filename = pyaedt.downloads.download_file(
80+
"icepak", "blocks-list.csv", destination=temp_folder.name
81+
)
8482

8583
with open(filename, "r") as csv_file:
8684
csv_reader = csv.DictReader(csv_file)
8785
for row in csv_reader:
88-
origin = [float(row["xs"]), float(row["ys"]), float(row["zs"])] # block starting point
86+
origin = [
87+
float(row["xs"]),
88+
float(row["ys"]),
89+
float(row["zs"]),
90+
] # block starting point
8991
dimensions = [
9092
float(row["xd"]),
9193
float(row["yd"]),
@@ -132,14 +134,15 @@
132134
# column of the csv file
133135
if row["Monitor_point"] == "1":
134136
ipk.monitor.assign_point_monitor_in_object(
135-
name=row["name"], monitor_quantity="Temperature", monitor_name=row["name"]
137+
name=row["name"],
138+
monitor_quantity="Temperature",
139+
monitor_name=row["name"],
136140
)
137141
# -
138142

139143

140-
# ## Compute power budget
141-
#
142-
# Calculate the power assigned to all the components
144+
# # Calculate the power assigned to all the components
145+
143146
power_budget, total_power = ipk.post.power_budget(units="W")
144147

145148
# ## Plot model
@@ -153,14 +156,18 @@
153156
# Set the colormap to use
154157

155158
cmap = plt.get_cmap("viridis")
156-
norm = mpl.colors.Normalize(vmin=min(power_budget.values()), vmax=max(power_budget.values()))
159+
norm = mpl.colors.Normalize(
160+
vmin=min(power_budget.values()), vmax=max(power_budget.values())
161+
)
157162
scalarMap = cm.ScalarMappable(norm=norm, cmap=cmap)
158163

159164
# Apply the color based on the power assigned and the colormap
160165

161166
for actor in pyvista_plot.objects:
162167
if actor.name in power_budget:
163-
actor.color = [int(i * 255) for i in scalarMap.to_rgba(power_budget[actor.name])[0:3]]
168+
actor.color = [
169+
int(i * 255) for i in scalarMap.to_rgba(power_budget[actor.name])[0:3]
170+
]
164171
actor.opacity = 1
165172

166173
# Generate the plot and export
@@ -171,8 +178,14 @@
171178
Image(os.path.join(temp_folder.name, "object_power.jpg"))
172179

173180
# ## Release AEDT
174-
#
175-
# Release AEDT.
176181

177182
ipk.release_desktop(True, True)
183+
184+
# ## Cleanup
185+
#
186+
# All project files are saved in the folder ``temp_dir.name``.
187+
# If you've run this example as a Jupyter notebook you
188+
# can retrieve those project files. The following cell removes
189+
# all temporary files, including the project folder.
190+
178191
temp_folder.cleanup()

examples/04-Icepak/icepak_ecad_import.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# Set constant values
1717

1818
AEDT_VERSION = "2024.1"
19+
NG_MODE = False # Open Electronics UI when the application is launched.
1920

2021
# ## Open project
2122
#
@@ -28,7 +29,7 @@
2829
project=os.path.join(temp_folder.name, "Icepak_ECAD_Import.aedt"),
2930
version=AEDT_VERSION,
3031
new_desktop=True,
31-
non_graphical=True,
32+
non_graphical=NG_MODE,
3233
)
3334
# -
3435

@@ -50,7 +51,9 @@
5051
# Download ECAD and IDF files
5152

5253
def_path = pyaedt.downloads.download_file(
53-
source="icepak/Icepak_ECAD_Import/A1_uprev.aedb", name="edb.def", destination=temp_folder.name
54+
source="icepak/Icepak_ECAD_Import/A1_uprev.aedb",
55+
name="edb.def",
56+
destination=temp_folder.name,
5457
)
5558
board_path = pyaedt.downloads.download_file(
5659
source="icepak/Icepak_ECAD_Import/", name="A1.bdf", destination=temp_folder.name
@@ -99,8 +102,12 @@
99102
)
100103

101104
# ## Release AEDT
102-
#
103-
# Release AEDT.
104105

105106
ipk.release_desktop(close_projects=True, close_desktop=True)
107+
108+
# ## Cleanup
109+
#
110+
# All project files are saved in the folder ``temp_dir.name``. If you've run this example as a Jupyter notebook you
111+
# can retrieve those project files. The following cell removes all temporary files, including the project folder.
112+
106113
temp_folder.cleanup()

0 commit comments

Comments
 (0)