Including a causal relation in a Modelica simulation leads to translation Error while flattening model

我们两清 提交于 2019-12-31 05:23:07

问题


I want to simulate a controller for a mass-spring model which works based on energy:

model model
//constants
  parameter Real m = 1;
  parameter Real k = 1;
  parameter Real Fmax = 3;
  parameter Real x0 = 1;
  parameter Real x1 = 2;
  parameter Real t1 = 1;

//variables
  Real x, v, a, xy, vm;

initial equation
  x = x0;
  v = 2;

equation
  v = der(x);
  a = der(v);
  m * a + k * x = F;

algorithm
  vm := sign(xy - x)*sqrt(2 * (Fmax * abs(xy - x) + k * (xy^2 - x^2) / 2) / m);

  // step signal
  if time  < t1 then
    xy := x0;
  else 
    xy := x1;
  end if;

  if xy == x then
    F := k * x;
  else
    F := sign(vm - v) * Fmax;
  end if;
end model;

But it leads to the erorr message:

Translation Error

Error occurred while flattening model

I would appreciate if you could help me know what is the problem and how I can fix it.

P.S.1. SIMULINK is also not able to finish!

P.S.2. New version of the code can be seen here.

来源:https://stackoverflow.com/questions/54782904/including-a-causal-relation-in-a-modelica-simulation-leads-to-translation-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!