Guide to Modeling Types, Part 2

Qucs-S is an open source program for modeling electronic circuits. Qucs-S is cross-platform (Linux and Windows are supported) and is written in C++ using the Qt library set. My previous articles tell about this program. For Qucs-S, it is also recommended to use the open source Ngspice modeling engine. The current release of Qucs-S is version 24.3.2. The article continues a detailed examination of the types of modeling in Qucs-S, which was started in the first part: https://habr.com/ru/articles/789452/

Temperature sweep

Temperature analysis is a type of simulation on direct current. The difference is that the TEMP variable must be specified as a parameter, which is reserved for temperature in Ngspice. The screenshot shows an example of such simulation. The dependence of the transistor collector current on temperature is simulated.

Temperature sweep analysis

Temperature sweep analysis

The following example illustrates the use of temperature in the outer loop of Parameter Sweep. A circuit containing an NTC thermistor is simulated. This component is available in the Thermistor library supplied with the program.

Simulation of a circuit with a thermistor

Simulation of a circuit with a thermistor

Using Equations with the Ngspice Simulation Engine

Equations are required either to create parametric circuits or to manipulate the simulation results. If the program is running in SPICE compatibility mode (the default), then the use of equations has some peculiarities. Equations are divided into two types:

A peculiarity of Nutmeg equations is that they require specifying the type of modeling. This is due to the Ngspice syntax used, in which it is impossible to distinguish the type of modeling.

  • v(node) – voltage at some node of the circuit

  • i(V1) current through the source

  • V1#branch current through source, deprecated syntax

Ngspice only supports source currents in equations. An expression like i(R1) results in an error. To measure the current through another component, you need to connect a constant voltage source with zero voltage in series. The virtual ammeter that is available in Qucs-S is also a voltage source with zero voltage.

You can link the simulation to the Nutmeg equation by selecting it from the Simulation name drop-down list in the equation properties dialog as shown in the screenshot:

Nutmeg Equation component properties dialog

Nutmeg Equation component properties dialog

Let's look at an example. Let's simulate an RC chain so that the capacitor and resistor values ​​are calculated based on the cutoff frequency (parameter fc). In the screenshot, we see that in addition to the circuit itself, the AC1 simulation is specified on the circuit field, and two equations are placed. The .PARAM parameter calculates the component values, and the Nutmeg Equation post-processor equation calculates the transfer coefficient K of the RC chain and the input impedance Zin. This equation is tied to the AC1 simulation. From the simulation results, it is clear that the 3 dB cutoff frequency was obtained at a frequency of 10 kHz, as was specified through the parameters.

Modeling a circuit with equations

Modeling a circuit with equations

Nutmeg equations can use various mathematical functions. The full list can be found in the Ngspice documentation.

Using equations with the Qucsator modeling engine

Qucsator is not a SPICE-compatible engine and uses a different type of equation called the Qucsator Equation. If Qucsator is selected as the default engine, this equation will be added to the schematic via a toolbar button.

Qucsator equations have a different syntax that is not compatible with SPICE. The difference is that currents and voltages are defined uniquely. Therefore, there is no need to tie the simulation to the equation. Also, unlike SPICE, Qucsator is case-sensitive.

  • node.v – voltage at node node when simulating with alternating current

  • node.V – voltage at node node when simulating with direct current

  • node.Vt – voltage in node node in the transient process

  • V1.I – current through source V1 during DC simulation

  • V1.i – current through source V1 when simulating with alternating current

  • V1.It – current through source V1 during transient process simulation

  • Pr1.It – current through virtual ammeter Pr1

  • Pr1.Vt – voltage on the virtual voltmeter Pr1

It should be noted that Qucsator has built-in functions for transforming matrices of two-port networks. This is very convenient for analyzing microwave circuits. These functions should be used in conjunction with S-parameter modeling. Here are the main ones:

  • stoz() transforms an S-parameter matrix into a Z-parameter matrix

  • stoy() transforms a matrix of S-parameters into a matrix of Y-parameters

  • rtoswr() converts reflection coefficient to SWR

The screenshot shows an example of modeling a microwave amplifier using equations.

Modeling a microwave amplifier with equations

Modeling a microwave amplifier with equations

More information about Qucsator equations can be found in the manual for the old version of the program: https://qucs.sourceforge.net/docs/tutorial/getstarted.pdf The QucsatorRF engine supplied with Qucs-S is completely identical to the old version in terms of equation support.

Parameter sweep with Ngspice engine

Parametric analysis is usually used when it is necessary to obtain a family of graphs, for example, a family of frequency response, which depend on some circuit parameter. To use this type of modeling, the Parameter Sweep component should be placed on the circuit. In the dialog box of the properties of this type of modeling, you should specify the type of modeling to which the parameter sweep will be linked (Simulation drop-down list), as well as the parameter for the sweep (Sweep Parameter input field).

The following is allowed as a parameter:

  • Component name. Only resistor (R) or capacitor (C) is allowed.

  • The name of a variable declared as a parameter (.PARAM)

For variable sweep to work, Ngspice version 37 or later is required. The screenshot shows an example of parametric analysis setup. AC1 is selected as the simulation, which must be previously placed on the circuit. Resistor R6 is selected as the sweep parameter.

Setting parametric analysis properties

Setting parametric analysis properties

The following two screenshots illustrate examples of parametric analysis with a component as a parameter and a variable as a parameter. In the second example, the capacitor value in an RC circuit is calculated parametrically through a variable that specifies the cutoff frequency. In both cases, we obtain a family of frequency responses as a result.

Using a resistor as a parameter

Using a resistor as a parameter

Using a variable as a parameter

Using a variable as a parameter

Zero-pole analysis

Zero-pole analysis allows you to calculate the location of the zeros and poles of the transfer function on the complex plane. A brief theory on this issue can be found here, for example: https://www.allaboutcircuits.com/technical-articles/understanding-poles-and-zeros-in-transfer-functions/ This modeling is used in the analysis of, for example, active filters in the frequency domain.

As an example, we will synthesize a 5th-order Butterworth active filter using the built-in filter synthesis utility (Tools→ Active filter synthesis). We will select the initial data as shown in the screenshot. If you click the Calculate and copy to clipboard button, the synthesized circuit will be copied to the clipboard, and it can then be pasted into the document.

Utility for synthesizing active filters

Utility for synthesizing active filters

As a result of the calculation, the program, in addition to the nominal values ​​of the elements, reports that the filter transfer function has 5 poles, which are symmetrically located on the complex plane. The program produces a normalized result for a single cutoff frequency.

Let's simulate the location of the zeros and poles for this active filter. To do this, place the Pole/Zero analysis component on the diagram. In the properties, you need to specify a pair of input and output nodes. In our case, the input signal is supplied between the nodes in and 0, and the output is taken between the nodes out and 0. Node 0 in SPICE-compatible simulators always corresponds to ground. Leave the rest of the settings unchanged. The zero-pole analysis properties dialog is shown in the following screenshot.

Properties of zero-pole analysis

Properties of zero-pole analysis

After modeling, we place a polar coordinates graph on the diagram and plot the pole variable. We get a graph of the location of the poles on the complex plane. We also see five poles. In the diagram properties, you should specify the stars line type. The numbers differ from the result in the previous screenshot. This is due to the fact that the simulator produces data multiplied by the circular cutoff frequency 2*pi*fc.

Zero-pole analysis

Zero-pole analysis

Conclusion

The first and second parts of the article cover most of the simulation types available in Qucs-S. Other simulation types can be found in the Ngspice documentation and examples supplied with the program. Finally, a list of Qucs-S resources is provided.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *