Title: The Qstar simulator
1The Qstar simulator
2Overview of talk
- Motivation for Qstar
- What can it do?
- Who needs it?
- Useful future extensions
- Conclusions
3Motivation for Qstar
- Circuit equations have the structure
- However, simulators as Spice, Pstar do not
- explicitly form the circuit equations.
4Structure of e.g. SPICE, Pstar
input file
Circuit description
Circuit state x
Evaluation
Vectors j(x), q(x), matrices G(x), C(x)
Solver
5Problems for mathematician
- Circuit equations not explicitly available
- One cannot easily play with the equations in
e.g. MATLAB/Mathematica
- Pstar only provides what is needed for existing
methods. E.g. implementing Rosenbrock-Wanner
methods requires
6What does Qstar do?
- Basic idea is similar to Lex/Yacc tools.
- Qstar reads a .pstar file and generates the
circuit equations explicitly.
- It then outputs these equations in an arbitrary
output format (MATLAB, C, LaTeX,).
- Qstar itself doesnt do any numerical computation.
7Structure of Qstar
input file
Qstar
MATLAB file
LaTeX file
C file
C program by user
Compile run
Results
8Qstar output formats
- /home/houbenqstar2 -h formats
- This is Qstar2, the multi-format circuit equation
assembler.
- c) 1999, Stephan Houben
- The following formats are supported
-
- octave -- "Native" Octave output format
(default).
- octavecpp -- C code usable by Octave.
- dassl -- Output format for the DASSL solver
in Octave.
- fsolve -- Output format for Octave's fsolve'
function.
- latex -- LaTeX output format.
- matlab -- Matlab output format.
- numlab -- C code usable by NumLab.
- ocaml -- Objective Caml code.
- scheme -- code for Scheme
- sanecpp -- C code usable by the Sane Vector
Library
- daecpp -- C subclass from DAE class, usable
by the Sane Vector Library
9Example circuit
10Input file
Title Test circuit 6 / Typical simulation ti
me scale t 0, 1.5e-3 / / To start up set
vn(1) 1 at t 0. / include "transistor.pst
ar" circuit e_1(0,5) 10 r_1(0,2) 12k
r_2(2,5) 8.1k l_1(0,3) 0.01 r_3(3,4)
3 c_1(0,1) 0.1u c_2(1,4) 47n transi
stor_1(4,2,1) r_4(1,5) 1.5k end
11Circuit equations
12Resulting MATLAB file
- if exist('x')
- x zeros(7, 1)
- end
- if exist('t')
- t 0
- end
- j zeros(7, 1)
- j(1)(((- ((1e-15(exp(min(((x(2)-
x(1))/0.025),52.0))max(((x(2)-
x(1))/0.025)-51.0,1)- 1))/10)- (1e-15(exp(min(((x
(2)- x(1))/0.025),52.0))max(((x(2)-
x(1))/0.025)-51.0,1)- 1)))(1e-15(exp(min(((x(2)-
x(4))/0.025),52.0))max(((x(2)-
x(4))/0.025)-51.0,1)- 1)))((x(1)-
x(5))/1500.0)) - j(2)(((- (- x(2)/12000.0)((x(2)-
x(5))/8100.0))((1e-15(exp(min(((x(2)-
x(4))/0.025),52.0))max(((x(2)-
x(4))/0.025)-51.0,1)- 1))/10))((1e-15(exp(min(((
x(2)- x(1))/0.025),52.0))max(((x(2)-
x(1))/0.025)-51.0,1)- 1))/10)) - j(3)(- x(7)((x(3)- x(4))/3))
- j(4)(((- ((x(3)- x(4))/3)- ((1e-15(exp(min(((x(2
)- x(4))/0.025),52.0))max(((x(2)-
x(4))/0.025)-51.0,1)- 1))/10))(1e-15(exp(min(((x
(2)- x(1))/0.025),52.0))max(((x(2)-
x(1))/0.025)-51.0,1)- 1)))- (1e-15(exp(min(((x(2)
- x(4))/0.025),52.0))max(((x(2)-
x(4))/0.025)-51.0,1)- 1))) - j(5)((- x(6)- ((x(2)- x(5))/8100.0))- ((x(1)-
x(5))/1500.0))
- j(6)(- x(5)- 10)
- j(7)- x(3)
- q zeros(7, 1)
- .
- .
- .
13Resulting C file
- void evalCircuit(double t, const Vector x,
Vector j, Vector q, Matrix G, Matrix C)
-
- j.resize(7)
- j.fill(0)
- j(0)(((- ((1e-15(((((x(1)- x(0))/0.025) 52.0)?(exp(((x(1)- x(0))/0.025)))(3.83100800072e
22(((x(1)- x(0))/0.025) - 51.0)))- 1))/10)-
(1e-15(((((x(1)- x(0))/0.025) 52.0)?(exp(((x(1)- x(0))/0.025)))(3.83100800072e
22(((x(1)- x(0))/0.025) - 51.0)))-
1)))(1e-15(((((x(1)- x(3))/0.025) 52.0)?(exp(((x(1)- x(3))/0.025)))(3.83100800072e
22(((x(1)- x(3))/0.025) - 51.0)))- 1)))((x(0)-
x(4))/1500.0)) - j(1)(((- (- x(1)/12000.0)((x(1)-
x(4))/8100.0))((1e-15(((((x(1)- x(3))/0.025) 52.0)?(exp(((x(1)- x(3))/0.025)))(3.83100800072e
22(((x(1)- x(3))/0.025) - 51.0)))-
1))/10))((1e-15(((((x(1)- x(0))/0.025) 52.0)?(exp(((x(1)- x(0))/0.025)))(3.83100800072e
22(((x(1)- x(0))/0.025) - 51.0)))- 1))/10)) - j(2)(- x(6)((x(2)- x(3))/3))
- j(3)(((- ((x(2)- x(3))/3)- ((1e-15(((((x(1)-
x(3))/0.025) x(3))/0.025)))(3.83100800072e22(((x(1)-
x(3))/0.025) - 51.0)))- 1))/10))(1e-15(((((x(1)-
x(0))/0.025) x(0))/0.025)))(3.83100800072e22(((x(1)-
x(0))/0.025) - 51.0)))- 1)))- (1e-15(((((x(1)-
x(3))/0.025) x(3))/0.025)))(3.83100800072e22(((x(1)-
x(3))/0.025) - 51.0)))- 1))) - j(4)((- x(5)- ((x(1)- x(4))/8100.0))- ((x(0)-
x(4))/1500.0))
- j(5)(- x(4)- 10)
- j(6)- x(2)
- q.resize(7)
- .
- .
- .
14Easy to add new output formats
- Qstar has an object-oriented structure.
- Output formats inherit from class Output.
- class LaTeXOutput(output.Output)
- functions
- "exp" "es",
- "log" "\\logs",
- "sin" "\\sins",
- "cos" "\\coss",
- "tan" "\\tans",
- "sqrt" "\\sqrts",
- "neg" "- s",
-
- def output_time(self)
- return "t"
- def output_variable(self, var, index)
- return "s_d" (var, index1)
15Limitations of Qstar
- Does not handle the full Pstar language. It
could be extended, but some things (e.g.
transient..end blocks) dont make sense
inQstar. - Cannot use model libraries in C this limitation
is intrinsic in the goal to get explicit
equations.
16Qstar for templates?
- Since Qstar generates C code for each separate
circuit, it could be used to produce so-called
templates.
- A template is a dedicated circuit simulator,
which only handles a single circuit layout but is
very fast (good for optimisation).
17Useful future extensions
- More models currently there is only one
transistor-model (Bipolar), by S. Onneweer.
- A MOSFET model would be useful.
- More output formats Mathematica might be
useful.
18Conclusions
- Qstar is useful as a research tool.
- It is where possible compatible with Pstar, but
full compatibility is probably not possible
and/or worthwhile.
- Qstar is basically finished, but it could benefit
from some extensions.
19Future maintenance
- Useful for SCG to keep Qstar available (for
future students, industry contacts).
- Extensions can be implemented on a by need
basis.