Skip to content

Commit

Permalink
- fixed keepHessian
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20844 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Vitalij Ruge committed May 26, 2014
1 parent 7d241f2 commit 2d3d4cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Expand Up @@ -52,9 +52,6 @@ inline void allocate_der_struct(OptDataStructure *s, OptDataDim * dim, DATA* dat
const int nJ2 = dim->nJ2;
const int nx = dim->nx;
int i, j, k;
const int nH0 = optData->dim.nH0_;
const int nH1 = optData->dim.nH1_;
const int nhess = (nsi*np-1)*nH0+nH1;
char * cflags;

cflags = (char*)omc_flagValue[FLAG_UP_HESSIAN];
Expand Down Expand Up @@ -164,8 +161,12 @@ inline void allocate_der_struct(OptDataStructure *s, OptDataDim * dim, DATA* dat
for(j = 0; j < nv; ++j)
optData->Hl[j] = (long double *)calloc(nv, sizeof(long double));

if(optData->dim.updateHessian > 0)
if(optData->dim.updateHessian > 0){
const int nH0 = optData->dim.nH0_;
const int nH1 = optData->dim.nH1_;
const int nhess = (nsi*np-1)*nH0+nH1;
optData->oldH = (double *)malloc(nhess*sizeof(double));
}

optData->dim.iter_updateHessian = optData->dim.updateHessian-1;

Expand Down
6 changes: 4 additions & 2 deletions SimulationRuntime/c/simulation/solver/nonlinearSystem.c
Expand Up @@ -375,13 +375,15 @@ double extraPolate(DATA *data, double old1, double old2)
{
double retValue;

if(data->localData[1]->timeValue == data->localData[2]->timeValue)
if( data->localData[1]->timeValue == data->localData[2]->timeValue || old1 == old2)
{
retValue = old1;
}
else
{
retValue = old2 + ((data->localData[0]->timeValue - data->localData[2]->timeValue)/(data->localData[1]->timeValue - data->localData[2]->timeValue)) * (old1-old2);
retValue = ((data->localData[0]->timeValue - data->localData[2]->timeValue)*old1 +
(data->localData[1]->timeValue - data->localData[0]->timeValue)*old2)/
(data->localData[1]->timeValue - data->localData[2]->timeValue);
}

return retValue;
Expand Down

0 comments on commit 2d3d4cd

Please sign in to comment.