-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsherlock.py
175 lines (126 loc) · 4.82 KB
/
sherlock.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# # Setup from Sherlock inputs
# This example shows how to create an Icepak project from Sherlock
# files (STEP and CSV) and an AEDB board.
#
# Keywords: **Icepak**, **Sherlock**.
# ## Perform imports and define constants
#
# Perform required imports.
# +
import os
import tempfile
import time
import ansys.aedt.core
# -
# Define constants
AEDT_VERSION = "2025.1"
NUM_CORES = 4
NG_MODE = False # Open AEDT UI when it is launched.
# ## Set paths and define input files and variables
#
# Set paths.
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
input_dir = ansys.aedt.core.downloads.download_sherlock(destination=temp_folder.name)
# Define input files.
material_name = "MaterialExport.csv"
component_properties = "TutorialBoardPartsList.csv"
component_step = "TutorialBoard.stp"
aedt_odb_project = "SherlockTutorial.aedt"
# Define variables that are needed later.
aedt_odb_design_name = "PCB"
outline_polygon_name = "poly_14188"
# Define input files with paths.
material_list = os.path.join(input_dir, material_name)
component_list = os.path.join(input_dir, component_properties)
validation = os.path.join(temp_folder.name, "validation.log")
file_path = os.path.join(input_dir, component_step)
project_name = os.path.join(temp_folder.name, component_step[:-3] + "aedt")
# ## Create Icepak model
ipk = ansys.aedt.core.Icepak(
project=project_name, version=AEDT_VERSION, non_graphical=NG_MODE
)
# Disable autosave to speed up the import.
ipk.autosave_disable()
# Import a PCB from an AEDB file.
odb_path = os.path.join(input_dir, aedt_odb_project)
ipk.create_pcb_from_3dlayout(
component_name="Board", project_name=odb_path, design_name=aedt_odb_design_name
)
# Create an offset coordinate system to match ODB++ with the Sherlock STEP file.
# The thickness is computed from the ``"Board"`` component. (``"Board1"`` is the
# instance name of the ``"Board"`` native component and is used to offset the coordinate system.)
bb = ipk.modeler.user_defined_components["Board1"].bounding_box
stackup_thickness = bb[-1] - bb[2]
ipk.modeler.create_coordinate_system(
origin=[0, 0, stackup_thickness / 2], mode="view", view="XY"
)
# Import the board components from an MCAD file and remove the PCB object as it is already
# imported with the ECAD.
ipk.modeler.import_3d_cad(file_path, refresh_all_ids=False)
ipk.modeler.delete_objects_containing("pcb", False)
# Modify the air region. Padding values are passed in this order: [+X, -X, +Y, -Y, +Z, -Z]
ipk.mesh.global_mesh_region.global_region.padding_values = [20, 20, 20, 20, 300, 300]
# ## Assign materials and power dissipation conditions from Sherlock
#
# Use the Sherlock file to assign materials.
ipk.assignmaterial_from_sherlock_files(
component_file=component_list, material_file=material_list
)
# Delete objects with no material assignments.
no_material_objs = ipk.modeler.get_objects_by_material(material="")
ipk.modeler.delete(assignment=no_material_objs)
ipk.save_project()
# Assign power blocks from the Sherlock file.
total_power = ipk.assign_block_from_sherlock_file(csv_name=component_list)
# ## Assign openings
#
# Assign opening boundary condition to all the faces of the region.
ipk.assign_openings(ipk.modeler.get_object_faces("Region"))
# ## Create simulation setup
# ### Set global mesh settings
ipk.globalMeshSettings(
3,
gap_min_elements="1",
noOgrids=True,
MLM_en=True,
MLM_Type="2D",
edge_min_elements="2",
object="Region",
)
# ### Add postprocessing object
# Create the point monitor.
point1 = ipk.monitor.assign_point_monitor(
point_position=ipk.modeler["COMP_U10"].top_face_z.center, monitor_name="Point1"
)
# Create a line for reporting after the simulation.
line = ipk.modeler.create_polyline(
points=[
ipk.modeler["COMP_U10"].top_face_z.vertices[0].position,
ipk.modeler["COMP_U10"].top_face_z.vertices[2].position,
],
non_model=True,
)
# ### Solve
# To solve quickly, the maximum iterations are set to 20. For better accuracy, you
# can increase the maximum to at least 100.
setup1 = ipk.create_setup()
setup1.props["Solution Initialization - Y Velocity"] = "1m_per_sec"
setup1.props["Radiation Model"] = "Discrete Ordinates Model"
setup1.props["Include Gravity"] = True
setup1.props["Secondary Gradient"] = True
setup1.props["Convergence Criteria - Max Iterations"] = 100
# Check for intersections using validation and fix them by
# assigning priorities.
ipk.assign_priority_on_intersections()
# ## Release AEDT
ipk.save_project()
ipk.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()