next version of PSS2
which was reviewed and rewritten on branch `PSS-2-try-to-rebase+4' by Stefano Perticaroli and Francesco Lannutti
This commit is contained in:
parent
0be61b3e5a
commit
79bffc78a1
13
configure.ac
13
configure.ac
|
|
@ -145,6 +145,10 @@ AC_ARG_ENABLE([cider],
|
|||
AC_ARG_ENABLE([adms],
|
||||
[AS_HELP_STRING([--enable-adms], [Enable ADMS code models, (experimental)])])
|
||||
|
||||
# --enable-pss: enable PSS Analysis
|
||||
AC_ARG_ENABLE([pss],
|
||||
[AS_HELP_STRING([--enable-pss], [Enable PSS Analysis, (experimental)])])
|
||||
|
||||
# --enable-ndev: define NDEV in the code. An interface for external device i.e. numerical device
|
||||
AC_ARG_ENABLE([ndev],
|
||||
[AS_HELP_STRING([--enable-ndev], [Enable NDEV interface, (experimental)])])
|
||||
|
|
@ -782,6 +786,9 @@ if test "x$enable_pzdebug" = xyes; then
|
|||
AC_DEFINE([PZDEBUG], [], [Define if you want to debug pole-zero analysis])
|
||||
AC_MSG_RESULT([WARNING: Pole/Zero analysis debug is enabled])
|
||||
fi
|
||||
if test "x$enable_pss" = xyes; then
|
||||
AC_DEFINE([WITH_PSS], [], [Define if you want PSS analysis])
|
||||
fi
|
||||
if test "x$enable_blktmsdebug" = xyes; then
|
||||
AC_DEFINE([D_DBG_BLOCKTIMES], [], [Define if we want debug distortion analysis (BLOCKTIMES)])
|
||||
AC_MSG_RESULT([WARNING: Distortion analysis debug *D_DBG_BLOCKTIMES* is enabled])
|
||||
|
|
@ -867,6 +874,8 @@ AM_CONDITIONAL([CIDER_WANTED], [test "x$enable_cider" = xyes])
|
|||
AM_CONDITIONAL([NUMDEV_WANTED], [test "x$enable_cider" = xyes])
|
||||
|
||||
|
||||
AM_CONDITIONAL([PSS_WANTED], [test "x$enable_pss" = xyes])
|
||||
|
||||
# adms option
|
||||
if test "x$enable_adms" = xyes ; then
|
||||
AC_MSG_RESULT([**********************************
|
||||
|
|
@ -990,6 +999,10 @@ if test "x$enable_openmp" = xyes; then
|
|||
AC_MSG_RESULT([OpenMP feature enabled])
|
||||
fi
|
||||
|
||||
if test "x$enable_pss" = "xyes"; then
|
||||
AC_MSG_RESULT([WARNING: PSS analysis enabled])
|
||||
fi
|
||||
|
||||
# Output Files
|
||||
# ------------
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
Colpitt's Oscillator Circuit
|
||||
* Colpitt is an harmonic oscillator (LC based) which use
|
||||
* a capacitive partition of resonator to feed the single
|
||||
* active device.
|
||||
* Predicted frequency is about 3.30435e+06 Hz.
|
||||
|
||||
* Models:
|
||||
.model qnl npn(level=1 bf=80 rb=100 ccs=2pf tf=0.3ns tr=6ns cje=3pf cjc=2pf va=50)
|
||||
|
||||
r1 1 0 1
|
||||
q1 2 1 3 qnl
|
||||
vcc 4 0 5
|
||||
rl 4 2 750
|
||||
c1 2 3 500p
|
||||
c2 4 3 4500p
|
||||
l1 4 2 5uH
|
||||
re 3 6 4.65k
|
||||
vee 6 0 dc -10 pwl 0 0 1e-9 -10
|
||||
|
||||
*.tran 30n 12u
|
||||
.pss 3.1e6 500e-6 3 256 10 50 5e-3
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
Complimentary Cross Quad CMOS Oscillator
|
||||
* Predicted frequency is 5.61224e+08 Hz.
|
||||
*
|
||||
* PLOT i1
|
||||
|
||||
* Supply
|
||||
vdd vdd gnd 1.2 pwl 0 1.2 1e-9 1.2
|
||||
rdd vdd vdd_ana 70m
|
||||
rgnd gnd gnd_ana 70m
|
||||
|
||||
* Cross quad
|
||||
mpsx v_plus v_minus vdd_ana vdd_ana pch w=10u l=0.1u
|
||||
mnsx v_plus v_minus gnd_ana gnd_ana nch w=10u l=0.1u
|
||||
mpdx v_minus v_plus vdd_ana vdd_ana pch w=10u l=0.1u
|
||||
mndx v_minus v_plus gnd_ana gnd_ana nch w=10u l=0.1u
|
||||
|
||||
* Lumped elements model of real inductor
|
||||
ls v_plus i1 19.462n ic=0.06
|
||||
rs i1 v_minus 7.789
|
||||
cs v_plus v_minus 443f
|
||||
coxs v_plus is 2.178p
|
||||
coxd v_minus id 2.178p
|
||||
rsis is gnd_ana 308
|
||||
rsid id gnd_ana 308
|
||||
csis is gnd_ana 51f
|
||||
csid id gnd_ana 51f
|
||||
|
||||
* Parallel capacitor to determine leading resonance
|
||||
cp v_plus v_minus 3.4p
|
||||
|
||||
.model nch nmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=0.1u wmax=10u )
|
||||
.model pch pmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=0.1u wmax=10u )
|
||||
|
||||
*.tran 0.05n 1u uic
|
||||
.pss 500e6 1u 1 1024 10 10 5e-3 uic
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
Hartley's Oscillator Circuit
|
||||
* Hartley is an harmonic oscillator (LC based) which use
|
||||
* an inductive partition of resonator to feed the single
|
||||
* active device. Output is taken on node 2.
|
||||
* Prediceted frequency is about 121.176 Hz.
|
||||
*
|
||||
* PLOT V(3)
|
||||
|
||||
* Models:
|
||||
.model qnl npn(level=1 bf=80 rb=100 ccs=2pf tf=0.3ns tr=6ns cje=3pf cjc=2pf va=50)
|
||||
|
||||
vcc 1 0 5 pwl 0 0 1e-5 5
|
||||
r1 1 2 0.2k
|
||||
q1 2 3 0 qnl
|
||||
c1 3 4 633n
|
||||
l1 3 0 1.5
|
||||
l2 0 4 500m
|
||||
r2 4 2 100
|
||||
|
||||
*.tran 300n 50m
|
||||
.pss 50 200e-3 2 1024 11 10 5e-3 uic
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
Ring CMOS Oscillator
|
||||
* Oscillation is taken on node "bout".
|
||||
* Predicted frequency is 3.8e+09 Hz.
|
||||
*
|
||||
* PLOT bout
|
||||
|
||||
* Supply
|
||||
vdd vdd gnd 1.2 pwl 0 1.2 1e-9 1.2
|
||||
rdd vdd vdd_ana 70m
|
||||
rgnd gnd gnd_ana 70m
|
||||
|
||||
* Inverter
|
||||
mp1 inv1 inv3 vdd_ana vdd_ana pch w=10u l=0.18u
|
||||
mn1 inv1 inv3 gnd_ana gnd_ana nch w=10u l=0.18u
|
||||
mp2 inv2 inv1 vdd_ana vdd_ana pch w=10u l=0.18u
|
||||
mn2 inv2 inv1 gnd_ana gnd_ana nch w=10u l=0.18u
|
||||
mp3 inv3 inv2 vdd_ana vdd_ana pch w=10u l=0.18u
|
||||
mn3 inv3 inv2 gnd_ana gnd_ana nch w=10u l=0.18u
|
||||
|
||||
* Buffer out
|
||||
mp4 bout inv3 vdd_ana vdd_ana pch w=10u l=0.18u
|
||||
mn4 bout inv3 gnd_ana gnd_ana nch w=10u l=0.18u
|
||||
|
||||
.model nch nmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=0.1u wmax=10u )
|
||||
.model pch pmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=0.1u wmax=10u )
|
||||
|
||||
*.tran 0.005n 100n
|
||||
*.plot tran v(4)
|
||||
.pss 624e6 500n 1 1024 10 5 5e-3 uic
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
Vackar's Oscillator Circuit
|
||||
* Vackar is a derivation of Colpitt's oscillator (LC based).
|
||||
* Oscillation is taken on node 4.
|
||||
* Predicted frequency is 1.91803e+06Hz.
|
||||
|
||||
* Models:
|
||||
.model qnl npn(level=1 bf=80 rb=100 ccs=2pf tf=0.3ns tr=6ns cje=3pf cjc=2pf va=50)
|
||||
|
||||
vcc 1 0 5 pwl 0 10 1e-9 5
|
||||
lrfc 1 2 100u
|
||||
cdec 2 0 7n
|
||||
q1 3 2 0 qnl
|
||||
rb 3 0 4700
|
||||
c1 3 4 100p
|
||||
c2 3 0 600p
|
||||
c0 4 0 1n
|
||||
l1 4 1 6.2u
|
||||
|
||||
*.tran 30n 12u
|
||||
*.plot tran v(4)
|
||||
.pss 1e6 10e-6 4 1024 10 50 5e-3 uic
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
Van Der Pol Oscillator
|
||||
* Prediceted frequency is about 4.54167e+06 Hz.
|
||||
|
||||
* Third harmonic is high as the first one
|
||||
Ba gib 0 I=-1e-2*v(gib,0)+1e-2*v(gib,0)^3
|
||||
* Q is about 10
|
||||
La gib 0 1.2e-6
|
||||
Ra gib 0 158.113
|
||||
Ca gib 0 1e-9 ic=0.5
|
||||
*La gib 0 1e-9
|
||||
*Ra gib 0 474.6
|
||||
*Ca gib 0 1e-9 ic=0.5
|
||||
* Ghost node... Test for my PSS!
|
||||
Rb bad 0 1k
|
||||
|
||||
*.tran 1e-9 150e-6 uic
|
||||
.pss 0.8e6 130e-6 1 50 10 50 5e-3 uic
|
||||
|
|
@ -275,6 +275,14 @@ struct comm spcp_coms[] = {
|
|||
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS,
|
||||
NULL,
|
||||
"[.tran line args] : Do a transient analysis." } ,
|
||||
#ifdef WITH_PSS
|
||||
/* SP: Steady State Analysis */
|
||||
{ "pss", com_pss, TRUE, TRUE,
|
||||
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS,
|
||||
NULL,
|
||||
"[.pss line args] : Do a periodic state analysis." } ,
|
||||
/* SP */
|
||||
#endif
|
||||
{ "ac", com_ac, TRUE, TRUE,
|
||||
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS,
|
||||
NULL,
|
||||
|
|
@ -698,6 +706,14 @@ struct comm nutcp_coms[] = {
|
|||
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS,
|
||||
NULL,
|
||||
"[.tran line args] : Do a transient analysis." } ,
|
||||
#ifdef WITH_PSS
|
||||
/* SP: Steady State Analysis */
|
||||
{ "pss", NULL, TRUE, TRUE,
|
||||
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS,
|
||||
NULL,
|
||||
"[.pss line args] : Do a periodic steady state analysis." } ,
|
||||
/* SP */
|
||||
#endif
|
||||
{ "ac", NULL, TRUE, TRUE,
|
||||
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -702,6 +702,8 @@ OUTattributes(runDesc *plotPtr, IFuid varName, int param, IFvalue *value)
|
|||
runDesc *run = plotPtr; // FIXME
|
||||
GRIDTYPE type;
|
||||
|
||||
struct dvec *d;
|
||||
|
||||
NG_IGNORE(value);
|
||||
|
||||
if (param == OUT_SCALE_LIN)
|
||||
|
|
@ -722,10 +724,12 @@ OUTattributes(runDesc *plotPtr, IFuid varName, int param, IFvalue *value)
|
|||
}
|
||||
} else {
|
||||
if (varName) {
|
||||
struct dvec *d;
|
||||
for (d = run->runPlot->pl_dvecs; d; d = d->v_next)
|
||||
if (!strcmp(varName, d->v_name))
|
||||
d->v_gridtype = type;
|
||||
} else if (param == PLOT_COMB) {
|
||||
for (d = run->runPlot->pl_dvecs; d; d = d->v_next)
|
||||
d->v_plottype = param;
|
||||
} else {
|
||||
run->runPlot->pl_scale->v_gridtype = type;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,6 +169,17 @@ com_noise(wordlist *wl)
|
|||
}
|
||||
|
||||
|
||||
#ifdef WITH_PSS
|
||||
/* SP: Steady State Analysis */
|
||||
void
|
||||
com_pss(wordlist *wl)
|
||||
{
|
||||
dosim("pss", wl);
|
||||
}
|
||||
/* SP */
|
||||
#endif
|
||||
|
||||
|
||||
static int
|
||||
dosim(
|
||||
char *what, /* in: command (pz,op,dc,ac,tf,tran,sens,disto,noise,run) */
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ void com_dc(wordlist *wl);
|
|||
void com_ac(wordlist *wl);
|
||||
void com_tf(wordlist *wl);
|
||||
void com_tran(wordlist *wl);
|
||||
/* SP: Stady State Analysis */
|
||||
void com_pss(wordlist *wl);
|
||||
/* SP */
|
||||
void com_sens(wordlist *wl);
|
||||
void com_disto(wordlist *wl);
|
||||
void com_noise(wordlist *wl);
|
||||
|
|
|
|||
|
|
@ -303,6 +303,53 @@ if_sens_run(CKTcircuit *ckt, wordlist *args, INPtables *tab)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_PSS
|
||||
/* *********************** */
|
||||
/* PSS - Spertica - 100910 */
|
||||
/* *********************** */
|
||||
if (strcmp(token, "pss") == 0) {
|
||||
JOB *pssJob;
|
||||
which = -1;
|
||||
for (j = 0; j < ft_sim->numAnalyses; j++)
|
||||
if (strcmp(ft_sim->analyses[j]->name, "PSS") == 0) {
|
||||
which = j;
|
||||
break;
|
||||
}
|
||||
if (which == -1) {
|
||||
current->error = INPerrCat
|
||||
(current->error,
|
||||
INPmkTemp("periodic steady state analysis unsupported\n"));
|
||||
return (0); /* temporary */
|
||||
}
|
||||
err = ft_sim->newAnalysis (ft_curckt->ci_ckt, which, "pssan",
|
||||
& pssJob, ft_curckt->ci_specTask);
|
||||
if (err) {
|
||||
ft_sperror(err, "createPSS");
|
||||
return (0);
|
||||
}
|
||||
|
||||
parm = INPgetValue(ckt, &line, IF_REAL, tab); /* Guessed Frequency */
|
||||
error = INPapName(ckt, which, pssJob, "fguess", parm);
|
||||
if (error)
|
||||
current->error = INPerrCat(current->error, INPerror(error));
|
||||
|
||||
parm = INPgetValue(ckt, &line, IF_REAL, tab); /* Stabilization time */
|
||||
error = INPapName(ckt, which, pssJob, "stabtime", parm);
|
||||
if (error)
|
||||
current->error = INPerrCat(current->error, INPerror(error));
|
||||
|
||||
parm = INPgetValue(ckt, &line, IF_INTEGER, tab); /* PSS points */
|
||||
error = INPapName(ckt, which, pssJob, "points", parm);
|
||||
if (error)
|
||||
current->error = INPerrCat(current->error, INPerror(error));
|
||||
|
||||
parm = INPgetValue(ckt, &line, IF_INTEGER, tab); /* PSS points */
|
||||
error = INPapName(ckt, which, pssJob, "harmonics", parm);
|
||||
if (error)
|
||||
current->error = INPerrCat(current->error, INPerror(error));
|
||||
}
|
||||
#endif
|
||||
|
||||
next:
|
||||
while (*line) { /* read the entire line */
|
||||
|
||||
|
|
|
|||
|
|
@ -218,6 +218,11 @@ if_run(CKTcircuit *ckt, char *what, wordlist *args, INPtables *tab)
|
|||
eq(what, "sens") ||
|
||||
eq(what, "tf") ||
|
||||
eq(what, "noise")
|
||||
#ifdef WITH_PSS
|
||||
/* SP: Steady State Analysis */
|
||||
|| eq(what, "pss")
|
||||
/* SP */
|
||||
#endif
|
||||
)
|
||||
{
|
||||
s = wl_flatten(args); /* va: tfree char's tmalloc'ed in wl_flatten */
|
||||
|
|
@ -334,6 +339,11 @@ if_run(CKTcircuit *ckt, char *what, wordlist *args, INPtables *tab)
|
|||
(eq(what, "adjsen")) ||
|
||||
(eq(what, "sens")) ||
|
||||
(eq(what, "tf")) ||
|
||||
#ifdef WITH_PSS
|
||||
/* SP: Steady State Analysis */
|
||||
(eq(what, "pss")) ||
|
||||
/* SP */
|
||||
#endif
|
||||
(eq(what, "run")))
|
||||
{
|
||||
/*CDHW Run the analysis pointed to by ci_curTask CDHW*/
|
||||
|
|
|
|||
|
|
@ -78,10 +78,11 @@ struct plotab plotabs[NUMPLOTTYPES] = {
|
|||
{ "sp", "sp" } ,
|
||||
{ "harm", "harm" },
|
||||
{ "spect", "spect" },
|
||||
{ "pss", "periodic" },
|
||||
};
|
||||
|
||||
int notypes = 19;
|
||||
int noplotabs = 21;
|
||||
int noplotabs = 22;
|
||||
|
||||
|
||||
/* A command to define types for vectors and plots. This will generally
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ include_HEADERS = \
|
|||
plot.h \
|
||||
pnode.h \
|
||||
profile.h \
|
||||
pssdefs.h \
|
||||
pzdefs.h \
|
||||
sen2defs.h \
|
||||
sensdefs.h \
|
||||
|
|
|
|||
|
|
@ -264,6 +264,19 @@ struct CKTcircuit {
|
|||
Enh_Ckt_Data_t *enh; /* data used by general enhancements */
|
||||
#endif
|
||||
/* gtri - evt - wbk - 5/20/91 - add event-driven and enhancements data */
|
||||
|
||||
#ifdef WITH_PSS
|
||||
/* SP: Periodic Steady State Analysis - 100609 */
|
||||
double CKTstabTime; /* PSS stab time */
|
||||
double CKTguessedFreq; /* PSS guessed frequency */
|
||||
int CKTharms; /* PSS harmonics */
|
||||
long int CKTpsspoints; /* PSS number of samples */
|
||||
char *CKToscNode; /* PSS oscnode */
|
||||
double CKTsteady_coeff; /* PSS Steady Coefficient */
|
||||
int CKTsc_iter; /* PSS Maximum Number of Shooting Iterations */
|
||||
/* SP: 100609 */
|
||||
#endif
|
||||
|
||||
unsigned int CKTisLinear:1; /* flag to indicate that the circuit
|
||||
contains only linear elements */
|
||||
unsigned int CKTnoopac:1; /* flag to indicate that OP will not be evaluated
|
||||
|
|
@ -380,6 +393,16 @@ extern int TFsetParm(CKTcircuit *, JOB *, int , IFvalue *);
|
|||
extern int TRANaskQuest(CKTcircuit *, JOB *, int , IFvalue *);
|
||||
extern int TRANsetParm(CKTcircuit *, JOB *, int , IFvalue *);
|
||||
extern int TRANinit(CKTcircuit *, JOB *);
|
||||
|
||||
#ifdef WITH_PSS
|
||||
/* SP: Steady State Analysis */
|
||||
extern int PSSaskQuest(CKTcircuit *, JOB *, int , IFvalue *);
|
||||
extern int PSSsetParm(CKTcircuit *, JOB *, int , IFvalue *);
|
||||
extern int PSSinit(CKTcircuit *, JOB *);
|
||||
extern int DCpss(CKTcircuit *, int);
|
||||
/* SP */
|
||||
#endif
|
||||
|
||||
extern int NaskQuest(CKTcircuit *, JOB *, int, IFvalue *);
|
||||
extern int NsetParm(CKTcircuit *, JOB *, int, IFvalue *);
|
||||
extern int NIacIter(CKTcircuit *);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
/**********
|
||||
Author: 2010-05 Stefano Perticaroli ``spertica''
|
||||
Review: 2012-10 Francesco Lannutti
|
||||
**********/
|
||||
|
||||
#ifndef PSS_H
|
||||
#define PSS_H
|
||||
|
||||
#include "ngspice/jobdefs.h"
|
||||
#include "ngspice/tskdefs.h"
|
||||
/*
|
||||
* PSSdefs.h - defs for pss analyses
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int JOBtype;
|
||||
JOB *JOBnextJob;
|
||||
char *JOBname;
|
||||
double PSSguessedFreq;
|
||||
CKTnode *PSSoscNode;
|
||||
double PSSstabTime;
|
||||
long PSSmode;
|
||||
long int PSSpoints;
|
||||
int PSSharms;
|
||||
runDesc *PSSplot_td;
|
||||
runDesc *PSSplot_fd;
|
||||
int sc_iter;
|
||||
double steady_coeff;
|
||||
} PSSan;
|
||||
|
||||
#define GUESSED_FREQ 1
|
||||
#define STAB_TIME 2
|
||||
#define OSC_NODE 3
|
||||
#define PSS_POINTS 4
|
||||
#define PSS_HARMS 5
|
||||
#define PSS_UIC 6
|
||||
#define SC_ITER 7
|
||||
#define STEADY_COEFF 8
|
||||
|
||||
#endif
|
||||
|
|
@ -98,6 +98,15 @@ libckt_la_SOURCES = \
|
|||
cluster.c
|
||||
|
||||
|
||||
if PSS_WANTED
|
||||
libckt_la_SOURCES += \
|
||||
dcpss.c \
|
||||
pssaskq.c \
|
||||
pssinit.c \
|
||||
psssetp.c
|
||||
endif
|
||||
|
||||
|
||||
AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include -I$(top_srcdir)/src/spicelib/devices
|
||||
AM_CFLAGS = $(STATIC)
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@ extern SPICEanalysis DISTOinfo;
|
|||
extern SPICEanalysis NOISEinfo;
|
||||
extern SPICEanalysis SENSinfo;
|
||||
|
||||
#ifdef WITH_PSS
|
||||
extern SPICEanalysis PSSinfo;
|
||||
#endif
|
||||
|
||||
SPICEanalysis *analInfo[] = {
|
||||
&OPTinfo,
|
||||
&ACinfo,
|
||||
|
|
@ -27,6 +31,9 @@ SPICEanalysis *analInfo[] = {
|
|||
&DISTOinfo,
|
||||
&NOISEinfo,
|
||||
&SENSinfo,
|
||||
#ifdef WITH_PSS
|
||||
&PSSinfo,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,54 @@
|
|||
/**********
|
||||
Author: 2010-05 Stefano Perticaroli ``spertica''
|
||||
**********/
|
||||
|
||||
#include "ngspice/ngspice.h"
|
||||
#include "ngspice/ifsim.h"
|
||||
#include "ngspice/iferrmsg.h"
|
||||
#include "ngspice/cktdefs.h"
|
||||
#include "ngspice/pssdefs.h"
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
PSSaskQuest(CKTcircuit *ckt, JOB *anal, int which, IFvalue *value)
|
||||
{
|
||||
PSSan *job = (PSSan *) anal;
|
||||
|
||||
NG_IGNORE(ckt);
|
||||
|
||||
switch(which) {
|
||||
|
||||
case GUESSED_FREQ:
|
||||
value->rValue = job->PSSguessedFreq;
|
||||
break;
|
||||
case OSC_NODE:
|
||||
value->nValue = job->PSSoscNode;
|
||||
break;
|
||||
case STAB_TIME:
|
||||
value->rValue = job->PSSstabTime;
|
||||
break;
|
||||
case PSS_UIC:
|
||||
if (job->PSSmode & MODEUIC) {
|
||||
value->iValue = 1;
|
||||
} else {
|
||||
value->iValue = 0;
|
||||
}
|
||||
break;
|
||||
case PSS_POINTS:
|
||||
value->iValue = (int)job->PSSpoints;
|
||||
break;
|
||||
case PSS_HARMS:
|
||||
value->iValue = job->PSSharms;
|
||||
break;
|
||||
case SC_ITER:
|
||||
value->iValue = job->sc_iter;
|
||||
break;
|
||||
case STEADY_COEFF:
|
||||
value->rValue = job->steady_coeff;
|
||||
break;
|
||||
|
||||
default:
|
||||
return(E_BADPARM);
|
||||
}
|
||||
return(OK);
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
/**********
|
||||
Author: 2010-05 Stefano Perticaroli ``spertica''
|
||||
**********/
|
||||
|
||||
#include "ngspice/ngspice.h"
|
||||
#include "ngspice/cktdefs.h"
|
||||
#include "ngspice/trandefs.h"
|
||||
#include "ngspice/pssdefs.h"
|
||||
#include "ngspice/iferrmsg.h"
|
||||
|
||||
int PSSinit(CKTcircuit *ckt, JOB *anal)
|
||||
{
|
||||
PSSan *job = (PSSan *) anal;
|
||||
|
||||
/* Step is chosen empirically to be 1% of PSSguessedFreq */
|
||||
ckt->CKTstep = 0.01 * (1/job->PSSguessedFreq);
|
||||
/* Init time should be always zero */
|
||||
ckt->CKTinitTime = 0;
|
||||
/* MaxStep should not exceed Nyquist criterion */
|
||||
ckt->CKTmaxStep = 0.5*(1/job->PSSguessedFreq);
|
||||
ckt->CKTdelmin = 1e-9*ckt->CKTmaxStep;
|
||||
ckt->CKTmode = job->PSSmode;
|
||||
/* modified CKTdefs.h for the following - 100609 */
|
||||
ckt->CKTstabTime = job->PSSstabTime;
|
||||
ckt->CKTguessedFreq = job->PSSguessedFreq;
|
||||
ckt->CKTharms = job->PSSharms;
|
||||
ckt->CKTpsspoints = job->PSSpoints;
|
||||
ckt->CKTsc_iter = job->sc_iter;
|
||||
ckt->CKTsteady_coeff = job->steady_coeff;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/**********
|
||||
Author: 2010-05 Stefano Perticaroli ``spertica''
|
||||
**********/
|
||||
|
||||
#include "ngspice/ngspice.h"
|
||||
#include "ngspice/ifsim.h"
|
||||
#include "ngspice/iferrmsg.h"
|
||||
#include "ngspice/cktdefs.h"
|
||||
#include "ngspice/pssdefs.h"
|
||||
|
||||
#include "analysis.h"
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
PSSsetParm(CKTcircuit *ckt, JOB *anal, int which, IFvalue *value)
|
||||
{
|
||||
PSSan *job = (PSSan *) anal;
|
||||
|
||||
NG_IGNORE(ckt);
|
||||
|
||||
switch(which) {
|
||||
|
||||
case GUESSED_FREQ:
|
||||
job->PSSguessedFreq = value->rValue;
|
||||
break;
|
||||
case OSC_NODE:
|
||||
job->PSSoscNode = value->nValue;
|
||||
break;
|
||||
case STAB_TIME:
|
||||
job->PSSstabTime = value->rValue;
|
||||
break;
|
||||
case PSS_POINTS:
|
||||
job->PSSpoints = value->iValue;
|
||||
break;
|
||||
case PSS_HARMS:
|
||||
job->PSSharms = value->iValue;
|
||||
break;
|
||||
case PSS_UIC:
|
||||
if(value->iValue) {
|
||||
job->PSSmode |= MODEUIC;
|
||||
}
|
||||
break;
|
||||
case SC_ITER:
|
||||
job->sc_iter = value->iValue;
|
||||
break;
|
||||
case STEADY_COEFF:
|
||||
job->steady_coeff = value->rValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
return(E_BADPARM);
|
||||
}
|
||||
return(OK);
|
||||
}
|
||||
|
||||
|
||||
static IFparm PSSparms[] = {
|
||||
{ "fguess", GUESSED_FREQ, IF_SET|IF_REAL, "guessed frequency" },
|
||||
{ "oscnode", OSC_NODE, IF_SET|IF_STRING, "oscillation node" },
|
||||
{ "stabtime", STAB_TIME, IF_SET|IF_REAL, "stabilization time" },
|
||||
{ "points", PSS_POINTS, IF_SET|IF_INTEGER, "pick equispaced number of time points in PSS" },
|
||||
{ "harmonics", PSS_HARMS, IF_SET|IF_INTEGER, "consider only given number of harmonics in PSS from DC" },
|
||||
{ "uic", PSS_UIC, IF_SET|IF_INTEGER, "use initial conditions (1 true - 0 false)" },
|
||||
{ "sc_iter", SC_ITER, IF_SET|IF_INTEGER, "maxmimum number of shooting cycle iterations" },
|
||||
{ "steady_coeff", STEADY_COEFF, IF_SET|IF_INTEGER, "set steady coefficient for convergence test" }
|
||||
};
|
||||
|
||||
SPICEanalysis PSSinfo = {
|
||||
{
|
||||
"PSS",
|
||||
"Periodic Steady State analysis",
|
||||
|
||||
sizeof(PSSparms)/sizeof(IFparm),
|
||||
PSSparms
|
||||
},
|
||||
sizeof(PSSan),
|
||||
TIMEDOMAIN,
|
||||
1,
|
||||
PSSsetParm,
|
||||
PSSaskQuest,
|
||||
PSSinit,
|
||||
DCpss
|
||||
};
|
||||
|
|
@ -627,6 +627,73 @@ dot_sens2(char *line, CKTcircuit *ckt, INPtables *tab, card *current,
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_PSS
|
||||
/*SP: Steady State Analyis */
|
||||
static int
|
||||
dot_pss(char *line, void *ckt, INPtables *tab, card *current,
|
||||
void *task, void *gnode, JOB *foo)
|
||||
{
|
||||
int error; /* error code temporary */
|
||||
IFvalue ptemp; /* a value structure to package resistance into */
|
||||
IFvalue *parm; /* a pointer to a value struct for function returns */
|
||||
char *nname; /* the oscNode name */
|
||||
CKTnode *nnode; /* the oscNode node */
|
||||
int which; /* which analysis we are performing */
|
||||
int i; /* generic loop variable */
|
||||
char *word; /* something to stick a word of input into */
|
||||
|
||||
NG_IGNORE(gnode);
|
||||
|
||||
/* .pss Fguess StabTime OscNode <UIC>*/
|
||||
which = -1;
|
||||
for (i = 0; i < ft_sim->numAnalyses; i++) {
|
||||
if (strcmp(ft_sim->analyses[i]->name, "PSS") == 0) {
|
||||
which = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (which == -1) {
|
||||
LITERR("Periodic steady state analysis unsupported.\n");
|
||||
return (0);
|
||||
}
|
||||
IFC(newAnalysis, (ckt, which, "Periodic Steady State Analysis", &foo, task));
|
||||
|
||||
parm = INPgetValue(ckt, &line, IF_REAL, tab); /* Fguess */
|
||||
GCA(INPapName, (ckt, which, foo, "fguess", parm));
|
||||
|
||||
parm = INPgetValue(ckt, &line, IF_REAL, tab); /* StabTime */
|
||||
GCA(INPapName, (ckt, which, foo, "stabtime", parm));
|
||||
|
||||
INPgetNetTok(&line, &nname, 0);
|
||||
INPtermInsert(ckt, &nname, tab, &nnode);
|
||||
ptemp.nValue = nnode;
|
||||
GCA(INPapName, (ckt, which, foo, "oscnode", &ptemp)) /* OscNode given as string */
|
||||
|
||||
parm = INPgetValue(ckt, &line, IF_INTEGER, tab); /* PSS points */
|
||||
GCA(INPapName, (ckt, which, foo, "points", parm));
|
||||
|
||||
parm = INPgetValue(ckt, &line, IF_INTEGER, tab); /* PSS harmonics */
|
||||
GCA(INPapName, (ckt, which, foo, "harmonics", parm));
|
||||
|
||||
parm = INPgetValue(ckt, &line, IF_INTEGER, tab); /* SC iterations */
|
||||
GCA(INPapName, (ckt, which, foo, "sc_iter", parm));
|
||||
|
||||
parm = INPgetValue(ckt, &line, IF_REAL, tab); /* Steady coefficient */
|
||||
GCA(INPapName, (ckt, which, foo, "steady_coeff", parm));
|
||||
|
||||
if (*line) {
|
||||
INPgetTok(&line, &word, 1); /* uic? */
|
||||
if (strcmp(word, "uic") == 0) {
|
||||
ptemp.iValue = 1;
|
||||
GCA(INPapName, (ckt, which, foo, "uic", &ptemp));
|
||||
} else {
|
||||
fprintf(stderr,"Error: unknown parameter %s on .pss - ignored\n", word);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
/* SP */
|
||||
#endif
|
||||
|
||||
static int
|
||||
dot_options(char *line, CKTcircuit *ckt, INPtables *tab, card *current,
|
||||
|
|
@ -707,6 +774,13 @@ INP2dot(CKTcircuit *ckt, INPtables *tab, card *current, TSKtask *task, CKTnode *
|
|||
} else if ((strcmp(token, ".tran") == 0)) {
|
||||
rtn = dot_tran(line, ckt, tab, current, task, gnode, foo);
|
||||
goto quit;
|
||||
#ifdef WITH_PSS
|
||||
/* SP: Steady State Analysis */
|
||||
} else if ((strcmp(token, ".pss") == 0)) {
|
||||
rtn = dot_pss(line, ckt, tab, current, task, gnode, foo);
|
||||
goto quit;
|
||||
/* SP */
|
||||
#endif
|
||||
} else if ((strcmp(token, ".subckt") == 0) ||
|
||||
(strcmp(token, ".ends") == 0)) {
|
||||
/* not yet implemented - warn & ignore */
|
||||
|
|
|
|||
|
|
@ -2756,6 +2756,10 @@
|
|||
RelativePath="..\src\spicelib\devices\jfet2\psmodel.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\ngspice\pssdefs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\frontend\plotting\pvec.h"
|
||||
>
|
||||
|
|
|
|||
Loading…
Reference in New Issue