From 737e02469c6dfca6ad002f2816637c6cef0d64fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20T=C3=A4uber?= Date: Mon, 23 May 2016 23:48:51 +0200 Subject: [PATCH] Change input tol of Newton solver to 2-norm ticket:3923 --- SimulationRuntime/c/simulation/solver/model_help.c | 4 ++-- .../c/simulation/solver/nonlinearSolverHomotopy.c | 6 +++--- SimulationRuntime/c/util/simulation_options.c | 14 ++++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/SimulationRuntime/c/simulation/solver/model_help.c b/SimulationRuntime/c/simulation/solver/model_help.c index 0239b12a661..266877236df 100644 --- a/SimulationRuntime/c/simulation/solver/model_help.c +++ b/SimulationRuntime/c/simulation/solver/model_help.c @@ -53,8 +53,8 @@ int maxEventIterations = 20; double linearSparseSolverMaxDensity = 0.2; int linearSparseSolverMinSize = 4001; -double newtonXTol = 1e-24; -double newtonFTol = 1e-24; +double newtonXTol = 1e-12; +double newtonFTol = 1e-12; const size_t SIZERINGBUFFER = 3; int compiledInDAEMode = 0; diff --git a/SimulationRuntime/c/simulation/solver/nonlinearSolverHomotopy.c b/SimulationRuntime/c/simulation/solver/nonlinearSolverHomotopy.c index 9b43e24371b..fad16f1f516 100644 --- a/SimulationRuntime/c/simulation/solver/nonlinearSolverHomotopy.c +++ b/SimulationRuntime/c/simulation/solver/nonlinearSolverHomotopy.c @@ -150,8 +150,8 @@ int allocateHomotopyData(int size, void** voiddata) data->initialized = 0; data->n = size; data->m = size + 1; - data->xtol = newtonXTol; - data->ftol = newtonFTol; + data->xtol = newtonXTol*newtonXTol; + data->ftol = newtonFTol*newtonFTol; data->error_f = 0; @@ -1279,7 +1279,7 @@ static int newtonAlgorithm(DATA_HOMOTOPY* solverData, double* x) /* debug information */ - debugString(LOG_NLS_V, "error measurements:"); + debugString(LOG_NLS_V, "error measurements (squared):"); debugDouble(LOG_NLS_V, "delta_x =", delta_x); debugDouble(LOG_NLS_V, "delta_x_scaled =", delta_x_scaled); debugDouble(LOG_NLS_V, "eps_x =", solverData->xtol); diff --git a/SimulationRuntime/c/util/simulation_options.c b/SimulationRuntime/c/util/simulation_options.c index a46622965a0..4eca7149039 100644 --- a/SimulationRuntime/c/util/simulation_options.c +++ b/SimulationRuntime/c/util/simulation_options.c @@ -148,8 +148,8 @@ const char *FLAG_DESC[FLAG_MAX+1] = { /* FLAG_MAX_ORDER */ "value specifies maximum integration order, used by dassl solver", /* FLAG_MAX_STEP_SIZE */ "value specifies maximum absolute step size, used by dassl solver", /* FLAG_MEASURETIMEPLOTFORMAT */ "value specifies the output format of the measure time functionality", - /* FLAG_NEWTON_FTOL */ "[double (default 1e-24)] tolerance for accepting accuracy in Newton solver", - /* FLAG_NEWTON_XTOL */ "[double (default 1e-24)] tolerance for updating solution vector in Newton solver", + /* FLAG_NEWTON_FTOL */ "[double (default 1e-12)] tolerance respecting residuals for updating solution vector in Newton solver", + /* FLAG_NEWTON_XTOL */ "[double (default 1e-12)] tolerance respecting newton correction (delta_x) for updating solution vector in Newton solver", /* FLAG_NEWTON_STRATEGY */ "value specifies the damping strategy for the newton solver", /* FLAG_NLS */ "value specifies the nonlinear solver", /* FLAG_NLS_INFO */ "outputs detailed information about solving process of non-linear systems into csv files.", @@ -290,11 +290,13 @@ const char *FLAG_DETAILED_DESC[FLAG_MAX+1] = { " * gif\n" " * ...", /* FLAG_NEWTON_FTOL */ - " Tolerance for accepting accuracy in Newton solver." - " The value is a Double with default value 1e-24.", + " Tolerance respecting residuals for updating solution vector in Newton solver." + " Solution is accepted if the (scaled) 2-norm of the residuals is smaller than the tolerance newtonFTol and the (scaled) newton correction (delta_x) is smaller than the tolerance newtonXTol." + " The value is a Double with default value 1e-12.", /* FLAG_NEWTON_XTOL */ - " Tolerance for updating solution vector in Newton solver." - " The value is a Double with default value 1e-24.", + " Tolerance respecting newton correction (delta_x) for updating solution vector in Newton solver." + " Solution is accepted if the (scaled) 2-norm of the residuals is smaller than the tolerance newtonFTol and the (scaled) newton correction (delta_x) is smaller than the tolerance newtonXTol." + " The value is a Double with default value 1e-12.", /* FLAG_NEWTON_STRATEGY */ " Value specifies the damping strategy for the newton solver.", /* FLAG_NLS */