Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Adding linearization support for MultiBody library and CombiTables

Adding linearization support for MultiBody library and CombiTables

The nightly openmodelica package  just returns 0 when linearizing a model with a MultiBody.Body for A/B/C/D, and stable/ release return errors. Are there plans to support this. I would be willing to help fix it if someone can point me in the right direction. I'm trying to linearize an aircraft based on the MultiBody library and using Modelica.Blocks.CombiTables so I need all of this to be working with the linearization. An option to do a simple finite difference Jacobian approximation would also be useful until the symbolic jacobian is fully working. I would also be willing to help write this but again need some direction as where the code should be added.

Re: Adding linearization support for MultiBody library and CombiTables

I'm working on tracking down the error with combi tables with the nightly openmodelica:

Here is the test model:

model Linearization
  import Modelica.Blocks.Tables.CombiTable1Ds;
  CombiTable1Ds testTable(table={{0,0},{1,1}},columns={2});
  Real x1(start=1);
  Real x2(start=2);
  parameter Real a=6,b=2,c=4;
  input Real u = 0;
  output Real y;
  Real tVal;
equation
  connect(testTable.y[1],tVal);
  connect(testTable.u,u);
  der(x1) = x1*(a-b*x1-x2);
  der(x2) = x2*(c-x1-x2) + tVal;
  y = x1 * u + x2 * u;
end Linearization;

here is the backtrace:

(gdb) run -l 0
Starting program: /tmp/jgoppert/Linearization -l 0
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
Linearization will performed at point of time: 0

Program received signal SIGSEGV, Segmentation fault.
0x0804df87 in eqFunction_11 (data=0xbffff000, discreteCall=0 '\000') at Linearization.c:599
599      $Py$pDERAdummyVarA = (($Px1$pDERAx1 * $Pu) + ($Px2$pDERAx2 * $Pu));
(gdb) backtrace
#0  0x0804df87 in eqFunction_11 (data=0xbffff000, discreteCall=0 '\000')
    at Linearization.c:599
#1  0x0804e1cf in functionJacA_column (data=0xbffff000) at Linearization.c:619
#2  0x0804e4a6 in functionJacA_dense (data=0xbffff000, jac=0x80ddb18) at Linearization.c:652
#3  0x0805e8e7 in linearize(DATA*) ()
#4  0x0805d171 in startNonInteractiveSimulation(int, char**, DATA*) ()
#5  0x0805d9c3 in _main_SimulationRuntime ()
#6  0x08050cc2 in main (argc=3, argv=0xbffff214) at Linearization.c:1263

Re: Adding linearization support for MultiBody library and CombiTables

This seems to be a general problem with linearization for the nightly build. It can't even linearize without a combitable, I'm switching to stable to test the combitable support.

Re: Adding linearization support for MultiBody library and CombiTables

In stable, combitables have the jacobian computed correctly, but the linearization is not correct:
The equation used is:

der(x) = A*x + B*u;
y = C*x +  D*u;

where: A=df/dx, B=df/du, C = dh/dx, D = dh/du

The above equation only works for u0=0, x0=0, dx0=0, and y0=0. (The typical conditions for equilibrium).
For this to work in general these equations should be used instead:

der(x) = A*(x-x0) + B*(u-u0) + dx0;
y = C*(x-x0) +  D*(u-u0) + y0;

Also, for blocks with no states, there is an error due to incorrect syntax with the dummy x variable added:
Real x_P$dummy = x[1];

Re: Adding linearization support for MultiBody library and CombiTables

Attempting to linearize a MultiBody example on stable:

model Body
  import Modelica.Mechanics.MultiBody.Parts.Body;
  import Modelica.Mechanics.MultiBody.World;
  inner World world;
  Body body;
end Body;

Yields these errors:

Error: Internal error BackendDAEOptimize.derive failed: ARRAY_EQUATION-case
Error: Internal error BackendDAEOptimize.derive failed
Error: Internal error BackendDAEOptimize.deriveAll failed
Error: Internal error BackendDAEOptimize.derive failed: ARRAY_EQUATION-case
Error: Internal error BackendDAEOptimize.derive failed
Error: Internal error BackendDAEOptimize.deriveAll failed
Error: Internal error BackendDAEOptimize.generateSymbolicJacobian failed
Error: Internal error BackendDAEOptimize.createJacobian failed
Error: Internal error Generation of LinearModel Matrices failed. Function: BackendDAEOpimize.createLinearModelMatrixes
Error: Internal error Optimisation Module generateSymbolicLinearization failed.
Error: Internal error array equations currently only supported on form v = functioncall(...)
Error: Internal error createOdeSystem failed for Array 0 {16, 17, 18}
Error: Internal error createEquations failed
Error: Internal error createOdeSystem failed for {29:19}
Error: Internal error createEquations failed
Error: Internal error createOdeSystem failed for {7:26}
Error: Internal error createEquations failed
Error: Internal error createOdeSystem failed for {30:20}

Re: Adding linearization support for MultiBody library and CombiTables

For now, I'm getting around this error by using my own kinematics with a multibody frame connector. It seems to be due to the array-equation case not being handled yet. Stable did linearize my own kinematics block.

Re: Adding linearization support for MultiBody library and CombiTables

I was able to get multibody to linearize correctly by making one small change:

I replaced:

Code:

    

    annotation (derivative(noDerivative=R) = Internal.resolve2_der,
        __Dymola_InlineAfterIndexReduction=true);

with:

Code:

    

    annotation(Inline=true);
    annotation (derivative(noDerivative=R) = Internal.resolve2_der,
        __Dymola_InlineAfterIndexReduction=true);

Note that putting:

Code:

    

     annotation (Inline=true,derivative(noDerivative=R) = Internal.resolve2_der,
        __Dymola_InlineAfterIndexReduction=true);

Also does not work for some reason.

There are 0 guests and 0 other users also viewing this topic
You are here: