{ "cells": [ { "cell_type": "markdown", "id": "1ecf701f", "metadata": {}, "source": [ "# Double Pulse Test\n", "\n", "Description: build the equivalent circuit of a DPT\n", "\n", "In this example the steps to build up the circuit schematic are shown.\n", "1. Insert Circuit Components\n", "3. Create the Wiring\n", "4. Insert simulation set up\n", "3. View the results.\n", "\n", "Keywords: **Power Electronics**, **Double Pulse Testing**" ] }, { "cell_type": "markdown", "id": "403082c1", "metadata": {}, "source": [ "## Perform imports and define constants\n", "\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "0d8f6c42", "metadata": {}, "outputs": [], "source": [ "import os\n", "import tempfile\n", "import time" ] }, { "cell_type": "code", "execution_count": null, "id": "ab09e661", "metadata": {}, "outputs": [], "source": [ "import ansys.aedt.core" ] }, { "cell_type": "markdown", "id": "814dafcf", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "7d9a02c6", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2024.2\"\n", "NUM_CORES = 4\n", "NG_MODE = False # Open AEDT UI when it is launched." ] }, { "cell_type": "markdown", "id": "865a41c5", "metadata": {}, "source": [ "## Create temporary directory\n", "\n", "Create a temporary directory where downloaded data or\n", "dumped data can be stored.\n", "If you'd like to retrieve the project data for subsequent use,\n", "the temporary folder name is given by ``temp_folder.name``." ] }, { "cell_type": "code", "execution_count": null, "id": "fb2fac26", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")" ] }, { "cell_type": "markdown", "id": "d9170985", "metadata": {}, "source": [ "## Launch AEDT and Circuit" ] }, { "cell_type": "code", "execution_count": null, "id": "1aebac66", "metadata": {}, "outputs": [], "source": [ "project_name = os.path.join(temp_folder.name, \"my_project.aedt\")\n", "circuit = ansys.aedt.core.Circuit(\n", " project=project_name,\n", " version=AEDT_VERSION,\n", " non_graphical=NG_MODE,\n", " new_desktop=True,\n", ")\n", "circuit.modeler.schematic.schematic_units = \"mil\"" ] }, { "cell_type": "markdown", "id": "a1315d0d", "metadata": {}, "source": [ "## Variable initialization to create a parametric design\n", "\n", "Initialize dictionary that contain all the definitions for the design variables." ] }, { "cell_type": "code", "execution_count": null, "id": "b938b5e6", "metadata": {}, "outputs": [], "source": [ "design_properties = {\n", " \"VoltageDCbus\": \"400V\",\n", " \"r_g1\": \"2.2\",\n", " \"r_g2\": \"2.2\",\n", " \"c_dc_link\": \"0.0005farad\",\n", " \"l_load\": \"7.7e-5\",\n", " \"Vgate_top\": \"-5V\",\n", " \"r_load\": \"0.1\",\n", " \"r_dc_link\": \"1e6\",\n", " \"v_pwl_high\": \"18.0V\",\n", " \"v_pwl_low\": \"-5.0V\",\n", "}" ] }, { "cell_type": "markdown", "id": "b953a839", "metadata": {}, "source": [ "Define design variables from the created dictionaries." ] }, { "cell_type": "code", "execution_count": null, "id": "ce0619ec", "metadata": {}, "outputs": [], "source": [ "for k, v in design_properties.items():\n", " circuit[k] = v" ] }, { "cell_type": "markdown", "id": "e7499d34", "metadata": {}, "source": [ "## Insert Circuit Elements into the Schematic\n", "\n", "Define starting position for component placement." ] }, { "cell_type": "code", "execution_count": null, "id": "cfbcf87f", "metadata": {}, "outputs": [], "source": [ "y_upper_pin = 5200\n", "y_lower_pin = 2000" ] }, { "cell_type": "markdown", "id": "639bc38a", "metadata": {}, "source": [ "Define parametrically high and low voltage level for pwl voltage source." ] }, { "cell_type": "code", "execution_count": null, "id": "56097792", "metadata": {}, "outputs": [], "source": [ "time_list_pwl = [\n", " 0.0,\n", " 5.0e-6,\n", " 5.001e-6,\n", " 9.825e-06,\n", " 9.826e-06,\n", " 1.1e-05,\n", " 1.1001e-05,\n", " 1.3e-05,\n", " 1.3001e-05,\n", "]\n", "volt_list_pwl = [\n", " \"v_pwl_low\",\n", " \"v_pwl_low\",\n", " \"v_pwl_high\",\n", " \"v_pwl_high\",\n", " \"v_pwl_low\",\n", " \"v_pwl_low\",\n", " \"v_pwl_high\",\n", " \"v_pwl_high\",\n", " \"v_pwl_low\",\n", "]" ] }, { "cell_type": "markdown", "id": "cd0be1b2", "metadata": {}, "source": [ "Add circuit components to the schematic." ] }, { "cell_type": "code", "execution_count": null, "id": "7eb2f788", "metadata": {}, "outputs": [], "source": [ "v_pwl = circuit.modeler.components.create_voltage_pwl(\n", " name=\"v_pwl\",\n", " time_list=time_list_pwl,\n", " voltage_list=volt_list_pwl,\n", " location=[600, 2800],\n", ")\n", "v_gate_top = circuit.modeler.components.create_voltage_dc(\n", " name=\"Vgate_top\", value=\"Vgate_top\", location=[600, 4500]\n", ")\n", "v_dc_bus = circuit.modeler.components.create_voltage_dc(\n", " name=\"v_dc_bus\", value=\"VoltageDCbus\", location=[-1800, 3800]\n", ")\n", "c_dc_link = circuit.modeler.schematic.create_capacitor(\n", " name=\"c_dc_link\", value=\"c_dc_link\", location=[-1300, 3800], angle=90\n", ")\n", "r_dc_link = circuit.modeler.schematic.create_resistor(\n", " name=\"r_dc_link\", value=\"r_dc_link\", location=[-700, 3800], angle=90\n", ")\n", "l_load = circuit.modeler.schematic.create_inductor(\n", " name=\"l_load\", value=\"l_load\", location=[3000, 4800], angle=-90\n", ")\n", "r_load = circuit.modeler.schematic.create_resistor(\n", " name=\"r_load\", value=\"r_load\", location=[3000, 4300], angle=90\n", ")\n", "r_g1 = circuit.modeler.schematic.create_resistor(\n", " name=\"r_g1\", value=\"r_g1\", location=[1400, 4700], angle=180\n", ")\n", "r_g2 = circuit.modeler.schematic.create_resistor(\n", " name=\"r_g2\", value=\"r_g2\", location=[1400, 3100], angle=180\n", ")\n", "voltm_g = circuit.modeler.components.components_catalog[\"Probes:VPROBE_DIFF\"].place(\n", " assignment=\"voltage_g\", location=[100, 2900], angle=270\n", ")\n", "voltm_g.parameters[\"Name\"] = \"voltage_g\"\n", "voltm_ds = circuit.modeler.components.components_catalog[\"Probes:VPROBE_DIFF\"].place(\n", " assignment=\"voltage_ds\", location=[2500, 3300], angle=0\n", ")\n", "voltm_ds.parameters[\"Name\"] = \"voltage_ds\"\n", "amm_top = circuit.modeler.components.components_catalog[\"Probes:IPROBE\"].place(\n", " assignment=\"Itop\", location=[1100, 5200], angle=0\n", ")\n", "amm_top.parameters[\"Name\"] = \"Itop\"\n", "amm_ind = circuit.modeler.components.components_catalog[\"Probes:IPROBE\"].place(\n", " assignment=\"Iinductor\", location=[2500, 4000], angle=0\n", ")\n", "amm_ind.parameters[\"Name\"] = \"Iinductor\"\n", "amm_bot = circuit.modeler.components.components_catalog[\"Probes:IPROBE\"].place(\n", " assignment=\"Ibottom\", location=[2000, 3600], angle=270\n", ")\n", "amm_bot.parameters[\"Name\"] = \"Ibottom\"" ] }, { "cell_type": "markdown", "id": "1bb406f2", "metadata": {}, "source": [ "## Add nMOS components from Component Library.\n", "\n", "Please check that chosen component can access the method place()\n", "If you need to insert a component from a spice model,\n", "please use the method: circuit.modeler.components.create_component_from_spicemodel" ] }, { "cell_type": "code", "execution_count": null, "id": "cc425733", "metadata": {}, "outputs": [], "source": [ "nmos_h = circuit.modeler.components.components_catalog[\n", " \"Power Electronics Tools\\\\Power Semiconductors\\\\MOSFET\\\\STMicroelectronics:SCT040H65G3AG_V2\"\n", "].place(assignment=\"NMOS_HS\", location=[1500, 4700], angle=0)\n", "nmos_l = circuit.modeler.components.components_catalog[\n", " \"Power Electronics Tools\\\\Power Semiconductors\\\\MOSFET\\\\STMicroelectronics:SCT040H65G3AG_V2\"\n", "].place(\"NMOS_LS\", location=[1500, 3100], angle=0)" ] }, { "cell_type": "markdown", "id": "5127da3a", "metadata": {}, "source": [ "## Create wiring to complete the schematic." ] }, { "cell_type": "code", "execution_count": null, "id": "e0b7215f", "metadata": {}, "outputs": [], "source": [ "circuit.modeler.schematic.connect_components_in_series(\n", " assignment=[l_load, r_load], use_wire=True\n", ")\n", "circuit.modeler.schematic.connect_components_in_series(\n", " assignment=[v_gate_top, r_g1], use_wire=True\n", ")\n", "circuit.modeler.schematic.connect_components_in_series(\n", " assignment=[v_pwl, r_g2], use_wire=True\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [v_dc_bus.pins[1].location[0], v_dc_bus.pins[1].location[1]],\n", " [v_dc_bus.pins[1].location[0], y_upper_pin],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [c_dc_link.pins[1].location[0], c_dc_link.pins[1].location[1]],\n", " [c_dc_link.pins[1].location[0], y_upper_pin],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [r_dc_link.pins[0].location[0], r_dc_link.pins[0].location[1]],\n", " [r_dc_link.pins[0].location[0], y_upper_pin],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [l_load.pins[0].location[0], l_load.pins[0].location[1]],\n", " [l_load.pins[0].location[0], y_upper_pin],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [l_load.pins[0].location[0], y_upper_pin],\n", " [nmos_h.pins[0].location[0], y_upper_pin],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [v_dc_bus.pins[0].location[0], y_upper_pin],\n", " [amm_top.pins[0].location[0], amm_top.pins[0].location[1]],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [amm_top.pins[1].location[0], amm_top.pins[1].location[1]],\n", " [nmos_h.pins[0].location[0], y_upper_pin],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [nmos_h.pins[0].location[0], y_upper_pin],\n", " [nmos_h.pins[0].location[0], nmos_h.pins[0].location[1]],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [voltm_g.pins[1].location[0], voltm_g.pins[1].location[1]],\n", " [voltm_g.pins[1].location[0], v_pwl.pins[0].location[1]],\n", " [v_pwl.pins[0].location[0], v_pwl.pins[0].location[1]],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [v_pwl.pins[0].location[0], v_pwl.pins[0].location[1]],\n", " [nmos_l.pins[3].location[0], v_pwl.pins[0].location[1]],\n", " [nmos_l.pins[3].location[0], nmos_l.pins[3].location[1]],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [v_gate_top.pins[0].location[0], v_gate_top.pins[0].location[1]],\n", " [nmos_h.pins[3].location[0], v_gate_top.pins[0].location[1]],\n", " [nmos_h.pins[3].location[0], nmos_h.pins[3].location[1]],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [nmos_h.pins[0].location[0], y_upper_pin],\n", " [nmos_h.pins[0].location[0], nmos_h.pins[0].location[1]],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [r_load.pins[1].location[0], r_load.pins[1].location[1]],\n", " [r_load.pins[1].location[0], amm_ind.pins[1].location[1]],\n", " [amm_ind.pins[1].location[0], amm_ind.pins[1].location[1]],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [amm_ind.pins[0].location[0], amm_ind.pins[0].location[1]],\n", " [amm_bot.pins[0].location[0], amm_ind.pins[0].location[1]],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [voltm_g.pins[0].location[0], voltm_g.pins[0].location[1]],\n", " [v_pwl.pins[0].location[0], voltm_g.pins[0].location[1]],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [v_dc_bus.pins[0].location[0], v_dc_bus.pins[0].location[1]],\n", " [v_dc_bus.pins[0].location[0], y_lower_pin],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [c_dc_link.pins[0].location[0], c_dc_link.pins[0].location[1]],\n", " [c_dc_link.pins[0].location[0], y_lower_pin],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [r_dc_link.pins[1].location[0], r_dc_link.pins[1].location[1]],\n", " [r_dc_link.pins[1].location[0], y_lower_pin],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [nmos_l.pins[2].location[0], nmos_l.pins[2].location[1]],\n", " [nmos_l.pins[2].location[0], y_lower_pin],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [voltm_ds.pins[1].location[0], voltm_ds.pins[1].location[1]],\n", " [voltm_ds.pins[1].location[0], y_lower_pin],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [nmos_l.pins[2].location[0], nmos_l.pins[2].location[1]],\n", " [nmos_l.pins[2].location[0], y_lower_pin],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [nmos_h.pins[2].location[0], nmos_h.pins[2].location[1]],\n", " [amm_bot.pins[0].location[0], amm_bot.pins[0].location[1]],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [nmos_l.pins[0].location[0], nmos_l.pins[0].location[1]],\n", " [amm_bot.pins[1].location[0], amm_bot.pins[1].location[1]],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [nmos_l.pins[0].location[0], nmos_l.pins[0].location[1]],\n", " [voltm_ds.pins[0].location[0], voltm_ds.pins[0].location[1]],\n", " ]\n", ")\n", "circuit.modeler.schematic.create_wire(\n", " [\n", " [v_dc_bus.pins[1].location[0], y_lower_pin],\n", " [voltm_ds.pins[1].location[0], y_lower_pin],\n", " ]\n", ")\n", "gnd = circuit.modeler.components.create_gnd(\n", " location=[voltm_ds.pins[1].location[0], y_lower_pin - 100]\n", ")\n", "r_g1.pins[1].connect_to_component(assignment=nmos_h.pins[1], use_wire=True)\n", "r_g2.pins[1].connect_to_component(assignment=nmos_l.pins[1], use_wire=True)" ] }, { "cell_type": "markdown", "id": "048c2144", "metadata": {}, "source": [ "## Create a transient setup" ] }, { "cell_type": "code", "execution_count": null, "id": "219679e1", "metadata": {}, "outputs": [], "source": [ "setup_name = \"MyTransient\"\n", "setup1 = circuit.create_setup(\n", " name=setup_name, setup_type=circuit.SETUPS.NexximTransient\n", ")\n", "setup1.props[\"TransientData\"] = [\"0.05ns\", \"15us\"]\n", "circuit.modeler.zoom_to_fit()" ] }, { "cell_type": "markdown", "id": "e522e7d0", "metadata": {}, "source": [ "Solve transient setup" ] }, { "cell_type": "code", "execution_count": null, "id": "11be8108", "metadata": {}, "outputs": [], "source": [ "circuit.analyze(setup_name, cores=NUM_CORES)" ] }, { "cell_type": "markdown", "id": "bf4487c9", "metadata": {}, "source": [ "## Plot Double Pulse Test results\n", "\n", "Create a report" ] }, { "cell_type": "code", "execution_count": null, "id": "24a26b41", "metadata": {}, "outputs": [], "source": [ "new_report = circuit.post.create_report(\n", " expressions=[\n", " \"V(voltage_g)\",\n", " \"V(voltage_ds)\",\n", " \"Ipositive(Ibottom)\",\n", " \"Ipositive(Iinductor)\",\n", " ],\n", " domain=\"Time\",\n", " plot_name=\"Plot V,I\",\n", ")" ] }, { "cell_type": "markdown", "id": "175e957c", "metadata": {}, "source": [ "## Release AEDT" ] }, { "cell_type": "code", "execution_count": null, "id": "9bc59d22", "metadata": {}, "outputs": [], "source": [ "circuit.save_project()\n", "circuit.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": "10c6f536", "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": "27530e82", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }