Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 78c97ac

Browse files
bernhardbachmannOpenModelica-Hudson
authored andcommitted
Fix some scaling issues
1 parent 94567d2 commit 78c97ac

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

SimulationRuntime/c/simulation/solver/nonlinearSolverHomotopy.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,8 @@ void vecDivScaling(int n, double *a, double *b, double *c)
620620
{
621621
int i;
622622
for (i=0;i<n;i++)
623-
c[i] = a[i]/fmax(1.0,fabs(b[i]));
623+
c[i] = a[i]/fabs(b[i]);
624+
// c[i] = a[i]/fmax(1.0,fabs(b[i]));
624625
}
625626

626627
void vecNormalize(int n, double *a, double *b)
@@ -722,14 +723,16 @@ void scaleMatrixRows(int n, int m, double *A)
722723
int i, j;
723724
double rowMax;
724725
for (i=0;i<n;i++) {
725-
rowMax = delta; /* This might be changed to smaller number */
726-
for (j=0;j<m;j++) {
726+
rowMax = 0; /* This might be changed to delta */
727+
for (j=0;j<n;j++) {
727728
if (fabs(A[i+j*(m-1)]) > rowMax) {
728729
rowMax = fabs(A[i+j*(m-1)]);
729730
}
730731
}
731-
for (j=0;j<m;j++)
732-
A[i+j*(m-1)] /= rowMax;
732+
if (rowMax>0) {
733+
for (j=0;j<m;j++)
734+
A[i+j*(m-1)] /= rowMax;
735+
}
733736
}
734737
}
735738

@@ -1465,7 +1468,7 @@ static int newtonAlgorithm(DATA_HOMOTOPY* solverData, double* x)
14651468
);
14661469
}
14671470
#endif
1468-
if ((error_f_sqrd_scaled < 1e-30*error_f_sqrd) || countNegativeSteps > 20)
1471+
if (countNegativeSteps > 20)
14691472
{
14701473
debugInt(LOG_NLS_V,"UPS! Something happened, NegativeSteps = ", countNegativeSteps);
14711474
solverData->info = -1;

0 commit comments

Comments
 (0)