diff --git a/ChangeLog b/ChangeLog index ed0be888f..ee166419f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,12 +4,6 @@ src/frontend/parser/complete.c : Memory leaks plugged -2003-07-14 Stefan Jones - - * src/include/enh.h src/spicelib/analysis/{acan.c,cktload.c,cktsetup.c,cktsopt.c} - src/spicelib/devices/cktinit.c src/include/optdefs.h : - Removed XSPICE rshunt option, use gshunt from ngspice instead. - 2003-07-09 Stefan Jones * configure.in : Add extra check for tclreadline and headers diff --git a/src/include/enh.h b/src/include/enh.h index 8616191b2..18108d4be 100755 --- a/src/include/enh.h +++ b/src/include/enh.h @@ -83,13 +83,25 @@ typedef struct { double step; /* Fractional step amount */ } Enh_Conv_Limit_t; + +typedef struct { + Mif_Boolean_t enabled; /* True if rshunt option used */ + double gshunt; /* 1.0 / rshunt */ + int num_nodes; /* Number of nodes in matrix */ + double **diag; /* Pointers to matrix diagonals */ +} Enh_Rshunt_t; + + typedef struct { Enh_Bkpt_t breakpoint; /* Data used by dynamic breakpoints */ Enh_Ramp_t ramp; /* New options added to simulator */ Enh_Conv_Debug_t conv_debug; /* Convergence debug info dumping data */ Enh_Conv_Limit_t conv_limit; /* Convergence limiting info */ + Enh_Rshunt_t rshunt_data; /* Shunt conductance from nodes to ground */ } Enh_Ckt_Data_t; + + void ENHreport_conv_prob(Enh_Conv_Source_t type, char *name, char *msg); struct line *ENHtranslate_poly(struct line *deck); diff --git a/src/include/optdefs.h b/src/include/optdefs.h index d2f14fb95..5df48e853 100644 --- a/src/include/optdefs.h +++ b/src/include/optdefs.h @@ -126,6 +126,7 @@ typedef struct { #define OPT_ENH_CONV_ABS_STEP 105 #define OPT_ENH_CONV_STEP 106 #define OPT_MIF_AUTO_PARTIAL 107 +#define OPT_ENH_RSHUNT 108 /* gtri - end - wbk - add new options */ #endif diff --git a/src/spicelib/analysis/acan.c b/src/spicelib/analysis/acan.c index cce782bca..02ea0cf51 100644 --- a/src/spicelib/analysis/acan.c +++ b/src/spicelib/analysis/acan.c @@ -365,6 +365,20 @@ CKTacLoad(CKTcircuit *ckt) } #ifdef XSPICE + /* gtri - begin - Put resistors to ground at all nodes. */ + /* Value of resistor is set by new "rshunt" option. */ + + if(ckt->enh->rshunt_data.enabled) { + for(i = 0; i < ckt->enh->rshunt_data.num_nodes; i++) { + *(ckt->enh->rshunt_data.diag[i]) += + ckt->enh->rshunt_data.gshunt; + } + } + + /* gtri - end - Put resistors to ground at all nodes */ + + + /* gtri - add - wbk - 11/26/90 - reset the MIF init flags */ /* init is set by CKTinit and should be true only for first load call */ diff --git a/src/spicelib/analysis/cktload.c b/src/spicelib/analysis/cktload.c index dbe383845..e86bec724 100644 --- a/src/spicelib/analysis/cktload.c +++ b/src/spicelib/analysis/cktload.c @@ -44,6 +44,16 @@ CKTload(CKTcircuit *ckt) int noncon; #endif /* STEPDEBUG */ +#ifdef XSPICE + /* gtri - begin - Put resistors to ground at all nodes */ + /* SMPmatrix *matrix; maschmann : deleted , because unused */ + + double gshunt; + int num_nodes; + + /* gtri - begin - Put resistors to ground at all nodes */ +#endif + startTime = (*(SPfrontEnd->IFseconds))(); size = SMPmatSize(ckt->CKTmatrix); for (i=0;i<=size;i++) { @@ -85,7 +95,19 @@ CKTload(CKTcircuit *ckt) /* gtri - end - wbk - 11/26/90 */ + /* gtri - begin - Put resistors to ground at all nodes. */ + /* Value of resistor is set by new "rshunt" option. */ + + if(ckt->enh->rshunt_data.enabled) { + gshunt = ckt->enh->rshunt_data.gshunt; + num_nodes = ckt->enh->rshunt_data.num_nodes; + for(i = 0; i < num_nodes; i++) { + *(ckt->enh->rshunt_data.diag[i]) += gshunt; + } + } #endif + /* gtri - end - Put resistors to ground at all nodes */ + if(ckt->CKTmode & MODEDC) { /* consider doing nodeset & ic assignments */ diff --git a/src/spicelib/analysis/cktsetup.c b/src/spicelib/analysis/cktsetup.c index 964f35b26..d5f05c021 100644 --- a/src/spicelib/analysis/cktsetup.c +++ b/src/spicelib/analysis/cktsetup.c @@ -31,6 +31,12 @@ CKTsetup(CKTcircuit *ckt) { int i; int error; +#ifdef XSPICE + /* gtri - begin - Setup for adding rshunt option resistors */ + CKTnode *node; + int num_nodes; + /* gtri - end - Setup for adding rshunt option resistors */ +#endif SMPmatrix *matrix; ckt->CKTnumStates=0; @@ -74,6 +80,38 @@ CKTsetup(CKTcircuit *ckt) error = NIreinit(ckt); if(error) return(error); } +#ifdef XSPICE + /* gtri - begin - Setup for adding rshunt option resistors */ + + if(ckt->enh->rshunt_data.enabled) { + + /* Count number of voltage nodes in circuit */ + for(num_nodes = 0, node = ckt->CKTnodes; node; node = node->next) + if((node->type == NODE_VOLTAGE) && (node->number != 0)) + num_nodes++; + + /* Allocate space for the matrix diagonal data */ + if(num_nodes > 0) { + ckt->enh->rshunt_data.diag = + (double **) MALLOC(num_nodes * sizeof(double *)); + } + + /* Set the number of nodes in the rshunt data */ + ckt->enh->rshunt_data.num_nodes = num_nodes; + + /* Get/create matrix diagonal entry following what RESsetup does */ + for(i = 0, node = ckt->CKTnodes; node; node = node->next) { + if((node->type == NODE_VOLTAGE) && (node->number != 0)) { + ckt->enh->rshunt_data.diag[i] = + SMPmakeElt(matrix,node->number,node->number); + i++; + } + } + + } + + /* gtri - end - Setup for adding rshunt option resistors */ +#endif return(OK); } diff --git a/src/spicelib/analysis/cktsopt.c b/src/spicelib/analysis/cktsopt.c index 344af45c0..3a963bf53 100644 --- a/src/spicelib/analysis/cktsopt.c +++ b/src/spicelib/analysis/cktsopt.c @@ -184,6 +184,15 @@ CKTsetOpt(void *ckt, void *anal, int opt, IFvalue *val) g_mif_info.auto_partial.global = MIF_TRUE; break; + case OPT_ENH_RSHUNT: + if(val->rValue > 1.0e-30) { + ((CKTcircuit *) ckt)->enh->rshunt_data.enabled = MIF_TRUE; + ((CKTcircuit *) ckt)->enh->rshunt_data.gshunt = 1.0 / val->rValue; + } + else { + printf("WARNING - Rshunt option too small. Ignored.\n"); + } + break; #endif /* gtri - end - wbk - add new options */ default: @@ -202,6 +211,7 @@ static IFparm OPTtbl[] = { { "convstep", OPT_ENH_CONV_STEP, IF_SET|IF_REAL, "Fractional step allowed by code model inputs between iterations" }, { "convabsstep", OPT_ENH_CONV_ABS_STEP, IF_SET|IF_REAL, "Absolute step allowed by code model inputs between iterations" }, { "autopartial", OPT_MIF_AUTO_PARTIAL, IF_SET|IF_FLAG, "Use auto-partial computation for all models" }, + { "rshunt", OPT_ENH_RSHUNT, IF_SET|IF_REAL, "Shunt resistance from analog nodes to ground" }, /* gtri - end - wbk - add new options */ #endif { "noopiter", OPT_NOOPITER,IF_SET|IF_FLAG,"Go directly to gmin stepping" }, diff --git a/src/spicelib/devices/cktinit.c b/src/spicelib/devices/cktinit.c index 9448ace1f..bfd7d966a 100644 --- a/src/spicelib/devices/cktinit.c +++ b/src/spicelib/devices/cktinit.c @@ -107,6 +107,7 @@ CKTinit(void **ckt) /* new circuit to create */ (sckt)->enh->conv_limit.enabled = MIF_TRUE; (sckt)->enh->conv_limit.step = 0.25; (sckt)->enh->conv_limit.abs_step = 0.1; + (sckt)->enh->rshunt_data.enabled = MIF_FALSE; /* gtri - end - wbk - allocate/initialize substructs */