Browse Source

adapt the sense2 code to ngspice

workaround, make the opaque struct MatrixElement partially visible

this struct is private to the `sparse' world,
  and lives in "maths/sparse/spdefs.h"
which can't be included here, because
  it is incompatible to the rest of ngspice.

this is the same problem as in
  ciderlib/oned/oneprint.c
  ciderlib/twod/twoprint.c
pre-master-46
dwarning 13 years ago
committed by rlar
parent
commit
bef25a8b58
  1. 6
      src/spicelib/analysis/dctran.c
  2. 5
      src/spicelib/devices/bjt/bjtsupd.c
  3. 2
      src/unsupported/cktsenup.c
  4. 35
      src/unsupported/cktsncom.c
  5. 4
      src/unsupported/cktsnld.c
  6. 2
      src/unsupported/cktsnprt.c
  7. 2
      src/unsupported/cktsnset.c
  8. 9
      src/unsupported/snstart.c

6
src/spicelib/analysis/dctran.c

@ -80,9 +80,6 @@ DCtran(CKTcircuit *ckt,
#ifdef WANT_SENSE2
int save, save2, size;
long save1;
#ifdef SENSDEBUG
FILE *outsen;
#endif /* SENSDEBUG */
#endif
int save_order;
long save_mode;
@ -484,9 +481,6 @@ DCtran(CKTcircuit *ckt,
#ifdef WANT_SENSE2
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN)){
ckt->CKTsenInfo->SENmode = save;
#ifdef SENSDEBUG
fclose(outsen);
#endif /* SENSDEBUG */
}
#endif
return(OK);

5
src/spicelib/devices/bjt/bjtsupd.c

@ -55,9 +55,8 @@ BJTsUpdate(GENmodel *inModel, CKTcircuit *ckt)
sxpbx = 0;
#ifdef SENSDEBUG
printf("senupdate Instance name: %s\n",here->BJTname);
printf("iparmno = %d,CKTag[0] = %.2e,CKTag[1] = %.2e\n",
iparmno,ckt->CKTag[0],ckt->CKTag[1]);
printf("CKTag[0] = %.2e,CKTag[1] = %.2e\n",
ckt->CKTag[0],ckt->CKTag[1]);
printf("capbe = %.7e\n",here->BJTcapbe);
printf("capbc = %.7e\n",here->BJTcapbc);
printf("capsub = %.7e\n",here->BJTcapsub);

2
src/unsupported/cktsenup.c

@ -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;

35
src/unsupported/cktsncom.c

@ -17,6 +17,22 @@ Author: 1985 Thomas L. Quarles
#include "ngspice/trandefs.h"
#include "ngspice/suffix.h"
// #include "../maths/sparse/spdefs.h"
//
// this include file from `sparse' is incompatible
// with the rest of ngspice
// so we can unfortunatly not include here
// instead we cheat a bit and
// introduce the opaque struct MatrixElement here
// (only the first struct members which are of importance to us)
struct MatrixElement
{
double Real;
double Imag;
// ...
};
int
CKTsenComp(CKTcircuit *ckt)
@ -66,14 +82,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");
@ -88,11 +104,13 @@ 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);
for (col = 1; col <= size; col++) {
elt = SMPfindElt(ckt->CKTmatrix, row , col , 0);
if (elt)
printf("%.7e ", elt->Real);
else
printf("0.0000000e+00 ");
}
printf("\n");
}
#endif
@ -154,9 +172,10 @@ 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);
elt = SMPfindElt(ckt->CKTmatrix, row , col , 0);
if (elt) {
printf("%.7e ", elt->Real);
printf("+j%.7e\t", elt->Imag);
} else{
printf("0.0000000e+00 ");
printf("+j0.0000000e+00\t");

4
src/unsupported/cktsnld.c

@ -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;

2
src/unsupported/cktsnprt.c

@ -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);
}

2
src/unsupported/cktsnset.c

@ -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;

9
src/unsupported/snstart.c

@ -25,8 +25,7 @@ SENstartup(CKTcircuit *ckt, int restart)
GENinstance *fast;
if (restart) {
fprintf(stderr, "unsupported code, (SENstartup), doesn't support restart\n");
exit(1);
fprintf(stdout, "Sensitivity-2 analysis: unsupported code\n");
}
#ifdef SENSDEBUG
@ -37,7 +36,7 @@ SENstartup(CKTcircuit *ckt, int restart)
ckt->CKTsenInfo->SENpertfac = 1e-4;
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 +48,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…
Cancel
Save