FAQTop, Main, Index
The most frequent questions are collected here.
- Where to find list of availible arguments for devices, models and analyses?
- How to use different simulators for the same circuit (managing namespaces)?
- How to change parameter of existing element?
- Is scaling suffixes allowed?
- How to change node name connected to pin of existing element?
- How to find the list of optional parameters for elements?
- How to get raw data after simulation?
- How to get the names of all vectors in raw file?
- How to get log file after simulation?
Where to find list of availible arguments for devices, models and analyses?Top, Main, Index
For the selected simulator, you need to open the documentation for the corresponding namespace, such as Ngspice. Then, select the category you are interested in:
- ::SpiceGenTcl::Ngspice::BasicDevices - for basic devices like resistors, capacitors, etc.
- ::SpiceGenTcl::Ngspice::Sources - for current and voltage sources.
- ::SpiceGenTcl::Ngspice::SemiconductorDevices - for semiconductor devices like diodes, transistors, etc.
- ::SpiceGenTcl::Ngspice::Analyses - for availible analysis for selected simulator.
Check out ::SpiceGenTcl::Ngspice::BasicDevices::Resistor as an example.
There, you can find a list of all available methods, a description of the arguments, an example of how the element string appears in the netlist, and an example of creating an object of the Resistor class.
How to use different simulators for the same circuit (managing namespaces)?Top, Main, Index
Each supported simulator has its own namespace. For example, ::SpiceGenTcl::Ngspice
is used for Ngspice, and ::SpiceGenTcl::Xyce
is used for Xyce. Additionally, there is the ::SpiceGenTcl::Common
namespace for devices with syntax that is compatible across most simulators.
To use a particular simulator, you can call ::SpiceGenTcl::importNgspice or ::SpiceGenTcl::importXyce to import all command names into the current scope. This approach is convenient because it minimizes code changes. Using full command paths would be more cumbersome. Many elements share the same interface (such as nodes and parameters), so the same code works with different simulators with minimal modifications.
You can also import element commands individually, like this:
This allows you to import the appropriate simulator in conditional statements, depending on a global variable that defines the simulator currently in use.
How to change parameter of existing element?Top, Main, Index
For all elements with parameters you can change parameter value by its name with method ::SpiceGenTcl::Device::setParamValue.
For example here we change the resistance value of basic resistor:
The name of the parameter can be found in the documentation here. In the parameter table, the option for resistance is labeled -r
, so the name used for resistance is 'r'.
Another option is to call the ::SpiceGenTcl::Device::getParams method, which returns a list of all parameters with their values. For example:
It returns:
So parameter name is 'r' with value '10'.
Is scaling suffixes allowed?Top, Main, Index
Yes, for numerical values scaling suffixes are allowed, the full list is: f p n u m k meg g t. It must be placed after the numerical value, for example, 10u or 10Meg. Forms 10uV or 1kOhm are not allowed.
How to change node name connected to pin of existing element?Top, Main, Index
For all elements with pins, you can change the connected node's name by using the pin name with the method ::SpiceGenTcl::Device::setPinNodeName.
For example, here we change the node name of the basic resistor's positive pin:
The pin name can be found in the documentation here. In the parameter table, the pins are listed as npNode
and nmNode
, so the names used for the positive and negative pins are 'np' and 'nm', respectively. This pin_nameNode
convention applies to all elements in the package.
Another option is to call the ::SpiceGenTcl::Device::getPins method, which returns a list of all pins with their connected node names. For example:
It returns:
So pins names are 'np' and 'nm' with connected nets 'net1' and 'net2'.
How to find the list of optional parameters for elements?Top, Main, Index
The list of parameters in the documentation includes descriptions of the mandatory arguments and availible options. But for some elements, especially models, there could be dozens of parameters, and I wanted to avoid cluttering the documentation.
Typically, any optional parameters for elements are also optional in the simulator they relate to, so you can find a list of them in the simulator's manual. The convention for these parameters is -nameOfParam value
. For example, for a basic resistor in Ngspice, you can provide values for the temperature coefficients, 'tc1' and 'tc2'. In SpiceGenTcl, these are added during the initialization of the resistor like this:
Here we provide the mandatory parameters:
- name of device without 'R' designator: '1'
- nets connected to pins: 'net1' and 'net2'
- value of resistance: '-r 10' Parameters 'tc1' and 'tc2' are provided here as optional arguments.
As a last resort, you can look directly at the source code in the documentation. Simply open the Show source
option, and you'll find an arguments description within the constructor
method:
For models the parameters are defined in this list:
The same applies to all elements (devices and models) in the package.
How to get raw data after simulation?Top, Main, Index
After a successful simulation, an object of the ::SpiceGenTcl::RawFile class is created and attached to the top-level ::SpiceGenTcl::Circuit object. To retrieve the result vectors, simply call the ::SpiceGenTcl::Circuit::getDataDict method on the ::SpiceGenTcl::Circuit object. This method returns the result vectors as a dictionary, with vector names as keys and the vectors themselves as values. You can then access these vectors using the dict get
command.
Example:
How to get the names of all vectors in raw file?Top, Main, Index
For this task, you should first retrieve the ::SpiceGenTcl::RawFile object reference from the ::SpiceGenTcl::Circuit object using the configure -Data
method. Then, call the ::SpiceGenTcl::RawFile::getVariablesNames method, which returns a list of all variable names.
Example:
There are also methods for retrieve all voltages and currents names separated from each other: ::SpiceGenTcl::RawFile::getVoltagesNames and ::SpiceGenTcl::RawFile::getCurrentsNames.
How to get log file after simulation?Top, Main, Index
There is a property method for it in object of ::SpiceGenTcl::Circuit class - configure -Log
, it returns string containing log file.
Example: