Skip to content

Commit

Permalink
Logging of homotopy path fixed.
Browse files Browse the repository at this point in the history
  - Save csv file without "sep=," in first line. OMEdit can't open the file
    with that.
  - Workaround for `homotopy parameter lambda` print to work with asserts.
  • Loading branch information
AnHeuermann authored and sjoelund committed Aug 8, 2019
1 parent cb352b8 commit 895ffe6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
Expand Up @@ -267,6 +267,7 @@ static int symbolic_initialization(DATA *data, threadData_t *threadData)
{
long step;
char buffer[4096];
double lambda;

infoStreamPrint(LOG_INIT, 0, "Global homotopy with equidistant step size started.");

Expand All @@ -277,9 +278,10 @@ static int symbolic_initialization(DATA *data, threadData_t *threadData)
sprintf(buffer, "%s_equidistant_global_homotopy.csv", mData->modelFilePrefix);
infoStreamPrint(LOG_INIT, 0, "The homotopy path will be exported to %s.", buffer);
pFile = omc_fopen(buffer, "wt");
fprintf(pFile, "\"sep=%s\"\n%s", sep, "\"lambda\"");
for(i=0; i<mData->nVariablesReal; ++i)
fprintf(pFile, "\"lambda\"");
for(i=0; i<mData->nVariablesReal; ++i) {
fprintf(pFile, "%s\"%s\"", sep, mData->realVarsData[i].info.name);
}
fprintf(pFile, "\n");
}
#endif
Expand All @@ -288,23 +290,26 @@ static int symbolic_initialization(DATA *data, threadData_t *threadData)
for(step=0; step<init_lambda_steps; ++step)
{
data->simulationInfo->lambda = ((double)step)/(init_lambda_steps-1);
infoStreamPrint(LOG_INIT, 0, "homotopy parameter lambda = %g", data->simulationInfo->lambda);
lambda = data->simulationInfo->lambda;
infoStreamPrint(LOG_INIT, 0, "homotopy parameter lambda = %g", lambda);

if(data->simulationInfo->lambda > 1.0) {
if(data->simulationInfo->lambda > 1.0)
{
data->simulationInfo->lambda = 1.0;
lambda = 1.0;
}

if(0 == step)
data->callback->functionInitialEquations_lambda0(data, threadData);
else
data->callback->functionInitialEquations(data, threadData);

infoStreamPrint(LOG_INIT, 0, "homotopy parameter lambda = %g done\n---------------------------", data->simulationInfo->lambda);
infoStreamPrint(LOG_INIT, 0, "homotopy parameter lambda = %g done\n---------------------------", lambda);

#if !defined(OMC_NO_FILESYSTEM)
if(ACTIVE_STREAM(LOG_INIT))
{
fprintf(pFile, "%.16g", data->simulationInfo->lambda);
fprintf(pFile, "%.16g", lambda);
for(i=0; i<mData->nVariablesReal; ++i)
fprintf(pFile, "%s%.16g", sep, data->localData[0]->realVars[i]);
fprintf(pFile, "\n");
Expand Down
30 changes: 15 additions & 15 deletions testsuite/simulation/modelica/initialization/homotopy4_solver.mos
Expand Up @@ -647,13 +647,13 @@ readFile("homotopy4_solver_system.log"); remove("homotopy4_solver_system.log");
// LOG_INIT | info | homotopy process
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 0
// LOG_INIT | info | homotopy parameter lambda = 1 done
// LOG_INIT | info | homotopy parameter lambda = 0 done
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 0.333333
// LOG_INIT | info | homotopy parameter lambda = 1 done
// LOG_INIT | info | homotopy parameter lambda = 0.333333 done
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 0.666667
// LOG_INIT | info | homotopy parameter lambda = 1 done
// LOG_INIT | info | homotopy parameter lambda = 0.666667 done
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 1
// LOG_INIT | info | homotopy parameter lambda = 1 done
Expand Down Expand Up @@ -736,13 +736,13 @@ readFile("homotopy4_solver_system.log"); remove("homotopy4_solver_system.log");
// LOG_INIT | info | homotopy process
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 0
// LOG_INIT | info | homotopy parameter lambda = 1 done
// LOG_INIT | info | homotopy parameter lambda = 0 done
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 0.333333
// LOG_INIT | info | homotopy parameter lambda = 1 done
// LOG_INIT | info | homotopy parameter lambda = 0.333333 done
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 0.666667
// LOG_INIT | info | homotopy parameter lambda = 1 done
// LOG_INIT | info | homotopy parameter lambda = 0.666667 done
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 1
// LOG_INIT | info | homotopy parameter lambda = 1 done
Expand Down Expand Up @@ -825,13 +825,13 @@ readFile("homotopy4_solver_system.log"); remove("homotopy4_solver_system.log");
// LOG_INIT | info | homotopy process
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 0
// LOG_INIT | info | homotopy parameter lambda = 1 done
// LOG_INIT | info | homotopy parameter lambda = 0 done
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 0.333333
// LOG_INIT | info | homotopy parameter lambda = 1 done
// LOG_INIT | info | homotopy parameter lambda = 0.333333 done
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 0.666667
// LOG_INIT | info | homotopy parameter lambda = 1 done
// LOG_INIT | info | homotopy parameter lambda = 0.666667 done
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 1
// LOG_INIT | info | homotopy parameter lambda = 1 done
Expand Down Expand Up @@ -914,13 +914,13 @@ readFile("homotopy4_solver_system.log"); remove("homotopy4_solver_system.log");
// LOG_INIT | info | homotopy process
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 0
// LOG_INIT | info | homotopy parameter lambda = 1 done
// LOG_INIT | info | homotopy parameter lambda = 0 done
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 0.333333
// LOG_INIT | info | homotopy parameter lambda = 1 done
// LOG_INIT | info | homotopy parameter lambda = 0.333333 done
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 0.666667
// LOG_INIT | info | homotopy parameter lambda = 1 done
// LOG_INIT | info | homotopy parameter lambda = 0.666667 done
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 1
// LOG_INIT | info | homotopy parameter lambda = 1 done
Expand Down Expand Up @@ -1003,13 +1003,13 @@ readFile("homotopy4_solver_system.log"); remove("homotopy4_solver_system.log");
// LOG_INIT | info | homotopy process
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 0
// LOG_INIT | info | homotopy parameter lambda = 1 done
// LOG_INIT | info | homotopy parameter lambda = 0 done
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 0.333333
// LOG_INIT | info | homotopy parameter lambda = 1 done
// LOG_INIT | info | homotopy parameter lambda = 0.333333 done
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 0.666667
// LOG_INIT | info | homotopy parameter lambda = 1 done
// LOG_INIT | info | homotopy parameter lambda = 0.666667 done
// | | | | ---------------------------
// LOG_INIT | info | homotopy parameter lambda = 1
// LOG_INIT | info | homotopy parameter lambda = 1 done
Expand Down

0 comments on commit 895ffe6

Please sign in to comment.