{ "cells": [ { "cell_type": "markdown", "id": "60398399", "metadata": {}, "source": [ "# Import Setup AC\n", "This example shows how to import SIwave, HFSS setups for AC analysis. In this example, we are going to\n", "\n", "- Download an example board\n", "- Create a configuration file\n", " - add setups\n", "- Import the configuration file" ] }, { "cell_type": "markdown", "id": "a23b196e", "metadata": {}, "source": [ "### Import the required packages" ] }, { "cell_type": "code", "execution_count": null, "id": "656b2deb", "metadata": {}, "outputs": [], "source": [ "import json\n", "from pathlib import Path\n", "import tempfile\n", "\n", "from ansys.aedt.core.downloads import download_file\n", "\n", "from pyedb import Edb\n", "\n", "AEDT_VERSION = \"2024.2\"\n", "NG_MODE = False\n" ] }, { "cell_type": "markdown", "id": "83f5a938", "metadata": {}, "source": [ "Download the example PCB data." ] }, { "cell_type": "code", "execution_count": null, "id": "4754ae7a", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")\n", "file_edb = download_file(source=\"edb/ANSYS-HSD_V1.aedb\", destination=temp_folder.name)" ] }, { "cell_type": "markdown", "id": "edaf5ee2", "metadata": {}, "source": [ "## Load example layout." ] }, { "cell_type": "code", "execution_count": null, "id": "8e8446b0", "metadata": {}, "outputs": [], "source": [ "edbapp = Edb(file_edb, edbversion=AEDT_VERSION)" ] }, { "cell_type": "markdown", "id": "4b8e2993", "metadata": {}, "source": [ "## Create an empty dictionary to host all configurations." ] }, { "cell_type": "code", "execution_count": null, "id": "5671d45e", "metadata": {}, "outputs": [], "source": [ "cfg = dict()" ] }, { "cell_type": "markdown", "id": "5647eb09", "metadata": {}, "source": [ "## Create an SIwave SYZ setup" ] }, { "cell_type": "markdown", "id": "628debfb", "metadata": {}, "source": [ "Keywords\n", "\n", "- **name**. Name of the setup.\n", "- **type**. Type of the analysis setup. Supported types are 'siwave_ac', 'siwave_dc', 'hfss'.\n", "- **pi_slider_position**. PI slider position. Supported values are from '0', '1', '2'. 0:speed, 1:balanced,\n", "2:accuracy.\n", "- **freq_sweep**. List of frequency sweeps.\n", " - **name**. Name of the sweep.\n", " - **type**. Type of the sweep. Supported types are 'interpolation', 'discrete', 'broadband'.\n", " - **frequencies**. Frequency distribution.\n", " - **distribution**. Supported distributions are 'linear_count', 'linear_scale', 'log_scale'.\n", " - **start**. Start frequency. Example, 1e6, \"1MHz\".\n", " - **stop**. Stop frequency. Example, 1e9, \"1GHz\".\n", " - **increment**." ] }, { "cell_type": "code", "execution_count": null, "id": "7ca52c66", "metadata": {}, "outputs": [], "source": [ "siwave_setup = {\n", " \"name\": \"siwave_1\",\n", " \"type\": \"siwave_ac\",\n", " \"pi_slider_position\": 1,\n", " \"freq_sweep\": [\n", " {\n", " \"name\": \"Sweep1\",\n", " \"type\": \"interpolation\",\n", " \"frequencies\": [{\"distribution\": \"log_scale\", \"start\": 1e6, \"stop\": 1e9, \"increment\": 20}],\n", " }\n", " ],\n", "}" ] }, { "cell_type": "markdown", "id": "ec3aa681", "metadata": {}, "source": [ "## Create a HFSS setup" ] }, { "cell_type": "markdown", "id": "9e753999", "metadata": {}, "source": [ "Keywords\n", "\n", "- **name**. Name of the setup.\n", "- **type**. Type of the analysis setup. Supported types are 'siwave_ac', 'siwave_dc', 'hfss'.\n", "- **f_adapt**. Adaptive frequency.\n", "- **max_num_passes**. Maximum number of passes.\n", "- **max_mag_delta_s**. Convergence criteria delta S.\n", "- **mesh_operations**. Mesh operations.\n", " - **name**. Name of the mesh operation.\n", " - **type**. Type of the mesh operation. The supported types are 'base', 'length', 'skin_depth'.\n", " - **max_length**. Maximum length of elements.\n", " - **restrict_length**. Whether to restrict length of elements.\n", " - **refine_inside**. Whether to turn on refine inside objects.\n", " - **nets_layers_list**. {'layer_name':['net_name_1', 'net_name_2']}\n", "- **freq_sweep**. List of frequency sweeps.\n", " - **name**. Name of the sweep.\n", " - **type**. Type of the sweep. Supported types are 'interpolation', 'discrete', 'broadband'.\n", " - **frequencies**. Frequency distribution.\n", " - **distribution**. Supported distributions are 'linear_count', 'linear_scale', 'log_scale'.\n", " - **start**. Start frequency. Example, 1e6, \"1MHz\".\n", " - **stop**. Stop frequency. Example, 1e9, \"1GHz\".\n", " - **increment**." ] }, { "cell_type": "code", "execution_count": null, "id": "4230435f", "metadata": {}, "outputs": [], "source": [ "hfss_setup = {\n", " \"name\": \"hfss_1\",\n", " \"type\": \"hfss\",\n", " \"f_adapt\": \"5GHz\",\n", " \"max_num_passes\": 10,\n", " \"max_mag_delta_s\": 0.02,\n", " \"mesh_operations\": [\n", " {\n", " \"name\": \"mop_1\",\n", " \"type\": \"length\",\n", " \"max_length\": \"3mm\",\n", " \"restrict_length\": True,\n", " \"refine_inside\": False,\n", " \"nets_layers_list\": {\"GND\": [\"1_Top\", \"16_Bottom\"]},\n", " }\n", " ],\n", " \"freq_sweep\": [\n", " {\n", " \"name\": \"Sweep1\",\n", " \"type\": \"interpolation\",\n", " \"frequencies\": [{\"distribution\": \"log_scale\", \"start\": 1e6, \"stop\": 1e9, \"increment\": 20}],\n", " }\n", " ],\n", "}" ] }, { "cell_type": "markdown", "id": "7ac59109", "metadata": {}, "source": [ "## Add setups in configuration" ] }, { "cell_type": "code", "execution_count": null, "id": "12ba0aeb", "metadata": {}, "outputs": [], "source": [ "cfg[\"setups\"] = [siwave_setup, hfss_setup]" ] }, { "cell_type": "markdown", "id": "c3eec153", "metadata": {}, "source": [ "## Write configuration into as json file" ] }, { "cell_type": "code", "execution_count": null, "id": "7cdf4799", "metadata": {}, "outputs": [], "source": [ "file_json = Path(temp_folder.name) / \"edb_configuration.json\"\n", "with open(file_json, \"w\") as f:\n", " json.dump(cfg, f, indent=4, ensure_ascii=False)" ] }, { "cell_type": "markdown", "id": "fa26d3cb", "metadata": {}, "source": [ "## Import configuration into example layout" ] }, { "cell_type": "code", "execution_count": null, "id": "73f68f3a", "metadata": {}, "outputs": [], "source": [ "edbapp.configuration.load(config_file=file_json)\n", "edbapp.configuration.run()" ] }, { "cell_type": "markdown", "id": "09b9d987", "metadata": {}, "source": [ "## Review" ] }, { "cell_type": "code", "execution_count": null, "id": "c29e294f", "metadata": {}, "outputs": [], "source": [ "edbapp.setups" ] }, { "cell_type": "markdown", "id": "31d2728d", "metadata": {}, "source": [ "## Save and close Edb\n", "The temporary folder will be deleted once the execution of this script is finished. Replace **edbapp.save()** with\n", "**edbapp.save_as(\"C:/example.aedb\")** to keep the example project." ] }, { "cell_type": "code", "execution_count": null, "id": "1a388ca3", "metadata": {}, "outputs": [], "source": [ "edbapp.save()\n", "edbapp.close()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }