Help - Search - Members - Calendar
Full Version: Integrator with reset at given value
Modelica Forum > Modelica > Modelica
denis
Hi folks,
I have got the following problem with my modelica model:
I want to create an integrator i.e. der(x)=2 and when x reaches the value of 5 the value of x should jump back to zero and then integration should start again.

I tried it the following way:

algorithm
der(x) =2;
when x>5 then
x :=0; //this assignment might be the problem, since it leads to too many equations
end when;

I am urged not to use any trigger, since the integrator should work for any der(x)=f(t).

thanks for your help,
denis
wagner
Hi denis,

the problem is, as you already stated, the x:=0 assignment. Modelica provides a function which is called reinit. With reinit you can reinitialize state variables.

A model with the bahviour you'd like to have looks like this:

QUELLTEXT

model ResetIntegrator
  Real x(start=0);
equation
  der(x)=2;
  when (x>5) then
    reinit(x,0); //here the integrator is reseted to zero
  end when;
end ResetIntegrator;


Regards

wagner
denis
Thank you. Very helpful tip.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.