Question: Simple Totalizer for dynamic simulation question

Hello again,

I have another simple question. I have a dynamic simulation that I've put together, and I'm solving the system of equations using "dsolve(odeset,numeric)", and all is going well there. However, I added a "product totalizer" that integrates my exit flow with the command:

Ptotal := ptot(t) = int(Fexit, t)

And that works well if the Fexit is a fixed number in my simulation. However, I wanted to change the Fexit variable at certain points in time, so I used the piecewise command:

Fexit := piecewise(`and`(t >= 25, t < 30), 2, `and`(t >= 35, t < 34), 2, 0)

The simulation looks fine with the piecewise logic, but the integration above does not. It looks like the integration resets itself to zero where the steps occur. So my questions are:

1. Why is this happening (probably related to the numerical algorithm and the discontinuity)?
2. Can I stop the integration from resetting when the piecewise changes occur?
3. Is there a better way of doing this?
4. Is there an easier way of inducing a up-down step pattern to a dynamic simulation like this?

Thanks in advance! This is a lot of fun!

Fred
Please Wait...