Fixed Sensitivity Analysis integration for KLU
This commit is contained in:
parent
0823ed4e16
commit
0429238df5
|
|
@ -1090,3 +1090,21 @@ SMPzeroRow (SMPmatrix *eMatrix, int Row)
|
||||||
|
|
||||||
return spError (Matrix) ;
|
return spError (Matrix) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SMPconstMult()
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SMPconstMult (SMPmatrix *Matrix, double constant)
|
||||||
|
{
|
||||||
|
spConstMult (Matrix->SPmatrix, constant) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SMPmultiply()
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SMPmultiply (SMPmatrix *Matrix, double *RHS, double *Solution, double *iRHS, double *iSolution)
|
||||||
|
{
|
||||||
|
spMultiply (Matrix->SPmatrix, RHS, Solution, iRHS, iSolution) ;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,7 @@ int sens_sens(CKTcircuit *ckt, int restart)
|
||||||
static double freq;
|
static double freq;
|
||||||
static int nfreqs;
|
static int nfreqs;
|
||||||
static int i;
|
static int i;
|
||||||
static SMPmatrix *delta_Y = NULL;
|
static SMPmatrix *delta_Y = NULL, *Y;
|
||||||
static MatrixFrame *Y;
|
|
||||||
static double step_size;
|
static double step_size;
|
||||||
double *E, *iE;
|
double *E, *iE;
|
||||||
IFvalue value, nvalue;
|
IFvalue value, nvalue;
|
||||||
|
|
@ -142,7 +141,7 @@ int sens_sens(CKTcircuit *ckt, int restart)
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
size = SMPmatSize(ckt->CKTmatrix->SPmatrix);
|
size = SMPmatSize(ckt->CKTmatrix);
|
||||||
|
|
||||||
/* Create the perturbation matrix */
|
/* Create the perturbation matrix */
|
||||||
error = SMPnewMatrix(delta_Y, size);
|
error = SMPnewMatrix(delta_Y, size);
|
||||||
|
|
@ -243,7 +242,7 @@ int sens_sens(CKTcircuit *ckt, int restart)
|
||||||
|
|
||||||
E = ckt->CKTrhs;
|
E = ckt->CKTrhs;
|
||||||
iE = ckt->CKTirhs;
|
iE = ckt->CKTirhs;
|
||||||
Y = ckt->CKTmatrix->SPmatrix;
|
Y = ckt->CKTmatrix;
|
||||||
|
|
||||||
#ifdef ASDEBUG
|
#ifdef ASDEBUG
|
||||||
DEBUG(1) {
|
DEBUG(1) {
|
||||||
|
|
@ -318,7 +317,7 @@ int sens_sens(CKTcircuit *ckt, int restart)
|
||||||
/* NIacIter solves into CKTrhsOld, CKTirhsOld and CKTmatrix->SPmatrix */
|
/* NIacIter solves into CKTrhsOld, CKTirhsOld and CKTmatrix->SPmatrix */
|
||||||
E = ckt->CKTrhsOld;
|
E = ckt->CKTrhsOld;
|
||||||
iE = ckt->CKTirhsOld;
|
iE = ckt->CKTirhsOld;
|
||||||
Y = ckt->CKTmatrix->SPmatrix;
|
Y = ckt->CKTmatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use a different vector & matrix */
|
/* Use a different vector & matrix */
|
||||||
|
|
@ -358,7 +357,7 @@ int sens_sens(CKTcircuit *ckt, int restart)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SMPcClear(delta_Y->SPmatrix);
|
SMPcClear(delta_Y);
|
||||||
|
|
||||||
for (j = 0; j < size; j++) {
|
for (j = 0; j < size; j++) {
|
||||||
delta_I[j] = 0.0;
|
delta_I[j] = 0.0;
|
||||||
|
|
@ -430,7 +429,7 @@ int sens_sens(CKTcircuit *ckt, int restart)
|
||||||
if (error && error != E_BADPARM)
|
if (error && error != E_BADPARM)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
SMPconstMult(delta_Y->SPmatrix, -1.0);
|
SMPconstMult(delta_Y, -1.0);
|
||||||
for (j = 0; j < size; j++) {
|
for (j = 0; j < size; j++) {
|
||||||
delta_I[j] *= -1.0;
|
delta_I[j] *= -1.0;
|
||||||
delta_iI[j] *= -1.0;
|
delta_iI[j] *= -1.0;
|
||||||
|
|
@ -439,7 +438,7 @@ int sens_sens(CKTcircuit *ckt, int restart)
|
||||||
#ifdef ASDEBUG
|
#ifdef ASDEBUG
|
||||||
DEBUG(2) {
|
DEBUG(2) {
|
||||||
printf("Effect of negating matrix:\n");
|
printf("Effect of negating matrix:\n");
|
||||||
SMPprint(delta_Y->SPmatrix, NULL);
|
SMPprint(delta_Y, NULL);
|
||||||
for (j = 0; j < size; j++)
|
for (j = 0; j < size; j++)
|
||||||
printf("%d: %g, %g\n", j,
|
printf("%d: %g, %g\n", j,
|
||||||
delta_I[j], delta_iI[j]);
|
delta_I[j], delta_iI[j]);
|
||||||
|
|
@ -465,7 +464,7 @@ int sens_sens(CKTcircuit *ckt, int restart)
|
||||||
#ifdef ASDEBUG
|
#ifdef ASDEBUG
|
||||||
DEBUG(2) {
|
DEBUG(2) {
|
||||||
printf("Effect of changing the parameter:\n");
|
printf("Effect of changing the parameter:\n");
|
||||||
SMPprint(delta_Y->SPmatrix, NULL);
|
SMPprint(delta_Y, NULL);
|
||||||
for (j = 0; j < size; j++)
|
for (j = 0; j < size; j++)
|
||||||
printf("%d: %g, %g\n", j,
|
printf("%d: %g, %g\n", j,
|
||||||
delta_I[j], delta_iI[j]);
|
delta_I[j], delta_iI[j]);
|
||||||
|
|
@ -489,7 +488,7 @@ int sens_sens(CKTcircuit *ckt, int restart)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* delta_Y E */
|
/* delta_Y E */
|
||||||
SMPmultiply(delta_Y->SPmatrix, delta_I_delta_Y, E,
|
SMPmultiply(delta_Y, delta_I_delta_Y, E,
|
||||||
delta_iI_delta_Y, iE);
|
delta_iI_delta_Y, iE);
|
||||||
|
|
||||||
#ifdef ASDEBUG
|
#ifdef ASDEBUG
|
||||||
|
|
@ -608,7 +607,7 @@ int sens_sens(CKTcircuit *ckt, int restart)
|
||||||
release_context(ckt->CKTirhs, saved_irhs);
|
release_context(ckt->CKTirhs, saved_irhs);
|
||||||
release_context(ckt->CKTmatrix->SPmatrix, saved_matrix);
|
release_context(ckt->CKTmatrix->SPmatrix, saved_matrix);
|
||||||
|
|
||||||
SMPdestroy(delta_Y->SPmatrix);
|
SMPdestroy(delta_Y);
|
||||||
FREE(delta_I);
|
FREE(delta_I);
|
||||||
FREE(delta_iI);
|
FREE(delta_iI);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue