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

Derivative of inputs not allowed

Derivative of inputs not allowed

I've a model that has to take the derivative of the input.
However, when run, OM says:
Translation    16:07:34        0:0-0:0    Error building simulator. Buildlog: gcc  [...]
Translation    16:07:34        0:0-0:0    The model requires derivatives of some inputs as listed below:
der(SOC)
der(SOC)

Maybe it is just a question of supplying the derivatives at t=0: later the program should be able to calculate them.
But I cannot envisage how to tell the program these t=0 derivatives.
Any suggestions?

Code:


model MinorLoop
  Modelica.Blocks.Interfaces.RealOutput Uoc annotation(Placement(transformation(extent = {{100,-10},{120,10}})));
  Modelica.Blocks.Interfaces.RealInput SOC annotation(Placement(transformation(extent = {{-140,-20},{-100,20}})));
  parameter Real k = 10;
  Real derUocSoc,Corr;
  Modelica.Blocks.Tables.CombiTable1D UocT(smoothness = Modelica.Blocks.Types.Smoothness.ContinuousDerivative, table = [0,2.85,2.85;0.2,3.2,3.22;0.5,3.29,3.31;0.9,3.32,3.34;1,3.39,3.39], columns = {2,3}) annotation(Placement(transformation(extent = {{-50,-10},{-30,10}})));
  Modelica.Blocks.Routing.Replicator replicator(nout = 2) annotation(Placement(transformation(extent = {{-82,-10},{-62,10}})));
initial equation
  Uoc = (UocT.y[1] + UocT.y[2]) / 2;
equation
  if der(SOC) >= 0 then
    derUocSoc = der(UocT.y[2]) / der(SOC);
    Corr = k * (UocT.y[2] - Uoc);
  else
    derUocSoc = der(UocT.y[1]) / der(SOC);
    Corr = -k * (UocT.y[1] - Uoc);
  end if;
  der(Uoc) / der(SOC) = derUocSoc + Corr;
  connect(replicator.u,SOC) annotation(Line(points = {{-84,0},{-120,0}}, color = {0,0,127}, smooth = Smooth.None));
  connect(UocT.u,replicator.y) annotation(Line(points = {{-52,0},{-61,0}}, color = {0,0,127}, smooth = Smooth.None));
  annotation(Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100,-100},{100,100}}), graphics), Icon(coordinateSystem(preserveAspectRatio = false, extent = {{-100,-100},{100,100}}), graphics = {Rectangle(extent = {{-100,100},{100,-100}}, lineColor = {0,0,255}, fillColor = {255,255,255}, fillPattern = FillPattern.Solid)}));
end MinorLoop;


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