Changeset df48ecd5 in OpenModelica
- Timestamp:
- 2023-03-17T19:04:24+01:00 (14 months ago)
- Branches:
- maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master
- Children:
- 4101671, eb7ee9f
- Parents:
- dc27243d
- git-author:
- bernhardbachmann <bernhardbachmann@…> (03/17/23 19:04:24)
- git-committer:
- GitHub <noreply@…> (03/17/23 19:04:24)
- Location:
- OMCompiler/SimulationRuntime/c/simulation/solver
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
OMCompiler/SimulationRuntime/c/simulation/solver/gbode_events.c
r9d76c7b7 rdf48ecd5 76 76 { 77 77 c = 0.5 * (*a + *b); 78 79 if (gbData->eventSearch == 0) { 80 /*calculates states at time c using interpolation */ 81 if (isInnerIntegration) { 82 gbfData = gbData->gbfData; 83 gb_interpolation(gbfData->interpolation, 84 gbfData->timeLeft, gbfData->yLeft, gbfData->kLeft, 85 gbfData->timeRight, gbfData->yRight, gbfData->kRight, 86 c, gbfData->y1, 87 gbData->nStates, NULL, gbData->nStates, gbfData->tableau, gbfData->x, gbfData->k); 88 y = gbfData->y1; 89 } else { 90 gb_interpolation(gbData->interpolation, 91 gbData->timeLeft, gbData->yLeft, gbData->kLeft, 92 gbData->timeRight, gbData->yRight, gbData->kRight, 93 c, gbData->y1, 94 gbData->nStates, NULL, gbData->nStates, gbData->tableau, gbData->x, gbData->k); 95 y = gbData->y1; 96 } 78 data->localData[0]->timeValue = c; 79 80 /*calculates states at time c using interpolation */ 81 if (isInnerIntegration) { 82 gbfData = gbData->gbfData; 83 gb_interpolation(gbfData->interpolation, 84 gbfData->timeLeft, gbfData->yLeft, gbfData->kLeft, 85 gbfData->timeRight, gbfData->yRight, gbfData->kRight, 86 c, data->localData[0]->realVars, 87 gbData->nStates, NULL, gbData->nStates, gbfData->tableau, gbfData->x, gbfData->k); 97 88 } else { 98 /*calculates states at time c using integration */ 99 if (isInnerIntegration) { 100 gbData->gbfData->time = gbData->gbfData->timeLeft; 101 memcpy(gbData->gbfData->yOld, gbData->gbfData->yLeft, gbData->nStates * sizeof(double)); 102 103 gbData->gbfData->stepSize = c - gbData->gbfData->time; 104 gb_step_info = gbData->gbfData->step_fun(data, threadData, solverInfo); 105 y = gbData->gbfData->y; 106 } else { 107 gbData->time = gbData->timeLeft; 108 memcpy(gbData->yOld, gbData->yLeft, gbData->nStates * sizeof(double)); 109 110 gbData->stepSize = c - gbData->time; 111 gb_step_info = gbData->step_fun(data, threadData, solverInfo); 112 y = gbData->y; 113 } 114 115 // error handling: try half of the step size! 116 if (gb_step_info != 0) 117 { 118 errorStreamPrint(LOG_STDOUT, 0, "gbode_event: Failed to calculate event time = %5g.", c); 119 exit(1); 120 } 121 } 122 123 data->localData[0]->timeValue = c; 124 for(i=0; i < data->modelData->nStates; i++) 125 { 126 data->localData[0]->realVars[i] = y[i]; 89 gb_interpolation(gbData->interpolation, 90 gbData->timeLeft, gbData->yLeft, gbData->kLeft, 91 gbData->timeRight, gbData->yRight, gbData->kRight, 92 c, data->localData[0]->realVars, 93 gbData->nStates, NULL, gbData->nStates, gbData->tableau, gbData->x, gbData->k); 127 94 } 128 95 -
OMCompiler/SimulationRuntime/c/simulation/solver/gbode_main.c
rc9a7342d rdf48ecd5 533 533 gbData->err_threshold = 0.1; 534 534 gbData->err_int = 0; // needed, if GB_INTERPOL_HERMITE_ERRCTRL or GB_DENSE_OUTPUT_ERRCTRL is used 535 gbData->eventSearch = 0; // use interpolation for event time search536 537 535 538 536 if (gbData->multi_rate) { -
OMCompiler/SimulationRuntime/c/simulation/solver/gbode_main.h
rcfdfe6e7 rdf48ecd5 165 165 int *slowStatesIdx; /* Indices of slow states */ 166 166 int *sortedStatesIdx; /* Indices of all states sorted for highest error */ 167 unsigned int eventSearch; /* Defines the mode of event handling (0 => interpolation, 1 => integration) */168 167 modelica_boolean isFirstStep; /* True during first Runge-Kutta integrator step, false otherwise */ 169 168 unsigned int nlSystemSize; /* Size of non-linear system to solve in a RK step. */ -
OMCompiler/SimulationRuntime/c/simulation/solver/gbode_nls.c
r9d76c7b7 rdf48ecd5 491 491 /* Retry solution process with updated Jacobian */ 492 492 if (!solved) { 493 infoStreamPrint(LOG_STDOUT, 0, "GBODE: Solution of NLS failed, Try with updated Jacobian .");493 infoStreamPrint(LOG_STDOUT, 0, "GBODE: Solution of NLS failed, Try with updated Jacobian at time %g.", gbData->time); 494 494 set_kinsol_parameters(kin_mem, nlsData->size * 4, SUNFALSE, 10, 100*DBL_EPSILON); 495 495 solved = solveNLS(data, threadData, nlsData);
Note: See TracChangeset
for help on using the changeset viewer.