[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-user: ngspice:try to add vc1, vc2 to res model.
Please find patch file attached. I'm trying to add vc1,2 to res model.
Notation
R1 2 1 w=10u l=100u vc1=7e-5 vc2=1e-3
But
.model rmod (
+ VC1=7e-5
+ VC2=1e-3
+ )
R1 2 1 rmod w=10u l=100u vc1=7e-5 vc2=1e-3
Doesn't work. What I'm doing wrong?
Thanks,
Alex.
Common subdirectories: ngspice-original/ng-spice-rework/src/spicelib/devices/res/CVS and ngspice/ng-spice-rework/src/spicelib/devices/res/CVS
Only in ngspice/ng-spice-rework/src/spicelib/devices/res/: .deps
Only in ngspice/ng-spice-rework/src/spicelib/devices/res/: Makefile
Only in ngspice/ng-spice-rework/src/spicelib/devices/res/: Makefile.in
diff -u ngspice-original/ng-spice-rework/src/spicelib/devices/res/resask.c ngspice/ng-spice-rework/src/spicelib/devices/res/resask.c
--- ngspice-original/ng-spice-rework/src/spicelib/devices/res/resask.c 2009-06-14 12:37:52.578562944 -0700
+++ ngspice/ng-spice-rework/src/spicelib/devices/res/resask.c 2009-06-14 12:49:48.653551529 -0700
@@ -64,12 +64,18 @@
case RES_M:
value->rValue = fast->RESm;
return(OK);
- case RES_TC1:
- value->rValue = fast->REStc1;
- return(OK);
- case RES_TC2:
- value->rValue = fast->REStc2;
- return(OK);
+ case RES_TC1:
+ value->rValue = fast->REStc1;
+ return(OK);
+ case RES_TC2:
+ value->rValue = fast->REStc2;
+ return(OK);
+ case RES_VC1:
+ value->rValue = fast->RESvc1;
+ return(OK);
+ case RES_VC2:
+ value->rValue = fast->RESvc2;
+ return(OK);
case RES_NOISY:
value->iValue = fast->RESnoisy;
return(OK);
diff -u ngspice-original/ng-spice-rework/src/spicelib/devices/res/res.c ngspice/ng-spice-rework/src/spicelib/devices/res/res.c
--- ngspice-original/ng-spice-rework/src/spicelib/devices/res/res.c 2009-06-14 12:37:52.559563322 -0700
+++ ngspice/ng-spice-rework/src/spicelib/devices/res/res.c 2009-06-14 14:54:01.025553126 -0700
@@ -22,6 +22,9 @@
IOPU( "tc", RES_TC1, IF_REAL, "First order temp. coefficient"),
IOPU( "tc1", RES_TC1, IF_REAL, "First order temp. coefficient"),
IOPU( "tc2", RES_TC2, IF_REAL, "Second order temp. coefficient"),
+ IOPU( "vc", RES_VC1, IF_REAL, "First order volt. coefficient"),
+ IOPU( "vc1", RES_VC1, IF_REAL, "First order volt. coefficient"),
+ IOPU( "vc2", RES_VC2, IF_REAL, "Second order volt. coefficient"),
IOPU( "scale", RES_SCALE, IF_REAL, "Scale factor"),
IOP( "noisy", RES_NOISY, IF_INTEGER, "Resistor generate noise"),
IP( "sens_resist", RES_RESIST_SENS, IF_FLAG,
@@ -46,6 +49,8 @@
IOPR( "dlr", RES_MOD_SHORT, IF_REAL,"Shortening of resistor"),
IOPQ( "tc1", RES_MOD_TC1, IF_REAL,"First order temp. coefficient"),
IOPQO( "tc2", RES_MOD_TC2, IF_REAL,"Second order temp. coefficient"),
+ IOPQ( "vc1", RES_MOD_VC1, IF_REAL,"First order volt. coefficient"),
+ IOPQO( "vc2", RES_MOD_VC2, IF_REAL,"Second order volt. coefficient"),
IOPX( "defw", RES_MOD_DEFWIDTH, IF_REAL,"Default device width"),
IOPR( "w", RES_MOD_DEFWIDTH, IF_REAL,"Default device width"),
IOPQ( "kf", RES_MOD_KF, IF_REAL,"Flicker noise coefficient"),
diff -u ngspice-original/ng-spice-rework/src/spicelib/devices/res/resdefs.h ngspice/ng-spice-rework/src/spicelib/devices/res/resdefs.h
--- ngspice-original/ng-spice-rework/src/spicelib/devices/res/resdefs.h 2009-06-14 12:37:52.579552456 -0700
+++ ngspice/ng-spice-rework/src/spicelib/devices/res/resdefs.h 2009-06-14 15:12:25.114801141 -0700
@@ -43,6 +43,10 @@
double RESm; /* Multiplicity factor for this instance */
double REStc1; /* first temperature coefficient of resistors */
double REStc2; /* second temperature coefficient of resistors */
+/* alx begin */
+ double RESvc1; /* first voltage coefficient of resistors */
+ double RESvc2; /* second voltage coefficient of resistors */
+/* alx end */
int RESnoisy; /* Set if the resistor generates noise */
double *RESposPosptr; /* pointer to sparse matrix diagonal at
* (positive,positive) */
@@ -63,6 +67,10 @@
unsigned RESmGiven : 1; /* indicates M parameter specified */
unsigned REStc1Given : 1; /* indicates tc1 parameter specified */
unsigned REStc2Given : 1; /* indicates tc2 parameter specified */
+/* alx begin */
+ unsigned RESvc1Given : 1; /* indicates vc1 parameter specified */
+ unsigned RESvc2Given : 1; /* indicates vc2 parameter specified */
+/* alx end */
unsigned RESnoisyGiven : 1; /* indicates if noisy is specified */
int RESsenParmNo; /* parameter # for sensitivity use;
* set equal to 0 if not a design parameter*/
@@ -98,6 +106,8 @@
double REStnom; /* temperature at which resistance measured */
double REStempCoeff1; /* first temperature coefficient of resistors */
double REStempCoeff2; /* second temperature coefficient of resistors */
+ double RESvoltCoeff1; /* first voltage coefficient of resistors */
+ double RESvoltCoeff2; /* second voltage coefficient of resistors */
double RESsheetRes; /* sheet resistance of devices in ohms/square */
double RESdefWidth; /* default width of a resistor */
double RESnarrow; /* amount by which device is narrower than drawn */
@@ -107,6 +117,8 @@
unsigned REStnomGiven :1; /* flag to indicate nominal temp. was given */
unsigned REStc1Given :1; /* flag to indicate tc1 was specified */
unsigned REStc2Given :1; /* flag to indicate tc2 was specified */
+ unsigned RESvc1Given :1; /* flag to indicate vc1 was specified */
+ unsigned RESvc2Given :1; /* flag to indicate vc2 was specified */
unsigned RESsheetResGiven :1; /* flag to indicate sheet resistance given*/
unsigned RESdefWidthGiven :1; /* flag to indicate default width given */
unsigned RESnarrowGiven :1; /* flag to indicate narrow effect given */
@@ -134,6 +146,8 @@
/* tanaka */
#define RES_TC1 16
#define RES_TC2 17
+#define RES_VC1 18
+#define RES_VC2 19
/* model parameters */
#define RES_MOD_TC1 101
@@ -146,6 +160,8 @@
#define RES_MOD_SHORT 108
#define RES_MOD_KF 109
#define RES_MOD_AF 110
+#define RES_MOD_VC1 111
+#define RES_MOD_VC2 112
/* device questions */
#define RES_QUEST_SENS_REAL 201
diff -u ngspice-original/ng-spice-rework/src/spicelib/devices/res/resload.c ngspice/ng-spice-rework/src/spicelib/devices/res/resload.c
--- ngspice-original/ng-spice-rework/src/spicelib/devices/res/resload.c 2009-06-14 12:37:52.556562241 -0700
+++ ngspice/ng-spice-rework/src/spicelib/devices/res/resload.c 2009-06-19 12:27:18.715124567 -0700
@@ -18,7 +18,9 @@
RESmodel *model = (RESmodel *)inModel;
double m;
double difference;
+ double vdifference;
double factor;
+ double vactor;
/* loop through all the resistor models */
@@ -31,18 +33,25 @@
if(!here->REStc1Given) here->REStc1 = 0.0;
if(!here->REStc2Given) here->REStc2 = 0.0;
+ if(!here->RESvc1Given) here->RESvc1 = 0.0;
+ if(!here->RESvc2Given) here->RESvc2 = 0.0;
if(!here->RESmGiven) here->RESm = 1.0;
if (here->RESowner != ARCHme) continue;
- here->REScurrent = (*(ckt->CKTrhsOld+here->RESposNode) -
- *(ckt->CKTrhsOld+here->RESnegNode)) * here->RESconduct;
+ vdifference = fabs(*(ckt->CKTrhsOld+here->RESposNode) -
+ *(ckt->CKTrhsOld+here->RESnegNode));
+
+ here->REScurrent = vdifference * here->RESconduct;
difference = (here->REStemp + here->RESdtemp) - 300.15;
factor = 1.0 + (here->REStc1)*difference +
(here->REStc2)*difference*difference;
- m = (here->RESm)/factor;
+ vactor = 1.0 + (here->RESvc1)*vdifference +
+ (here->RESvc2)*vdifference*vdifference;
+
+ m = (here->RESm)/factor/vactor;
*(here->RESposPosptr) += m * here->RESconduct;
*(here->RESnegNegptr) += m * here->RESconduct;
@@ -62,6 +71,7 @@
RESmodel *model = (RESmodel *)inModel;
double m;
double difference;
+ double vdifference;
double factor;
/* loop through all the resistor models */
@@ -74,6 +84,8 @@
if(!here->REStc1Given) here->REStc1 = 0.0;
if(!here->REStc2Given) here->REStc2 = 0.0;
+ if(!here->RESvc1Given) here->RESvc1 = 0.0;
+ if(!here->RESvc2Given) here->RESvc2 = 0.0;
if(!here->RESmGiven) here->RESm = 1.0;
if (here->RESowner != ARCHme) continue;
Only in ngspice/ng-spice-rework/src/spicelib/devices/res/: .resload.c.swp
diff -u ngspice-original/ng-spice-rework/src/spicelib/devices/res/resmask.c ngspice/ng-spice-rework/src/spicelib/devices/res/resmask.c
--- ngspice-original/ng-spice-rework/src/spicelib/devices/res/resmask.c 2009-06-14 12:37:52.584582076 -0700
+++ ngspice/ng-spice-rework/src/spicelib/devices/res/resmask.c 2009-06-14 12:52:36.565551856 -0700
@@ -31,6 +31,12 @@
case RES_MOD_TC2:
value->rValue = model->REStempCoeff2;
return(OK);
+ case RES_MOD_VC1:
+ value->rValue = model->RESvoltCoeff1;
+ return(OK);
+ case RES_MOD_VC2:
+ value->rValue = model->RESvoltCoeff2;
+ return(OK);
case RES_MOD_RSH:
value->rValue = model->RESsheetRes;
return(OK);
diff -u ngspice-original/ng-spice-rework/src/spicelib/devices/res/resmpar.c ngspice/ng-spice-rework/src/spicelib/devices/res/resmpar.c
--- ngspice-original/ng-spice-rework/src/spicelib/devices/res/resmpar.c 2009-06-14 12:37:52.557563277 -0700
+++ ngspice/ng-spice-rework/src/spicelib/devices/res/resmpar.c 2009-06-14 15:13:23.665551809 -0700
@@ -30,6 +30,14 @@
model->REStempCoeff2 = value->rValue;
model->REStc2Given = TRUE;
break;
+ case RES_MOD_VC1:
+ model->RESvoltCoeff1 = value->rValue;
+ model->RESvc1Given = TRUE;
+ break;
+ case RES_MOD_VC2:
+ model->RESvoltCoeff2 = value->rValue;
+ model->RESvc2Given = TRUE;
+ break;
case RES_MOD_RSH:
model->RESsheetRes = value->rValue;
model->RESsheetResGiven = TRUE;
diff -u ngspice-original/ng-spice-rework/src/spicelib/devices/res/resparam.c ngspice/ng-spice-rework/src/spicelib/devices/res/resparam.c
--- ngspice-original/ng-spice-rework/src/spicelib/devices/res/resparam.c 2009-06-14 12:37:52.582562895 -0700
+++ ngspice/ng-spice-rework/src/spicelib/devices/res/resparam.c 2009-06-14 14:46:31.848551557 -0700
@@ -63,6 +63,14 @@
here->REStc2 = value->rValue;
here->REStc2Given = TRUE;
break;
+ case RES_VC1:
+ here->RESvc1 = value->rValue;
+ here->RESvc1Given = TRUE;
+ break;
+ case RES_VC2:
+ here->RESvc2 = value->rValue;
+ here->RESvc2Given = TRUE;
+ break;
case RES_NOISY:
here->RESnoisy = value->iValue;
here->RESnoisyGiven = TRUE;
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user