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
  • » VladimirDP
  • » Profile

Posts

Posts

Feb-25-19 07:42:44
I look for a block of OMEdit similar to S-function of Simulink

Dear colleagues,

I have to build up a model containing a set of differential equations and PID Controller in OMEdit. I have found the block "Der". There is only one differential equation can be used.  Does the OMEdit have a block similar to the S-function of Simulink to solve a set of differential equations? Enclosed, please, find out my model made in Simulink.

Regards, Vladimir.

Oct-23-15 18:02:47
Category: Programming

One can find in the book of Peter Fritzson "Introduction to Object-Oriented Modeling..." the script:

model FlatTank
// Tank related variables and parameters
parameter Real flowLevel(unit="m3/s")=0.02;
parameter Real area(unit="m2") =1;
parameter Real flowGain(unit="m2/s") =0.05;
Real h(start=0,unit="m") "Tank level";
Real qInflow(unit="m3/s") "Flow through input valve";
Real qOutflow(unit="m3/s") "Flow through output valve";
// Controller related variables and parameters
parameter Real K=2 "Gain";
parameter Real T(unit="s")= 10 "Time constant";
parameter Real minV=0, maxV=10; // Limits for flow output
Real ref = 0.25 "Reference level for control";
Real error "Deviation from reference level";
Real outCtr "Control signal without limiter";
Real x; "State variable for controller";
equation
assert(minV>=0,"minV must be greater or equal to zero");//
der(h) = (qInflow-qOutflow)/area; // Mass balance equation
qInflow = if time>150 then 3*flowLevel else flowLevel;
qOutflow = LimitValue(minV,maxV,-flowGain*outCtr);
error = ref-h;
der(x) = error/T;
outCtr = K*(error+x);
end FlatTank;

The error occurred while flattening model FlatTank:
""[<interactive>:22:1-22:50:writable] Error: Class LimitValue not found in scope FlatTank (looking for a function or record)."
How to correct the script?

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