Download this example
Download this example as a Jupyter Notebook or as a Python script.
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.
[1]:
import os
import tempfile
import time
import ansys.aedt.core
Define constants
[2]:
AEDT_VERSION = "2024.2"
NUM_CORES = 4
NG_MODE = False # Open AEDT UI when it is launched.
Set paths and define input files and variables#
Set paths.
[3]:
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
input_dir = ansys.aedt.core.downloads.download_sherlock(destination=temp_folder.name)
Define input files.
[4]:
material_name = "MaterialExport.csv"
component_properties = "TutorialBoardPartsList.csv"
component_step = "TutorialBoard.stp"
aedt_odb_project = "SherlockTutorial.aedt"
Define variables that are needed later.
[5]:
aedt_odb_design_name = "PCB"
outline_polygon_name = "poly_14188"
Define input files with paths.
[6]:
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#
[7]:
ipk = ansys.aedt.core.Icepak(
project=project_name, version=AEDT_VERSION, non_graphical=NG_MODE
)
PyAEDT INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)].
PyAEDT INFO: PyAEDT version 0.15.dev0.
PyAEDT INFO: Initializing new Desktop session.
PyAEDT INFO: Log on console is enabled.
PyAEDT INFO: Log on file C:\Users\ansys\AppData\Local\Temp\pyaedt_ansys_21a8dc2c-320d-4010-b220-0385ece6d6d7.log is enabled.
PyAEDT INFO: Log on AEDT is enabled.
PyAEDT INFO: Debug logger is disabled. PyAEDT methods will not be logged.
PyAEDT INFO: Launching PyAEDT with gRPC plugin.
PyAEDT INFO: New AEDT session is starting on gRPC port 56857.
PyAEDT WARNING: Electronics Desktop license not found on the default license server.
PyAEDT INFO: Electronics Desktop started on gRPC port: 56857 after 2.0430338382720947 seconds.
PyAEDT INFO: AEDT installation Path C:\Program Files\AnsysEM\v242\Win64
PyAEDT INFO: Ansoft.ElectronicsDesktop.2024.2 version started with process ID 12864.
PyAEDT INFO: Project TutorialBoard has been created.
PyAEDT INFO: No design is present. Inserting a new design.
PyAEDT INFO: Added design 'Icepak_TIR' of type Icepak.
PyAEDT INFO: Aedt Objects correctly read
Disable autosave to speed up the import.
[8]:
ipk.autosave_disable()
[8]:
True
Import a PCB from an AEDB file.
[9]:
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
)
PyAEDT INFO: Modeler class has been initialized! Elapsed time: 0m 1sec
PyAEDT INFO: Materials class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: Closing the AEDT Project SherlockTutorial
PyAEDT INFO: Project SherlockTutorial closed correctly
PyAEDT INFO: PCB component correctly created in Icepak.
[9]:
<ansys.aedt.core.modules.boundary.layout_boundary.NativeComponentPCB at 0x1e2d1e96650>
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.)
[10]:
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"
)
[10]:
<ansys.aedt.core.modeler.cad.modeler.CoordinateSystem at 0x1e2d33ab310>
Import the board components from an MCAD file and remove the PCB object as it is already imported with the ECAD.
[11]:
ipk.modeler.import_3d_cad(file_path, refresh_all_ids=False)
ipk.modeler.delete_objects_containing("pcb", False)
PyAEDT INFO: Step file C:\Users\ansys\AppData\Local\Temp\tmpso6495a7.ansys\sherlock\TutorialBoard.stp imported
PyAEDT INFO: Parsing design objects. This operation can take time
PyAEDT INFO: Refreshing bodies from Object Info
PyAEDT INFO: Bodies Info Refreshed Elapsed time: 0m 0sec
PyAEDT INFO: 3D Modeler objects parsed. Elapsed time: 0m 0sec
PyAEDT INFO: Deleted 1 Objects: PCB.
PyAEDT INFO: Deleted 1 objects
[11]:
True
Modify the air region. Padding values are passed in this order: [+X, -X, +Y, -Y, +Z, -Z]
[12]:
ipk.mesh.global_mesh_region.global_region.padding_values = [20, 20, 20, 20, 300, 300]
PyAEDT INFO: Parsing C:/Users/ansys/AppData/Local/Temp/tmpso6495a7.ansys/TutorialBoard.aedt.
PyAEDT INFO: File C:/Users/ansys/AppData/Local/Temp/tmpso6495a7.ansys/TutorialBoard.aedt correctly loaded. Elapsed time: 0m 0sec
PyAEDT INFO: aedt file load time 0.015625476837158203
PyAEDT WARNING: No mesh operation found.
PyAEDT WARNING: No mesh region found.
PyAEDT WARNING: Property Command is read-only.
PyAEDT INFO: Mesh class has been initialized! Elapsed time: 0m 0sec
PyAEDT WARNING: Property Command is read-only.
PyAEDT WARNING: Property Command is read-only.
PyAEDT WARNING: Property Command is read-only.
PyAEDT WARNING: Property Command is read-only.
PyAEDT WARNING: Property Command is read-only.
PyAEDT WARNING: Property Command is read-only.
PyAEDT WARNING: Property Command is read-only.
PyAEDT WARNING: Property Command is read-only.
PyAEDT WARNING: Property Command is read-only.
PyAEDT WARNING: Property Command is read-only.
PyAEDT WARNING: Property Command is read-only.
PyAEDT WARNING: Property Command is read-only.
Assign materials and power dissipation conditions from Sherlock#
Use the Sherlock file to assign materials.
[13]:
ipk.assignmaterial_from_sherlock_files(
component_file=component_list, material_file=material_list
)
PyAEDT INFO: Adding new material to the Project Library: bariumtitanate
PyAEDT INFO: Material has been added in Desktop.
PyAEDT INFO: Adding new material to the Project Library: epoxyencapsulant
PyAEDT INFO: Material has been added in Desktop.
PyAEDT INFO: Adding new material to the Project Library: laminate-bga
PyAEDT INFO: Material has been added in Desktop.
PyAEDT INFO: Dataset Mass_Density_IGVR4N doesn't exist.
PyAEDT INFO: Dataset $Mass_Density_IGVR4N created successfully.
PyAEDT INFO: Dataset Youngs_Modulus_YF28FH doesn't exist.
PyAEDT INFO: Dataset $Youngs_Modulus_YF28FH created successfully.
[13]:
True
Delete objects with no material assignments.
[14]:
no_material_objs = ipk.modeler.get_objects_by_material(material="")
ipk.modeler.delete(assignment=no_material_objs)
ipk.save_project()
PyAEDT INFO: Parsing design objects. This operation can take time
PyAEDT INFO: Refreshing bodies from Object Info
PyAEDT INFO: Bodies Info Refreshed Elapsed time: 0m 0sec
PyAEDT INFO: 3D Modeler objects parsed. Elapsed time: 0m 0sec
PyAEDT INFO: Deleted 158 Objects: COMP_R58,COMP_R57,COMP_R56,COMP_R55,COMP_R54,COMP_R53,COMP_R52,COMP_R51,COMP_R50,COMP_R49,COMP_R48,COMP_R47,COMP_R46,COMP_R45,COMP_R44,COMP_R43,COMP_R42,COMP_R41,COMP_R40,COMP_R39,COMP_R38,COMP_R37,COMP_R36,COMP_R35,COMP_R34,COMP...
PyAEDT INFO: Project TutorialBoard Saved correctly
[14]:
True
Assign power blocks from the Sherlock file.
[15]:
total_power = ipk.assign_block_from_sherlock_file(csv_name=component_list)
PyAEDT INFO: Boundary Block COMP_C1 has been created.
PyAEDT INFO: Boundary Block COMP_C2 has been created.
PyAEDT INFO: Boundary Block COMP_C3 has been created.
PyAEDT INFO: Boundary Block COMP_C4 has been created.
PyAEDT INFO: Boundary Block COMP_C5 has been created.
PyAEDT INFO: Boundary Block COMP_C6 has been created.
PyAEDT INFO: Boundary Block COMP_C7 has been created.
PyAEDT INFO: Boundary Block COMP_C8 has been created.
PyAEDT INFO: Boundary Block COMP_C9 has been created.
PyAEDT INFO: Boundary Block COMP_C10 has been created.
PyAEDT INFO: Boundary Block COMP_C11 has been created.
PyAEDT INFO: Boundary Block COMP_C12 has been created.
PyAEDT INFO: Boundary Block COMP_C13 has been created.
PyAEDT INFO: Boundary Block COMP_C14 has been created.
PyAEDT INFO: Boundary Block COMP_C15 has been created.
PyAEDT INFO: Boundary Block COMP_C16 has been created.
PyAEDT INFO: Boundary Block COMP_C17 has been created.
PyAEDT INFO: Boundary Block COMP_C18 has been created.
PyAEDT INFO: Boundary Block COMP_C19 has been created.
PyAEDT INFO: Boundary Block COMP_C20 has been created.
PyAEDT INFO: Boundary Block COMP_C21 has been created.
PyAEDT INFO: Boundary Block COMP_C22 has been created.
PyAEDT INFO: Boundary Block COMP_C23 has been created.
PyAEDT INFO: Boundary Block COMP_C24 has been created.
PyAEDT INFO: Boundary Block COMP_C25 has been created.
PyAEDT INFO: Boundary Block COMP_C26 has been created.
PyAEDT INFO: Boundary Block COMP_C27 has been created.
PyAEDT INFO: Boundary Block COMP_C28 has been created.
PyAEDT INFO: Boundary Block COMP_C29 has been created.
PyAEDT INFO: Boundary Block COMP_C30 has been created.
PyAEDT INFO: Boundary Block COMP_J1 has been created.
PyAEDT INFO: Boundary Block COMP_Q1 has been created.
PyAEDT INFO: Boundary Block COMP_Q2 has been created.
PyAEDT INFO: Boundary Block COMP_Q3 has been created.
PyAEDT INFO: Boundary Block COMP_Q4 has been created.
PyAEDT INFO: Boundary Block COMP_Q5 has been created.
PyAEDT INFO: Boundary Block COMP_Q6 has been created.
PyAEDT INFO: Boundary Block COMP_Q7 has been created.
PyAEDT INFO: Boundary Block COMP_Q8 has been created.
PyAEDT INFO: Boundary Block COMP_Q9 has been created.
PyAEDT INFO: Boundary Block COMP_Q10 has been created.
PyAEDT INFO: Boundary Block COMP_Q11 has been created.
PyAEDT INFO: Boundary Block COMP_Q12 has been created.
PyAEDT INFO: Boundary Block COMP_Q13 has been created.
PyAEDT INFO: Boundary Block COMP_Q14 has been created.
PyAEDT INFO: Boundary Block COMP_Q15 has been created.
PyAEDT INFO: Boundary Block COMP_Q16 has been created.
PyAEDT INFO: Boundary Block COMP_U1 has been created.
PyAEDT INFO: Boundary Block COMP_U2 has been created.
PyAEDT INFO: Boundary Block COMP_U3 has been created.
PyAEDT INFO: Boundary Block COMP_U4 has been created.
PyAEDT INFO: Boundary Block COMP_U5 has been created.
PyAEDT INFO: Boundary Block COMP_U6 has been created.
PyAEDT INFO: Boundary Block COMP_U7 has been created.
PyAEDT INFO: Boundary Block COMP_U8 has been created.
PyAEDT INFO: Boundary Block COMP_U9 has been created.
PyAEDT INFO: Boundary Block COMP_U10 has been created.
PyAEDT INFO: Boundary Block COMP_U11 has been created.
PyAEDT INFO: Boundary Block COMP_U12 has been created.
PyAEDT INFO: Boundary Block COMP_U13 has been created.
PyAEDT INFO: Boundary Block COMP_U14 has been created.
PyAEDT INFO: Boundary Block COMP_U15 has been created.
PyAEDT INFO: Boundary Block COMP_U16 has been created.
PyAEDT INFO: Blocks inserted with total power 2.2W.
[16]:
# ## Assign openings
#
# Assign opening boundary condition to all the faces of the region.
ipk.assign_openings(ipk.modeler.get_object_faces("Region"))
PyAEDT INFO: Parsing C:/Users/ansys/AppData/Local/Temp/tmpso6495a7.ansys/TutorialBoard.aedt.
PyAEDT INFO: File C:/Users/ansys/AppData/Local/Temp/tmpso6495a7.ansys/TutorialBoard.aedt correctly loaded. Elapsed time: 0m 0sec
PyAEDT INFO: aedt file load time 0.11220598220825195
PyAEDT INFO: Boundary Opening Opening_F4RV84 has been created.
[16]:
<ansys.aedt.core.modules.boundary.common.BoundaryObject at 0x1e2d33abdf0>
Create simulation setup#
Set global mesh settings#
[17]:
ipk.globalMeshSettings(
3,
gap_min_elements="1",
noOgrids=True,
MLM_en=True,
MLM_Type="2D",
edge_min_elements="2",
object="Region",
)
[17]:
True
Add postprocessing object#
Create the point monitor.
[18]:
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.
[19]:
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.
[20]:
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.
[21]:
ipk.assign_priority_on_intersections()
PyAEDT INFO: Project TutorialBoard Saved correctly
PyAEDT INFO: 0 Intersections have been found. Applying Priorities
[21]:
True
Release AEDT#
[22]:
ipk.save_project()
ipk.release_desktop()
# Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory.
time.sleep(3)
PyAEDT INFO: Project TutorialBoard Saved correctly
PyAEDT INFO: Desktop has been released and closed.
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.
[23]:
temp_folder.cleanup()
Download this example
Download this example as a Jupyter Notebook or as a Python script.