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