{ "cells": [ { "cell_type": "markdown", "id": "8a1a280b", "metadata": {}, "source": [ "# EDB: parameterized design\n", "\n", "This example shows how to\n", "1. Set up an HFSS project using SimulationConfiguration class.\n", "2. Create automatically parametrized design.\n", "\n", "This image shows the layout created in this example:\n", "\n", "\n" ] }, { "cell_type": "markdown", "id": "ebdd6cc5", "metadata": {}, "source": [ "## Import dependencies." ] }, { "cell_type": "code", "execution_count": null, "id": "35334f9d", "metadata": {}, "outputs": [], "source": [ "import tempfile" ] }, { "cell_type": "code", "execution_count": null, "id": "87aa357c", "metadata": {}, "outputs": [], "source": [ "import ansys.aedt.core" ] }, { "cell_type": "code", "execution_count": null, "id": "935896bb", "metadata": {}, "outputs": [], "source": [ "import pyedb\n", "from pyedb.misc.downloads import download_file" ] }, { "cell_type": "markdown", "id": "aed68068", "metadata": {}, "source": [ "## Create an instance of a pyedb.Edb object." ] }, { "cell_type": "code", "execution_count": null, "id": "270b5713", "metadata": {}, "outputs": [], "source": [ "temp_dir = tempfile.TemporaryDirectory(suffix=\".ansys\")\n", "target_aedb = download_file(\"edb/ANSYS-HSD_V1.aedb\", destination=temp_dir.name)\n", "print(\"Project is located in \", target_aedb)\n", "\n", "# Select EDB version (change it manually if needed, e.g. \"2024.2\")\n", "edb_version = \"2024.2\"\n", "print(f\"EDB version: {edb_version}\")\n", "\n", "edb = pyedb.Edb(edbpath=target_aedb, edbversion=edb_version)\n", "print(\"AEDB file is located in {}\".format(target_aedb))" ] }, { "cell_type": "markdown", "id": "7ab4a4a6", "metadata": {}, "source": [ "## Prepare the layout for the simulation\n", "\n", "The ``new_simulation_configuration()`` method creates an instance of\n", "the ``SimulationConfiguration`` class. This class helps define all preprocessing steps\n", "required to set up the PCB for simulation. After the simulation configuration has been defined,\n", "they are applied to the EDB using the ``Edb.build_simulation()`` method." ] }, { "cell_type": "code", "execution_count": null, "id": "da119c66", "metadata": {}, "outputs": [], "source": [ "simulation_configuration = edb.new_simulation_configuration()\n", "simulation_configuration.signal_nets = [\n", " \"PCIe_Gen4_RX0_P\",\n", " \"PCIe_Gen4_RX0_N\",\n", " \"PCIe_Gen4_RX1_P\",\n", " \"PCIe_Gen4_RX1_N\",\n", "]\n", "simulation_configuration.power_nets = [\"GND\"]\n", "simulation_configuration.components = [\"X1\", \"U1\"]\n", "simulation_configuration.do_cutout_subdesign = True\n", "simulation_configuration.start_freq = \"OGHz\"\n", "simulation_configuration.stop_freq = \"20GHz\"\n", "simulation_configuration.step_freq = \"10MHz\"" ] }, { "cell_type": "markdown", "id": "a2c65bc3", "metadata": {}, "source": [ "Now apply the simulation setup to the EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "a142fbcb", "metadata": {}, "outputs": [], "source": [ "edb.build_simulation_project(simulation_configuration)" ] }, { "cell_type": "markdown", "id": "224c914c", "metadata": {}, "source": [ "## Parameterize\n", "\n", "The layout can automatically be set up to enable parametric studies. For example, the\n", "impact of antipad diameter or trace width on signal integrity performance may be invested\n", "parametrically." ] }, { "cell_type": "code", "execution_count": null, "id": "8a83b078", "metadata": {}, "outputs": [], "source": [ "edb.auto_parametrize_design(layers=True, materials=True, via_holes=True, pads=True, antipads=True, traces=True)\n", "edb.save_edb()\n", "edb.close_edb()" ] }, { "cell_type": "markdown", "id": "4aad2639", "metadata": {}, "source": [ "## Open project in AEDT\n", "\n", "All manipulations thus far have been executed using the EDB API, which provides fast,\n", "streamlined processing of layout data in non-graphical mode. The layout and simulation\n", "setup can be visualized by opening it using the 3D Layout editor in AEDT.\n", "\n", "Note that there may be some delay while AEDT is being launched." ] }, { "cell_type": "code", "execution_count": null, "id": "f75b931c", "metadata": {}, "outputs": [], "source": [ "hfss = ansys.aedt.core.Hfss3dLayout(\n", " projectname=target_aedb,\n", " specified_version=edb_version,\n", " non_graphical=False,\n", " new_desktop_session=True,\n", ")" ] }, { "cell_type": "markdown", "id": "93279204", "metadata": {}, "source": [ "The following cell can be used to ensure that the design is valid for simulation." ] }, { "cell_type": "code", "execution_count": null, "id": "8595ee3a", "metadata": {}, "outputs": [], "source": [ "validation_info = hfss.validate_full_design()\n", "is_ready_to_simulate = True" ] }, { "cell_type": "code", "execution_count": null, "id": "b9f5fb51", "metadata": {}, "outputs": [], "source": [ "for s in validation_info[0]:\n", " if \"error\" in s:\n", " print(s)\n", " is_ready_to_simulate = False\n", "\n", "if is_ready_to_simulate:\n", " print(\"The model is ready for simulation.\")\n", "else:\n", " print(\"There are errors in the model that must be fixed.\")" ] }, { "cell_type": "markdown", "id": "cba14ef7", "metadata": {}, "source": [ "## Release the application from the Python kernel\n", "\n", "It is important to release the application from the Python kernel after\n", "execution of the script. The default behavior of the ``release_desktop()`` method closes all open\n", "projects and closes the application.\n", "\n", "If you want to continue working on the project in graphical mode\n", "after script execution, call the following method with both arguments set to ``False``." ] }, { "cell_type": "code", "execution_count": null, "id": "21fe9ef7", "metadata": {}, "outputs": [], "source": [ "hfss.release_desktop(close_projects=True, close_desktop=True)\n", "temp_dir.cleanup() # Remove the temporary folder and files. All data will be removd!" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }