Opened 10 years ago

Closed 7 years ago

#2839 closed defect (fixed)

Jacobi matrix not calculated correctly when I give Linearization time in simulate-command

Reported by: hage02@… Owned by: Willi Braun
Priority: high Milestone: Future
Component: *unknown* Version: trunk
Keywords: linearization Cc:

Description (last modified by Willi Braun)

I have OpenModelica 1.9.0 for Windows, and I want to get the Jacobian
(linearization).

When I simulate a model and I do Simulation flags: Jacobian Matrix it is
generated for a lot of timesteps (=ok),
but when I add a Linearization Time(optional): I get a generated linear
model with A (from A-B-C-D-matrix) which should be the Jacobian , but the
elements are false. I get values of 3e-314 etc., clearly nok.

Happens with also the smallest models (copy/paste the following model):

model probeer
  Modelica.Mechanics.Translational.Components.Mass mass1(m = 1, s(start = 0.1)) annotation(Placement(visible = true, transformation(origin = {-18.1034,26.4368}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Mechanics.Translational.Components.Spring spring1(c = 1000) annotation(Placement(visible = true, transformation(origin = {14.9425,25.8621}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Mechanics.Translational.Components.Fixed fixed1 annotation(Placement(visible = true, transformation(origin = {52.5862,24.1379}, extent = {{-10,-10},{10,10}}, rotation = 0)));
equation
  connect(spring1.flange_b,fixed1.flange) annotation(Line(points = {{24.9425,25.8621},{52.5862,25.8621},{52.5862,24.1379},{52.5862,24.1379}}));
  connect(mass1.flange_b,spring1.flange_a) annotation(Line(points = {{-8.10345,26.4368},{4.31034,26.4368},{4.31034,26.4368},{4.31034,26.4368}}));
  annotation(Icon(coordinateSystem(extent = {{-100,-100},{100,100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2,2})), Diagram(coordinateSystem(extent = {{-100,-100},{100,100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2,2})), experiment(StartTime = 0, StopTime = 1, Tolerance = 0.000001));
end probeer;

The jacobian should be:
0 1
-1000 0

Output (linearization at t=0):
stdout | info | Linearization will performed at point of time: 0.000000
LOG_INIT | info | ### START INITIALIZATION ###
LOG_INIT | info | updating start-values
LOG_INIT | info | initialization method: symbolic [solves the initialization problem symbolically - default]
LOG_SOTI | info | ### SOLUTION OF THE INITIALIZATION ###
| | | | | states variables
| | | | | | [1] Real mass1.v(start=0, nominal=1) = 0 (pre: 0)
| | | | | | [2] Real mass1.s(start=0.1, nominal=1) = 0.1 (pre: 0.1)
| | | | | derivatives variables
| | | | | | [3] Real der(mass1.v) = -100 (pre: 0)
| | | | | | [4] Real der(mass1.s) = 0 (pre: 0)
| | | | | other real variables
| | | | | | [5] Real spring1.f(start=0, nominal=1) = -100 (pre: 0)
| | | | | | [6] Real spring1.s_rel(start=0, nominal=1) = -0.1 (pre: 0)
| | | | | | [7] Real mass1.a(start=0, nominal=1) = -100 (pre: 0)
| | | | | | [8] Real mass1.flange_b.s(start=0, nominal=1) = 0.1 (pre: 0)
| | | | | | [9] Real mass1.flange_a.s(start=0, nominal=1) = 0.1 (pre: 0)
| | | | | | [10] Real mass1.flange_a.f(start=0, nominal=1) = 0 (pre: 0)
| | | | | integer variables
| | | | | boolean variables
| | | | | string variables
LOG_INIT | info | ### END INITIALIZATION ###
LOG_STATS | info | ### STATISTICS ###
LOG_STATS | info | timer
| | | | | 4.61831e-005s [ 6.6%] pre-initialization
| | | | | 0.000128286s [ 18.3%] initialization
| | | | | 0s [ 0.0%] steps
| | | | | 0s [ 0.0%] creating output-file
| | | | | 0s [ 0.0%] event-handling
| | | | | 0s [ 0.0%] overhead
| | | | | 0.000525608s [ 75.1%] simulation
| | | | | 0.000700077s [100.0%] total
LOG_STATS | info | events
| | | | | 0 state events
| | | | | 0 time events
LOG_STATS | info | solver
| | | | | 0 steps taken
| | | | | 0 calls of functionODE
| | | | | 0 evaluations of jacobian
| | | | | 0 error test failures
| | | | | 0 convergence test failures
LOG_STATS | info | ### END STATISTICS ###
Caluculate one col:
LOG_JAC | info | seed: data->simulationInfo.analyticJacobians[index].seedVars[0]= 1.000000
LOG_JAC | info | seed: data->simulationInfo.analyticJacobians[index].seedVars[1]= 0.000000
LOG_JAC | info | write in jac[0]-[0,0]=6.36599e-314 from row[0]=6.36599e-314
LOG_JAC | info | write in jac[1]-[0,1]=9.00067e-308 from row[0]=9.00067e-308
Caluculate one col:
LOG_JAC | info | seed: data->simulationInfo.analyticJacobians[index].seedVars[0]= 0.000000
LOG_JAC | info | seed: data->simulationInfo.analyticJacobians[index].seedVars[1]= 1.000000
LOG_JAC | info | write in jac[2]-[1,0]=6.36599e-314 from row[1]=6.36599e-314
LOG_JAC | info | write in jac[3]-[1,1]=9.00067e-308 from row[1]=9.00067e-308
LOG_JAC | info | Print jac:

6.36599e-314 6.36599e-314
9.00067e-308 9.00067e-308

LOG_STATS | info | model linear_probeer
| | | | parameter Integer n = 2; states
| | | | parameter Integer k = 0;
top-level inputs
| | | | parameter Integer l = 0; top-level outputs
| | | | parameter Real x0[2] = {0,0.1};
| | | | parameter Real u0[0] = {i for i in 1:0};
| | | | parameter Real A[2,2] = [6.365987385741524e-314,6.365987385741524e-314;9.000674322924625e-308,9.000674322924625e-308];
| | | | parameter Real B[2,0] = zeros(2,0);
| | | | parameter Real C[0,2] = zeros(0,2);
| | | | parameter Real D[0,0] = zeros(0,0);
| | | | Real x[2](start=x0);
| | | | input Real u[0];
| | | | output Real y[0];
| | | |
| | | | Real x_Pmass1Pv = x[1];
| | | | Real x_Pmass1Ps = x[2];
| | | |
| | | | equation
| | | | der(x) = A * x + B * u;
| | | | y = C * x + D * u;
| | | | end linear_probeer;
| | | |
stdout | info | Linear model is created!

Change History (3)

comment:1 by Adrian Pop, 10 years ago

Owner: changed from willi braun to Willi Braun
Status: newassigned

comment:2 by Willi Braun, 10 years ago

Description: modified (diff)
Status: assignedaccepted
Summary: JAcobi matrix not calculated correctly when I give Linearization time in simulate-commandJacobi matrix not calculated correctly when I give Linearization time in simulate-command

Okay, actually the linearisation works fine and I get the expected result, but I need to add an error messages when the linearization was not created but is tried to use.
Since the linearizeation is created ether with the api-call linearize(modelname, stoptime) or by adding +generateSymbolicLinearization as argument to omc.

Last edited 10 years ago by Willi Braun (previous) (diff)

comment:3 by Willi Braun, 7 years ago

Resolution: fixed
Status: acceptedclosed

In the meanwhile we have for this cases the numerical linearization.

Note: See TracTickets for help on using tickets.