sensitivity, use numStates and numSenStates instead of hardcoded literals

This commit is contained in:
rlar 2018-04-22 18:08:00 +02:00
parent dfbce23cae
commit b045c945c9
26 changed files with 56 additions and 34 deletions

View File

@ -371,7 +371,7 @@ BJTsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
here->BJTstate = *states;
*states += BJTnumStates;
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){
*states += 8 * (ckt->CKTsenInfo->SENparms);
*states += BJTnumSenStates * (ckt->CKTsenInfo->SENparms);
}
if(model->BJTcollectorResist == 0) {

View File

@ -75,9 +75,14 @@ typedef struct sCAPinstance {
#define CAPqcap CAPstate /* charge on the capacitor */
#define CAPccap CAPstate+1 /* current through the capacitor */
#define CAPnumStates 2
#define CAPsensxp CAPstate+2 /* charge sensitivities and their derivatives.
+3 for the derivatives - pointer to the
beginning of the array */
* +3 for the derivatives - pointer to the
* beginning of the array */
#define CAPnumSenStates 2
#ifdef USE_CUSPICE
typedef struct sCAPparamCPUstruct {

View File

@ -103,9 +103,9 @@ CAPsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
}
here->CAPqcap = *states;
*states += 2;
*states += CAPnumStates;
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){
*states += 2 * (ckt->CKTsenInfo->SENparms);
*states += CAPnumSenStates * (ckt->CKTsenInfo->SENparms);
}
/* macro to make elements with built in test for out of memory */

View File

@ -169,10 +169,15 @@ typedef struct sDIOinstance {
#define DIOconduct DIOstate+2
#define DIOcapCharge DIOstate+3
#define DIOcapCurrent DIOstate+4
#define DIOnumStates 5
#define DIOsensxp DIOstate+5 /* charge sensitivities and their derivatives.
* +6 for the derivatives - pointer to the
* beginning of the array */
#define DIOnumSenStates 2
/* per model data */

View File

@ -201,9 +201,9 @@ DIOsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
here->DIOjunctionSWCap = model->DIOjunctionSWCap * here->DIOpj;
here->DIOstate = *states;
*states += 5;
*states += DIOnumStates;
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){
*states += 2 * (ckt->CKTsenInfo->SENparms);
*states += DIOnumSenStates * (ckt->CKTsenInfo->SENparms);
}
if(model->DIOresist == 0) {

View File

@ -12,8 +12,6 @@ Modified: Paolo Nenzi
#include "ngspice/complex.h"
#include "ngspice/noisedef.h"
#define HFETAnumStates 24
typedef struct sHFETAinstance {
struct GENinstance gen;
@ -97,6 +95,8 @@ typedef struct sHFETAinstance {
#define HFETAgmg HFETAstate+22
#define HFETAgmd HFETAstate+23
#define HFETAnumStates 24
int HFETAoff;

View File

@ -249,7 +249,6 @@ HFETAsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
}
here->HFETAstate = *states;
/* *states += 24; */
*states += HFETAnumStates;
if(model->HFETArs != 0) {

View File

@ -63,7 +63,9 @@ typedef struct sHFET2instance {
#define HFET2cqgs HFET2state+10
#define HFET2qgd HFET2state+11
#define HFET2cqgd HFET2state+12
#define HFET2numStates 13
int HFET2mode;
int HFET2off;

View File

@ -133,7 +133,7 @@ int HFET2setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *state
IFuid tmpName;
here->HFET2state = *states;
*states += 13;
*states += HFET2numStates;
if(!here->HFET2lengthGiven)
L = 1e-6;

View File

@ -89,10 +89,15 @@ struct sINDinstance {
#define INDflux INDstate /* flux in the inductor */
#define INDvolt INDstate+1 /* voltage - save an entry in table */
#define INDnumStates 2
#define INDsensxp INDstate+2 /* charge sensitivities and their derivatives.
* +3 for the derivatives - pointer to the
* beginning of the array */
#define INDnumSenStates 2
#ifdef USE_CUSPICE
typedef struct sINDparamCPUstruct {
double *INDcpuPointersD [4];

View File

@ -80,9 +80,9 @@ INDsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
here=INDnextInstance(here)) {
here->INDflux = *states;
*states += 2 ;
*states += INDnumStates ;
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){
*states += 2 * (ckt->CKTsenInfo->SENparms);
*states += INDnumSenStates * (ckt->CKTsenInfo->SENparms);
}
if(here->INDbrEq == 0) {

View File

@ -186,6 +186,8 @@ typedef struct sJFETinstance {
#define JFETqgd JFETstate+11
#define JFETcqgd JFETstate+12
#define JFETnumStates 13
/* per model data */
typedef struct sJFETmodel { /* model structure for a jfet */

View File

@ -115,7 +115,7 @@ JFETsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
here->JFETm = 1;
}
here->JFETstate = *states;
*states += 13;
*states += JFETnumStates;
if(model->JFETsourceResist != 0) {
if(here->JFETsourcePrimeNode == 0) {

View File

@ -196,7 +196,9 @@ typedef struct sJFET2instance {
#define JFET2pave JFET2state+15
#define JFET2vtrap JFET2state+16
#define JFET2vgstrap JFET2state+17
#define JFET2_STATE_COUNT 18
#define JFET2unknown JFET2state+18
#define JFET2numStates 19
/* per model data */

View File

@ -55,7 +55,7 @@ JFET2setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
}
here->JFET2state = *states;
*states += JFET2_STATE_COUNT + 1;
*states += JFET2numStates;
if(model->JFET2rs != 0) {
if(here->JFET2sourcePrimeNode == 0) {

View File

@ -111,6 +111,8 @@ typedef struct sMESAinstance {
#define MESAggdpp MESAstate+18
#define MESAcgdpp MESAstate+19
#define MESAnumStates 20
int MESAoff;
unsigned MESAlengthGiven : 1;
unsigned MESAwidthGiven : 1;

View File

@ -257,7 +257,7 @@ MESAsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
here->MESAstate = *states;
*states += 20;
*states += MESAnumStates;
if(model->MESAsourceResist != 0) {
if(here->MESAsourcePrimeNode == 0) {

View File

@ -318,9 +318,9 @@ typedef struct sMOS1instance {
#define MOS1numStates 17
#define MOS1sensxpgs MOS1states+17 /* charge sensitivities and
their derivatives. +18 for the derivatives:
pointer to the beginning of the array */
#define MOS1sensxpgs MOS1states+17 /* charge sensitivities and their derivatives.
* +18 for the derivatives
* pointer to the beginning of the array */
#define MOS1sensxpgd MOS1states+19
#define MOS1sensxpgb MOS1states+21
#define MOS1sensxpbs MOS1states+23

View File

@ -102,7 +102,7 @@ MOS1setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt,
*states += MOS1numStates;
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){
*states += 10 * (ckt->CKTsenInfo->SENparms);
*states += MOS1numSenStates * (ckt->CKTsenInfo->SENparms);
}
if(!here->MOS1drainPerimiterGiven) {

View File

@ -325,8 +325,8 @@ typedef struct sMOS2instance {
#define MOS2sensxpgs MOS2states+17 /* charge sensitivities and their derivatives
+18 for the derivatives - pointer to the
beginning of the array */
* +18 for the derivatives
* pointer to the beginning of the array */
#define MOS2sensxpgd MOS2states+19
#define MOS2sensxpgb MOS2states+21

View File

@ -134,7 +134,7 @@ MOS2setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
*states += MOS2numStates;
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){
*states += 10 * (ckt->CKTsenInfo->SENparms);
*states += MOS2numSenStates * (ckt->CKTsenInfo->SENparms);
}
if(!here->MOS2drainPerimiterGiven) {

View File

@ -250,9 +250,9 @@ typedef struct sMOS6instance {
#define MOS6numStates 17
#define MOS6sensxpgs MOS6states+17 /* charge sensitivities and
their derivatives. +18 for the derivatives:
pointer to the beginning of the array */
#define MOS6sensxpgs MOS6states+17 /* charge sensitivities and their derivatives.
* +18 for the derivatives
* pointer to the beginning of the array */
#define MOS6sensxpgd MOS6states+19
#define MOS6sensxpgb MOS6states+21
#define MOS6sensxpbs MOS6states+23

View File

@ -150,7 +150,7 @@ MOS6setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt,
here->MOS6states = *states;
*states += MOS6numStates;
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){
*states += 10 * (ckt->CKTsenInfo->SENparms);
*states += MOS6numSenStates * (ckt->CKTsenInfo->SENparms);
}
if((model->MOS6drainResistance != 0 ||

View File

@ -334,7 +334,7 @@ SOI3setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
here->SOI3states = *states;
*states += SOI3numStates;
/* if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){
*states += 10 * (ckt->CKTsenInfo->SENparms);
*states += SOI3numSenStates * (ckt->CKTsenInfo->SENparms);
}
*/
/****** Part 4 - check resistance values for internal nodes, ******/

View File

@ -393,9 +393,9 @@ typedef struct sVBICinstance {
#define VBICnumStates 66
#define VBICsensxpbe VBICstate+66 /* charge sensitivities and their
derivatives. +67 for the derivatives -
pointer to the beginning of the array */
#define VBICsensxpbe VBICstate+66 /* charge sensitivities and their derivatives.
* +67 for the derivatives
* pointer to the beginning of the array */
#define VBICsensxpbex VBICstate+68
#define VBICsensxpbc VBICstate+70
#define VBICsensxpbcx VBICstate+72

View File

@ -403,7 +403,7 @@ VBICsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
here->VBICstate = *states;
*states += VBICnumStates;
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){
*states += 10 * (ckt->CKTsenInfo->SENparms);
*states += VBICnumSenStates * (ckt->CKTsenInfo->SENparms);
}
if(model->VBICextCollResist == 0) {