Download this example
Download this example as a Jupyter Notebook or as a Python script.
Circuit Netlist to Schematic#
This example shows how to create components in the circuit schematic editor from a netlist file.
Note that HSPICE files are fully supported and that broad coverage is provided for many other formats.
Keywords: Circuit, netlist.
Perform imports and define constants#
Import the required packages.
[1]:
import os
import tempfile
import time
import ansys.aedt.core
Define constants.#
[2]:
AEDT_VERSION = "2024.2"
NG_MODE = False # Open AEDT UI when it is launched.
Create temporary directory#
Create a temporary directory where downloaded data or dumped data can be stored. If you’d like to retrieve the project data for subsequent use, the temporary folder name is given by temp_folder.name
.
[3]:
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
Launch AEDT with Circuit#
Launch AEDT with Circuit. The ansys.aedt.core.Desktop
class initializes AEDT and starts it on the specified version in the specified graphical mode.
[4]:
netlist = ansys.aedt.core.downloads.download_netlist(destination=temp_folder.name)
circuit = ansys.aedt.core.Circuit(
project=os.path.join(temp_folder.name, "NetlistExample"),
version=AEDT_VERSION,
non_graphical=NG_MODE,
new_desktop=True,
)
PyAEDT INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
PyAEDT INFO: PyAEDT version 0.12.dev0.
PyAEDT INFO: Initializing new Desktop session.
PyAEDT INFO: Log on console is enabled.
PyAEDT INFO: Log on file C:\Users\ansys\AppData\Local\Temp\pyaedt_ansys_5679b1ce-9e69-4c0b-8b34-afb7e48f0b86.log is enabled.
PyAEDT INFO: Log on AEDT is enabled.
PyAEDT INFO: Debug logger is disabled. PyAEDT methods will not be logged.
PyAEDT INFO: Launching PyAEDT with gRPC plugin.
PyAEDT INFO: New AEDT session is starting on gRPC port 54667
PyAEDT INFO: AEDT installation Path C:\Program Files\AnsysEM\v242\Win64
PyAEDT INFO: Ansoft.ElectronicsDesktop.2024.2 version started with process ID 6368.
PyAEDT INFO: Project NetlistExample has been created.
PyAEDT INFO: No design is present. Inserting a new design.
PyAEDT INFO: Added design 'Circuit Design_MOI' of type Circuit Design.
PyAEDT INFO: Aedt Objects correctly read
Define a parameter#
Specify the voltage as a parameter.
[5]:
circuit["Voltage"] = "5"
Create schematic from netlist file#
Create a schematic from a netlist file. The create_schematic_from_netlist()
method reads the netlist file and parses it. All components are parsed, but only these categories are mapped: R, L, C, Q, U, J, V, and I.
[6]:
circuit.create_schematic_from_netlist(netlist)
PyAEDT INFO: ModelerCircuit class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: ModelerNexxim class has been initialized!
PyAEDT INFO: Modeler class has been initialized! Elapsed time: 0m 0sec
['NAME:Models_Netlist', 'Info:=', ['Type:=', 0, 'NumTerminals:=', 0, 'DataSource:=', '', 'ModifiedOn:=', '', 'Manufacturer:=', '', 'Symbol:=', 'Models_Netlist', 'ModelNames:=', '', 'Footprint:=', '', 'Description:=', '', 'InfoTopic:=', '', 'InfoHelpFile:=', '', 'IconFile:=', '', 'Library:=', '', 'OriginalLocation:=', 'Project', 'IEEE:=', '', 'Author:=', '', 'OriginalAuthor:=', '', 'CreationDate:=', '', 'ExampleFile:=', '', 'HiddenComponent:=', 0, 'CircuitEnv:=', 0, 'GroupID:=', 0], 'CircuitEnv:=', 0, 'Refbase:=', 'x', 'NumParts:=', 1, 'ModSinceLib:=', True, 'CompExtID:=', 1, ['NAME:Parameters', 'ButtonProp:=', ['CosimDefinition', 'D', '', 'Edit', 'Edit', 40501, 'ButtonPropClientData:=', []], 'MenuProp:=', ['CoSimulator', 'D', '', 'DefaultNetlist', 0]], ['NAME:CosimDefinitions', ['NAME:CosimDefinition', 'CosimulatorType:=', 4, 'CosimDefName:=', 'DefaultNetlist', 'IsDefinition:=', True, 'Connect:=', True, 'Data:=', ['Nexxim Circuit:=', 'x@ID '], 'GRef:=', ['Nexxim Circuit:=', '']], 'DefaultCosim:=', 'DefaultNetlist']]
PyAEDT WARNING:
could not be imported
['NAME:STS6NF20V', 'Info:=', ['Type:=', 0, 'NumTerminals:=', 8, 'DataSource:=', '', 'ModifiedOn:=', 1591858313, 'Manufacturer:=', '', 'Symbol:=', 'STS6NF20V', 'ModelNames:=', '', 'Footprint:=', '', 'Description:=', '', 'InfoTopic:=', '', 'InfoHelpFile:=', '', 'IconFile:=', '', 'Library:=', '', 'OriginalLocation:=', 'Project', 'IEEE:=', '', 'Author:=', '', 'OriginalAuthor:=', '', 'CreationDate:=', 1591858313, 'ExampleFile:=', '', 'HiddenComponent:=', 0, 'CircuitEnv:=', 0, 'GroupID:=', 0], 'CircuitEnv:=', 0, 'Refbase:=', 'Q', 'NumParts:=', 1, 'ModSinceLib:=', True, 'Terminal:=', ['Pin1', 'Pin1', 'A', False, 0, 1, '', 'Electrical', '0'], 'Terminal:=', ['Pin2', 'Pin2', 'A', False, 0, 1, '', 'Electrical', '0'], 'Terminal:=', ['Pin3', 'Pin3', 'A', False, 0, 1, '', 'Electrical', '0'], 'Terminal:=', ['Pin4', 'Pin4', 'A', False, 0, 1, '', 'Electrical', '0'], 'Terminal:=', ['Pin5', 'Pin5', 'A', False, 0, 1, '', 'Electrical', '0'], 'Terminal:=', ['Pin6', 'Pin6', 'A', False, 0, 1, '', 'Electrical', '0'], 'Terminal:=', ['Pin7', 'Pin7', 'A', False, 0, 1, '', 'Electrical', '0'], 'Terminal:=', ['Pin8', 'Pin8', 'A', False, 0, 1, '', 'Electrical', '0'], 'CompExtID:=', 1, ['NAME:Parameters', 'TextValueProp:=', ['MOD', 'D', '', 'STS6NF20V'], 'ButtonProp:=', ['CosimDefinition', 'D', '', 'Edit', 'Edit', 40501, 'ButtonPropClientData:=', []], 'MenuProp:=', ['CoSimulator', 'D', '', 'DefaultNetlist', 0]], ['NAME:CosimDefinitions', ['NAME:CosimDefinition', 'CosimulatorType:=', 4, 'CosimDefName:=', 'DefaultNetlist', 'IsDefinition:=', True, 'Connect:=', True, 'Data:=', ['Nexxim Circuit:=', 'Q@ID %0 STS6NF20V %1 STS6NF20V %2 STS6NF20V %3 STS6NF20V %4 STS6NF20V %5 STS6NF20V %6 STS6NF20V %7 STS6NF20V @MOD '], 'GRef:=', ['Nexxim Circuit:=', '']], 'DefaultCosim:=', 'DefaultNetlist']]
['NAME:CON4', 'Info:=', ['Type:=', 0, 'NumTerminals:=', 5, 'DataSource:=', '', 'ModifiedOn:=', 1591858313, 'Manufacturer:=', '', 'Symbol:=', 'CON4', 'ModelNames:=', '', 'Footprint:=', '', 'Description:=', '', 'InfoTopic:=', '', 'InfoHelpFile:=', '', 'IconFile:=', '', 'Library:=', '', 'OriginalLocation:=', 'Project', 'IEEE:=', '', 'Author:=', '', 'OriginalAuthor:=', '', 'CreationDate:=', 1591858313, 'ExampleFile:=', '', 'HiddenComponent:=', 0, 'CircuitEnv:=', 0, 'GroupID:=', 0], 'CircuitEnv:=', 0, 'Refbase:=', 'J', 'NumParts:=', 1, 'ModSinceLib:=', True, 'Terminal:=', ['Pin1', 'Pin1', 'A', False, 0, 1, '', 'Electrical', '0'], 'Terminal:=', ['Pin2', 'Pin2', 'A', False, 0, 1, '', 'Electrical', '0'], 'Terminal:=', ['Pin3', 'Pin3', 'A', False, 0, 1, '', 'Electrical', '0'], 'Terminal:=', ['Pin4', 'Pin4', 'A', False, 0, 1, '', 'Electrical', '0'], 'Terminal:=', ['Pin5', 'Pin5', 'A', False, 0, 1, '', 'Electrical', '0'], 'CompExtID:=', 1, ['NAME:Parameters', 'TextValueProp:=', ['MOD', 'D', '', 'CON4'], 'ButtonProp:=', ['CosimDefinition', 'D', '', 'Edit', 'Edit', 40501, 'ButtonPropClientData:=', []], 'MenuProp:=', ['CoSimulator', 'D', '', 'DefaultNetlist', 0]], ['NAME:CosimDefinitions', ['NAME:CosimDefinition', 'CosimulatorType:=', 4, 'CosimDefName:=', 'DefaultNetlist', 'IsDefinition:=', True, 'Connect:=', True, 'Data:=', ['Nexxim Circuit:=', 'J@ID %0 CON4 %1 CON4 %2 CON4 %3 CON4 %4 CON4 @MOD '], 'GRef:=', ['Nexxim Circuit:=', '']], 'DefaultCosim:=', 'DefaultNetlist']]
['NAME:DCH010505SN7', 'Info:=', ['Type:=', 0, 'NumTerminals:=', 4, 'DataSource:=', '', 'ModifiedOn:=', 1591858313, 'Manufacturer:=', '', 'Symbol:=', 'DCH010505SN7', 'ModelNames:=', '', 'Footprint:=', '', 'Description:=', '', 'InfoTopic:=', '', 'InfoHelpFile:=', '', 'IconFile:=', '', 'Library:=', '', 'OriginalLocation:=', 'Project', 'IEEE:=', '', 'Author:=', '', 'OriginalAuthor:=', '', 'CreationDate:=', 1591858313, 'ExampleFile:=', '', 'HiddenComponent:=', 0, 'CircuitEnv:=', 0, 'GroupID:=', 0], 'CircuitEnv:=', 0, 'Refbase:=', 'U', 'NumParts:=', 1, 'ModSinceLib:=', True, 'Terminal:=', ['Pin1', 'Pin1', 'A', False, 0, 1, '', 'Electrical', '0'], 'Terminal:=', ['Pin2', 'Pin2', 'A', False, 0, 1, '', 'Electrical', '0'], 'Terminal:=', ['Pin3', 'Pin3', 'A', False, 0, 1, '', 'Electrical', '0'], 'Terminal:=', ['Pin4', 'Pin4', 'A', False, 0, 1, '', 'Electrical', '0'], 'CompExtID:=', 1, ['NAME:Parameters', 'TextValueProp:=', ['MOD', 'D', '', 'DCH010505SN7'], 'ButtonProp:=', ['CosimDefinition', 'D', '', 'Edit', 'Edit', 40501, 'ButtonPropClientData:=', []], 'MenuProp:=', ['CoSimulator', 'D', '', 'DefaultNetlist', 0]], ['NAME:CosimDefinitions', ['NAME:CosimDefinition', 'CosimulatorType:=', 4, 'CosimDefName:=', 'DefaultNetlist', 'IsDefinition:=', True, 'Connect:=', True, 'Data:=', ['Nexxim Circuit:=', 'U@ID %0 DCH010505SN7 %1 DCH010505SN7 %2 DCH010505SN7 %3 DCH010505SN7 @MOD '], 'GRef:=', ['Nexxim Circuit:=', '']], 'DefaultCosim:=', 'DefaultNetlist']]
PyAEDT WARNING: .END
could not be imported
PyAEDT INFO: Netlist was correctly imported into Circuit Design_MOI
[6]:
True
Release AEDT#
Release AEDT and close the example.
[7]:
circuit.save_project()
circuit.release_desktop()
# Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory.
time.sleep(3)
PyAEDT INFO: Project NetlistExample Saved correctly
PyAEDT INFO: Desktop has been released and closed.
Clean up#
All project files are saved in the folder temp_folder.name
. If you’ve run this example as a Jupyter notebook, you can retrieve those project files. The following cell removes all temporary files, including the project folder.
[8]:
temp_folder.cleanup()
Download this example
Download this example as a Jupyter Notebook or as a Python script.