Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles
**********/
#include "ngspice/ngspice.h"
#include "ngspice/ifsim.h"
#include "ngspice/inpdefs.h"
#include "ngspice/inpmacs.h"
#include "ngspice/fteext.h"
#include "ngspice/iferrmsg.h"
#include "ngspice/cktdefs.h"
#include "inppas4.h"
#include "inpxx.h"
#ifdef XSPICE
#include "ngspice/mifproto.h"
#endif
add a capacitor to each voltage node */
void INPpas4(CKTcircuit *ckt, INPtables *tab)
{
CKTnode* node;
int mytype = -1;
IFuid uid;
int error;
GENinstance* fast;
IFvalue ptemp;
int nadded = 0;
double csval = 0.;
if (!cp_getvar("cshunt_value", CP_REAL, &csval, 0))
return;
if ((mytype = INPtypelook("Capacitor")) < 0) {
fprintf(stderr, "Device type Capacitor not supported by this binary\n");
return;
}
if (!tab->defCmod) {
IFnewUid(ckt, &uid, NULL, "C", UID_MODEL, NULL);
error = (*(ft_sim->newModel))(ckt, mytype, &(tab->defCmod), uid);
}
for (node = ckt->CKTnodes; node; node = node->next) {
if (node->type == NODE_VOLTAGE && (node->number > 0)) {
int nn = node->number;
char* devname = tprintf("capac%dshunt", nn);
(*(ft_sim->newInstance))(ckt, tab->defCmod, &fast, devname);
(*(ft_sim->bindNode))(ckt, fast, 1, node);
ptemp.rValue = csval;
error = INPpName("capacitance", &ptemp, ckt, mytype, fast);
ckt->CKTstat->STATdevNum[mytype].instNum++;
ckt->CKTstat->STATtotalDev++;
nadded++;
}
}
printf("Option cshunt: %d capacitors added with %g F each\n", nadded, csval);
}