Browse Source

Added multiplicity parameter m to resistors and updated tests

pre-master-46
pnenzi 26 years ago
parent
commit
090c6b6d6f
  1. 4
      DEVICES
  2. 1
      src/spicelib/devices/res/res.c
  3. 5
      src/spicelib/devices/res/resask.c
  4. 5
      src/spicelib/devices/res/resdefs.h
  5. 4
      src/spicelib/devices/res/resparam.c
  6. 5
      src/spicelib/devices/res/restemp.c
  7. 25
      tests/resistor.cir
  8. 1110
      tests/resistor.out

4
DEVICES

@ -19,8 +19,8 @@ IND - Inductor
RES - Resistor RES - Resistor
This is a modified version of the spice3 resistance model. This This is a modified version of the spice3 resistance model. This
model supports different ac and dc values (ac=...). This changes model supports different ac and dc values (ac=...). This changes
are introduced by Serban Popescu. This device needs more
testing.
are introduced by Serban Popescu. The "multiplicity factor" (m)
has been introduced.
*)Rework 11: The code has been modified to reflect spice parsing *)Rework 11: The code has been modified to reflect spice parsing
standard. standard.

1
src/spicelib/devices/res/res.c

@ -16,6 +16,7 @@ IFparm RESpTable[] = { /* parameters */
IOPZU( "temp", RES_TEMP, IF_REAL,"Instance operating temperature"), IOPZU( "temp", RES_TEMP, IF_REAL,"Instance operating temperature"),
IOPQU( "l", RES_LENGTH, IF_REAL,"Length"), IOPQU( "l", RES_LENGTH, IF_REAL,"Length"),
IOPZU( "w", RES_WIDTH, IF_REAL,"Width"), IOPZU( "w", RES_WIDTH, IF_REAL,"Width"),
IOPU( "m", RES_M, IF_REAL, "Multiplication factor"),
IP( "sens_resist", RES_RESIST_SENS, IF_FLAG, IP( "sens_resist", RES_RESIST_SENS, IF_FLAG,
"flag to request sensitivity WRT resistance"), "flag to request sensitivity WRT resistance"),
OP( "i", RES_CURRENT,IF_REAL,"Current"), OP( "i", RES_CURRENT,IF_REAL,"Current"),

5
src/spicelib/devices/res/resask.c

@ -43,9 +43,12 @@ RESask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value,
case RES_LENGTH: case RES_LENGTH:
value->rValue = fast->RESlength; value->rValue = fast->RESlength;
return(OK); return(OK);
case RES_WIDTH :
case RES_WIDTH:
value->rValue = fast->RESwidth; value->rValue = fast->RESwidth;
return(OK); return(OK);
case RES_M:
value->rValue = fast->RESm;
return(OK);
case RES_QUEST_SENS_DC: case RES_QUEST_SENS_DC:
if(ckt->CKTsenInfo){ if(ckt->CKTsenInfo){
value->rValue = *(ckt->CKTsenInfo->SEN_Sap[select->iValue + 1]+ value->rValue = *(ckt->CKTsenInfo->SEN_Sap[select->iValue + 1]+

5
src/spicelib/devices/res/resdefs.h

@ -36,6 +36,7 @@ typedef struct sRESinstance {
double RESacConduct; /* AC conductance */ double RESacConduct; /* AC conductance */
double RESwidth; /* width of the resistor */ double RESwidth; /* width of the resistor */
double RESlength; /* length of the resistor */ double RESlength; /* length of the resistor */
double RESm; /* Multiplicity factor for this instance */
double *RESposPosptr; /* pointer to sparse matrix diagonal at double *RESposPosptr; /* pointer to sparse matrix diagonal at
* (positive,positive) */ * (positive,positive) */
double *RESnegNegptr; /* pointer to sparse matrix diagonal at double *RESnegNegptr; /* pointer to sparse matrix diagonal at
@ -49,7 +50,8 @@ typedef struct sRESinstance {
unsigned RESlengthGiven : 1; /* flag to indicate length given */ unsigned RESlengthGiven : 1; /* flag to indicate length given */
unsigned REStempGiven : 1; /* indicates temperature specified */ unsigned REStempGiven : 1; /* indicates temperature specified */
/* serban */ /* serban */
unsigned RESacresGiven : 1; /* indicates AC value specified */
unsigned RESacresGiven : 1; /* indicates AC value specified */
unsigned RESmGiven : 1; /* indicates M parameter specified */
int RESsenParmNo; /* parameter # for sensitivity use; int RESsenParmNo; /* parameter # for sensitivity use;
set equal to 0 if not a design parameter*/ set equal to 0 if not a design parameter*/
#ifndef NONOISE #ifndef NONOISE
@ -97,6 +99,7 @@ typedef struct sRESmodel { /* model structure for a resistor */
/* serban */ /* serban */
#define RES_ACRESIST 10 #define RES_ACRESIST 10
#define RES_ACCONDUCT 11 #define RES_ACCONDUCT 11
#define RES_M 12 /* pn */
/* model parameters */ /* model parameters */

4
src/spicelib/devices/res/resparam.c

@ -39,6 +39,10 @@ RESparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
break; break;
case RES_RESIST_SENS: case RES_RESIST_SENS:
here->RESsenParmNo = value->iValue; here->RESsenParmNo = value->iValue;
break;
case RES_M:
here->RESm = value->rValue;
here->RESmGiven = TRUE;
break; break;
default: default:
return(E_BADPARM); return(E_BADPARM);

5
src/spicelib/devices/res/restemp.c

@ -64,9 +64,14 @@ REStemp(GENmodel *inModel, CKTcircuit *ckt)
here->RESconduct = 1.0/(here->RESresist * factor); here->RESconduct = 1.0/(here->RESresist * factor);
if(here->RESmGiven)
here->RESconduct = here->RESconduct * here->RESm;
/* Paolo Nenzi: Temperature effects for AC value */ /* Paolo Nenzi: Temperature effects for AC value */
if(here->RESacresGiven) if(here->RESacresGiven)
here->RESacConduct = 1.0/(here->RESacResist * factor); here->RESacConduct = 1.0/(here->RESacResist * factor);
if (here->RESmGiven)
here->RESacConduct = here->RESacConduct * here->RESm;
} }
} }
return(OK); return(OK);

25
tests/resistor.cir

@ -1,9 +1,24 @@
A simple resistor with a voltage source
A paralled resistor array
R1 1 0 10k
V1 1 0 1
Vin 1 0 DC 1 SIN (0 1 100MEG 1NS 0.0) AC 1
.TRAN 1ns 6ns
.PRINT TRAN I(V1)
VR1 1 2 DC 0
R1 2 0 10K
VR2 1 3 DC 0
R2 3 0 10K ac=5K
VR3 1 4 DC 0
R3 4 0 rmodel1 L=11u W=2u ac=2.5k
VR4 1 5 DC 0
R4 5 0 10K ac=5k m=2
.model rmodel1 R RSH = 1000 NARROW = 1u
.OP
.TRAN 1ns 10ns
.AC DEC 100 1MEG 100MEG
.PRINT TRAN I(VR1), I(VR2), I(VR3), I(VR4)
.PRINT AC I(VR1), I(VR2), I(VR3), I(VR4)
.END .END

1110
tests/resistor.out
File diff suppressed because it is too large
View File

Loading…
Cancel
Save