Qucs-S: Qucs with SPICE
How to simulate a common emitter bjt amplifier in qucs 0.0.18. Simulating the frequency response, DC bias, and transient response. In this video I'm using ve. 8 Modelling the 555 Timer263 8.1 Introduction.263 8.2 The Qucs 555 timer model.
Download linksThe latest stable release is Qucs-0.0.22. It is based on stable Qucs-0.0.19:
Contibuition guideQucs-S is open for everyone's contribution. See here for contribution guide. | News
| Simulation example with Qucs-S and Ngspice(More screenshots...) PublicationsQucs-S is also a research software. Check our publication list. |
What is Qucs-S?
Qucs-S is a spin-off of the Qucscross-platform circuit simulator. 'S' letter indicates SPICE. The purpose of the Qucs-S subproject is to use free SPICE circuit simulation kernels with the Qucs GUI. It merges the power of SPICE and the simplicity of the Qucs GUI. Qucs intentionally uses its own SPICE incompatible simulation kernel Qucsator.It has advanced RF and AC domain simulation features, but most of the existing industrial SPICE models are incompatible with it. Qucs-S is not a simulator by itself, but it requires to use a simulation backendwith it. The schematic document format of Qucs and Qucs-S are fully compatible. Qucs-S allows to use the following simulation kernels with it:- Ngspice is recommended to use. Ngspice is powerful mixed-level/mixed-signal circuit simulator. The most of industrial SPICE models are compatible with Ngspice. It has an excellent performance for time-domain simulation of switching circuits and powerful postprocessor.
- XYCE is a new SPICE-compatible circuit simulator written by Sandia from the scratch. It supports basic SPICE simulation types and has an advanced RF simulation features such as Harmonic balance simulation.
- SpiceOpus is developed by the Faculty of Electrical Engineering of the Ljubljana University. It based on the SPICE-3f5 code
- Qucsator as backward compatible
Screenshots
- MOSFET power switch
- JFET mixer
- Single-ended tube amplifier
- Hi-Fi bipolar transistor audio amplifier
Main features
- Backward compatible with Qucs by the component types and simulations
- Direct support of SPICE models from components datasheets. SPICE model could be added to schematic without any adaptation.
- Basic SPICE components: RCL, BJT, MOSFET, JFET, MESFET, switches;
- Advanced SPICE components: Equation-defined sources and RCLs, transmission lines;
- Direct support of SPICE Modelcards, SPICE sections (.IC, .NODESET);
- Parametric circuits (.PARAM) and SPICE postrprocessor (Nutmeg)
- Basic SPICE simulations: DC, AC, TRAN;
- Advanced SPICE simulation: DISTO, NOISE, SENS (added in 0.0.20), Spectrum analysis;
- Single-tone and Multitone Harmonic balance analysis with XYCE backend;
- Nutmeg script simulation: direct access to the SPICE code and construct your own simulation;
- XYCE script simulation type;
- XYCE digital devices library;
- XSPICE CodeModel synthesizer;
- User mathematical functions definitions with .FUNC (added in 0.0.20);
Installation
Linux
AppImage for all Linux distributions
You can run Qucs-S on all Linux platforms using AppImage without building it from source. AppImage already includes Qt4 librariesand you don't need to install them explicitly. Simple make AppImage executable and run it from console or your file manager. Pleasenote that AppImage doesn't include Ngspice and you need to install them using system package manager.Debian repository
Debian(7,8, and 9) and Ubuntu(14.04 and 16.04) repositories are available for Qucs-S. Packages arebuilt with automatic Open Build Service (OBS) tool from OpenSUSE team. Go to downloadrepositoryYou need to perform the following steps to add this repository in system (forDebian 9). For othe distributions simple replace the URLs.- Download GPG key:
wget -c
http://download.opensuse.org/repositories/home:/ra3xdh/Debian_9.0/Release.key - Add the following line to /etc/apt/sources.list:
deb http://download.opensuse.org/repositories/home:/ra3xdh/Debian_9.0/ ./ - Import key and update repos:
apt-key add Release.key
apt-get update - Install Qucs-S
apt-get install qucs-s
dpkg -i qucs-s-0.0.19S_amd64.deb
You may need to install the following dependencies: lib4qt4-qt3support,ibqt4-svg, ngspice
RPM packages for CentOS and Fedora
You need to simple add reposotries using the yum package manager. Let's consider example for CentOS:
- First add repository
yum-config-manager --add-repo http://download.opensuse.org/repositories/home:/ra3xdh/CentOS_7/
yum-config-manager --enable ra3xdh - Then check that repository is added
yum repolist alll
- And finally install the qucs-s package
yum install qucs-s
Building from source
If binary packages are not available for your distrubution, then you will need to build Qucs-S from source:- Install all necessary dependencies: Qt, C++ compilers, etc.
- Install desired simulation backends: Ngspice, XYCE, SpiceOpus. You can use all these backends together or only one of them. Install basic Qucs (0.0.18 or newer) if Qucsator is needed.
- Download and unpack tarball
- Use CMake to compile. Autotools doesn't support this installation mode and will not work!
- Invoke make and make install
tar xvfz qucs-s-0.0.21.tar.gz
cd qucs-s-0.0.21
mkdir builddir
cd builddir
cmake ..
make
make install
The last command make install should be executed from root user. It willinstall Qucs-S into default prefix /usr/local/. Use -DCMAKE_INSTALL_PREFIX=... to override the default locationNo additional configure options are needed now.
Slackware SlackBuild
Slack Build script is available for Slackware distribution. It will download andcompile Qucs-S automatically. You will obtain the binary Qucs-S package. Performthe following steps to install Qucs-S:- Clone this repository:
git clone https://github.com/ra3xdh/QucsS.SlackBuild - Run SlackBuild as root:
cd QucsS.S.SlackBuild
./qucs-S.SlackBuild - Install txz package with installpkg command
Windows
You need to use binary installer for Windows. You need to download and installNgspice and/or XYCE manually from official websites: http://ngspice.org/https://xyce.sandia.gov respectively.Important note for Ngspice on Windows: Unpack Ngspice ZIP package strictly to theC:SPICE location. Otherwise XSPICE model will not work! If you are getting strange errors with Ngspice on Windows and cannot ot simulate even simple circuit, please check that Ngspice is installed strictly in C:SPICE . All Ngspice packages including offcial should be installed in a such way.
It's recommended special build of Ngspice-26 for WindowsNgspice26_QucsS.zip. Default Ngspice package also will work but it may have some limitation. CustomNgspice build solves the following issues:
- Windows GUI of Ngspice is disabled. It allows Qucs-S to obtain logs from Ngspice.
- Added CMPP preprocessor and C headers set mandatory for development of CodeModel libraries. Default Ngspice build is shipped without it.
Usage
Linux
Run qucs-s from the the command line or launch Qucs-S icon in your desktopenvironment menu after the installation. You will need to select default simulationbackend at the first run. You can change it later in the application settings.Windows
Launch Qucs-S in the system Start menu. You will also need to select defaultsimulator on the first application start. You will need to set default simulatorat the first run. Correct simulator paths setting is necessary for Windows.Authors
- Vadim Kuznetsov ra3xdh@gmail.com
- Mike Brinson mbrin72043@yahoo.co.uk
Contribution guide
Steps to contribute
Source code of the Qucs-S is hosted at the Github in the following repository: https://github.com/ra3xdh/qucs_s. You need to clone this repository if you wish to contribute.
git clone -b current https://github.com/ra3xdh/qucs_s
cd qucs_s
git checkout -b your_feature
Use CMake to compile Qucs-S. After you make changes, prepare a pull request to Qucs-S repository.
Branching model
Currently there are two main branches in my home Qucs repository:- master is release candidate for the next Qucs-S release. This branch provides side-by-side installation of Qucs and Qucs-S. Main application executable is named to qucs-s. Only CMake is supported.
- current is development branch. Use this branch to target patches. It uses traditional Qucs build system. There may exist some experimental branches forked form this branch. I merge current into master time to time.
Release tarball is obtained from master with some Bash script. I distribute only Qucs-GUI and some utilities with Qucs-S package.
My changes only concentrated on GUI side, and you need to rebuild GUI only to test Qucs-S. You may take Qucsator from usual Qucs installation.
Build instruction (development branches)
For qucs-s-stable you need to set WITH_SPICE cmake key. Autotools will not work. Perform the following commnads to build all: git clone https://github.com/ra3xdh/qucs_s/
cd qucs_s
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/some_path
make
Then install and launch qucs-s executable.(to top...)
Documentation
- Main documentation page at readthedocs.io
- Presentation at the Spring MOS-AK 2016 at Lausanne
- Presentation at the Spring MOS-AK 2017 at Lausanne
- Presentation at the MIXDES2017 conference: Part 1 and Part 2
Publications
Qucs-S is not a simple circuit simulator, but also a research software. Pleasecite our articles, if you are using Qucs-S in your research.- Brinson, M. E., and Kuznetsov, V. (2016) A new approach to compact semiconductor device modelling with Qucs Verilog-A analogue module synthesis. Int. J. Numer. Model., 29: 1070-1088. (BibTeX)
- D. Tomaszewski, G. Głuszko, M. Brinson, V. Kuznetsov and W. Grabinski, 'FOSS as an efficient tool for extraction of MOSFET compact model parameters,' 2016 MIXDES - 23rd International Conference Mixed Design of Integrated Circuits and Systems, Lodz, 2016, pp. 68-73. (BibTeX)
- M. Brinson and V. Kuznetsov, 'Qucs-0.0.19S: A new open-source circuit simulator and its application for hardware design,' 2016 International Siberian Conference on Control and Communications (SIBCON), Moscow, 2016, pp. 1-5. (BibTeX)
- M. Brinson and V. Kuznetsov, 'Improvements in Qucs-S equation-defined modelling of semiconductor devices and IC's,' 2017 MIXDES - 24th International Conference 'Mixed Design of Integrated Circuits and Systems, Bydgoszcz, 2017, pp. 137-142. (BibTeX)
- M. Brinson and V. Kuznetsov, 'Extended behavioural device modelling and circuit simulation with Qucs-S' International Journal of Electronics, 2017, pp.1 - 14 (BibTeX)
Fourier simulation¶
The Qucs-S implementation of Fourier simulation allows users to perform a Fourier analysis ofone or more time domain circuit signals and to investigate their spectrum in the frequency domain.Qucs-S Fourier simulation is implemented by Ngspice, Xyce and SPICE OPUS.Fourier simulation is available to Qucs-S users via a special icon called Fourier simulation.This icon is located in the simulations group. To request a Fourier simulationplace a copy of the “Fourier simulation” icon on the current work schematic alongside a transient simulation icon.Qucs-S Fourier simulation uses the simulation data generated by a transient simulation and has no meaning without a set of transienttime domain data. The link between Fourier simulation and transient simulation is formed by entering thename of the coupled transient simulation as the first property of Fourier simulation.
The Fourier analysis property list has the following entries:
Sim
— Linked transient simulation icon name.numfreq
— Number of harmonics: variable number for ngspice and SPICE OPUS but fixed at 10 for Xyce.F0
— This parameter is the fundamental frequency of the generated frequency domain spectrum.Vars
— This parameter is a list of output signals. These may be node voltages and currents. In the list each entry must be space separated.
Fourier simulation creates four output vectors for each specified output signal, forexample in the case of signal v(out)
:
magnitude(v(out))
— Magnitude spectrum.phase(v(out))
— Phase spectrum (in degrees–).norm(mag(v(out))
— Normalized magnitude spectrum.norm(phase(v(out))
— Normalized phase spectrum.
Qucs-S allows each of these four display vectors to be plotted.
Here is a small example of a Fourier simulation which demonstrates the main features introduced aboveand the relation between small signal AC simulation and Fourier simulation.
Figure 5.1 Fourier and small signal AC analysis of a single stage transistor amplifier.
Additional Ngspice, SPICE OPUS and Xyce Fourier simulation examples¶
Figure 5.1.1 SPICE OPUS Fourier simulation basic example.
Figure 5.1.2 Ngspice Fourier simulation basic example: see section 17.5.25 of the NgspiceUser Manual for an explanation of the Ngnutmeg fouriermn statement.
Figure 5.1.3 Xyce Fourier simulation basic example: simulation controlled by transient simulation and Fourier simulation Icons.
Figure 5.1.4 Xyce Fourier simulation: controlled by Xyce script; see section 2.1.6 of the XyceReference Guide for an explanation of the .four and associated .print statement.
Distortion simulation¶
SPICE Distortion analysis provides a small signal distortion analysis of a circuit being simulated.To request a distortion analysis place a copy of the special Distortion analysis icon on the current work schematic.It undertakes a simulation similar to the small signal AC analysis, but calculates the circuit distortioncomponents instead. SPICE Distortion analysis is only available with ngspice. The calculated distortion components,for example values for the second and third harmonic components, can be extracted using ngnutmeg script statements.Refer to the official ngspice manual for the details of the available ngnutmeg operators and functions.
Ngspice Distortion analysis requires that the circuit being simulated is driven by aspecial AC voltage source component.This extended signal source can be found in the Spice components group. You need to specify voltage source parameters DISTOF1
and/orDISTOF2
for the ngspice Distortion analysis to function correctly. Refer to the official ngspice manual fora detailed description of all the ngspice Distortion analysis features. Please NOTE that the standard Qucs AC source will not workwith ngspice Distortion analysis.
Here is an basic example of the application of SPICE Distortion analysis for estimating the distortion components of asingle stage transistor amplifier.
Figure 5.2 SPICE small signal distortion analysis of a single stage transistor amplifier.
Noise simulation¶
SPICE noise simulation allows the calculation of total circuit noise over a specified frequency bandwidth.ngspice noise simulation creates two vectors:
onoise_total
— Integrated output noise.inoise_total
— Equivalent input noise.
Spice4qucs allows these vectors to be plotted. NOTE the Noise simulation at a single signalfrequency only outputs a single set of noise data. At this time only ngspice has noise analysisimplemented. However, in the near future is expected that noise simulation will be added to Xyce.
To set up a Noise analysis add the following four parameters to the Noise analysis icondrop-down list:
Bandwidthlimits
— Analysis start and stop frequencies in Hz.Pointscount
— The number of noise simulation frequency points.Output
— The output parameter name; this may be a node voltage or branch current.Source
— Name of the input voltage source. A standard Qucs voltage source is allowed in this context.
Figure 5.3 Noise analysis of a single stage transistor amplifier.
Qucs Vs Ltspice
One and two parameter sweep controlled simulations¶
Both one and two Parameter sweep simulations (in nested loops) are implemented with Ngspice, SPICE OPUS and Xyce.However, there is no warranty that proper results will be obtained with the Xyce time domain simulationlinked to Parameter sweep changes, mainly because Xyce uses an adaptive time step for each step of a sweep variable.Parameter sweep simulations operating with DC and frequency domain circuit simulation do not suffer from this problem and normallyreport accurate output data.
The differences between the Qucs-S and Qucs Parameter sweep definitions are listed below
Qucs Vs Ltspice
- Qucs-S uses a component name instead of a variable name to set a sweep component instance value;for example use
C1
,R1
, etc. to sweep capacitance and resistance values of componentsC1
andR1
. - Ngspice and Xyce allow model parameter values to be swept using the following notation:Ngspice uses
@dev[param]
and Xyce usesdev:param
.This notation is selected by setting the Parameter sweep variable SweepModel to true.Note also that the Ngspice nutmeg command altermod can also be used to change thevalue of a component or model parameter value. Qucs legacy devices use notationComponent_name.Parameter_name
.This notation is selected by setting the Parameter sweep variable SweepModel to false.Table 5.1 shows the allowed combinations of SweepModel and parameter values.All other combinations are illegal and will give incorrect output data or cause Qucs-S to crash and should no be used. - Qucs-S does not allow the use of
.PARAM
and.GLOBAL_PARAM
names as sweep variables.
Table 5.1 Allowed combinations of Component/Model identifiers and SweepMpdel access codes
Simulator | SweepModel | Component access | Model access |
---|---|---|---|
Qucsator | FALSE | Value | |
FALSE | Device.parameter_value | ||
Ngspice | FALSE | Name | |
TRUE | @Device_name[parameter_name] | ||
Xyce | FALSE | Name | |
TRUE | Device_name:parameter_name |
Figure 5.4 shows how changing the values of collector resistance effects the mid-band gain of a single stage BJTamplifier. Theoretically, the ideal gain is given by R2/R4
, suggesting good agreement between the simulatedoutput data and theory. The schematic illustrated in Figure 5.4 also presents a technique for scanning a componentvalue in different simulation domains. In this example the same component value ( R2
) is changed by a Parameter sweepicon linked to individual simulation icons (SW3+TR1
and SW2+AC1
).
Figure 5.4 Ngspice component sweep example.
The example shown in Figure 5.5 demonstrates the effect of changing capacitor C1 on the low frequency response ofthe single stage BJT amplifier introduced in Figure 5.4. Figures 5.6 and 5.7 introduce further extensions of the Qucs-Sswept parameter capabilities. Notice that Xyce allows semiconductor, and indeed other component models with parameters specifiedby the .MODEL
statement, to be swept in DC simulations. However, this is not the case with Ngspice and SPICE OPUS DC simulations whereonly independent voltage and current source values and resistor values can be swept. This limitation follows directly from the originalSPICE 3f5 simulator C code. In contrast to Ngspice and SPICE OPUS, Xyce includes a .STEP statement which supports an extended rangeof swept component parameter features, making it similar to the original Qucs swept parameter simulation.
Figure 5.5 Xyce component sweep example two.
Figure 5.6 Two variable nested loop parameter scan: Ngspice and Xyce BJT output characteristics.
Figure 5.7 Effects of BJT BF parameter scan on DC collector current: Xyce simualtion.
Qucs and SPICE simulation of device and circuit temperature properties¶
Spectrum analysis with Ngspice and Nutmeg scripting¶
Qucs-S have no unified simulation type “Spectrum analysis” for all simulationbackends. But you may use Nutmeg scripting to implement Spectrum analysis ifNgspice or SpiceOpus is selected as the default simulation kernel.
Qucsstudio
Let’s consider double balanced passive diode mixer circuit.
Figure 5.8 Diode double balanced mixer simulation
Balanced mixer circuit has two inputs: local oscillator(f_{LO}=15mathrm{MHz}) (LO
node) and RF signal (f_{RF}=7mathrm{MHz})(RF
node on schematic) and gives a set of signals at the outputs. Transformermodels are taken from the Transformer library form the Qucs-S distribution.Output signal is taken from the out
node. It contains components with thefollowing frequencies:
The following two components are the strongest (upper IF and lower IFrespectively):
We should see these signals as peaks at the spectrum plot.
We want to obtain mixer output voltage plot V(out)
. It’s need to use Nutmegscripting to obtain the spectrum. Nutmeg script component serves for thispurpose at the presented circuit. Let’s consider Nutmeg script structure. Suchstructure is need to be used for every spectrum analysis. Nutmeg script sourcecode is presented here:
Spectrum calculation is performed by the fft()
operator at the line #3.The argument of this function is transient simulation result vector (voltage orcurrent). And it’s need to perform a transient simulation before.Transient simulation is performed at the line #1. Simulation step is (t_s=1mathrm{ns})and duration is (T_d=10mathrm{mu s}). This gives
spectrum points.
Frequency step will be:
We can summarize that the smallest timestep and the longest duration gives themost precise frequency step and spectrum analysis precision. But it increasesthe simulation time.
Ngspice uses dynamic timestep calculation at simulation time. And real timestepmay differ from the specified in the tran
statement. It’s need to performsimulation analysis linearization. Line#2 linearizes simulation result (outputvoltage V(out)
). Vector V(out)
contains now linearized transient simulationresult and could be passed to the fft()
input (line #3).
Qucsstudio Vs Qucs
After FFT we can plot V(out)
vector and see spectrum. But we can apply anypostprocessing to it. For example we can express spectrum in decibels (dB) withdB()
nutmeg function (line #4, S
variable). You need to specify thesetwo variables in the Nutmeg script properties (Figure 5.9)
Qucs Manual
Figure 5.9 Nutmeg script properties setup
Simulation results are shown in the Figure 5.10. Both spectrum and logarithmicspectrum (dB) are shown.
Qucs-spice
Figure 5.10 Spectrum simulation result.
We can see two main peak on spectrum ((f_{IF1}=22 mathrm{MHz}) and (f_{IF2}=8mathrm{MHz})respectively). RF and LO signals are rejected.