static int simulationUpdate(DATA* data, threadData_t *threadData, SOLVER_INFO* solverInfo) { prefixedName_updateContinuousSystem(data, threadData); if (solverInfo->solverMethod == S_SYM_IMP_EULER) data->callback->symEulerUpdate(data, solverInfo->solverStepSize); saveZeroCrossings(data, threadData); messageClose(LOG_SOLVER); /***** Event handling *****/ if (measure_time_flag) rt_tick(SIM_TIMER_EVENT); int syncRet = handleTimers(data, threadData, solverInfo); int syncRet1; do { int eventType = checkEvents(data, threadData, solverInfo->eventLst, &(solverInfo->currentTime), solverInfo); if(eventType > 0 || syncRet == 2) /* event */ { threadData->currentErrorStage = ERROR_EVENTHANDLING; infoStreamPrint(LOG_EVENTS, 1, "%s event at time=%.12g", eventType == 1 ? "time" : "state", solverInfo->currentTime); /* prevent emit if noEventEmit flag is used */ if (!(omc_flag[FLAG_NOEVENTEMIT])) /* output left limit */ sim_result.emit(&sim_result, data, threadData); handleEvents(data, threadData, solverInfo->eventLst, &(solverInfo->currentTime), solverInfo); messageClose(LOG_EVENTS); threadData->currentErrorStage = ERROR_SIMULATION; solverInfo->didEventStep = 1; overwriteOldSimulationData(data); } else /* no event */ { solverInfo->laststep = solverInfo->currentTime; solverInfo->didEventStep = 0; } if (measure_time_flag) rt_accumulate(SIM_TIMER_EVENT); /***** End event handling *****/ /***** check state selection *****/ if (stateSelection(data, threadData, 1, 1)) { /* if new set is calculated reinit the solver */ solverInfo->didEventStep = 1; overwriteOldSimulationData(data); } /* Check for warning of variables out of range assert(min<x || x>xmax, ...)*/ data->callback->checkForAsserts(data, threadData); storePreValues(data); storeOldValues(data); syncRet1 = handleTimers(data, threadData, solverInfo); syncRet = syncRet1 == 0 ? syncRet : syncRet1; } while (syncRet1); return syncRet; }
fmiStatus fmiCompletedIntegratorStep(fmiComponent c, fmiBoolean* callEventUpdate) { ModelInstance* comp = (ModelInstance *)c; threadData_t *threadData = comp->threadData; if (invalidState(comp, "fmiCompletedIntegratorStep", modelInitialized)) return fmiError; if (nullPointer(comp, "fmiCompletedIntegratorStep", "callEventUpdate", callEventUpdate)) return fmiError; if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiCompletedIntegratorStep"); /* try */ MMC_TRY_INTERNAL(simulationJumpBuffer) comp->fmuData->callback->functionAlgebraics(comp->fmuData, comp->threadData); comp->fmuData->callback->output_function(comp->fmuData, comp->threadData); comp->fmuData->callback->function_storeDelayed(comp->fmuData, comp->threadData); storePreValues(comp->fmuData); *callEventUpdate = fmiFalse; /******** check state selection ********/ if (stateSelection(comp->fmuData, comp->threadData, 1, 0)) { if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiEventUpdate: Need to iterate state values changed!"); /* if new set is calculated reinit the solver */ *callEventUpdate = fmiTrue; } /* TODO: fix the extrapolation in non-linear system * then we can stop to save all variables in * in the whole ringbuffer */ overwriteOldSimulationData(comp->fmuData); return fmiOK; /* catch */ MMC_CATCH_INTERNAL(simulationJumpBuffer) comp->functions.logger(c, comp->instanceName, fmiError, "error", "fmiCompletedIntegratorStep: terminated by an assertion."); return fmiError; }
void Arkode::ArkodeCore() { _idid = ARKodeReInit(_arkodeMem, NULL, ARK_fCallback, _tCurrent, _ARK_y); _idid = ARKodeSetStopTime(_arkodeMem, _tEnd); _idid = ARKodeSetInitStep(_arkodeMem, 1e-12); if (_idid < 0) throw ModelicaSimulationError(SOLVER,"ARKode::ReInit"); bool writeEventOutput = (_settings->getGlobalSettings()->getOutputPointType() == OPT_ALL); bool writeOutput = !(_settings->getGlobalSettings()->getOutputPointType() == OPT_NONE); while (_solverStatus & ISolver::CONTINUE && !_interrupt ) { _ark_rt = ARKode(_arkodeMem, _tEnd, _ARK_y, &_tCurrent, ARK_ONE_STEP); _idid = ARKodeGetNumSteps(_arkodeMem, &_locStps); //if (_idid != CV_SUCCESS) // throw ModelicaSimulationError(SOLVER,"CVodeGetNumSteps failed. The cvode mem pointer is NULL"); _idid = ARKodeGetLastStep(_arkodeMem, &_h); //if (_idid != CV_SUCCESS) // throw ModelicaSimulationError(SOLVER,"CVodeGetLastStep failed. The cvode mem pointer is NULL"); //Check if there was at least one output-point within the last solver interval // -> Write output if true if (writeOutput) { writeArkodeOutput(_tCurrent, _h, _locStps); } //set completed step to system and check if terminate was called if(_continuous_system->stepCompleted(_tCurrent)) _solverStatus = DONE; // Perform state selection bool state_selection = stateSelection(); if (state_selection) _continuous_system->getContinuousStates(_z); _zeroFound = false; // Check if step was successful /* if (check_flag(&_cv_rt, "CVode", 1)) { _solverStatus = ISolver::SOLVERERROR; break; }*/ // A root was found if ((_ark_rt == ARK_ROOT_RETURN) && !isInterrupted()) { // CVode is setting _tCurrent to the time where the first event occurred double _abs = fabs(_tLastEvent - _tCurrent); _zeroFound = true; if ((_abs < 1e-3) && _event_n == 0) { _tLastEvent = _tCurrent; _event_n++; } else if ((_abs < 1e-3) && (_event_n >= 1 && _event_n < 500)) { _event_n++; } else if ((_abs >= 1e-3)) { //restart event counter _tLastEvent = _tCurrent; _event_n = 0; } else throw ModelicaSimulationError(EVENT_HANDLING,"Number of events exceeded in time interval " + to_string(_abs) + " at time " + to_string(_tCurrent)); // CVode has interpolated the states at time 'tCurrent' _time_system->setTime(_tCurrent); // To get steep steps in the result file, two value points (P1 and P2) must be added // // Y | (P2) X........... // | : // | : // |........X (P1) // |----------------------------------> // | ^ t // _tCurrent // Write the values of (P1) if (writeEventOutput) { _continuous_system->evaluateAll(IContinuous::CONTINUOUS); writeToFile(0, _tCurrent, _h); } _idid = ARKodeGetRootInfo(_arkodeMem, _zeroSign); for (int i = 0; i < _dimZeroFunc; i++) _events[i] = bool(_zeroSign[i]); if (_mixed_system->handleSystemEvents(_events)) { // State variables were reinitialized, thus we have to give these values to the cvode-solver // Take care about the memory regions, _z is the same like _CV_y _continuous_system->getContinuousStates(_z); } } if ((_zeroFound || state_selection)&& !isInterrupted()) { if (writeEventOutput) { _continuous_system->evaluateAll(IContinuous::CONTINUOUS); writeToFile(0, _tCurrent, _h); } _idid = ARKodeReInit(_arkodeMem, NULL, ARK_fCallback, _tCurrent, _ARK_y); if (_idid < 0) throw ModelicaSimulationError(SOLVER,"CVode::ReInit()"); // Der Eventzeitpunkt kann auf der Endzeit liegen (Time-Events). In diesem Fall wird der Solver beendet, da CVode sonst eine interne Warnung if (_tCurrent == _tEnd) _ark_rt = ARK_TSTOP_RETURN; } ++_outStps; _tLastSuccess = _tCurrent; if (_ark_rt == ARK_TSTOP_RETURN) { _time_system->setTime(_tEnd); //Solver has finished calculation - calculate the final values _continuous_system->setContinuousStates(NV_DATA_S(_ARK_y)); _continuous_system->evaluateAll(IContinuous::CONTINUOUS); if(writeOutput) writeToFile(0, _tEnd, _h); _accStps += _locStps; _solverStatus = DONE; } } }
void Ida::IDACore() { _idid = IDAReInit(_idaMem, _tCurrent, _CV_y,_CV_yp); _idid = IDASetStopTime(_idaMem, _tEnd); _idid = IDASetInitStep(_idaMem, 1e-12); if (_idid < 0) throw std::runtime_error("IDA::ReInit"); bool writeEventOutput = (_settings->getGlobalSettings()->getOutputPointType() == OPT_ALL); bool writeOutput = !(_settings->getGlobalSettings()->getOutputPointType() == OPT_NONE); while ((_solverStatus & ISolver::CONTINUE) && !_interrupt ) { _cv_rt = IDASolve(_idaMem, _tEnd, &_tCurrent, _CV_y, _CV_yp, IDA_ONE_STEP); _idid = IDAGetNumSteps(_idaMem, &_locStps); if (_idid != IDA_SUCCESS) throw std::runtime_error("IDAGetNumSteps failed. The ida mem pointer is NULL"); _idid =IDAGetLastStep(_idaMem, &_h); if (_idid != IDA_SUCCESS) throw std::runtime_error("IDAGetLastStep failed. The ida mem pointer is NULL"); //Check if there was at least one output-point within the last solver interval // -> Write output if true if (writeOutput) { writeIDAOutput(_tCurrent, _h, _locStps); } #ifdef RUNTIME_PROFILING MEASURETIME_REGION_DEFINE(idaStepCompletedHandler, "IDAStepCompleted"); if(MeasureTime::getInstance() != NULL) { MEASURETIME_START(measuredFunctionStartValues, idaStepCompletedHandler, "IDAStepCompleted"); } #endif //set completed step to system and check if terminate was called if(_continuous_system->stepCompleted(_tCurrent)) _solverStatus = DONE; #ifdef RUNTIME_PROFILING if(MeasureTime::getInstance() != NULL) { MEASURETIME_END(measuredFunctionStartValues, measuredFunctionEndValues, (*measureTimeFunctionsArray)[5], idaStepCompletedHandler); } #endif // Perform state selection bool state_selection = stateSelection(); if (state_selection) _continuous_system->getContinuousStates(_y); _zeroFound = false; // Check if step was successful if (check_flag(&_cv_rt, "IDA", 1)) { _solverStatus = ISolver::SOLVERERROR; break; } // A root was found if ((_cv_rt == IDA_ROOT_RETURN) && !isInterrupted()) { // IDA is setting _tCurrent to the time where the first event occurred double _abs = fabs(_tLastEvent - _tCurrent); _zeroFound = true; if ((_abs < 1e-3) && _event_n == 0) { _tLastEvent = _tCurrent; _event_n++; } else if ((_abs < 1e-3) && (_event_n >= 1 && _event_n < 500)) { _event_n++; } else if ((_abs >= 1e-3)) { //restart event counter _tLastEvent = _tCurrent; _event_n = 0; } else throw std::runtime_error("Number of events exceeded in time interval " + to_string(_abs) + " at time " + to_string(_tCurrent)); // IDA has interpolated the states at time 'tCurrent' _time_system->setTime(_tCurrent); // To get steep steps in the result file, two value points (P1 and P2) must be added // // Y | (P2) X........... // | : // | : // |........X (P1) // |----------------------------------> // | ^ t // _tCurrent // Write the values of (P1) if (writeEventOutput) { if(_dimAE>0) { _continuous_system->evaluateDAE(IContinuous::CONTINUOUS); } else { _continuous_system->evaluateAll(IContinuous::CONTINUOUS); } writeToFile(0, _tCurrent, _h); } _idid = IDAGetRootInfo(_idaMem, _zeroSign); for (int i = 0; i < _dimZeroFunc; i++) _events[i] = bool(_zeroSign[i]); if (_mixed_system->handleSystemEvents(_events)) { // State variables were reinitialized, thus we have to give these values to the ida-solver // Take care about the memory regions, _z is the same like _CV_y _continuous_system->getContinuousStates(_y); if(_dimAE>0) { _mixed_system->getAlgebraicDAEVars(_y+_dimStates); _continuous_system->getRHS(_yp); } calcFunction(_tCurrent, NV_DATA_S(_CV_y), NV_DATA_S(_CV_yp),_dae_res); } } if ((_zeroFound || state_selection)&& !isInterrupted()) { // Write the values of (P2) if (writeEventOutput) { // If we want to write the event-results, we should evaluate the whole system again if(_dimAE>0) { _continuous_system->evaluateDAE(IContinuous::CONTINUOUS); } else { _continuous_system->evaluateAll(IContinuous::CONTINUOUS); } writeToFile(0, _tCurrent, _h); } _idid = IDAReInit(_idaMem, _tCurrent, _CV_y,_CV_yp); if (_idid < 0) throw std::runtime_error("IDA::ReInit()"); // Der Eventzeitpunkt kann auf der Endzeit liegen (Time-Events). In diesem Fall wird der Solver beendet, da IDA sonst eine interne Warnung schmeißt if (_tCurrent == _tEnd) _cv_rt = IDA_TSTOP_RETURN; } // Zähler für die Anzahl der ausgegebenen Schritte erhöhen ++_outStps; _tLastSuccess = _tCurrent; if (_cv_rt == IDA_TSTOP_RETURN) { _time_system->setTime(_tEnd); _continuous_system->setContinuousStates(NV_DATA_S(_CV_y)); if(_dimAE>0) { _mixed_system->setAlgebraicDAEVars(NV_DATA_S(_CV_y)+_dimStates); _continuous_system->setStateDerivatives(NV_DATA_S(_CV_yp)); _continuous_system->evaluateDAE(IContinuous::CONTINUOUS); } else { _continuous_system->evaluateAll(IContinuous::CONTINUOUS); } if(writeOutput) writeToFile(0, _tEnd, _h); _accStps += _locStps; _solverStatus = DONE; } } }
fmiStatus fmiEventUpdate(fmiComponent c, fmiBoolean intermediateResults, fmiEventInfo* eventInfo) { int i; ModelInstance* comp = (ModelInstance *)c; threadData_t *threadData = comp->threadData; if (invalidState(comp, "fmiEventUpdate", modelInitialized)) return fmiError; if (nullPointer(comp, "fmiEventUpdate", "eventInfo", eventInfo)) return fmiError; eventInfo->stateValuesChanged = fmiFalse; if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiEventUpdate: Start Event Update! Next Sample Event %g", eventInfo->nextEventTime); /* try */ MMC_TRY_INTERNAL(simulationJumpBuffer) if (stateSelection(comp->fmuData, threadData, 1, 1)) { if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiEventUpdate: Need to iterate state values changed!"); /* if new set is calculated reinit the solver */ eventInfo->stateValuesChanged = fmiTrue; } storePreValues(comp->fmuData); /* activate sample event */ for(i=0; i<comp->fmuData->modelData->nSamples; ++i) { if(comp->fmuData->simulationInfo->nextSampleTimes[i] <= comp->fmuData->localData[0]->timeValue) { comp->fmuData->simulationInfo->samples[i] = 1; infoStreamPrint(LOG_EVENTS, 0, "[%ld] sample(%g, %g)", comp->fmuData->modelData->samplesInfo[i].index, comp->fmuData->modelData->samplesInfo[i].start, comp->fmuData->modelData->samplesInfo[i].interval); } } comp->fmuData->callback->functionDAE(comp->fmuData, threadData); /* deactivate sample events */ for(i=0; i<comp->fmuData->modelData->nSamples; ++i) { if(comp->fmuData->simulationInfo->samples[i]) { comp->fmuData->simulationInfo->samples[i] = 0; comp->fmuData->simulationInfo->nextSampleTimes[i] += comp->fmuData->modelData->samplesInfo[i].interval; } } for(i=0; i<comp->fmuData->modelData->nSamples; ++i) if((i == 0) || (comp->fmuData->simulationInfo->nextSampleTimes[i] < comp->fmuData->simulationInfo->nextSampleEvent)) comp->fmuData->simulationInfo->nextSampleEvent = comp->fmuData->simulationInfo->nextSampleTimes[i]; if(comp->fmuData->callback->checkForDiscreteChanges(comp->fmuData, threadData) || comp->fmuData->simulationInfo->needToIterate || checkRelations(comp->fmuData) || eventInfo->stateValuesChanged) { intermediateResults = fmiTrue; if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiEventUpdate: Need to iterate(discrete changes)!"); eventInfo->iterationConverged = fmiTrue; eventInfo->stateValueReferencesChanged = fmiFalse; eventInfo->stateValuesChanged = fmiTrue; eventInfo->terminateSimulation = fmiFalse; } else { intermediateResults = fmiFalse; eventInfo->iterationConverged = fmiTrue; eventInfo->stateValueReferencesChanged = fmiFalse; eventInfo->terminateSimulation = fmiFalse; } /* due to an event overwrite old values */ overwriteOldSimulationData(comp->fmuData); /* TODO: check the event iteration for relation * in fmi import and export. This is an workaround, * since the iteration seem not starting. */ storePreValues(comp->fmuData); updateRelationsPre(comp->fmuData); if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiEventUpdate: intermediateResults = %d", intermediateResults); //Get Next Event Time double nextSampleEvent=0; nextSampleEvent = getNextSampleTimeFMU(comp->fmuData); if (nextSampleEvent == -1) { eventInfo->upcomingTimeEvent = fmiFalse; } else { eventInfo->upcomingTimeEvent = fmiTrue; eventInfo->nextEventTime = nextSampleEvent; } if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiEventUpdate: Checked for Sample Events! Next Sample Event %g",eventInfo->nextEventTime); return fmiOK; /* catch */ MMC_CATCH_INTERNAL(simulationJumpBuffer) comp->functions.logger(c, comp->instanceName, fmiError, "error", "fmiEventUpdate: terminated by an assertion."); return fmiError; }
void CppDASSL::solve(const SOLVERCALL action) { bool writeEventOutput = (_settings->getGlobalSettings()->getOutputPointType() == OPT_ALL); bool writeOutput = !(_settings->getGlobalSettings()->getOutputPointType() == OPT_NONE); double t,tend; if ((action & RECORDCALL) && (action & FIRST_CALL)) { initialize(); return; } if (action & RECALL) { writeToFile(0, _tCurrent, _h); _continuous_systems[0]->getContinuousStates(_y); } // Initialization phase t=_tCurrent; _time_systems[0]->setTime(t); _continuous_systems[0]->setContinuousStates(_y); if(writeOutput) { tend=_tCurrent+_hOut; _continuous_systems[0]->evaluateODE(IContinuous::ALL); // vxworksupdate SolverDefaultImplementation::writeToFile(0, t, _h); } else { tend=_tEnd; } _continuous_systems[0]->getRHS(_yp); bool state_selection; if(!_dimZeroFunc) { int idid=dasslSolver.solve(&res,_dimSys,t,&_y[0],&_yp[0],tend,_data,NULL,NULL,NULL,_dimZeroFunc,NULL,false); for(int i=0; i<_numThreads; ++i) _continuous_systems[i]->stepCompleted(t); state_selection = stateSelection(); if (state_selection) { _continuous_systems[0]->getContinuousStates(_y); _continuous_systems[0]->setContinuousStates(_y); _continuous_systems[0]->evaluateODE(IContinuous::ALL); // vxworksupdate _continuous_systems[0]->getRHS(_yp); } while(idid==-1 || idid==1 || (writeOutput && idid>1)) { _time_systems[0]->setTime(t); _continuous_systems[0]->setContinuousStates(_y); if(writeOutput) { if(t>=tend) { if(t>=_tEnd) { break; } else { if (t+_hOut>=_tEnd) { tend=_tEnd; } else { tend+=_hOut; } } _continuous_systems[0]->evaluateAll(IContinuous::ALL); SolverDefaultImplementation::writeToFile(0, t, _h); } } idid=dasslSolver.solve(&res,_dimSys,t,&_y[0],&_yp[0],tend,_data,NULL,NULL,NULL,_dimZeroFunc,NULL,true); _continuous_systems[0]->stepCompleted(t); state_selection = stateSelection(); if (state_selection) { _continuous_systems[0]->getContinuousStates(_y); _continuous_systems[0]->setContinuousStates(_y); _continuous_systems[0]->evaluateODE(IContinuous::ALL); // vxworksupdate _continuous_systems[0]->getRHS(_yp); } } } else { if(_jroot) delete [] _jroot; _jroot=new int[_dimZeroFunc]; int idid=dasslSolver.solve(&res,_dimSys,t,&_y[0],&_yp[0],_tEnd,_data,NULL,NULL,&zeroes,_dimZeroFunc,_jroot,false); #pragma omp parallel for num_threads(_numThreads) for(int i=0; i<_numThreads; ++i) { _continuous_systems[i]->setContinuousStates(_y); //_continuous_systems[i]->evaluateODE(IContinuous::ALL); _continuous_systems[i]->stepCompleted(t); } state_selection = stateSelection(); if (state_selection) { for(size_t i = 0; i < _state_selections[0]->getDimStateSets(); i++) { _state_selections[0]->getAMatrix(i,_matrix); _state_selections[0]->getStates(i,_states); for(int j=1; j<_numThreads; ++j) { _state_selections[j]->setAMatrix(i,_matrix); _state_selections[j]->setStates(i,_states); } } // for(int i=1; i<_numThreads; ++i) { // _continuous_system[i]->setContinuousStates(_y); // _system_state_selection[i-1]->stateSelection(1); // } _continuous_systems[0]->getContinuousStates(_y); for(int i=1; i<_numThreads; ++i) { _continuous_systems[i]->setContinuousStates(_y); } _continuous_systems[0]->setContinuousStates(_y); _continuous_systems[0]->evaluateODE(IContinuous::ALL); // vxworksupdate _continuous_systems[0]->getRHS(_yp); } if(idid==5) { _time_systems[0]->setTime(t); _continuous_systems[0]->setContinuousStates(_y); _continuous_systems[0]->evaluateAll(IContinuous::ALL); SolverDefaultImplementation::writeToFile(0, t, _h); for (int i = 0; i < _dimZeroFunc; i++) _events[i] = bool(_jroot[i]); for(int i=1; i<_numThreads; ++i) { _continuous_systems[i]->setContinuousStates(_y); _mixed_systems[i]->handleSystemEvents(_events); } if (_mixed_systems[0]->handleSystemEvents(_events)) { _continuous_systems[0]->getContinuousStates(_y); _continuous_systems[0]->setContinuousStates(_y); _continuous_systems[0]->evaluateODE(IContinuous::ALL); // vxworksupdate _continuous_systems[0]->getRHS(_yp); } } int run=2; while(idid==-1 || idid==5 || idid==1 || (writeOutput && idid>1)) { _time_systems[0]->setTime(t); _continuous_systems[0]->setContinuousStates(_y); if(writeOutput) { if(t>=tend) { if(t>=_tEnd) { break; } else { if (t+_hOut>=_tEnd) { tend=_tEnd; } else { tend+=_hOut; } } _continuous_systems[0]->evaluateAll(IContinuous::ALL); SolverDefaultImplementation::writeToFile(0, t, _h); } } if(idid==5 || state_selection ) { idid=dasslSolver.solve(&res,_dimSys,t,&_y[0],&_yp[0],tend,_data,NULL,NULL,&zeroes,_dimZeroFunc,_jroot,false); } else { idid=dasslSolver.solve(&res,_dimSys,t,&_y[0],&_yp[0],tend,_data,NULL,NULL,&zeroes,_dimZeroFunc,_jroot,true); } #pragma omp parallel for num_threads(_numThreads) for(int i=0; i<_numThreads; ++i) { _continuous_systems[i]->setContinuousStates(_y); //_continuous_systems[i]->evaluateODE(IContinuous::ALL); _continuous_systems[i]->stepCompleted(t); } state_selection = stateSelection(); run++; if (state_selection) { for(size_t i = 0; i < _state_selections[0]->getDimStateSets(); i++) { _state_selections[0]->getAMatrix(i,_matrix); _state_selections[0]->getStates(i,_states); for(int j=1; j<_numThreads; ++j) { _state_selections[j]->setAMatrix(i,_matrix); _state_selections[j]->setStates(i,_states); } } _continuous_systems[0]->getContinuousStates(_y); for(int i=1; i<_numThreads; ++i) { _continuous_systems[i]->setContinuousStates(_y); } _continuous_systems[0]->setContinuousStates(_y); _continuous_systems[0]->evaluateODE(IContinuous::ALL); // vxworksupdate _continuous_systems[0]->getRHS(_yp); } ; if(idid==5) { _time_systems[0]->setTime(t); _continuous_systems[0]->setContinuousStates(_y); _continuous_systems[0]->evaluateAll(IContinuous::ALL); SolverDefaultImplementation::writeToFile(0, t, _h); for (int i = 0; i < _dimZeroFunc; i++) _events[i] = bool(_jroot[i]); for(int i=1; i<_numThreads; ++i) { _continuous_systems[i]->setContinuousStates(_y); _mixed_systems[i]->handleSystemEvents(_events); } if (_mixed_systems[0]->handleSystemEvents(_events)) { _continuous_systems[0]->getContinuousStates(_y); _continuous_systems[0]->setContinuousStates(_y); _continuous_systems[0]->evaluateODE(IContinuous::ALL); // vxworksupdate _continuous_systems[0]->getRHS(_yp); } } } } _tCurrent=_tEnd; if(writeOutput) { _time_systems[0]->setTime(_tCurrent); _continuous_systems[0]->setContinuousStates(_y); _continuous_systems[0]->evaluateAll(IContinuous::ALL); SolverDefaultImplementation::writeToFile(0, t, _h); } _solverStatus = ISolver::DONE; }