Ticket #2539: stepSize.diff

File stepSize.diff, 4.4 KB (added by Lennart Ochel, 11 years ago)
  • SimulationRuntime/c/simulation/solver/perform_simulation.c

     
    9696  SIMULATION_INFO *simInfo = &(data->simulationInfo);
    9797
    9898  solverInfo->currentTime = simInfo->startTime;
     99 
     100  unsigned int __currStepNo = 0;
    99101
    100102  if(measure_time_flag)
    101103  {
     
    151153      rotateRingBuffer(data->simulationData, 1, (void**) data->localData);
    152154
    153155      /***** Calculation next step size *****/
    154       /* Calculate new step size after an event */
    155156      if(solverInfo->didEventStep == 1)
    156157      {
    157         if((solverInfo->currentTime - solverInfo->laststep) + DBL_EPSILON > simInfo->stepSize)
    158           solverInfo->currentStepSize = simInfo->stepSize;
    159         else
    160           solverInfo->currentStepSize = simInfo->stepSize - (solverInfo->currentTime - solverInfo->laststep);
    161        
    162158        infoStreamPrint(LOG_SOLVER, 0, "offset value for the next step: %.10f", (solverInfo->currentTime - solverInfo->laststep));
    163159      }
    164160      else
    165161      {
    166         solverInfo->currentStepSize = simInfo->stepSize;
     162        __currStepNo++;
    167163      }
    168 
    169       /* adjust final step? */
    170       if(solverInfo->currentTime + solverInfo->currentStepSize > simInfo->stopTime) {
    171         solverInfo->currentStepSize = simInfo->stopTime - solverInfo->currentTime;
    172       }
     164      solverInfo->currentStepSize = (double)(__currStepNo*(simInfo->stopTime-simInfo->startTime))/(simInfo->numSteps) + simInfo->startTime - solverInfo->currentTime;
    173165      /***** End calculation next step size *****/
    174166
    175167      /* check for next time event */
  • testsuite/openmodelica/cruntime/simoptions/testOutputIntervalDASSL.mos

     
    5656//     simulationOptions = "startTime = 0.0, stopTime = 2.0, numberOfIntervals = 6, tolerance = 0.000001, method = 'dassl', fileNamePrefix = 'testModel', options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = '-noEventEmit'",
    5757//     messages = ""
    5858// end SimulationResult;
    59 // 8
     59// 7
    6060// record SimulationResult
    6161//     resultFile = "testModel_res.mat",
    6262//     simulationOptions = "startTime = 0.0, stopTime = 3.0, numberOfIntervals = 500, tolerance = 0.000001, method = 'dassl', fileNamePrefix = 'testModel', options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = '-noEventEmit'",
  • testsuite/openmodelica/cruntime/simoptions/testOutputIntervalEuler.mos

     
    5656//     simulationOptions = "startTime = 0.0, stopTime = 2.0, numberOfIntervals = 6, tolerance = 0.000001, method = 'euler', fileNamePrefix = 'testModel', options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = '-noEventEmit'",
    5757//     messages = ""
    5858// end SimulationResult;
    59 // 8
     59// 7
    6060// record SimulationResult
    6161//     resultFile = "testModel_res.mat",
    6262//     simulationOptions = "startTime = 0.0, stopTime = 3.0, numberOfIntervals = 500, tolerance = 0.000001, method = 'euler', fileNamePrefix = 'testModel', options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = '-noEventEmit'",
  • testsuite/openmodelica/cruntime/simoptions/testOutputIntervalRK.mos

     
    6262//     simulationOptions = "startTime = 0.0, stopTime = 2.0, numberOfIntervals = 6, tolerance = 0.000001, method = 'rungekutta', fileNamePrefix = 'testModel', options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = '-noEventEmit'",
    6363//     messages = ""
    6464// end SimulationResult;
    65 // 8
     65// 7
    6666// endResult