Using Equations in QucsatorRF¶
Like ngspice, QucsatorRF also has an Equations feature.
However, unlike ngspice, QucsatorRF does not separate things into Parameters and Equations based on when they are computed. In QucsatorRF, all variables/data are accessible from the Equations feature. There is no need to use a different feature for pre-simulation and post-simulation computations.
The QucsatorRF Equations feature is very similar to the Equations feature in the upstream Qucs project. The QucsatorRF simulation backend is a fork of Qucsator, the only simulation backend supported by the upstream Qucs project. This means that most equations written for upstream Qucs will “just work” in Qucs-S, when used with QucsatorRF as the backend.
Example: RC Filter¶
When showing how to utilize Parameters and Equations in ngspice, an RC filter was used an example circuit. In that example, Parameters were used to manipulate component values before the simulation, while Equations were used to manipulate the results for graphing.
With QucsatorRF, the pre-processing and post-processing features are combined into a single Equations feature. This is accessible via the Qucsator Equation component, as shown below.
The Qucsator Equation schematic component, shown in the component browser at left, and placed on the schematic page at right.¶
To demonstrate this, we’ll use the same RC filter as the ngspice example. In Qucsator, it’s possible to create a single Equation component containing both the design equations (governing component values) and the postprocessing equation (the ratio of output to input voltage). The text of this equation is shown below (note the syntax difference in QucsatorRF equations compared to ngspice Nutmeg Equations and Parameters).
Warning
Qucsator equations are case-sensitive! This includes references to built-in functions.
For example, db(foo) will not work, you need to call dB(foo) instead.
r_1 = 1k
fc = 2k
C = 1/(2*pi*fc*r_1)
ratio_linear = out.v/in.v
ratio_dB = dB(out.v/in.v)
Using the equation text from above, we can create the following circuit. Note the graphed results contain both dB and linear format, utilizing the dB() function in QucsatorRF to easily produce a graph in dB format.
An example circuit utilizing the Equations feature with Qucsator.¶
Additional Examples¶
Since the syntax has remained unchanged since Qucs v0.0.19, many of the tutorials for original Qucs still apply to Qucsator Equations in Qucs-S. For additional examples, you may wish to visit these references:
Syntax Basics¶
The following operations and functions can be applied in QucsatorRF equations. Parameters in brackets [...] are optional.
Tip
For a more exhaustive reference, please see the Measurement Expressions Reference Manual, a document written by the original Qucs team. The syntax for QucsatorRF equations in Qucs-S is unchanged compared to upstream Qucs.
Operators¶
Arithmetic Operators¶
|
Unary plus |
|
Unary minus |
|
Addition |
|
Subtraction |
|
Multiplication |
|
Division |
|
Modulo (remainder of division) |
|
Power |
Logical Operators¶
|
Negation |
|
And |
`x |
|
|
Exclusive or |
|
Abbreviation for conditional expression - if |
|
Equal |
|
Not equal |
|
Less than |
|
Less than or equal |
|
Larger than |
|
Larger than or equal |
Math Functions¶
Vectors and Matrices: Creation¶
|
Creates |
|
Returns the length of the |
|
Real vector with |
|
Real vector with |
Vectors and Matrices: Basic Matrix Functions¶
|
Adjoint matrix of |
|
Determinant of a matrix |
|
Inverse matrix of |
|
Transposed matrix of |
Elementary Mathematical Functions: Basic Real and Complex Functions¶
|
Absolute value, magnitude of complex number |
|
Phase angle in radians of a complex number. Synonym for |
|
Phase angle in radians of a complex number |
|
Conjugate of a complex number |
|
Converts phase from degrees into radians |
|
Euclidean distance function |
|
Imaginary part of a complex number |
|
Magnitude of a complex number |
|
Square of the absolute value of a vector |
|
Phase angle in degrees of a complex number |
|
Transform polar coordinates |
|
Converts phase from radians into degrees |
|
Real part of a complex number |
|
Signum function |
|
Square (power of two) of a number |
|
Square root |
|
Unwrap angle |
Elementary Mathematical Functions: Exponential and Logarithmic Functions¶
|
Exponential function to basis e |
|
Limited exponential function |
|
Decimal logarithm |
|
Binary logarithm |
|
Natural logarithm (base e ) |
Elementary Mathematical Functions: Trigonometry¶
|
Cosine function |
|
Cosecant |
|
Cotangent function |
|
Secant |
|
Sine function |
|
Tangent function |
Elementary Mathematical Functions: Inverse Trigonometric Functions¶
|
Arc cosine (also known as “inverse cosine”) |
|
Arc cosecant |
|
Arc cotangent |
|
Arc secant |
|
Arc sine (also known as “inverse sine”) |
|
Arc tangent (also known as “inverse tangent”) |
Elementary Mathematical Functions: Hyperbolic Functions¶
|
Hyperbolic cosine |
|
Hyperbolic cosecant |
|
Hyperbolic cotangent |
|
Hyperbolic secant |
|
Hyperbolic sine |
|
Hyperbolic tangent |
Elementary Mathematical Functions: Inverse Hyperbolic Functions¶
|
Hyperbolic area cosine |
|
Hyperbolic area cosecant |
|
Hyperbolic area cotangent |
|
Hyperbolic area secant |
|
Hyperbolic area sine |
|
Hyperbolic area tangent |
Elementary Mathematical Functions: Rounding¶
|
Round to the next higher integer |
|
Truncate decimal places from real number |
|
Round to the next lower integer |
|
Round to nearest integer |
Elementary Mathematical Functions: Special Mathematical Functions¶
|
Modified Bessel function of order zero |
|
Bessel function of first kind and |
|
Bessel function of second kind and |
|
Error function |
|
Complementary error function |
|
Inverse error function |
|
Inverse complementary error function |
|
Sinc function (sin( |
|
Step function |
Data Analysis: Basic Statistics¶
|
Average of vector |
|
Cumulative average of vector elements |
|
Returns the greater of the values |
|
Maximum of vector |
|
Returns the lesser of the values |
|
Minimum of vector |
|
Root Mean Square of vector elements |
|
Running average of vector elements |
|
Standard deviation of vector elements |
|
Variance of vector elements |
|
Random number between 0.0 and 1.0 |
|
Give random seed |
Data Analysis: Basic Operation¶
cumprod(x) |
Cumulative product of vector elements |
cumsum(x) |
Cumulative sum of vector elements |
interpolate(f,x[,n]) |
Spline interpolation of vector f using n
equidistant points of x |
prod(x) |
|
sum(x) |
Sum of vector elements |
xvalue(f,yval) |
Returns x-value nearest to yval in single dependency
vector f |
yvalue(f,xval) |
Returns y-value nearest to xval in single dependency
vector f |
Data Analysis: Differentiation and Integration¶
|
Derives mathematical expression |
|
Differentiate vector |
|
Integrate vector |
Data Analysis: Signal Processing¶
|
Discrete Fourier Transform of vector |
|
Fast Fourier Transform of vector |
|
Shuffles the FFT values of vector |
|
Inverse Discrete Fourier Transform of function |
|
Inverse Discrete Fourier Transform of vector |
|
Inverse Fast Fourier Transform of vector |
|
Kaiser-Bessel derived window |
|
Discrete Fourier Transform of function |
Electronics Functions¶
Unit Conversion¶
|
dB value |
|
Convert voltage to power in dBm |
|
Convert power in dBm to power in Watts |
|
Convert power in Watts to power in dBm |
|
Thermal voltage for a given temperature |
Reflection Coefficients and VSWR¶
|
Converts reflection coefficient to voltage standing wave ratio (VSWR) |
|
Converts reflection coefficient to admittance; default |
|
Converts reflection coefficient to impedance; default |
|
Converts admittance to reflection coefficient; default |
|
Converts impedance to reflection coefficient; default |
N-Port Matrix Conversions¶
|
Converts S-parameter matrix to S-parameter matrix with a different Z0 |
|
Converts S-parameter matrix to Y-parameter matrix |
|
Converts S-parameter matrix to Z-parameter matrix |
|
Converts a two-port matrix: |
|
Converts Y-parameter matrix to S-parameter matrix |
|
Converts Y-parameter matrix to Z-parameter matrix |
|
Converts Z-parameter matrix to S-parameter matrix |
|
Converts Z-parameter matrix to Y-parameter matrix |
Amplifiers¶
|
Available power gain |
|
Operating power gain |
|
Mu stability factor of a two-port S-parameter matrix |
|
Mu’ stability factor of a two-port S-parameter matrix |
|
Noise Figure(s) |
|
Returns data selected from |
|
Rollet stability factor of a two-port S-parameter matrix |
|
Stability circle in the load plane |
|
Stability circle in the source plane |
|
Stability factor of a two-port S-parameter matrix |
|
Stability measure B1 of a two-port S-parameter matrix |
Nomenclature¶
Ranges¶
|
Range from |
|
Up to |
|
From |
|
No range limitations |
Matrices and Matrix Elements¶
|
The whole matrix |
|
Element being in 2nd row and 3rd column of matrix |
|
Vector consisting of 3rd column of matrix |
Immediate¶
|
Real number |
|
Complex number |
|
Vector |
|
Matrix |
Number suffixes¶
|
exa, 1e+18 |
|
peta, 1e+15 |
|
tera, 1e+12 |
|
giga, 1e+9 |
|
mega, 1e+6 |
|
kilo, 1e+3 |
|
milli, 1e-3 |
|
micro, 1e-6 |
|
nano, 1e-9 |
|
pico, 1e-12 |
|
femto, 1e-15 |
|
atto, 1e-18 |
Name of Values¶
|
S-parameter value |
nodename. |
DC voltage at node nodename |
name. |
DC current through component name |
nodename. |
AC voltage at node nodename |
name. |
AC current through component name |
nodename. |
AC noise voltage at node nodename |
name. |
AC noise current through component name |
nodename. |
Transient voltage at node nodename |
name. |
Transient current through component name |
Note: All voltages and currents are peak values. Note: Noise voltages are RMS values at 1 Hz bandwidth.
Constants¶
|
Imaginary unit (“square root of -1”) |
|
4*arctan(1) = 3.14159… |
|
Euler = 2.71828… |
|
Boltzmann constant = 1.38065e-23 J/K |
|
Elementary charge = 1.6021765e-19 C |