Qucs project news: candidate for releases with support for circuit modeling in SPICE is available

    Qucs is an open source electronic circuit simulator. About it tell me my previous articles on Habr.

    Now our project is preparing for the next release 0.0.19, which will be released in the coming weeks. This note provides an overview of the most anticipated innovation in recent years: support for Qucs circuit simulation in SPICE-compatible simulators.

    Qucs uses the Qucsator simulation core, designed from the ground up. This kernel has many advantages (S-parameter modeling, advanced post-processor), but also has numerous bugs related to time-domain modeling (Transient analysis). These bugs in particular do not allow you to simulate power electronics in Qucs. Now in Qucs you can simulate, for example, such a 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, 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 cat , the use of spice4qucs will be briefly discussed.



    Background



    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 the external console simulators Ngspice qucs-help.readthedocs.org/en/spice4qucs and Xyce xyce.sandia.gov . Of greatest interest is Ngspice, which is the best open-source circuit simulator, but does not have a graphical interface. With our patch suite, Qucs can serve as an interface for Ngspice.

    Development progress can be tracked here:

    github.com/Qucs/qucs/issues/226

    github.com/Qucs/qucs/issues/77

    github.com/Qucs/qucs/issues/181

    Purpose spice4qucs



    Spice4qucs is a well-balanced system of crutches and backups, a set of patches that allows you to connect external SPICE-compatible simulators to Qucs. The source code is in the main Qucs repository in the rebase_spice4qucs branch: github.com/Qucs/qucs/tree/rebase_spice4qucs The code turned out to be quite rich with crutches, since using netlist other than SPICE in the default Qucs simulator was an initially bad idea. This could only spawn crutches.

    So spice4qucs performs the following functions:

    • Converts Qucs schema to SPICE-netlist
    • Launches a third-party simulator
    • Converts Simulator Output 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 yet included in Linux distributions, so you need to manually compile everything:
    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 must be installed for developers and GCC.

    It is recommended that you use configure with the --prefix switch so as not to damage the Qucs system installation, but put it somewhere in a separate directory, for example in / opt. Instead of make install, it is better to use checkinstall, which will collect the package for your distribution.

    Installation for Windows is simple. You need to run the installer, select the installation path and click Next-> Next-> Finish.

    You also need to install Ngspice. It is not included in assemblies and must be installed separately. On Linux, such a package already exists and can be installed using the package manager, for example:
    apt-get install ngspice
    


    Using



    Consider use. It is assumed that the reader has previously worked with Qucs and knows how to model circuits in it. The greatest interest for practice is Ngspice. On the use of Xyce - read our documentation (link to kat).

    As an example, we simulate an oscillatory circuit. Let's see the frequency response in the frequency range from 1 to 10 MHz (AC analysis) and the response of the oscillatory circuit to a sinusoidal frequency of 7.5 MHz and an amplitude of 0.6 V. (Transient analysis).

    First, collect the following diagram. Save the circuit as RCL.sch This circuit can be modeled 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 opens.



    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 set the path to the simulator executable file. To do this, click Settings and go to the following dialog box:



    This step is required for Windows. You need to specify the path to the ngspice.exe file in the upper field (Ngspice executable location). For Linux, the default path is generally 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 Spice-netlist by clicking the Save Netlist button. Here is the netlist for our circuit:
    * 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 view page and build a chart. We 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 select the variables whose graphs you want to build (double-click). They go to the list on the right side of the window (shown by an arrow). That's it, the simulation is complete, we get the frequency response (current of the virtual current sensor - ac.i (pr1)) and the voltage waveforms (tran.v (vIn), tran.v (vR)). They need to be built on different graphs.



    Note that the schema node names are in the notation accepted in SPICE. 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 about incompatible components during simulation: These components are SPICE-incompatible ... The Equations Qucs system is partially compatible with SPICE. About restrictions read the documentation.
    • Added simulation types compatible with SPICE: .FOURIER, .NOISE and .DISTORTION S-parameter modeling does not work with spice4qucs.
    • Spice4qucs allows you to simulate circuits inaccessible to the default
      Qucsator simulator . First of all, this is power electronics, key circuits, circuits based on semiconductor devices operating with entry into cut-off mode, and circuits with a large number of components. For example, here's how to model a high-quality transistor sound amplifier:





    • Added many SPICE-compatible components and types of modeling. They are located in the 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 the Ngspice-style builder command. Also added models of semiconductor components with a full description of the model in SPICE format. This allows you to simply copy the model from existing libraries, bypassing the converters. Here is an example of a circuit with such a model:



    • Libraries are now allowed to include SPICE netlist. It is directly transferred 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 perspectives



    The fate of the spice4qucs project is unclear. Along with release 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-to-analog models. It will be possible to assign a default simulator to each circuit: Ngpsice, Qucsator or Xyce and perform the simulation using the system dialog (F2).

    Perhaps in the fall I will start parallel development of my own open source project based on Qucs and spice4qucs source codes and aimed at deep integration with SPICE and analog electronics modeling. The default simulator Qucsator will be cut and replaced with Ngspice and compatibility with the SPICE libraries will be provided, components fully compatible with SPICE will be implemented, etc.

    My previous posts on Qucs:




    Also popular now: