sense2, whitespace cleanup
checked for object file invariance
This commit is contained in:
parent
eb9060376c
commit
fd0f22701d
|
|
@ -2,8 +2,6 @@
|
|||
Copyright 1990 Regents of the University of California. All rights reserved.
|
||||
Author: 1985 Thomas L. Quarles
|
||||
**********/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "ngspice/ngspice.h"
|
||||
#include <stdio.h>
|
||||
|
|
@ -26,25 +24,23 @@ CKTsenAC(CKTcircuit *ckt)
|
|||
|
||||
#ifdef SENSDEBUG
|
||||
printf("CKTsenAC\n");
|
||||
#endif /* SENSDEBUG */
|
||||
|
||||
#endif
|
||||
|
||||
error = CKTsenLoad(ckt);
|
||||
if (error)
|
||||
return(error);
|
||||
return error;
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("after CKTsenLoad\n");
|
||||
#endif /* SENSDEBUG */
|
||||
#endif
|
||||
|
||||
error = CKTsenComp(ckt);
|
||||
if (error)
|
||||
return(error);
|
||||
return error;
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("after CKTsenComp\n");
|
||||
#endif /* SENSDEBUG */
|
||||
#endif
|
||||
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,11 @@
|
|||
Copyright 1990 Regents of the University of California. All rights reserved.
|
||||
Author: 1985 Thomas L. Quarles
|
||||
**********/
|
||||
/*
|
||||
*/
|
||||
|
||||
/* CKTsenUpdate(ckt)
|
||||
* this is a driver program to iterate through all the various
|
||||
* sensitivity update functions provided for the circuit elements
|
||||
* in the given circuit
|
||||
* sensitivity update functions provided for the circuit elements
|
||||
* in the given circuit
|
||||
*/
|
||||
|
||||
#include "ngspice/ngspice.h"
|
||||
|
|
@ -27,12 +25,12 @@ CKTsenUpdate(CKTcircuit *ckt)
|
|||
int i;
|
||||
int error;
|
||||
|
||||
|
||||
for (i=0;i<DEVmaxnum;i++) {
|
||||
if ( DEVices[i]->DEVsenUpdate && ckt->CKThead[i] ) {
|
||||
for (i = 0; i < DEVmaxnum; i++)
|
||||
if (DEVices[i]->DEVsenUpdate && ckt->CKThead[i]) {
|
||||
error = DEVices[i]->DEVsenUpdate (ckt->CKThead[i], ckt);
|
||||
if(error) return(error);
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,10 @@
|
|||
Copyright 1990 Regents of the University of California. All rights reserved.
|
||||
Author: 1985 Thomas L. Quarles
|
||||
**********/
|
||||
/*
|
||||
*/
|
||||
|
||||
/* CKTsenComp(ckt)
|
||||
* this is a program to solve the sensitivity equation
|
||||
* of the given circuit
|
||||
* this is a program to solve the sensitivity equation
|
||||
* of the given circuit
|
||||
*/
|
||||
|
||||
#include "ngspice/ngspice.h"
|
||||
|
|
@ -27,142 +25,139 @@ CKTsenComp(CKTcircuit *ckt)
|
|||
int row;
|
||||
int col;
|
||||
SENstruct *info;
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
char *rowe;
|
||||
SMPelement *elt;
|
||||
#endif /* SENSDEBUG */
|
||||
#endif
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("CKTsenComp\n");
|
||||
#endif /* SENSDEBUG */
|
||||
#endif
|
||||
|
||||
size = SMPmatSize(ckt->CKTmatrix);
|
||||
info = ckt->CKTsenInfo;
|
||||
|
||||
if((info->SENmode == DCSEN)||
|
||||
(info->SENmode == TRANSEN))
|
||||
{
|
||||
if ((info->SENmode == DCSEN) || (info->SENmode == TRANSEN)) {
|
||||
|
||||
/* loop throgh all the columns of RHS
|
||||
matrix - each column corresponding to a design
|
||||
parameter */
|
||||
|
||||
for (col=1;col<=info->SENparms;col++) {
|
||||
for(row=1;row<=size;row++){
|
||||
for (col = 1; col <= info->SENparms; col++) {
|
||||
|
||||
for (row = 1; row <= size; row++) {
|
||||
ckt->CKTsenRhs[row] = info->SEN_RHS[row][col];
|
||||
}
|
||||
|
||||
/* solve for the sensitivity values */
|
||||
SMPsolve(ckt->CKTmatrix,ckt->CKTsenRhs,ckt->CKTrhsSpare);
|
||||
SMPsolve(ckt->CKTmatrix, ckt->CKTsenRhs, ckt->CKTrhsSpare);
|
||||
|
||||
/* 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_RHS[row][col] = ckt->CKTsenRhs[row];
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("\n");
|
||||
printf("Sensitivity matrix :\n");
|
||||
|
||||
for(row=1;row<=size;row++){
|
||||
rowe=CKTnodName(ckt,row) ;
|
||||
if(strcmp("4",rowe)==0){
|
||||
for (col=1;col<=info->SENparms;col++) {
|
||||
for (row = 1; row <= size; row++) {
|
||||
rowe = CKTnodName(ckt, row);
|
||||
if (strcmp("4", rowe) == 0) {
|
||||
for (col = 1; col <= info->SENparms; col++) {
|
||||
printf("\t");
|
||||
printf("Sap(%s,%d) = %.5e\t",rowe,col,
|
||||
info->SEN_Sap[row][col]);
|
||||
printf("Sap(%s,%d) = %.5e\t", rowe, col,
|
||||
info->SEN_Sap[row][col]);
|
||||
}
|
||||
printf("\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
printf(" RHS matrix :\n");
|
||||
for(row=1;row<=size;row++){
|
||||
for (col=1;col<=info->SENparms;col++) {
|
||||
for (row = 1; row <= size; row++) {
|
||||
for (col = 1; col <= info->SENparms; col++) {
|
||||
printf(" ");
|
||||
printf("RHS(%d,%d) = %.7e ",row,col,
|
||||
info->SEN_RHS[row][col]);
|
||||
printf("RHS(%d,%d) = %.7e ", row, col,
|
||||
info->SEN_RHS[row][col]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
printf(" Jacobian matrix :\n");
|
||||
for(row=1; row<=size; row++){
|
||||
for(col=1; col<=size; col++){
|
||||
if(elt = SMPfindElt(ckt->CKTmatrix, row , col , 0)){
|
||||
printf("%.7e ",elt->SMPvalue);
|
||||
}
|
||||
else{
|
||||
for (row = 1; row <= size; row++) {
|
||||
for (col = 1; col <= size; col++)
|
||||
if (elt = SMPfindElt(ckt->CKTmatrix, row , col , 0))
|
||||
printf("%.7e ", elt->SMPvalue);
|
||||
else
|
||||
printf("0.0000000e+00 ");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if(info->SENmode == ACSEN){
|
||||
if (info->SENmode == ACSEN) {
|
||||
|
||||
/* loop throgh all the columns of RHS
|
||||
matrix - each column corresponding to a design
|
||||
parameter */
|
||||
|
||||
for (col=1;col<=info->SENparms;col++) {
|
||||
for (col = 1; col <= info->SENparms; col++) {
|
||||
|
||||
for(row=1;row<=size;row++){
|
||||
ckt->CKTsenRhs[row] = info->SEN_RHS[row][col];
|
||||
for (row = 1; row <= size; row++) {
|
||||
ckt->CKTsenRhs[row] = info->SEN_RHS[row][col];
|
||||
ckt->CKTseniRhs[row] = info->SEN_iRHS[row][col];
|
||||
}
|
||||
|
||||
/* solve for the sensitivity values ( both real and imag parts)*/
|
||||
SMPcSolve(ckt->CKTmatrix,ckt->CKTsenRhs,ckt->CKTseniRhs,
|
||||
ckt->CKTrhsSpare,ckt->CKTirhsSpare);
|
||||
SMPcSolve(ckt->CKTmatrix, ckt->CKTsenRhs, ckt->CKTseniRhs,
|
||||
ckt->CKTrhsSpare, ckt->CKTirhsSpare);
|
||||
|
||||
/* store the sensitivity values ( both real and imag parts)*/
|
||||
for(row=1;row<=size;row++){
|
||||
info->SEN_RHS[row][col] = ckt->CKTsenRhs[row];
|
||||
for (row = 1; row <= size; row++) {
|
||||
info->SEN_RHS[row][col] = ckt->CKTsenRhs[row];
|
||||
info->SEN_iRHS[row][col] = ckt->CKTseniRhs[row];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("\n");
|
||||
printf("CKTomega = %.7e rad/sec\t\n",ckt->CKTomega);
|
||||
printf("CKTomega = %.7e rad/sec\t\n", ckt->CKTomega);
|
||||
printf("Sensitivity matrix :\n");
|
||||
for(row=1;row<=size;row++){
|
||||
rowe=CKTnodName(ckt,row);
|
||||
for (col=1;col<=info->SENparms;col++) {
|
||||
for (row = 1; row <= size; row++) {
|
||||
rowe = CKTnodName(ckt, row);
|
||||
for (col = 1; col <= info->SENparms; col++) {
|
||||
printf("\t");
|
||||
printf("RHS(%s,%d) = %.5e",rowe,col,
|
||||
info->SEN_RHS[row][col]);
|
||||
printf(" + j %.5e\t",info->SEN_iRHS[row][col]);
|
||||
printf("RHS(%s,%d) = %.5e", rowe, col,
|
||||
info->SEN_RHS[row][col]);
|
||||
printf(" + j %.5e\t", info->SEN_iRHS[row][col]);
|
||||
printf("\n\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");
|
||||
for(row=1;row<=size;row++){
|
||||
for (col=1;col<=info->SENparms;col++) {
|
||||
for (row = 1; row <= size; row++) {
|
||||
for (col = 1; col <= info->SENparms; col++) {
|
||||
printf(" ");
|
||||
printf("RHS(%d,%d) = %.7e ",row,col,
|
||||
info->SEN_RHS[row][col]);
|
||||
printf("+j %.7e ",info->SEN_iRHS[row][col]);
|
||||
printf("RHS(%d,%d) = %.7e ", row, col,
|
||||
info->SEN_RHS[row][col]);
|
||||
printf("+j %.7e ", info->SEN_iRHS[row][col]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
printf(" Jacobian matrix for AC :\n");
|
||||
for(row=1; row<=size; row++){
|
||||
for(col=1; col<=size; col++){
|
||||
if(elt = SMPfindElt(ckt->CKTmatrix, row , col , 0)){
|
||||
printf("%.7e ",elt->SMPvalue);
|
||||
printf("+j%.7e\t",elt->SMPiValue);
|
||||
}
|
||||
else{
|
||||
for (row = 1; row <= size; row++) {
|
||||
for (col = 1; col <= size; col++) {
|
||||
if (elt = SMPfindElt(ckt->CKTmatrix, row , col , 0)) {
|
||||
printf("%.7e ", elt->SMPvalue);
|
||||
printf("+j%.7e\t", elt->SMPiValue);
|
||||
} else{
|
||||
printf("0.0000000e+00 ");
|
||||
printf("+j0.0000000e+00\t");
|
||||
}
|
||||
|
|
@ -172,6 +167,6 @@ CKTsenComp(CKTcircuit *ckt)
|
|||
#endif
|
||||
|
||||
}
|
||||
return(OK);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
Copyright 1990 Regents of the University of California. All rights reserved.
|
||||
Author: 1985 Thomas L. Quarles
|
||||
**********/
|
||||
/*
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* This routine performs the DC and Transient sensitivity
|
||||
* calculations
|
||||
*/
|
||||
|
|
@ -26,52 +24,62 @@ CKTsenDCtran(CKTcircuit *ckt)
|
|||
int error;
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("time = %.7e\n",ckt->CKTtime);
|
||||
printf("time = %.7e\n", ckt->CKTtime);
|
||||
printf("CKTsenDCtran\n");
|
||||
#endif /* SENSDEBUG */
|
||||
|
||||
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) &&
|
||||
(ckt->CKTmode & MODEINITTRAN)){
|
||||
#endif
|
||||
|
||||
if (ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) &&
|
||||
(ckt->CKTmode & MODEINITTRAN))
|
||||
{
|
||||
error = CKTsenLoad(ckt);
|
||||
if(error) return(error);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("after inittran senload\n");
|
||||
#endif /* SENSDEBUG */
|
||||
#endif
|
||||
error = CKTsenUpdate(ckt);
|
||||
if(error) return(error);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
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);
|
||||
if(error) return(error);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("after CKTsenLoad\n");
|
||||
#endif /* SENSDEBUG */
|
||||
#endif
|
||||
|
||||
error = CKTsenComp(ckt);
|
||||
if(error) return(error);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("after CKTsenComp\n");
|
||||
#endif /* SENSDEBUG */
|
||||
#endif
|
||||
|
||||
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode&TRANSEN) ){
|
||||
if (ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN)) {
|
||||
error = CKTsenUpdate(ckt);
|
||||
if(error) return(error);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("after CKTsenUpdate\n");
|
||||
#endif /* SENSDEBUG */
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,12 @@
|
|||
Copyright 1990 Regents of the University of California. All rights reserved.
|
||||
Author: 1985 Thomas L. Quarles
|
||||
**********/
|
||||
/*
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* CKTsenLoad(ckt)
|
||||
* this is a driver program to iterate through all the various
|
||||
* sensitivity load functions provided for the circuit elements
|
||||
* in the given circuit
|
||||
* sensitivity load functions provided for the circuit elements
|
||||
* in the given circuit
|
||||
*/
|
||||
|
||||
#include "ngspice/ngspice.h"
|
||||
|
|
@ -30,36 +28,40 @@ CKTsenLoad(CKTcircuit *ckt)
|
|||
int error;
|
||||
|
||||
size = SMPmatSize(ckt->CKTmatrix);
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("CKTsenLoad\n");
|
||||
#endif /* SENSDEBUG */
|
||||
#endif
|
||||
|
||||
if((ckt->CKTsenInfo->SENmode == DCSEN)||
|
||||
(ckt->CKTsenInfo->SENmode == TRANSEN)) {
|
||||
for (col=0;col<=ckt->CKTsenInfo->SENparms;col++) {
|
||||
for(row=0;row<=size;row++){
|
||||
ckt->CKTsenInfo->SEN_RHS[row][col]= 0;
|
||||
}
|
||||
}
|
||||
for (i=0;i<DEVmaxnum;i++) {
|
||||
if ( DEVices[i]->DEVsenLoad && ckt->CKThead[i] ) {
|
||||
if ((ckt->CKTsenInfo->SENmode == DCSEN) ||
|
||||
(ckt->CKTsenInfo->SENmode == TRANSEN))
|
||||
{
|
||||
for (col = 0; col <= ckt->CKTsenInfo->SENparms; col++)
|
||||
for (row = 0; row <= size; row++)
|
||||
ckt->CKTsenInfo->SEN_RHS[row][col] = 0;
|
||||
|
||||
for (i = 0; i < DEVmaxnum; i++)
|
||||
if (DEVices[i]->DEVsenLoad && ckt->CKThead[i]) {
|
||||
error = DEVices[i]->DEVsenLoad (ckt->CKThead[i], ckt);
|
||||
if(error) return(error);
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
}
|
||||
} else{
|
||||
for (col=0;col<=ckt->CKTsenInfo->SENparms;col++) {
|
||||
for(row=0;row<=size;row++){
|
||||
ckt->CKTsenInfo->SEN_RHS[row][col]= 0;
|
||||
ckt->CKTsenInfo->SEN_iRHS[row][col]= 0;
|
||||
|
||||
} else {
|
||||
|
||||
for (col = 0; col <= ckt->CKTsenInfo->SENparms; col++)
|
||||
for (row = 0; row <= size; row++) {
|
||||
ckt->CKTsenInfo->SEN_RHS[row][col] = 0;
|
||||
ckt->CKTsenInfo->SEN_iRHS[row][col] = 0;
|
||||
}
|
||||
}
|
||||
for (i=0;i<DEVmaxnum;i++) {
|
||||
if ( DEVices[i]->DEVsenAcLoad && ckt->CKThead[i] ) {
|
||||
|
||||
for (i = 0; i < DEVmaxnum; i++)
|
||||
if (DEVices[i]->DEVsenAcLoad && ckt->CKThead[i]) {
|
||||
error = DEVices[i]->DEVsenAcLoad (ckt->CKThead[i], ckt);
|
||||
if(error) return(error);
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
Copyright 1990 Regents of the University of California. All rights reserved.
|
||||
Author: 1985 Thomas L. Quarles
|
||||
**********/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "ngspice/ngspice.h"
|
||||
#include <stdio.h>
|
||||
|
|
@ -15,20 +13,18 @@ Author: 1985 Thomas L. Quarles
|
|||
#include "ngspice/suffix.h"
|
||||
|
||||
|
||||
/* CKTsenPrint(ckt)
|
||||
* this is a driver program to iterate through all the
|
||||
* various sensitivity print functions provided for
|
||||
* the circuit elements in the given circuit
|
||||
*/
|
||||
/* CKTsenPrint(ckt)
|
||||
* this is a driver program to iterate through all the
|
||||
* various sensitivity print functions provided for
|
||||
* the circuit elements in the given circuit
|
||||
*/
|
||||
|
||||
void
|
||||
CKTsenPrint(CKTcircuit *ckt)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<DEVmaxnum;i++) {
|
||||
if ( DEVices[i]->DEVsenPrint && ckt->CKThead[i] ) {
|
||||
for (i = 0; i < DEVmaxnum; i++)
|
||||
if (DEVices[i]->DEVsenPrint && ckt->CKThead[i])
|
||||
DEVices[i]->DEVsenPrint (ckt->CKThead[i], ckt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,15 +2,13 @@
|
|||
Copyright 1990 Regents of the University of California. All rights reserved.
|
||||
Author: 1985 Thomas L. Quarles
|
||||
**********/
|
||||
/*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* CKTsenSetup(ckt)
|
||||
* this is a driver program to iterate through all the various
|
||||
* sensitivity setup functions provided for the circuit elements
|
||||
* in the given circuit
|
||||
* sensitivity setup functions provided for the circuit elements
|
||||
* in the given circuit
|
||||
*/
|
||||
|
||||
#include "ngspice/ngspice.h"
|
||||
|
|
@ -29,22 +27,24 @@ CKTsenSetup(CKTcircuit *ckt)
|
|||
int i;
|
||||
int error;
|
||||
SENstruct *info;
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("CKTsenSetup\n");
|
||||
#endif /* SENSDEBUG */
|
||||
info = ckt->CKTsenInfo;
|
||||
info->SENparms = 0;
|
||||
#endif
|
||||
|
||||
for (i=0;i<DEVmaxnum;i++) {
|
||||
if ( DEVices[i]->DEVsenSetup && ckt->CKThead[i] ) {
|
||||
info = ckt->CKTsenInfo;
|
||||
info->SENparms = 0;
|
||||
|
||||
for (i = 0; i < DEVmaxnum; i++)
|
||||
if (DEVices[i]->DEVsenSetup && ckt->CKThead[i]) {
|
||||
error = DEVices[i]->DEVsenSetup (info, ckt->CKThead[i]);
|
||||
if(error) return(error);
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("CKTsenSetup end\n");
|
||||
#endif /* SENSDEBUG */
|
||||
return(OK);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ Copyright 1990 Regents of the University of California. All rights reserved.
|
|||
Author: 1985 Thomas L. Quarles
|
||||
**********/
|
||||
|
||||
/* SENdestroy(ckt)
|
||||
* this is a driver program to iterate through all the various
|
||||
* destroy functions provided for the circuit elements in the
|
||||
* given circuit
|
||||
*/
|
||||
/* SENdestroy(ckt)
|
||||
* this is a driver program to iterate through all the various
|
||||
* destroy functions provided for the circuit elements in the
|
||||
* given circuit
|
||||
*/
|
||||
|
||||
#include "ngspice/ngspice.h"
|
||||
#include <stdio.h>
|
||||
|
|
@ -23,43 +23,51 @@ SENdestroy(SENstruct *info)
|
|||
int i;
|
||||
int size;
|
||||
|
||||
size = info->SENsize;
|
||||
|
||||
size = info->SENsize;
|
||||
#ifdef SENSDEBUG
|
||||
printf("size = %d\n",size);
|
||||
printf("freeing sensitivity structure in SENdestroy\n");
|
||||
#endif /* SENSDEBUG */
|
||||
/*
|
||||
if(info->SENdevices) FREE(info->SENdevices);
|
||||
if(info->SENparmNames) FREE(info->SENparmNames);
|
||||
*/
|
||||
if(info->SEN_Sap){
|
||||
printf("size = %d\n", size);
|
||||
printf("freeing sensitivity structure in SENdestroy\n");
|
||||
#endif
|
||||
|
||||
/*
|
||||
if (info->SENdevices) FREE(info->SENdevices);
|
||||
if (info->SENparmNames) FREE(info->SENparmNames);
|
||||
*/
|
||||
|
||||
if (info->SEN_Sap) {
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("freeing SEN_Sap in SENdestroy\n");
|
||||
#endif /* SENSDEBUG */
|
||||
for(i=0;i<=size;i++){
|
||||
if(info->SEN_Sap[i]) 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]);
|
||||
}
|
||||
FREE(info->SEN_RHS);
|
||||
}
|
||||
if(info->SEN_iRHS){
|
||||
for(i=0;i<=size;i++){
|
||||
if(info->SEN_iRHS[i]) FREE(info->SEN_iRHS[i]);
|
||||
}
|
||||
FREE(info->SEN_Sap);
|
||||
}
|
||||
/*
|
||||
FREE(info);
|
||||
*/
|
||||
printf("freeing SEN_Sap in SENdestroy\n");
|
||||
#endif
|
||||
|
||||
for (i = 0; i <= size; i++)
|
||||
if (info->SEN_Sap[i])
|
||||
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]);
|
||||
FREE(info->SEN_RHS);
|
||||
}
|
||||
|
||||
if (info->SEN_iRHS) {
|
||||
for (i = 0; i <= size; i++)
|
||||
if (info->SEN_iRHS[i])
|
||||
FREE(info->SEN_iRHS[i]);
|
||||
FREE(info->SEN_Sap);
|
||||
}
|
||||
|
||||
/*
|
||||
FREE(info);
|
||||
*/
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("SENdestroy end\n");
|
||||
#endif /* SENSDEBUG */
|
||||
printf("SENdestroy end\n");
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,68 +12,72 @@ Author: 1985 Thomas L. Quarles
|
|||
#include "ngspice/suffix.h"
|
||||
#include "../spicelib/analysis/analysis.h"
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
|
||||
int
|
||||
SENsetParm(CKTcircuit *ckt, JOB *anal, int which, IFvalue *value)
|
||||
{
|
||||
NG_IGNORE(ckt);
|
||||
|
||||
|
||||
switch(which) {
|
||||
|
||||
case SEN_DC:
|
||||
if(value->iValue) {
|
||||
if (value->iValue)
|
||||
((SENstruct *)anal)->SENmode |= DCSEN;
|
||||
}
|
||||
break;
|
||||
|
||||
case SEN_AC:
|
||||
if(value->iValue) {
|
||||
if (value->iValue)
|
||||
((SENstruct *)anal)->SENmode |= ACSEN;
|
||||
}
|
||||
break;
|
||||
|
||||
case SEN_TRAN:
|
||||
if(value->iValue) {
|
||||
if (value->iValue)
|
||||
((SENstruct *)anal)->SENmode |= TRANSEN;
|
||||
}
|
||||
break;
|
||||
|
||||
case SEN_DEV:
|
||||
((SENstruct *)anal)->SENnumVal += 1;
|
||||
if( ! ((SENstruct *)anal)->SENdevices ) {
|
||||
if ( ! ((SENstruct *)anal)->SENdevices ) {
|
||||
((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);
|
||||
if( ((SENstruct *)anal)->SENparmNames == NULL) return(E_NOMEM);
|
||||
if (((SENstruct *)anal)->SENparmNames == NULL)
|
||||
return E_NOMEM;
|
||||
} else {
|
||||
((SENstruct *)anal)->SENdevices = TREALLOC(char *, ((SENstruct *)anal)->SENdevices, ((SENstruct *)anal)->SENnumVal);
|
||||
if( ((SENstruct *)anal)->SENdevices == NULL) return(E_NOMEM);
|
||||
((SENstruct *)anal)->SENparmNames = TREALLOC(char *, ((SENstruct *)anal)->SENparmNames, ((SENstruct *)anal)->SENnumVal) ;
|
||||
if( ((SENstruct *)anal)->SENparmNames == NULL) return(E_NOMEM);
|
||||
if (((SENstruct *)anal)->SENdevices == 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 ] =
|
||||
value->sValue;
|
||||
((SENstruct *)anal)->SENdevices [ ((SENstruct *)anal)->SENnumVal - 1 ] = value->sValue;
|
||||
break;
|
||||
|
||||
case SEN_PARM:
|
||||
((SENstruct *)anal)->SENparmNames [ ((SENstruct *)anal)->SENnumVal - 1 ] =
|
||||
value->sValue;
|
||||
((SENstruct *)anal)->SENparmNames [ ((SENstruct *)anal)->SENnumVal - 1 ] = value->sValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
return(E_BADPARM);
|
||||
return E_BADPARM;
|
||||
}
|
||||
return(OK);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
static IFparm SENparms[] = {
|
||||
{ "dc", SEN_DC, IF_SET|IF_FLAG, "sensitivity in DC analysis" },
|
||||
{ "op", SEN_DC, IF_SET|IF_FLAG, "sensitivity in DCop analysis" },
|
||||
{ "ac", SEN_AC, IF_SET|IF_FLAG, "sensitivity in AC analysis" },
|
||||
{ "tran", SEN_TRAN, IF_SET|IF_FLAG, "sensitivity in transient analysis"},
|
||||
{ "dc", SEN_DC, IF_SET|IF_FLAG, "sensitivity in DC analysis" },
|
||||
{ "op", SEN_DC, IF_SET|IF_FLAG, "sensitivity in DCop analysis" },
|
||||
{ "ac", SEN_AC, IF_SET|IF_FLAG, "sensitivity in AC analysis" },
|
||||
{ "tran", SEN_TRAN, IF_SET|IF_FLAG, "sensitivity in transient analysis"},
|
||||
{ "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",
|
||||
"Sensitivity analysis",
|
||||
|
||||
|
|
|
|||
|
|
@ -11,19 +11,19 @@ Author: 1985 Thomas L. Quarles
|
|||
#include "ngspice/cktdefs.h"
|
||||
#include "ngspice/suffix.h"
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
|
||||
int
|
||||
SENaskQuest(CKTcircuit *ckt, JOB *anal, int which, IFvalue *value)
|
||||
{
|
||||
NG_IGNORE(ckt);
|
||||
NG_IGNORE(anal);
|
||||
NG_IGNORE(value);
|
||||
|
||||
|
||||
switch(which) {
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return(E_BADPARM);
|
||||
}
|
||||
|
||||
return E_BADPARM;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,31 +29,38 @@ SENstartup(CKTcircuit *ckt, int restart)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
#ifdef SENSDEBUG
|
||||
printf("SENstartup\n");
|
||||
#endif /* SENSDEBUG */
|
||||
#endif
|
||||
|
||||
ckt->CKTsenInfo->SENstatus = NORMAL;
|
||||
ckt->CKTsenInfo->SENpertfac = 1e-4;
|
||||
ckt->CKTsenInfo->SENinitflag = ON;/* allocate memory in
|
||||
NIsenReinit */
|
||||
ckt->CKTsenInfo->SENinitflag = ON; /* allocate memory in NIsenReinit */
|
||||
|
||||
parmtemp.iValue = 1;
|
||||
for(i=0;i<ckt->CKTsenInfo->SENnumVal;i++) {
|
||||
|
||||
for (i = 0; i < ckt->CKTsenInfo->SENnumVal; i++) {
|
||||
type = -1;
|
||||
fast = NULL;
|
||||
err = CKTfndDev(ckt,&type,&fast,
|
||||
((ckt->CKTsenInfo->SENdevices)[i]),
|
||||
NULL, NULL);
|
||||
if(err != OK) return(err);
|
||||
|
||||
err = CKTfndDev(ckt, &type, &fast,
|
||||
ckt->CKTsenInfo->SENdevices[i],
|
||||
NULL, NULL);
|
||||
if (err != OK)
|
||||
return err;
|
||||
|
||||
err = CKTpName(
|
||||
((ckt->CKTsenInfo->SENparmNames)[i]),
|
||||
&parmtemp,ckt ,type,
|
||||
((ckt->CKTsenInfo->SENdevices)[i]),
|
||||
ckt->CKTsenInfo->SENparmNames[i],
|
||||
&parmtemp, ckt, type,
|
||||
ckt->CKTsenInfo->SENdevices[i],
|
||||
&fast);
|
||||
if(err != OK) return(err);
|
||||
if (err != OK)
|
||||
return err;
|
||||
}
|
||||
#ifdef SENSDEBUG
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("SENstartup end\n");
|
||||
#endif /* SENSDEBUG */
|
||||
return(OK);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue