sense2, whitespace cleanup

checked for object file invariance
This commit is contained in:
rlar 2013-04-07 17:33:48 +02:00
parent 581e0a6d11
commit e2867a3ede
11 changed files with 261 additions and 247 deletions

View File

@ -2,8 +2,6 @@
Copyright 1990 Regents of the University of California. All rights reserved. Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles Author: 1985 Thomas L. Quarles
**********/ **********/
/*
*/
#include "ngspice/ngspice.h" #include "ngspice/ngspice.h"
#include <stdio.h> #include <stdio.h>
@ -26,25 +24,23 @@ CKTsenAC(CKTcircuit *ckt)
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("CKTsenAC\n"); printf("CKTsenAC\n");
#endif /* SENSDEBUG */ #endif
error = CKTsenLoad(ckt); error = CKTsenLoad(ckt);
if (error) if (error)
return(error); return error;
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("after CKTsenLoad\n"); printf("after CKTsenLoad\n");
#endif /* SENSDEBUG */ #endif
error = CKTsenComp(ckt); error = CKTsenComp(ckt);
if (error) if (error)
return(error); return error;
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("after CKTsenComp\n"); printf("after CKTsenComp\n");
#endif /* SENSDEBUG */ #endif
return(OK); return OK;
} }

View File

@ -2,13 +2,11 @@
Copyright 1990 Regents of the University of California. All rights reserved. Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles Author: 1985 Thomas L. Quarles
**********/ **********/
/*
*/
/* CKTsenUpdate(ckt) /* CKTsenUpdate(ckt)
* this is a driver program to iterate through all the various * this is a driver program to iterate through all the various
* sensitivity update functions provided for the circuit elements * sensitivity update functions provided for the circuit elements
* in the given circuit * in the given circuit
*/ */
#include "ngspice/ngspice.h" #include "ngspice/ngspice.h"
@ -27,12 +25,12 @@ CKTsenUpdate(CKTcircuit *ckt)
int i; int i;
int error; int error;
for (i = 0; i < DEVmaxnum; i++)
for (i=0;i<DEVmaxnum;i++) { if (DEVices[i]->DEVsenUpdate && ckt->CKThead[i]) {
if ( DEVices[i]->DEVsenUpdate && ckt->CKThead[i] ) {
error = DEVices[i]->DEVsenUpdate (ckt->CKThead[i], ckt); error = DEVices[i]->DEVsenUpdate (ckt->CKThead[i], ckt);
if(error) return(error); if (error)
return error;
} }
}
return(OK); return OK;
} }

View File

@ -2,12 +2,10 @@
Copyright 1990 Regents of the University of California. All rights reserved. Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles Author: 1985 Thomas L. Quarles
**********/ **********/
/*
*/
/* CKTsenComp(ckt) /* CKTsenComp(ckt)
* this is a program to solve the sensitivity equation * this is a program to solve the sensitivity equation
* of the given circuit * of the given circuit
*/ */
#include "ngspice/ngspice.h" #include "ngspice/ngspice.h"
@ -27,142 +25,139 @@ CKTsenComp(CKTcircuit *ckt)
int row; int row;
int col; int col;
SENstruct *info; SENstruct *info;
#ifdef SENSDEBUG #ifdef SENSDEBUG
char *rowe; char *rowe;
SMPelement *elt; SMPelement *elt;
#endif /* SENSDEBUG */ #endif
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("CKTsenComp\n"); printf("CKTsenComp\n");
#endif /* SENSDEBUG */ #endif
size = SMPmatSize(ckt->CKTmatrix); size = SMPmatSize(ckt->CKTmatrix);
info = ckt->CKTsenInfo; info = ckt->CKTsenInfo;
if((info->SENmode == DCSEN)|| if ((info->SENmode == DCSEN) || (info->SENmode == TRANSEN)) {
(info->SENmode == TRANSEN))
{
/* loop throgh all the columns of RHS /* loop throgh all the columns of RHS
matrix - each column corresponding to a design matrix - each column corresponding to a design
parameter */ parameter */
for (col=1;col<=info->SENparms;col++) { for (col = 1; col <= info->SENparms; col++) {
for(row=1;row<=size;row++){
for (row = 1; row <= size; row++) {
ckt->CKTsenRhs[row] = info->SEN_RHS[row][col]; ckt->CKTsenRhs[row] = info->SEN_RHS[row][col];
} }
/* solve for the sensitivity values */ /* solve for the sensitivity values */
SMPsolve(ckt->CKTmatrix,ckt->CKTsenRhs,ckt->CKTrhsSpare); SMPsolve(ckt->CKTmatrix, ckt->CKTsenRhs, ckt->CKTrhsSpare);
/* store the sensitivity values */ /* store the sensitivity values */
for(row=1;row<=size;row++){ for (row = 1; row <= size; row++) {
info->SEN_Sap[row][col] = ckt->CKTsenRhs[row]; info->SEN_Sap[row][col] = ckt->CKTsenRhs[row];
info->SEN_RHS[row][col] = ckt->CKTsenRhs[row]; info->SEN_RHS[row][col] = ckt->CKTsenRhs[row];
} }
} }
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("\n"); printf("\n");
printf("Sensitivity matrix :\n"); printf("Sensitivity matrix :\n");
for(row=1;row<=size;row++){ for (row = 1; row <= size; row++) {
rowe=CKTnodName(ckt,row) ; rowe = CKTnodName(ckt, row);
if(strcmp("4",rowe)==0){ if (strcmp("4", rowe) == 0) {
for (col=1;col<=info->SENparms;col++) { for (col = 1; col <= info->SENparms; col++) {
printf("\t"); printf("\t");
printf("Sap(%s,%d) = %.5e\t",rowe,col, printf("Sap(%s,%d) = %.5e\t", rowe, col,
info->SEN_Sap[row][col]); info->SEN_Sap[row][col]);
} }
printf("\n\n"); printf("\n\n");
} }
} }
printf(" RHS matrix :\n"); printf(" RHS matrix :\n");
for(row=1;row<=size;row++){ for (row = 1; row <= size; row++) {
for (col=1;col<=info->SENparms;col++) { for (col = 1; col <= info->SENparms; col++) {
printf(" "); printf(" ");
printf("RHS(%d,%d) = %.7e ",row,col, printf("RHS(%d,%d) = %.7e ", row, col,
info->SEN_RHS[row][col]); info->SEN_RHS[row][col]);
} }
printf("\n"); printf("\n");
} }
printf(" Jacobian matrix :\n"); printf(" Jacobian matrix :\n");
for(row=1; row<=size; row++){ for (row = 1; row <= size; row++) {
for(col=1; col<=size; col++){ for (col = 1; col <= size; col++)
if(elt = SMPfindElt(ckt->CKTmatrix, row , col , 0)){ if (elt = SMPfindElt(ckt->CKTmatrix, row , col , 0))
printf("%.7e ",elt->SMPvalue); printf("%.7e ", elt->SMPvalue);
} else
else{
printf("0.0000000e+00 "); printf("0.0000000e+00 ");
}
}
printf("\n"); printf("\n");
} }
#endif #endif
} }
if(info->SENmode == ACSEN){ if (info->SENmode == ACSEN) {
/* loop throgh all the columns of RHS /* loop throgh all the columns of RHS
matrix - each column corresponding to a design matrix - each column corresponding to a design
parameter */ parameter */
for (col=1;col<=info->SENparms;col++) { for (col = 1; col <= info->SENparms; col++) {
for(row=1;row<=size;row++){ for (row = 1; row <= size; row++) {
ckt->CKTsenRhs[row] = info->SEN_RHS[row][col]; ckt->CKTsenRhs[row] = info->SEN_RHS[row][col];
ckt->CKTseniRhs[row] = info->SEN_iRHS[row][col]; ckt->CKTseniRhs[row] = info->SEN_iRHS[row][col];
} }
/* solve for the sensitivity values ( both real and imag parts)*/ /* solve for the sensitivity values ( both real and imag parts)*/
SMPcSolve(ckt->CKTmatrix,ckt->CKTsenRhs,ckt->CKTseniRhs, SMPcSolve(ckt->CKTmatrix, ckt->CKTsenRhs, ckt->CKTseniRhs,
ckt->CKTrhsSpare,ckt->CKTirhsSpare); ckt->CKTrhsSpare, ckt->CKTirhsSpare);
/* store the sensitivity values ( both real and imag parts)*/ /* store the sensitivity values ( both real and imag parts)*/
for(row=1;row<=size;row++){ for (row = 1; row <= size; row++) {
info->SEN_RHS[row][col] = ckt->CKTsenRhs[row]; info->SEN_RHS[row][col] = ckt->CKTsenRhs[row];
info->SEN_iRHS[row][col] = ckt->CKTseniRhs[row]; info->SEN_iRHS[row][col] = ckt->CKTseniRhs[row];
} }
} }
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("\n"); printf("\n");
printf("CKTomega = %.7e rad/sec\t\n",ckt->CKTomega); printf("CKTomega = %.7e rad/sec\t\n", ckt->CKTomega);
printf("Sensitivity matrix :\n"); printf("Sensitivity matrix :\n");
for(row=1;row<=size;row++){ for (row = 1; row <= size; row++) {
rowe=CKTnodName(ckt,row); rowe = CKTnodName(ckt, row);
for (col=1;col<=info->SENparms;col++) { for (col = 1; col <= info->SENparms; col++) {
printf("\t"); printf("\t");
printf("RHS(%s,%d) = %.5e",rowe,col, printf("RHS(%s,%d) = %.5e", rowe, col,
info->SEN_RHS[row][col]); info->SEN_RHS[row][col]);
printf(" + j %.5e\t",info->SEN_iRHS[row][col]); printf(" + j %.5e\t", info->SEN_iRHS[row][col]);
printf("\n\n"); printf("\n\n");
} }
printf("\n"); printf("\n");
} }
printf("CKTomega = %.7e rad/sec\t\n", ckt->CKTomega);
printf("CKTomega = %.7e rad/sec\t\n",ckt->CKTomega);
printf(" RHS matrix :\n"); printf(" RHS matrix :\n");
for(row=1;row<=size;row++){ for (row = 1; row <= size; row++) {
for (col=1;col<=info->SENparms;col++) { for (col = 1; col <= info->SENparms; col++) {
printf(" "); printf(" ");
printf("RHS(%d,%d) = %.7e ",row,col, printf("RHS(%d,%d) = %.7e ", row, col,
info->SEN_RHS[row][col]); info->SEN_RHS[row][col]);
printf("+j %.7e ",info->SEN_iRHS[row][col]); printf("+j %.7e ", info->SEN_iRHS[row][col]);
} }
printf("\n"); printf("\n");
} }
printf(" Jacobian matrix for AC :\n"); printf(" Jacobian matrix for AC :\n");
for(row=1; row<=size; row++){ for (row = 1; row <= size; row++) {
for(col=1; col<=size; col++){ for (col = 1; col <= size; col++) {
if(elt = SMPfindElt(ckt->CKTmatrix, row , col , 0)){ if (elt = SMPfindElt(ckt->CKTmatrix, row , col , 0)) {
printf("%.7e ",elt->SMPvalue); printf("%.7e ", elt->SMPvalue);
printf("+j%.7e\t",elt->SMPiValue); printf("+j%.7e\t", elt->SMPiValue);
} } else{
else{
printf("0.0000000e+00 "); printf("0.0000000e+00 ");
printf("+j0.0000000e+00\t"); printf("+j0.0000000e+00\t");
} }
@ -172,6 +167,6 @@ CKTsenComp(CKTcircuit *ckt)
#endif #endif
} }
return(OK);
}
return OK;
}

View File

@ -2,10 +2,8 @@
Copyright 1990 Regents of the University of California. All rights reserved. Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles Author: 1985 Thomas L. Quarles
**********/ **********/
/*
*/
/* /*
* This routine performs the DC and Transient sensitivity * This routine performs the DC and Transient sensitivity
* calculations * calculations
*/ */
@ -26,52 +24,62 @@ CKTsenDCtran(CKTcircuit *ckt)
int error; int error;
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("time = %.7e\n",ckt->CKTtime); printf("time = %.7e\n", ckt->CKTtime);
printf("CKTsenDCtran\n"); printf("CKTsenDCtran\n");
#endif /* SENSDEBUG */ #endif
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) &&
(ckt->CKTmode & MODEINITTRAN)){
if (ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) &&
(ckt->CKTmode & MODEINITTRAN))
{
error = CKTsenLoad(ckt); error = CKTsenLoad(ckt);
if(error) return(error); if (error)
return error;
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("after inittran senload\n"); printf("after inittran senload\n");
#endif /* SENSDEBUG */ #endif
error = CKTsenUpdate(ckt); error = CKTsenUpdate(ckt);
if(error) return(error); if (error)
return error;
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("after inittran senupdate\n"); printf("after inittran senupdate\n");
#endif /* SENSDEBUG */ #endif
}
if (ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) &&
!(ckt->CKTmode & MODETRANOP))
{
ckt->CKTmode = (ckt->CKTmode & (~INITF)) | MODEINITFLOAT;
} }
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN)&&
!(ckt->CKTmode&MODETRANOP))
ckt->CKTmode = (ckt->CKTmode&(~INITF))|MODEINITFLOAT;
error = CKTsenLoad(ckt); error = CKTsenLoad(ckt);
if(error) return(error); if (error)
return error;
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("after CKTsenLoad\n"); printf("after CKTsenLoad\n");
#endif /* SENSDEBUG */ #endif
error = CKTsenComp(ckt); error = CKTsenComp(ckt);
if(error) return(error); if (error)
return error;
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("after CKTsenComp\n"); printf("after CKTsenComp\n");
#endif /* SENSDEBUG */ #endif
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode&TRANSEN) ){ if (ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN)) {
error = CKTsenUpdate(ckt); error = CKTsenUpdate(ckt);
if(error) return(error); if (error)
return error;
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("after CKTsenUpdate\n"); printf("after CKTsenUpdate\n");
#endif /* SENSDEBUG */ #endif
} }
return OK;
return(OK);
} }

View File

@ -2,14 +2,12 @@
Copyright 1990 Regents of the University of California. All rights reserved. Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles Author: 1985 Thomas L. Quarles
**********/ **********/
/*
*/
/* /*
* CKTsenLoad(ckt) * CKTsenLoad(ckt)
* this is a driver program to iterate through all the various * this is a driver program to iterate through all the various
* sensitivity load functions provided for the circuit elements * sensitivity load functions provided for the circuit elements
* in the given circuit * in the given circuit
*/ */
#include "ngspice/ngspice.h" #include "ngspice/ngspice.h"
@ -30,36 +28,40 @@ CKTsenLoad(CKTcircuit *ckt)
int error; int error;
size = SMPmatSize(ckt->CKTmatrix); size = SMPmatSize(ckt->CKTmatrix);
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("CKTsenLoad\n"); printf("CKTsenLoad\n");
#endif /* SENSDEBUG */ #endif
if((ckt->CKTsenInfo->SENmode == DCSEN)|| if ((ckt->CKTsenInfo->SENmode == DCSEN) ||
(ckt->CKTsenInfo->SENmode == TRANSEN)) { (ckt->CKTsenInfo->SENmode == TRANSEN))
for (col=0;col<=ckt->CKTsenInfo->SENparms;col++) { {
for(row=0;row<=size;row++){ for (col = 0; col <= ckt->CKTsenInfo->SENparms; col++)
ckt->CKTsenInfo->SEN_RHS[row][col]= 0; for (row = 0; row <= size; row++)
} ckt->CKTsenInfo->SEN_RHS[row][col] = 0;
}
for (i=0;i<DEVmaxnum;i++) { for (i = 0; i < DEVmaxnum; i++)
if ( DEVices[i]->DEVsenLoad && ckt->CKThead[i] ) { if (DEVices[i]->DEVsenLoad && ckt->CKThead[i]) {
error = DEVices[i]->DEVsenLoad (ckt->CKThead[i], ckt); error = DEVices[i]->DEVsenLoad (ckt->CKThead[i], ckt);
if(error) return(error); if (error)
return error;
} }
}
} else{ } else {
for (col=0;col<=ckt->CKTsenInfo->SENparms;col++) {
for(row=0;row<=size;row++){ for (col = 0; col <= ckt->CKTsenInfo->SENparms; col++)
ckt->CKTsenInfo->SEN_RHS[row][col]= 0; for (row = 0; row <= size; row++) {
ckt->CKTsenInfo->SEN_iRHS[row][col]= 0; ckt->CKTsenInfo->SEN_RHS[row][col] = 0;
ckt->CKTsenInfo->SEN_iRHS[row][col] = 0;
} }
}
for (i=0;i<DEVmaxnum;i++) { for (i = 0; i < DEVmaxnum; i++)
if ( DEVices[i]->DEVsenAcLoad && ckt->CKThead[i] ) { if (DEVices[i]->DEVsenAcLoad && ckt->CKThead[i]) {
error = DEVices[i]->DEVsenAcLoad (ckt->CKThead[i], ckt); error = DEVices[i]->DEVsenAcLoad (ckt->CKThead[i], ckt);
if(error) return(error); if (error)
return error;
} }
}
} }
return(OK);
return OK;
} }

View File

@ -2,8 +2,6 @@
Copyright 1990 Regents of the University of California. All rights reserved. Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles Author: 1985 Thomas L. Quarles
**********/ **********/
/*
*/
#include "ngspice/ngspice.h" #include "ngspice/ngspice.h"
#include <stdio.h> #include <stdio.h>
@ -15,20 +13,18 @@ Author: 1985 Thomas L. Quarles
#include "ngspice/suffix.h" #include "ngspice/suffix.h"
/* CKTsenPrint(ckt) /* CKTsenPrint(ckt)
* this is a driver program to iterate through all the * this is a driver program to iterate through all the
* various sensitivity print functions provided for * various sensitivity print functions provided for
* the circuit elements in the given circuit * the circuit elements in the given circuit
*/ */
void void
CKTsenPrint(CKTcircuit *ckt) CKTsenPrint(CKTcircuit *ckt)
{ {
int i; int i;
for (i=0;i<DEVmaxnum;i++) { for (i = 0; i < DEVmaxnum; i++)
if ( DEVices[i]->DEVsenPrint && ckt->CKThead[i] ) { if (DEVices[i]->DEVsenPrint && ckt->CKThead[i])
DEVices[i]->DEVsenPrint (ckt->CKThead[i], ckt); DEVices[i]->DEVsenPrint (ckt->CKThead[i], ckt);
}
}
} }

View File

@ -2,15 +2,13 @@
Copyright 1990 Regents of the University of California. All rights reserved. Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles Author: 1985 Thomas L. Quarles
**********/ **********/
/*
*/
/* /*
* CKTsenSetup(ckt) * CKTsenSetup(ckt)
* this is a driver program to iterate through all the various * this is a driver program to iterate through all the various
* sensitivity setup functions provided for the circuit elements * sensitivity setup functions provided for the circuit elements
* in the given circuit * in the given circuit
*/ */
#include "ngspice/ngspice.h" #include "ngspice/ngspice.h"
@ -29,22 +27,24 @@ CKTsenSetup(CKTcircuit *ckt)
int i; int i;
int error; int error;
SENstruct *info; SENstruct *info;
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("CKTsenSetup\n"); printf("CKTsenSetup\n");
#endif /* SENSDEBUG */ #endif
info = ckt->CKTsenInfo;
info->SENparms = 0;
for (i=0;i<DEVmaxnum;i++) { info = ckt->CKTsenInfo;
if ( DEVices[i]->DEVsenSetup && ckt->CKThead[i] ) { info->SENparms = 0;
for (i = 0; i < DEVmaxnum; i++)
if (DEVices[i]->DEVsenSetup && ckt->CKThead[i]) {
error = DEVices[i]->DEVsenSetup (info, ckt->CKThead[i]); error = DEVices[i]->DEVsenSetup (info, ckt->CKThead[i]);
if(error) return(error); if (error)
return error;
} }
}
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("CKTsenSetup end\n"); printf("CKTsenSetup end\n");
#endif /* SENSDEBUG */ #endif
return(OK);
return OK;
} }

View File

@ -3,11 +3,11 @@ Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles Author: 1985 Thomas L. Quarles
**********/ **********/
/* SENdestroy(ckt) /* SENdestroy(ckt)
* this is a driver program to iterate through all the various * this is a driver program to iterate through all the various
* destroy functions provided for the circuit elements in the * destroy functions provided for the circuit elements in the
* given circuit * given circuit
*/ */
#include "ngspice/ngspice.h" #include "ngspice/ngspice.h"
#include <stdio.h> #include <stdio.h>
@ -23,43 +23,51 @@ SENdestroy(SENstruct *info)
int i; int i;
int size; int size;
size = info->SENsize;
size = info->SENsize;
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("size = %d\n",size); printf("size = %d\n", size);
printf("freeing sensitivity structure in SENdestroy\n"); printf("freeing sensitivity structure in SENdestroy\n");
#endif /* SENSDEBUG */ #endif
/*
if(info->SENdevices) FREE(info->SENdevices); /*
if(info->SENparmNames) FREE(info->SENparmNames); if (info->SENdevices) FREE(info->SENdevices);
*/ if (info->SENparmNames) FREE(info->SENparmNames);
if(info->SEN_Sap){ */
if (info->SEN_Sap) {
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("freeing SEN_Sap in SENdestroy\n"); printf("freeing SEN_Sap in SENdestroy\n");
#endif /* SENSDEBUG */ #endif
for(i=0;i<=size;i++){
if(info->SEN_Sap[i]) FREE(info->SEN_Sap[i]); for (i = 0; i <= size; i++)
} if (info->SEN_Sap[i])
FREE(info->SEN_Sap); FREE(info->SEN_Sap[i]);
} FREE(info->SEN_Sap);
if(info->SEN_RHS){ }
for(i=0;i<=size;i++){
if(info->SEN_RHS[i]) FREE(info->SEN_RHS[i]); if (info->SEN_RHS) {
} for (i = 0; i <= size; i++)
FREE(info->SEN_RHS); if (info->SEN_RHS[i])
} FREE(info->SEN_RHS[i]);
if(info->SEN_iRHS){ FREE(info->SEN_RHS);
for(i=0;i<=size;i++){ }
if(info->SEN_iRHS[i]) FREE(info->SEN_iRHS[i]);
} if (info->SEN_iRHS) {
FREE(info->SEN_Sap); for (i = 0; i <= size; i++)
} if (info->SEN_iRHS[i])
/* FREE(info->SEN_iRHS[i]);
FREE(info); FREE(info->SEN_Sap);
*/ }
/*
FREE(info);
*/
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("SENdestroy end\n"); printf("SENdestroy end\n");
#endif /* SENSDEBUG */ #endif
return; return;
} }

View File

@ -12,8 +12,8 @@ Author: 1985 Thomas L. Quarles
#include "ngspice/suffix.h" #include "ngspice/suffix.h"
#include "../spicelib/analysis/analysis.h" #include "../spicelib/analysis/analysis.h"
/* ARGSUSED */
int int
SENsetParm(CKTcircuit *ckt, JOB *anal, int which, IFvalue *value) SENsetParm(CKTcircuit *ckt, JOB *anal, int which, IFvalue *value)
{ {
NG_IGNORE(ckt); NG_IGNORE(ckt);
@ -21,59 +21,63 @@ SENsetParm(CKTcircuit *ckt, JOB *anal, int which, IFvalue *value)
switch(which) { switch(which) {
case SEN_DC: case SEN_DC:
if(value->iValue) { if (value->iValue)
((SENstruct *)anal)->SENmode |= DCSEN; ((SENstruct *)anal)->SENmode |= DCSEN;
}
break; break;
case SEN_AC: case SEN_AC:
if(value->iValue) { if (value->iValue)
((SENstruct *)anal)->SENmode |= ACSEN; ((SENstruct *)anal)->SENmode |= ACSEN;
}
break; break;
case SEN_TRAN: case SEN_TRAN:
if(value->iValue) { if (value->iValue)
((SENstruct *)anal)->SENmode |= TRANSEN; ((SENstruct *)anal)->SENmode |= TRANSEN;
}
break; break;
case SEN_DEV: case SEN_DEV:
((SENstruct *)anal)->SENnumVal += 1; ((SENstruct *)anal)->SENnumVal += 1;
if( ! ((SENstruct *)anal)->SENdevices ) { if ( ! ((SENstruct *)anal)->SENdevices ) {
((SENstruct *)anal)->SENdevices = TMALLOC(char *, ((SENstruct *)anal)->SENnumVal); ((SENstruct *)anal)->SENdevices = TMALLOC(char *, ((SENstruct *)anal)->SENnumVal);
if( ((SENstruct *)anal)->SENdevices == NULL) return(E_NOMEM); if (((SENstruct *)anal)->SENdevices == NULL)
return E_NOMEM;
((SENstruct *)anal)->SENparmNames = TMALLOC(char *, ((SENstruct *)anal)->SENnumVal); ((SENstruct *)anal)->SENparmNames = TMALLOC(char *, ((SENstruct *)anal)->SENnumVal);
if( ((SENstruct *)anal)->SENparmNames == NULL) return(E_NOMEM); if (((SENstruct *)anal)->SENparmNames == NULL)
return E_NOMEM;
} else { } else {
((SENstruct *)anal)->SENdevices = TREALLOC(char *, ((SENstruct *)anal)->SENdevices, ((SENstruct *)anal)->SENnumVal); ((SENstruct *)anal)->SENdevices = TREALLOC(char *, ((SENstruct *)anal)->SENdevices, ((SENstruct *)anal)->SENnumVal);
if( ((SENstruct *)anal)->SENdevices == NULL) return(E_NOMEM); if (((SENstruct *)anal)->SENdevices == NULL)
((SENstruct *)anal)->SENparmNames = TREALLOC(char *, ((SENstruct *)anal)->SENparmNames, ((SENstruct *)anal)->SENnumVal) ; return E_NOMEM;
if( ((SENstruct *)anal)->SENparmNames == NULL) return(E_NOMEM); ((SENstruct *)anal)->SENparmNames = TREALLOC(char *, ((SENstruct *)anal)->SENparmNames, ((SENstruct *)anal)->SENnumVal);
if (((SENstruct *)anal)->SENparmNames == NULL)
return E_NOMEM;
} }
((SENstruct *)anal)->SENdevices [ ((SENstruct *)anal)->SENnumVal - 1 ] = ((SENstruct *)anal)->SENdevices [ ((SENstruct *)anal)->SENnumVal - 1 ] = value->sValue;
value->sValue;
break; break;
case SEN_PARM: case SEN_PARM:
((SENstruct *)anal)->SENparmNames [ ((SENstruct *)anal)->SENnumVal - 1 ] = ((SENstruct *)anal)->SENparmNames [ ((SENstruct *)anal)->SENnumVal - 1 ] = value->sValue;
value->sValue;
break; break;
default: default:
return(E_BADPARM); return E_BADPARM;
} }
return(OK);
return OK;
} }
static IFparm SENparms[] = { static IFparm SENparms[] = {
{ "dc", SEN_DC, IF_SET|IF_FLAG, "sensitivity in DC analysis" }, { "dc", SEN_DC, IF_SET|IF_FLAG, "sensitivity in DC analysis" },
{ "op", SEN_DC, IF_SET|IF_FLAG, "sensitivity in DCop analysis" }, { "op", SEN_DC, IF_SET|IF_FLAG, "sensitivity in DCop analysis" },
{ "ac", SEN_AC, IF_SET|IF_FLAG, "sensitivity in AC analysis" }, { "ac", SEN_AC, IF_SET|IF_FLAG, "sensitivity in AC analysis" },
{ "tran", SEN_TRAN, IF_SET|IF_FLAG, "sensitivity in transient analysis"}, { "tran", SEN_TRAN, IF_SET|IF_FLAG, "sensitivity in transient analysis"},
{ "dev", SEN_DEV, IF_SET|IF_INSTANCE, "instance with design param." }, { "dev", SEN_DEV, IF_SET|IF_INSTANCE, "instance with design param." },
{ "parm", SEN_PARM, IF_SET|IF_STRING, "name of design parameter" }, { "parm", SEN_PARM, IF_SET|IF_STRING, "name of design parameter" },
}; };
SPICEanalysis SEN2info = { SPICEanalysis SEN2info = {
{ {
"SENS2", "SENS2",
"Sensitivity analysis", "Sensitivity analysis",

View File

@ -11,8 +11,8 @@ Author: 1985 Thomas L. Quarles
#include "ngspice/cktdefs.h" #include "ngspice/cktdefs.h"
#include "ngspice/suffix.h" #include "ngspice/suffix.h"
/* ARGSUSED */
int int
SENaskQuest(CKTcircuit *ckt, JOB *anal, int which, IFvalue *value) SENaskQuest(CKTcircuit *ckt, JOB *anal, int which, IFvalue *value)
{ {
NG_IGNORE(ckt); NG_IGNORE(ckt);
@ -24,6 +24,6 @@ SENaskQuest(CKTcircuit *ckt, JOB *anal, int which, IFvalue *value)
default: default:
break; break;
} }
return(E_BADPARM);
}
return E_BADPARM;
}

View File

@ -29,31 +29,38 @@ SENstartup(CKTcircuit *ckt, int restart)
exit(1); exit(1);
} }
#ifdef SENSDEBUG #ifdef SENSDEBUG
printf("SENstartup\n"); printf("SENstartup\n");
#endif /* SENSDEBUG */ #endif
ckt->CKTsenInfo->SENstatus = NORMAL; ckt->CKTsenInfo->SENstatus = NORMAL;
ckt->CKTsenInfo->SENpertfac = 1e-4; ckt->CKTsenInfo->SENpertfac = 1e-4;
ckt->CKTsenInfo->SENinitflag = ON;/* allocate memory in ckt->CKTsenInfo->SENinitflag = ON; /* allocate memory in NIsenReinit */
NIsenReinit */
parmtemp.iValue = 1; parmtemp.iValue = 1;
for(i=0;i<ckt->CKTsenInfo->SENnumVal;i++) {
for (i = 0; i < ckt->CKTsenInfo->SENnumVal; i++) {
type = -1; type = -1;
fast = NULL; fast = NULL;
err = CKTfndDev(ckt, &type, &fast, err = CKTfndDev(ckt, &type, &fast,
((ckt->CKTsenInfo->SENdevices)[i]), ckt->CKTsenInfo->SENdevices[i],
NULL, NULL); NULL, NULL);
if(err != OK) return(err); if (err != OK)
return err;
err = CKTpName( err = CKTpName(
((ckt->CKTsenInfo->SENparmNames)[i]), ckt->CKTsenInfo->SENparmNames[i],
&parmtemp,ckt ,type, &parmtemp, ckt, type,
((ckt->CKTsenInfo->SENdevices)[i]), ckt->CKTsenInfo->SENdevices[i],
&fast); &fast);
if(err != OK) return(err); if (err != OK)
return err;
} }
#ifdef SENSDEBUG
#ifdef SENSDEBUG
printf("SENstartup end\n"); printf("SENstartup end\n");
#endif /* SENSDEBUG */ #endif
return(OK);
return OK;
} }