Skip to content

Commit

Permalink
- adding relativ tolerance for bisection event search
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23943 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Willi Braun committed Jan 6, 2015
1 parent 903aeec commit 090ba38
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions SimulationRuntime/c/simulation/solver/events.c
Expand Up @@ -454,7 +454,6 @@ double bisection(DATA* data, double* a, double* b, double* states_a, double* sta
double TTOL = MINIMAL_STEP_SIZE;
double c;
long i=0;
int counter = 0;

double *backup_gout = (double*) malloc(data->modelData.nZeroCrossings * sizeof(double));

Expand All @@ -467,14 +466,9 @@ double bisection(DATA* data, double* a, double* b, double* states_a, double* sta
infoStreamPrint(LOG_ZEROCROSSINGS, 0, "bisection method starts in interval [%e, %e]", *a, *b);
infoStreamPrint(LOG_ZEROCROSSINGS, 0, "TTOL is set to: %e", TTOL);

while(fabs(*b - *a) > TTOL && counter++ < 100)
while(fabs(*b - *a) > TTOL + fabs(*b)*TTOL)
{
c = 0.5* (*a + *b);

if ( data->localData[0]->timeValue == c){
break;
}

data->localData[0]->timeValue = c;

/*calculates states at time c */
Expand Down

0 comments on commit 090ba38

Please sign in to comment.