Icepak: setup from Sherlock inputs#

This example shows how you can create an Icepak project from Sherlock files (STEP and CSV) and an AEDB board.

Perform required imports#

Perform required imports and set paths.

import time
import os
import tempfile
import datetime

from pyaedt import examples, generate_unique_folder_name

# Set paths
project_folder = generate_unique_folder_name()
input_dir = examples.download_sherlock()

Set non-graphical mode#

Set non-graphical mode. "PYAEDT_NON_GRAPHICAL" is needed to generate documentation only. You can set non_graphical value either to True or False.

non_graphical = os.getenv("PYAEDT_NON_GRAPHICAL", "False").lower() in ("true", "1", "t")

Define variables#

Define input variables. The following code creates all input variables that are needed to run this example.

material_name = "MaterialExport.csv"
component_properties = "TutorialBoardPartsList.csv"
component_step = "TutorialBoard.stp"
aedt_odb_project = "SherlockTutorial.aedt"
aedt_odb_design_name = "PCB"
stackup_thickness = 2.11836
outline_polygon_name = "poly_14188"

Import Icepak and AEDT#

Import Icepak and AEDT.

from pyaedt import Icepak
from pyaedt import Desktop

Launch AEDT#

Launch AEDT 2022 R2 in graphical mode.

Create Icepak project#

Create an Icepak project.

ipk = Icepak(project_name)

Delete region to speed up import#

Delete the region and disable autosave to speed up the import.

d.disable_autosave()
ipk.modeler.delete("Region")
component_name = "from_ODB"

Import PCB from AEDB file#

Import a PCB from an AEDB file.

odb_path = os.path.join(input_dir, aedt_odb_project)
ipk.create_pcb_from_3dlayout(
    component_name, odb_path, aedt_odb_design_name, extenttype="Polygon", outlinepolygon=outline_polygon_name
)
<pyaedt.modules.Boundary.NativeComponentObject object at 0x0000021D8F3C4640>

Create offset coordinate system#

Create an offset coordinate system to match ODB++ with the Sherlock STEP file.

ipk.modeler.create_coordinate_system([0, 0, stackup_thickness / 2], mode="view", view="XY")
<pyaedt.modeler.Modeler.CoordinateSystem object at 0x0000021D8F3AF9A0>

Import CAD file#

Import a CAD file.

ipk.modeler.import_3d_cad(file_path, refresh_all_ids=False)
True

Save CAD file#

Save the CAD file and refresh the properties from the parsing of the AEDT file.

ipk.save_project(refresh_obj_ids_after_save=True)
True

Plot model#

Plot the model.

ipk.plot(show=False, export_path=os.path.join(project_folder, "Sherlock_Example.jpg"), plot_air_objects=False)
Sherlock Example
<pyaedt.generic.plot.ModelPlotter object at 0x0000021D997E7880>

Delete PCB objects#

Delete the PCB objects.

ipk.modeler.delete_objects_containing("pcb", False)
True

Create region#

Create an air region.

ipk.modeler.create_air_region(*[20, 20, 300, 20, 20, 300])
<pyaedt.modeler.Object3d.Object3d object at 0x0000021DF1905A30>

Assign materials#

Assign materials from the the Sherlock file.

ipk.assignmaterial_from_sherlock_files(component_list, material_list)
True

Delete objects with no material assignments#

Delete objects with no materials assignments.

no_material_objs = ipk.modeler.get_objects_by_material("")
ipk.modeler.delete(no_material_objs)
ipk.save_project()
True

Assign power to component blocks#

Assign power to component blocks.

all_objects = ipk.modeler.object_names

Assign power blocks#

Assign power blocks from the Sherlock file.

total_power = ipk.assign_block_from_sherlock_file(component_list)

Plot model#

Plot the model again now that materials are assigned.

ipk.plot(show=False, export_path=os.path.join(project_folder, "Sherlock_Example.jpg"), plot_air_objects=False)
Sherlock Example
<pyaedt.generic.plot.ModelPlotter object at 0x0000021D99C34C70>

Set up boundaries#

Set up boundaries.

ipk.mesh.automatic_mesh_pcb(4)

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
ipk.assign_openings(ipk.modeler.get_object_faces("Region"))
<pyaedt.modules.Boundary.BoundaryObject object at 0x0000021D9BC37F40>

Check for intersections#

Check for intersections using validation and fix them by assigning priorities.

ipk.assign_priority_on_intersections()
True

Save project and release AEDT#

Save the project and release AEDT.

ipk.save_project()

end = time.time() - start
print("Elapsed time: {}".format(datetime.timedelta(seconds=end)))
print("Project Saved in {} ".format(ipk.project_file))
if os.name != "posix":
    ipk.release_desktop()
Elapsed time: 0:00:45.225601
Project Saved in D:/Temp/pyaedt_prj_UE3/TutorialBoard.aedt

Total running time of the script: ( 0 minutes 51.759 seconds)

Gallery generated by Sphinx-Gallery