Changeset 0c3a76e in OpenModelica


Ignore:
Timestamp:
2016-04-11T10:08:25+02:00 (8 years ago)
Author:
hudson <openmodelica@…>
Branches:
Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
Children:
390188e2
Parents:
3a64133c
git-author:
Lennart Ochel <lennart.ochel@…> (04/11/16 10:08:25)
git-committer:
hudson <openmodelica@…> (04/11/16 10:08:25)
Message:

Add new flag to set maximum number of bisection iterations

to determine state event time value

Location:
SimulationRuntime/c
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • SimulationRuntime/c/simulation/simulation_runtime.cpp

    r7d8f15f2 r0c3a76e  
    7777#include "simulation_info_json.h"
    7878#include "modelinfo.h"
     79#include "simulation/solver/events.h"
    7980#include "simulation/solver/model_help.h"
    8081#include "simulation/solver/mixedSystem.h"
     
    525526    init_lambda_steps_string = omc_flagValue[FLAG_ILS];
    526527    init_lambda_steps = atoi(init_lambda_steps_string.c_str());
     528  }
     529  if(omc_flag[FLAG_MAX_BISECTION_ITERATIONS]) {
     530    maxBisectionIterations = atoi(omc_flagValue[FLAG_MAX_BISECTION_ITERATIONS]);
     531    infoStreamPrint(LOG_STDOUT, 0, "Maximum number of bisection iterations changed to %d", maxBisectionIterations);
    527532  }
    528533  if(omc_flag[FLAG_MAX_EVENT_ITERATIONS]) {
  • SimulationRuntime/c/simulation/solver/events.c

    r34e4a4c r0c3a76e  
    5151#endif
    5252
     53int maxBisectionIterations = 0;
    5354double bisection(DATA* data, threadData_t *threadData, double*, double*, double*, double*, LIST*, LIST*);
    5455int checkZeroCrossings(DATA *data, LIST *list, LIST*);
     
    417418  long i=0;
    418419  /* n >= log(2)/log(2) + log(|b-a|/TOL)/log(2)*/
    419   unsigned int n = 1 + ceil(log(fabs(*b - *a)/TTOL)/log(2));
     420  unsigned int n = maxBisectionIterations > 0 ? maxBisectionIterations : 1 + ceil(log(fabs(*b - *a)/TTOL)/log(2));
    420421
    421422  memcpy(data->simulationInfo->zeroCrossingsBackup, data->simulationInfo->zeroCrossings, data->modelData->nZeroCrossings * sizeof(modelica_real));
  • SimulationRuntime/c/simulation/solver/events.h

    r34e4a4c r0c3a76e  
    4343#endif
    4444
     45extern int maxBisectionIterations;
    4546void checkForSampleEvent(DATA *data, SOLVER_INFO* solverInfo);
    4647int checkEvents(DATA* data, threadData_t *threadData, LIST* eventLst, modelica_boolean useRootFinding, double *eventTime);
  • SimulationRuntime/c/util/simulation_options.c

    r96898a5d r0c3a76e  
    6969  /* FLAG_LSS_MIN_SIZE */          "lssMinSize",
    7070  /* FLAG_LV */                    "lv",
     71  /* FLAG_MAX_BISECTION_ITERATIONS */  "mbi",
    7172  /* FLAG_MAX_EVENT_ITERATIONS */  "mei",
    7273  /* FLAG_MAX_ORDER */             "maxIntegrationOrder",
     
    135136  /* FLAG_LSS_MIN_SIZE */          "[int (default 4001)] value specifies the minimum system size for using a linear sparse solver",
    136137  /* FLAG_LV */                    "[string list] value specifies the logging level",
     138  /* FLAG_MAX_BISECTION_ITERATIONS */  "[int (default 0)] value specifies the maximum number of bisection iterations for state event detection or zero for default behavior",
    137139  /* FLAG_MAX_EVENT_ITERATIONS */  "[int (default 20)] value specifies the maximum number of event iterations",
    138140  /* FLAG_MAX_ORDER */             "value specifies maximum integration order, used by dassl solver",
     
    255257  "  Value (a comma-separated String list) specifies which logging levels to\n"
    256258  "  enable. Multiple options can be enabled at the same time.",
     259  /* FLAG_MAX_BISECTION_ITERATIONS */
     260  "  value specifies the maximum number of bisection iterations for state event\n"
     261  "  detection or zero for default behavior",
    257262  /* FLAG_MAX_EVENT_ITERATIONS */
    258263  "  Value specifies the maximum number of event iterations.\n"
     
    369374  /* FLAG_LSS_MIN_SIZE */          FLAG_TYPE_OPTION,
    370375  /* FLAG_LV */                    FLAG_TYPE_OPTION,
     376  /* FLAG_MAX_BISECTION_ITERATIONS */  FLAG_TYPE_OPTION,
    371377  /* FLAG_MAX_EVENT_ITERATIONS */  FLAG_TYPE_OPTION,
    372378  /* FLAG_MAX_ORDER */             FLAG_TYPE_OPTION,
  • SimulationRuntime/c/util/simulation_options.h

    r96898a5d r0c3a76e  
    7777  FLAG_LSS_MIN_SIZE,
    7878  FLAG_LV,
     79  FLAG_MAX_BISECTION_ITERATIONS,
    7980  FLAG_MAX_EVENT_ITERATIONS,
    8081  FLAG_MAX_ORDER,
Note: See TracChangeset for help on using the changeset viewer.