diff --git a/src/spicelib/parser/Makefile.am b/src/spicelib/parser/Makefile.am index 3cc7e7cce..5ef6e38ca 100644 --- a/src/spicelib/parser/Makefile.am +++ b/src/spicelib/parser/Makefile.am @@ -60,6 +60,8 @@ libinp_la_SOURCES = \ inppas2.h \ inppas3.c \ inppas3.h \ + inppas4.c \ + inppas4.h \ inppname.c \ inpptree.c \ inpptree-parser.y \ diff --git a/src/spicelib/parser/inppas4.c b/src/spicelib/parser/inppas4.c new file mode 100644 index 000000000..f3bda03fd --- /dev/null +++ b/src/spicelib/parser/inppas4.c @@ -0,0 +1,72 @@ +/********** +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 "inppas4.h" +#include "inpxx.h" + +#ifdef XSPICE +/* gtri - add - wbk - 11/9/90 - include function prototypes */ +#include "ngspice/mifproto.h" +/* gtri - end - wbk - 11/9/90 */ +#endif + + +/* uncomment to trace in this file */ +/*#define TRACE*/ + +/* pass 4 - If option cshunt is given, +add a capacitor to each voltage node */ +void INPpas4(CKTcircuit *ckt, INPtables * tab) +{ + CKTnode* node; + int mytype = -1; + IFuid uid; /* uid for default cap model */ + int error; /* error code temporary */ + GENinstance* fast; /* pointer to the actual instance */ + IFvalue ptemp; /* a value structure to package capacitance into */ + int nadded = 0; /* capacitors added */ + + if ((mytype = INPtypelook("Capacitor")) < 0) { + fprintf(stderr, "Device type Capacitor not supported by this binary\n"); + return; + } + + if (!tab->defCmod) { /* create default C model */ + IFnewUid(ckt, &uid, NULL, "C", UID_MODEL, NULL); + error = (*(ft_sim->newModel))(ckt, mytype, &(tab->defCmod), uid); + } + + /* scan through all nodes, add a new C device for each voltage node */ + 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); + + /* the top node, second node is gnd automatically */ + (*(ft_sim->bindNode))(ckt, fast, 1, node); + + /* value of the capacitance */ + ptemp.rValue = ft_curckt->ci_defTask->TSKcshunt; + error = INPpName("capacitance", &ptemp, ckt, mytype, fast); + + /* add device numbers for statistics */ + ckt->CKTstat->STATdevNum[mytype].instNum++; + ckt->CKTstat->STATtotalDev++; + + tfree(devname); + nadded++; + } + } + printf("Option cshunt: %d capacitors added with %g F each\n", nadded, ft_curckt->ci_defTask->TSKcshunt); +} diff --git a/src/spicelib/parser/inppas4.h b/src/spicelib/parser/inppas4.h new file mode 100644 index 000000000..96f5d1bc7 --- /dev/null +++ b/src/spicelib/parser/inppas4.h @@ -0,0 +1,8 @@ +#ifndef ngspice_INPPAS4_H +#define ngspice_INPPAS4_H + +#include "ngspice/inpdefs.h" + + + +#endif