{ "cells": [ { "cell_type": "markdown", "id": "4f4a1c2b", "metadata": {}, "source": [ "# Setup from Sherlock inputs" ] }, { "cell_type": "markdown", "id": "501bfd30", "metadata": {}, "source": [ "This example shows how to create an Icepak project from Sherlock\n", "files (STEP and CSV) and an AEDB board.\n", "\n", "Keywords: **Icepak**, **Sherlock**." ] }, { "cell_type": "markdown", "id": "a66ff135", "metadata": {}, "source": [ "## Perform imports and define constants\n", "\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "dd35eecc", "metadata": {}, "outputs": [], "source": [ "import os\n", "import tempfile\n", "import time\n", "\n", "import ansys.aedt.core\n", "from ansys.aedt.core.examples.downloads import download_sherlock\n" ] }, { "cell_type": "markdown", "id": "d5e19451", "metadata": {}, "source": [ "Define constants" ] }, { "cell_type": "code", "execution_count": null, "id": "c52127e7", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2026.1\"\n", "NUM_CORES = 4\n", "NG_MODE = False # Open AEDT UI when it is launched." ] }, { "cell_type": "markdown", "id": "75edf0c7", "metadata": {}, "source": [ "## Set paths and define input files and variables\n", "\n", "Set paths." ] }, { "cell_type": "code", "execution_count": null, "id": "c3b7fe53", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")\n", "input_dir = download_sherlock(local_path=temp_folder.name)" ] }, { "cell_type": "markdown", "id": "f90e977f", "metadata": {}, "source": [ "Define input files." ] }, { "cell_type": "code", "execution_count": null, "id": "e7ad153e", "metadata": {}, "outputs": [], "source": [ "material_name = \"MaterialExport.csv\"\n", "component_properties = \"TutorialBoardPartsList.csv\"\n", "component_step = \"TutorialBoard.stp\"\n", "aedt_odb_project = \"SherlockTutorial.aedt\"" ] }, { "cell_type": "markdown", "id": "e12b2e86", "metadata": {}, "source": [ "Define variables that are needed later." ] }, { "cell_type": "code", "execution_count": null, "id": "5794a6b4", "metadata": {}, "outputs": [], "source": [ "aedt_odb_design_name = \"PCB\"\n", "outline_polygon_name = \"poly_14188\"" ] }, { "cell_type": "markdown", "id": "f534bb34", "metadata": {}, "source": [ "Define input files with paths." ] }, { "cell_type": "code", "execution_count": null, "id": "c461f610", "metadata": {}, "outputs": [], "source": [ "material_list = os.path.join(input_dir, material_name)\n", "component_list = os.path.join(input_dir, component_properties)\n", "validation = os.path.join(temp_folder.name, \"validation.log\")\n", "file_path = os.path.join(input_dir, component_step)\n", "project_name = os.path.join(temp_folder.name, component_step[:-3] + \"aedt\")" ] }, { "cell_type": "markdown", "id": "cb835e02", "metadata": {}, "source": [ "## Create Icepak model" ] }, { "cell_type": "code", "execution_count": null, "id": "162f5cae", "metadata": {}, "outputs": [], "source": [ "ipk = ansys.aedt.core.Icepak(project=project_name, version=AEDT_VERSION, non_graphical=NG_MODE)" ] }, { "cell_type": "markdown", "id": "013fa55f", "metadata": {}, "source": [ "Disable autosave to speed up the import." ] }, { "cell_type": "code", "execution_count": null, "id": "32e38019", "metadata": {}, "outputs": [], "source": [ "ipk.autosave_disable()" ] }, { "cell_type": "markdown", "id": "c58cc8b0", "metadata": {}, "source": [ "Import a PCB from an AEDB file." ] }, { "cell_type": "code", "execution_count": null, "id": "3be1358e", "metadata": {}, "outputs": [], "source": [ "odb_path = os.path.join(input_dir, aedt_odb_project)\n", "ipk.create_pcb_from_3dlayout(component_name=\"Board\", project_name=odb_path, design_name=aedt_odb_design_name)" ] }, { "cell_type": "markdown", "id": "e9a9ca85", "metadata": {}, "source": [ "Create an offset coordinate system to match ODB++ with the Sherlock STEP file.\n", "The thickness is computed from the ``\"Board\"`` component. (``\"Board1\"`` is the\n", "instance name of the ``\"Board\"`` native component and is used to offset the coordinate system.)" ] }, { "cell_type": "code", "execution_count": null, "id": "4a1915a9", "metadata": {}, "outputs": [], "source": [ "bb = ipk.modeler.user_defined_components[\"Board1\"].bounding_box\n", "stackup_thickness = bb[-1] - bb[2]\n", "ipk.modeler.create_coordinate_system(origin=[0, 0, stackup_thickness / 2], mode=\"view\", view=\"XY\")" ] }, { "cell_type": "markdown", "id": "3338b1a2", "metadata": {}, "source": [ "Import the board components from an MCAD file and remove the PCB object as it is already\n", "imported with the ECAD." ] }, { "cell_type": "code", "execution_count": null, "id": "62663a49", "metadata": {}, "outputs": [], "source": [ "ipk.modeler.import_3d_cad(file_path, refresh_all_ids=False)\n", "ipk.modeler.delete_objects_containing(\"pcb\", False)" ] }, { "cell_type": "markdown", "id": "03cfc907", "metadata": {}, "source": [ "Modify the air region. Padding values are passed in this order: [+X, -X, +Y, -Y, +Z, -Z]" ] }, { "cell_type": "code", "execution_count": null, "id": "ae8c2595", "metadata": {}, "outputs": [], "source": [ "ipk.mesh.global_mesh_region.global_region.padding_values = [20, 20, 20, 20, 300, 300]" ] }, { "cell_type": "markdown", "id": "c6cfa299", "metadata": {}, "source": [ "## Assign materials and power dissipation conditions from Sherlock\n", "\n", "Use the Sherlock file to assign materials." ] }, { "cell_type": "code", "execution_count": null, "id": "522aada3", "metadata": {}, "outputs": [], "source": [ "ipk.assignmaterial_from_sherlock_files(component_file=component_list, material_file=material_list)" ] }, { "cell_type": "markdown", "id": "1c130fd3", "metadata": {}, "source": [ "Delete objects with no material assignments." ] }, { "cell_type": "code", "execution_count": null, "id": "3d5fb3a4", "metadata": {}, "outputs": [], "source": [ "no_material_objs = ipk.modeler.get_objects_by_material(material=\"\")\n", "ipk.modeler.delete(assignment=no_material_objs)\n", "ipk.save_project()" ] }, { "cell_type": "markdown", "id": "dfec2b61", "metadata": {}, "source": [ "Assign power blocks from the Sherlock file." ] }, { "cell_type": "code", "execution_count": null, "id": "2179561d", "metadata": {}, "outputs": [], "source": [ "total_power = ipk.assign_block_from_sherlock_file(csv_name=component_list)" ] }, { "cell_type": "code", "execution_count": null, "id": "31801c1b", "metadata": {}, "outputs": [], "source": [ "# ## Assign openings\n", "#\n", "# Assign opening boundary condition to all the faces of the region.\n", "ipk.assign_openings(ipk.modeler.get_object_faces(\"Region\"))" ] }, { "cell_type": "markdown", "id": "2f2890f7", "metadata": {}, "source": [ "## Create simulation setup\n", "### Set global mesh settings" ] }, { "cell_type": "code", "execution_count": null, "id": "f617657e", "metadata": { "lines_to_next_cell": 2 }, "outputs": [], "source": [ "ipk.globalMeshSettings(\n", " 3,\n", " gap_min_elements=\"1\",\n", " noOgrids=True,\n", " MLM_en=True,\n", " MLM_Type=\"2D\",\n", " edge_min_elements=\"2\",\n", " object=\"Region\",\n", ")" ] }, { "cell_type": "markdown", "id": "701b385a", "metadata": {}, "source": [ "### Add postprocessing object\n", "Create the point monitor." ] }, { "cell_type": "code", "execution_count": null, "id": "13295579", "metadata": {}, "outputs": [], "source": [ "point1 = ipk.monitor.assign_point_monitor(point_position=ipk.modeler[\"COMP_U10\"].top_face_z.center, monitor_name=\"Point1\")" ] }, { "cell_type": "markdown", "id": "f0df9ee9", "metadata": {}, "source": [ "Create a line for reporting after the simulation." ] }, { "cell_type": "code", "execution_count": null, "id": "b70159de", "metadata": {}, "outputs": [], "source": [ "line = ipk.modeler.create_polyline(\n", " points=[\n", " ipk.modeler[\"COMP_U10\"].top_face_z.vertices[0].position,\n", " ipk.modeler[\"COMP_U10\"].top_face_z.vertices[2].position,\n", " ],\n", " non_model=True,\n", ")" ] }, { "cell_type": "markdown", "id": "b9c6ccc4", "metadata": {}, "source": [ "### Solve\n", "To solve quickly, the maximum iterations are set to 20. For better accuracy, you\n", "can increase the maximum to at least 100." ] }, { "cell_type": "code", "execution_count": null, "id": "fae4c9c1", "metadata": { "lines_to_next_cell": 2 }, "outputs": [], "source": [ "setup1 = ipk.create_setup()\n", "setup1.props[\"Solution Initialization - Y Velocity\"] = \"1m_per_sec\"\n", "setup1.props[\"Radiation Model\"] = \"Discrete Ordinates Model\"\n", "setup1.props[\"Include Gravity\"] = True\n", "setup1.props[\"Secondary Gradient\"] = True\n", "setup1.props[\"Convergence Criteria - Max Iterations\"] = 100" ] }, { "cell_type": "markdown", "id": "af7c52f3", "metadata": {}, "source": [ "## Release AEDT" ] }, { "cell_type": "code", "execution_count": null, "id": "c6e2738c", "metadata": {}, "outputs": [], "source": [ "ipk.save_project()\n", "ipk.release_desktop()\n", "# Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory.\n", "time.sleep(3)" ] }, { "cell_type": "markdown", "id": "d50ecf56", "metadata": {}, "source": [ "## Clean up\n", "\n", "All project files are saved in the folder ``temp_folder.name``.\n", "If you've run this example as a Jupyter notebook, you\n", "can retrieve those project files. The following cell\n", "removes all temporary files, including the project folder." ] }, { "cell_type": "code", "execution_count": null, "id": "a2a834a6", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }