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

OMC-Error

OMC-Error

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?

Re: OMC-Error

Your script seems to be incomplete.
"LimitValue" is a function that receives "minV,maxV,-flowGain*outCtr" as Inputs.
To run your example, you also have to add that function (otherwise, it can be found by the model FlatTank). The code can be found in the same book one paragraph below.

function LimitValue
input Real pMin;
input Real pMax;
input Real p;
output Real pLim;
algorithm
pLim := if p>pMax then pMax
else if p<pMin then pMin
else p;
end LimitValue;

Regards, Jan

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