- Index
- » Programming
- » Modelica Language
- » reset continuous increasing variable...
reset continuous increasing variable and continue the increase
reset continuous increasing variable and continue the increase
Hey, im just starting with OM and i think my problem is really basic, but anyway i don't find a solution, here it is:
I have a diameter that should be increased continous and after reaching a specific diameter it should be set to the beginning value, but the increasing should continue after this. So it should be like:
0: 0.1
1: 0.2
2: 0.3
3: 0.1 <- reset point
4: 0.2
My Code looks like this
Code:
if s>s_max then
s= s_0;
else
der(s)= + v_grow;
end if;
where v_grow is the growing speed in m/s, s the diameter and s_0 the diameter for reset and start.
The Problem is, that if when s>s_max is reached, modelica tries to calculate the der(s) term anyway and runs into an error. But i don't know why....
Re: reset continuous increasing variable and continue the increase
I am guessing you want a saw-tooth wave form. I suggest a use of when for such event trigger situations.
Try this:
Code:
model ResetVariable
Real s;
Real v_grow = 2;
parameter Real s_0 = 0;
parameter Real s_max = 10;
initial equation
s = s_0;
equation
der(s) = v_grow;
when s>s_max then
reinit(s, s_0);
end when;
end ResetVariable;
- Index
- » Programming
- » Modelica Language
- » reset continuous increasing variable...