adapt the sense2 code to ngspice
This commit is contained in:
parent
685ed9112d
commit
d95e098488
|
|
@ -26,7 +26,7 @@ CKTsenUpdate(CKTcircuit *ckt)
|
|||
int error;
|
||||
|
||||
for (i = 0; i < DEVmaxnum; i++)
|
||||
if (DEVices[i]->DEVsenUpdate && ckt->CKThead[i]) {
|
||||
if (DEVices[i] && DEVices[i]->DEVsenUpdate && ckt->CKThead[i]) {
|
||||
error = DEVices[i]->DEVsenUpdate (ckt->CKThead[i], ckt);
|
||||
if (error)
|
||||
return error;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,26 @@ CKTsenComp(CKTcircuit *ckt)
|
|||
|
||||
#ifdef SENSDEBUG
|
||||
char *rowe;
|
||||
SMPelement *elt;
|
||||
// SMPelement *elt;
|
||||
double *elt;
|
||||
/*
|
||||
in smpdefs.h steht:
|
||||
typedef struct MatrixElement *SMPelement;
|
||||
SMPelement * SMPfindElt( SMPmatrix *, int , int , int );
|
||||
(die Fkt. steht in spsmp.c und gibt einen auf SMPelement * gecasteten Elementptr. zurück)
|
||||
|
||||
in sparse/spdefs.h steht:
|
||||
struct MatrixElement
|
||||
{
|
||||
RealNumber Real;
|
||||
RealNumber Imag;
|
||||
int Row;
|
||||
int Col;
|
||||
struct MatrixElement *NextInRow;
|
||||
struct MatrixElement *NextInCol;
|
||||
};
|
||||
typedef struct MatrixElement *ElementPtr;
|
||||
*/
|
||||
#endif
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
|
|
@ -66,14 +85,14 @@ CKTsenComp(CKTcircuit *ckt)
|
|||
|
||||
for (row = 1; row <= size; row++) {
|
||||
rowe = CKTnodName(ckt, row);
|
||||
if (strcmp("4", rowe) == 0) {
|
||||
// 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("\n\n");
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
printf(" RHS matrix :\n");
|
||||
|
|
@ -89,8 +108,10 @@ CKTsenComp(CKTcircuit *ckt)
|
|||
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);
|
||||
if ((elt = (double *)SMPfindElt(ckt->CKTmatrix, row , col , 0)))
|
||||
// printf("%.7e ", elt->SMPvalue); ------> gibts nicht
|
||||
// printf("%.7e ", elt->Real); ------> gibts auch nicht
|
||||
printf("%.7e ", *elt); // ------> geht aber nur für real Werte
|
||||
else
|
||||
printf("0.0000000e+00 ");
|
||||
printf("\n");
|
||||
|
|
@ -154,9 +175,11 @@ CKTsenComp(CKTcircuit *ckt)
|
|||
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);
|
||||
if ((elt = (double *)SMPfindElt(ckt->CKTmatrix, row , col , 0))) {
|
||||
// printf("%.7e ", elt->SMPvalue);
|
||||
// printf("+j%.7e\t", elt->SMPiValue);
|
||||
printf("%.7e ", *elt);
|
||||
printf("+j%.7e\t", *elt+1);
|
||||
} else{
|
||||
printf("0.0000000e+00 ");
|
||||
printf("+j0.0000000e+00\t");
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ CKTsenLoad(CKTcircuit *ckt)
|
|||
ckt->CKTsenInfo->SEN_RHS[row][col] = 0;
|
||||
|
||||
for (i = 0; i < DEVmaxnum; i++)
|
||||
if (DEVices[i]->DEVsenLoad && ckt->CKThead[i]) {
|
||||
if (DEVices[i] && DEVices[i]->DEVsenLoad && ckt->CKThead[i]) {
|
||||
error = DEVices[i]->DEVsenLoad (ckt->CKThead[i], ckt);
|
||||
if (error)
|
||||
return error;
|
||||
|
|
@ -56,7 +56,7 @@ CKTsenLoad(CKTcircuit *ckt)
|
|||
}
|
||||
|
||||
for (i = 0; i < DEVmaxnum; i++)
|
||||
if (DEVices[i]->DEVsenAcLoad && ckt->CKThead[i]) {
|
||||
if (DEVices[i] && DEVices[i]->DEVsenAcLoad && ckt->CKThead[i]) {
|
||||
error = DEVices[i]->DEVsenAcLoad (ckt->CKThead[i], ckt);
|
||||
if (error)
|
||||
return error;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,6 @@ CKTsenPrint(CKTcircuit *ckt)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < DEVmaxnum; i++)
|
||||
if (DEVices[i]->DEVsenPrint && ckt->CKThead[i])
|
||||
if (DEVices[i] && DEVices[i]->DEVsenPrint && ckt->CKThead[i])
|
||||
DEVices[i]->DEVsenPrint (ckt->CKThead[i], ckt);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ CKTsenSetup(CKTcircuit *ckt)
|
|||
info->SENparms = 0;
|
||||
|
||||
for (i = 0; i < DEVmaxnum; i++)
|
||||
if (DEVices[i]->DEVsenSetup && ckt->CKThead[i]) {
|
||||
if (DEVices[i] && DEVices[i]->DEVsenSetup && ckt->CKThead[i]) {
|
||||
error = DEVices[i]->DEVsenSetup (info, ckt->CKThead[i]);
|
||||
if (error)
|
||||
return error;
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ SENstartup(CKTcircuit *ckt, int restart)
|
|||
IFvalue parmtemp;
|
||||
int type;
|
||||
GENinstance *fast;
|
||||
|
||||
/*
|
||||
if (restart) {
|
||||
fprintf(stderr, "unsupported code, (SENstartup), doesn't support restart\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
*/
|
||||
#ifdef SENSDEBUG
|
||||
printf("SENstartup\n");
|
||||
#endif
|
||||
|
|
@ -38,6 +38,7 @@ SENstartup(CKTcircuit *ckt, int restart)
|
|||
ckt->CKTsenInfo->SENinitflag = ON; /* allocate memory in NIsenReinit */
|
||||
|
||||
parmtemp.iValue = 1;
|
||||
parmtemp.rValue = 1.0;
|
||||
|
||||
for (i = 0; i < ckt->CKTsenInfo->SENnumVal; i++) {
|
||||
type = -1;
|
||||
|
|
@ -49,6 +50,10 @@ SENstartup(CKTcircuit *ckt, int restart)
|
|||
if (err != OK)
|
||||
return err;
|
||||
|
||||
#ifdef SENSDEBUG
|
||||
printf("SENstartup Instance: %s Design parameter: %s\n", ckt->CKTsenInfo->SENdevices[i],
|
||||
ckt->CKTsenInfo->SENparmNames[i]);
|
||||
#endif
|
||||
err = CKTpName(
|
||||
ckt->CKTsenInfo->SENparmNames[i],
|
||||
&parmtemp, ckt, type,
|
||||
|
|
|
|||
Loading…
Reference in New Issue