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
  • Index
  • » Users
  • » fnoel
  • » Profile

Posts

Posts

Feb-10-18 09:16:09
FMU is not generated on Linux Xubuntu 16

Openmodelica is running very well. 

Feb-03-18 13:28:34
FMU is not generated on Linux Xubuntu 16

I have installed the latest version (1.12.0) on Linux XUbuntu 16.04.
When I try to generate a FMU : the console said that it was generated on default working directory on /tmp.
But the fmu zip was not there.

I fixed the problem on changing the working directory in OMedit (Tool->Options->General->Working Directory)
in a directory created on my home directory.

If you use the model "instantiate Model" on the left side of the button "Check Model", the flattened model appears in a small window,
so you may check the number of variables and equations.

I have some suggestions.

Don't you think that the connector must be defined outside your model :

Code:


connector TestOutputConnector
  output Real value;
end TestOutputConnector;
model TestFMU1
  parameter Real p = 1.0;
  TestOutputConnector c;
equation
  c.value = p;
end TestFMU1;

The name of your model is TestFMU2 and you want to build oa model called TestFMU1.

Is the tolerance signify :

     |  ( x(i) - x(i+1) ) /  x(i+1) | < tolerance ?

Where x is an unknown and i represent the number of the iteration : x( i ) is the value of an unknown x at the iteration i.

Mar-24-14 18:06:22
Enter a brief description of your topic

The simulation using the binary produced by Open Modelica give the right results but then the model is exported in FMU and executed in FMU
SDK, the results are different.

Mar-03-14 18:32:53
Enter a brief description of your topic

I'm using the FMU SDK to test the generated FMU on OM.

I test this example :

model DiscreteTimeObj
    parameter Real sample_interval = 0.1;
    Real x(start=5.0);
    Real y;
equation
    der(x) = -x;
    when sample(0, sample_interval) then
        y = x;
    end when;
end DiscreteTimeObj;


using the command (binary of the FMU sdk to test the fmu) :

fmusim_me.exe DiscreteTimeObj.fmu 1.0 0.01

that is to say with startTime = 0.0 stopTime=1.0 with a time step imposed to 0.01.
When I plot y, it remains constant to 5.0. This example works on OM : y decreases and has constant values
in the intervals of length 0.1.

Is it a limitation of the generated FMU that doesn't support the directive sample or is it the code of
the fmu testing program work ?

Thank you for the help.

For information, I simulate the model with the following code :

function sech
    input Real x;
    output Real y;
algorithm
    y := 2.0 / (exp(x) + exp(-x));
end sech;

model Hysteretic_curve
    parameter Real N = 1;
    parameter Real l = 0.816;
    parameter Real Ms = 1500000.0;
    parameter Real a = 350.0;
    parameter Real alpha = 0.0007;
    parameter Real c = 0.001;
    parameter Real k = 265.0;
    Real i , der_i_dt;
    Real H , der_H_dt;
    Real H_alpha_M, der_H_alpha_M_dt ;
    Real delta ;
    Real Man, der_Man_dH_alpha_M, der_Man_dt ;
    Real B ;
    Real M(start = 1.0e-6);
    Real coeff_debug1;
equation
    i        =         sqrt(2.0) * 2000.0 * sin(314.0 * time);
    der_i_dt = 314.0 * sqrt(2.0) * 2000.0 * cos(314.0 * time);
    H        = N * i / l ;
    der_H_dt = (N/l) * der_i_dt ;

    H_alpha_M        = ( H        + alpha * M      ) / a;
    der_H_alpha_M_dt = ( der_H_dt + alpha * der(M) ) / a;

    Man                = Ms * (   1.0 / tanh(H_alpha_M)                    - 1.0 /  H_alpha_M     );
    der_Man_dH_alpha_M = Ms * ( -(sech(H_alpha_M))^2 / (tanh(H_alpha_M))^2 + 1.0 / (H_alpha_M^2) ) ;
    der_Man_dt         = der_Man_dH_alpha_M * der_H_alpha_M_dt ;

    if der_H_dt > 0 then
        delta = 1;
    else
        delta = -1;
    end if;

    coeff_debug1 = (1.0 - c) * k - alpha * (Man - M) ;
    der(M) = ((1.0 - c) * der_H_dt * (Man - M)) / ((1.0 - c) * k - alpha * (Man - M)) + c * der_Man_dt;
    B      = 1.2566e-6  * ( H + M );
end Hysteretic_curve;


I think the the problem is due to coeff_debug1 wich tends to 0 during the first time steps.
The derivative of M tends to infinity and the solver is not able to compute a solution.
I used 0.000001 s time step and the crash occurs at t= 0.009021104s

The ODE of must be different if (1.0 - c) * k - alpha * (Man - M) tends to 0

Can send me
   1/ the modified code
   2/ the version of OM you use
   3/ the selected solver

I tried to calculate der(Man) and put it in the code but the my version
of OM crashed after few time steps.

I have a practical but probably not the best solution to your problem :

Code :

model Hysteretic_curve
  parameter Real N = 1;
  parameter Real l = 0.816;
  parameter Real Ms = 1500000.0;
  parameter Real a = 350;
  parameter Real alpha = 0.0007;
  parameter Real c = 0.001;
  parameter Real k = 265;
  constant Real pi = 3.14;
  Real deridt, i, delta, B;
  Real H(start = 0),Man(start = 0),M(start = 0);
equation
  i = sqrt(2) * 2000 * sin(314 * time);
  deridt = sqrt(2) * 2000 * 314 * cos(314 * time);
  der(H) = N * deridt / l;
  //---------------------
  Man = Ms * (1 / tanh((H + alpha * M) / a) - a / (H + alpha * M));
  // Compute der(Man) with der(H) and der(M)
  // You may use Maxima to compute litteral expression
  //---------------------
  if der(H) > 0 then
    delta = 1;
  else
    delta = -1;
  end if;
  der(M) = ((1 - c) * der(H) * (Man - M)) / ((1 - c) * k - alpha * (Man - M)) + c * der(Man);
  B=1.2566e-6*(H+M);
end Hysteretic_curve;

Hi ,

I saw the generated c-code in the temporary folder of windows and I succeed to compile it using the generated makefile.

But I've tried the same manipulation with the Cpp code (in a command line with simCodeTarget=Cpp) :
omc +s +q +simCodeTarget=Cpp MyLib.mo

If I try to compile :
mingw32-make.exe -f MyLib.makefile

The following errors appears :
MyLib.makefile:2: C:/OpenModelica1.9.0Beta//include/omc/cpp/ModelicaConfic.inc: No such file or directory
mingw32-make.exe: *** No rule to make target `C:/OpenModelica1.9.0Beta//include/omc/cpp/ModelicaConfic.inc'.  Stop.
There is no Cpp Folder in C:/OpenModelica1.9.0Beta//include/omc/

I saw that the generated Cpp code is relatively intendant : the main functionalities as initializing parameters, variables, update equations and compute
events are available to describe the system and plug a solver. Do you think in this case that the dependencies on OM environment may be reduced ?

Cheers,

F. NOEL

I'm a new user of the tool
I there a procedure that describe the way to compile the c++ generated code by OMC ?
The header files and the librairies to compile the this code are not available in the setup of OM.

  • Index
  • » Users
  • » fnoel
  • » Profile
You are here: