Qucs is an open source electronic circuit simulator. About him tell my previous articles on Habré.
Now our project is preparing for the next release of 0.0.19, which will be released in the coming weeks. This note provides an overview of the most expected innovations in recent years: support for modeling Qucs schemes in SPICE-compatible simulators.
Qucs uses the Qucsator simulation engine, developed from scratch. This core has many advantages (modeling of S-parameters, advanced postprocessor), but also has numerous bugs related to modeling in the time domain (Transient analysis). These bugs in particular do not allow power electronics to be modeled in Qucs. Now in Qucs you can simulate, for example, the following scheme:
')
Download packages for Linux and Windows with Ngspice support here:
github.com/ra3xdh/qucs/releases/tag/0.0.19S-rc1
UPD from 10/21/15: RC3 is now available:
github.com/ra3xdh/qucs/releases/tag/0.0.19S-rc3
The letter "S" in the release number means SPICE. Apparently, along with the release of 0.0.19, two sets of packages will be released: with the “S” index and with the usual numbering, since the further fate of spice4qucs is unclear.
The documentation for spice4qucs is here:
qucs-help.readthedocs.org/en/spice4qucs
Under the cat will be briefly discussed the use of spice4qucs.
Prehistory
For about 10 months, I and Mike Brinson (London Metropolitan University) have been developing the spice4qucs subsystem, which allows you to simulate Qucs schemes using external Ngspice
qucs-help.readthedocs.org/en/spice4qucs and Xyce
xyce.sandia.gov console simulators. Of greatest interest is Ngspice, which is the best open-source circuit simulator, but does not have a graphical interface. With our patch kit, Qucs can serve as an interface for Ngspice.
The development progress can be tracked here:
github.com/Qucs/qucs/issues/226
github.com/Qucs/qucs/issues/77
github.com/Qucs/qucs/issues/181
Destination spice4qucs
Spice4qucs is a
slender system of crutches and props patch set, which allows you to connect external SPICE-compatible simulators to Qucs. The source code is located in the main Qucs repository in the rebase_spice4qucs branch:
github.com/Qucs/qucs/tree/rebase_spice4qucs The code turned out to be quite saturated with crutches, since using a netlist other than SPICE in the default Qucs simulator was an inappropriate idea. It could only spawn crutches.
So, spice4qucs performs the following functions:
- Converts Qucs schema to SPICE netlist
- Runs third-party simulator
- Converts output from simulator to Qucs XML data format.
Examples of schemes that can be modeled in SPICE are in the $ QUCSDIR / share / qucs / doc / examples / ngspice directory where $ QUCSDIR is the root of the Qucs installation, for example / usr or C: / Program Files / Qucs.
Installation
This package is not included in Linux distributions yet, so you need to compile everything manually:
tar xvfz qucs-0.0.19-S1.tar.gz cd qucs-0.0.19-S1 ./configure --prefix=/path_to_install/ make -j_ make install
Qt4 for developers and GCC must be installed.
It is recommended to use configure with the --prefix key in order not to damage the Qucs system installation, but to put it somewhere in a separate directory, like in / opt. Instead of make install it is better to use checkinstall, which will build the package for your distribution.
Installation for Windows is simple. You need to run the installer, choose the path to install and click Next-> Next-> Finish.
You also need to install Ngspice. It is not included in the assembly and it must be installed separately. In Linux, this package is already there and can be installed using the package manager, for example:
apt-get install ngspice
Using
Consider usage. It is assumed that the reader has worked with Qucs before and knows how to model circuits in it. The greatest interest to practice is Ngspice. On using Xyce - read our documentation (link to kata).
As an example, simulate an oscillating circuit. Let's look at the frequency response in the frequency range from 1 to 10 MHz (AC analysis) and the response of the oscillating circuit to the sinusoidal effect with a frequency of 7.5 MHz and an amplitude of 0.6 V. (Transient analysis).
First, we collect the following scheme. Save the circuit as RCL.sch. This circuit can be simulated in Qucs by clicking Simulation-> Simulate (F2) and make sure that everything works.
Now we will model the circuit in Ngspice. Click Simulation-> Simulate with Spice. A dialog box appears.
In the drop-down list (1), you can select a simulator. Choose Ngspice. If the simulator is installed in a non-standard place, then you need to specify the path to the executable file of the simulator. To do this, click Settings and go to the next dialog box:
This step is required for Windows. You need to specify in the top field (Ngspice executable location) the path to the file ngspice.exe. For Linux, the default path is usually appropriate. Now we return to the previous dialog and click Simulate. In the dialog box, we see that the simulation was successful:
You can also export the scheme to the Spice-netlist by clicking the Save Netlist button. Here is the netlist for our scheme:
* Qucs 0.0.19 /home/vvk/qucs/examples/ngspice/RCL.sch V1 _net0 0 DC 0 SIN(0 0.6 7.5MEG 0 0) AC 0.6 VPr1 _net0 vIn DC 0 AC 0 L1 vIn _net1 10U R1 0 vR 30 C1 _net1 vR 40P .control set filetype=ascii AC LIN 1000 1MEG 10MEG write RCL_ac.txt VPr1#branch v(vIn) v(vR) destroy all TRAN 4.97512e-09 1e-06 0 write RCL_tran.txt VPr1#branch v(vIn) v(vR) destroy all exit .endc .END
Click Exit, go to the page view and build a chart. Place the Cartesian diagram. The chart properties dialog opens.
In the drop-down list (1), select RCL, in the drop-down list (2), select Ngspice. Then we select the variables whose graphs need to be built (by double-clicking). They go to the list on the right side of the window (indicated by an arrow). Everything, the modeling is completed, we get the frequency response (current of the virtual current sensor - ac.i (pr1)) and voltage oscillograms (tran.v (vIn), tran.v (vR)). They need to be built on different charts.
Notice that the names of the schematic nodes are in the form of a SPICE record. The prefix indicates the type of simulation (tran. Or ac.) And the simulator (ngspice /).
Opportunities
- Most Qucs components are compatible with SPICE. Subcircuits, library components are supported. An error message is displayed on incompatible components during the simulation: These components are SPICE-incompatible ... Qucs Equations System is partially compatible with SPICE. About restrictions to read the documentation.
- SPICE compatible simulation types have been added: .FOURIER, .NOISE and .DISTORTION S-parameter modeling does not work with spice4qucs.
- Spice4qucs allows you to simulate the schemes inaccessible to the default simulator
Qucsator. First of all, these are power electronics, key circuits, circuits on semiconductor devices that operate with entry into cut-off mode, and circuits with a large number of components. For example, this is how you can simulate a high-quality transistor audio amplifier:
- Added many SPICE-compatible components and types of modeling. They are located in groups: Spice components, Spice sections, and Spice simulations. Read more about them in the documentation. All these components will not work with the default Qucsator simulator. They implement the setting of parameters, initial conditions and Ngspice-style construction commands. Also added a model of semiconductor components with a complete description of the model in the format of SPICE. This allows you to simply copy the model from existing libraries, bypassing the converters. Here is an example of a circuit with this model:
- Libraries are now allowed to enable the spice netlist. It is directly transmitted to the SPICE-compatible simulator, bypassing the conversion. An example of such a library is here: github.com/ra3xdh/qucs-rus-complib/blob/master/Opamp.lib
Further prospects
The further fate of the project spice4qucs is unclear. Together with the release of 0.0.19 two sets of packages will be released - with and without spice4qucs support. The question of including this patch set in upstream remains open.
In the future, new components and types of modeling will be added, in particular digital-analog models. It will be possible to assign a default simulator to each scheme: Ngpsice, Qucsator or Xyce and perform modeling using the system dialog (F2).
Maybe in the fall, I will start parallel development of my own open source project based on the Qucs and spice4qucs source codes and aimed at deep integration with SPICE and analog electronics modeling. The default Qucsator simulator will be cut and replaced by Ngspice and ensured compatibility with SPICE libraries, components fully compatible with SPICE, etc. will be implemented.
My previous publications on Qucs: