Opened 7 years ago

Closed 6 years ago

#2559 closed defect (fixed)

Clean exit from Newton solver but error in log

Reported by: jakesson Owned by: Iakov Nakhimovski
Priority: major Milestone: 1.10
Component: FMI/Export Version: trunk
Keywords: Cc:

Description

Consider the following model:

model InitTest1
  Real x1,y1,z1;
  Real x2,y2,z2,w2;
  input Real u1;
  parameter Real p = 4;
initial equation
 der(x1) = if time>=1 then 1 elseif time>=2 then 3 else 5;
equation
 y1 - (if time>=5 then -z1 else z1) + x1 = 3;
 y1 + sin(z1) + x1 = 5 + u1 + p;
 der(x1) = -x1 + z1 * p;
 
y2 - (if time>=5 then -z2 else z1) + x1 = w2;
 y2 + sin(z2 + z1) + x2 = 5 + u1 + p - 3*w2 + der(x2);
 der(x2) = -x2 - x1 + z2 * p + w2;
 w2 + y2 + y1 + z1 + x2 = 4;

end InitTest1;

and the script:

from pymodelica import compile_fmu
from pymodelica import compile_jmu
from pyfmi import load_fmu

n = compile_fmu('InitTest1','InitTest.mo',compiler_log_level='i',
                compiler_options={'generate_only_initial_system':True})
m = load_fmu(n)

# NLE logging: 
# _log_level=5: iterations [NLE_ITERS]
# _log_level=6: jacobians  [NLE_ITERS_JAC]

#m.set_debug_logging(True)
m.set('_log_level',5)
m.set_fmil_log_level(5)
m.set('_nle_solver_log_level',3)

m.set('u1',3)

print 'u1' + str(m.get('u1'))
print 'x1' + str(m.get('x1'))
print 'y1' + str(m.get('y1'))
print 'z1' + str(m.get('z1'))

m.set('y1',0.)

m.initialize()

print "model initialized"

print 'u1' + str(m.get('u1'))
print 'x1' + str(m.get('x1'))
print 'y1' + str(m.get('y1'))
print 'z1' + str(m.get('z1'))

m.set('u1',4)

print "Inpu1t set"

print 'u1' + str(m.get('u1'))
print 'x1' + str(m.get('x1'))
print 'y1' + str(m.get('y1'))
print 'z1' + str(m.get('z1'))

m.get_derivatives()

m.set('y1',0.5)

print "Set initial valu1e of y1"

print 'x1' + str(m.get('x1'))
print 'y1' + str(m.get('y1'))
print 'z1' + str(m.get('z1'))

m.set('p',0.5)

print "Set initial valu1e of p"

print 'x1' + str(m.get('x1'))
print 'y1' + str(m.get('y1'))
print 'z1' + str(m.get('z1'))

The script runs without problems, even though there is an error indicating lack of convergence from the solver in the FMU log:

FMIL: module = Model, log level = 4: [INFO][FMU status:OK] [NLE_ITERS]Block:;1;Scaled norm:;        1.9205130340258350E-02;Residuals:;        0.0000000000000000E+00;        8.2919544415323854E-01;        4.3200998334214091E-11;       -1.7763568394002505E-15;
FMIL: module = Model, log level = 4: [INFO][FMU status:OK] [KINSOL_INFO]nni =    2   nfe =     35   fnorm =        0.01920513034025835
FMIL: module = Model, log level = 4: [INFO][FMU status:OK] [KINSOL_INFO]Return value: -5 (KIN_LINESEARCH_NONCONV)
FMIL: module = Model, log level = 3: [WARNING][FMU status:Warning] [KINSOL_ERROR]Error occured in KINSol at time 0.00s when solving block 1: 
FMIL: module = Model, log level = 3: [WARNING][FMU status:Warning] The line search algorithm was unable to find an iterate sufficiently distinct from the current iterate.
FMIL: module = Model, log level = 3: [WARNING][FMU status:Warning] [KINSOL_ERROR]Current function norm: 0.0192051, scaled step length: 3.92871e+06, tolerance: 1e-10
FMIL: module = Model, log level = 4: [INFO][FMU status:OK] [NLE_ITERS]Block:;1;Newton solver finished;
FMIL: module = Model, log level = 2: [ERROR][FMU status:Error] Could not converge after re-scaling equations in block 1
FMIL: module = Model, log level = 4: [INFO][FMU status:OK] [NLE_ITERS] Model equations evaluation finished

Change History (5)

comment:1 Changed 7 years ago by jakesson

changeset:4395:

Fixed a bug that made it possible for a Newton solver to fail without reporting an error, see #2559. Remains to add test.

comment:2 Changed 7 years ago by jakesson

changeset:4396:

Updated a failing test, see #2559.

comment:3 Changed 7 years ago by jakesson

Owner: set to Iakov Nakhimovski
Status: newassigned

comment:4 Changed 6 years ago by Tove Bergdahl

Milestone: 1.10.x1.10

comment:5 Changed 6 years ago by Iakov Nakhimovski

Resolution: fixed
Status: assignedclosed

r4953:

Added a test that exception is raised when NLE solver does not converge. See #2559

Note: See TracTickets for help on using tickets.