Simulation time affects simulation output

2 views (last 30 days)
Rasmus Pierong
Rasmus Pierong on 9 Jan 2014
Answered: Mischa Kim on 12 Jan 2014
I am simulating the rather complex process of algae and bacteria dynamics in a waste water treatment plant using Simulink (MATLAB varsion 2012a). A snapshot illustrating the model set-up is attached. All dynamics are defined in a MATLAB S-function and simulations are done using the ode15s solver.
A simulation of 13 days yields reasonable output data. As an example I attach a graph of the ammonium, ammonia, nitrite and nitrate concentrations.
A simulation of 14 days yields incorrect output data in terms of negative concentrations. As an example I attach the corresponding graph of the ammonium, ammonia, nitrite and nitrate concentrations. The very strange thing is that the negative concentrations appear after nine or ten days allready (not possible to see from the graph). For example the nitrate concentration is about -1e7 g(NO3-N)*m⁻³ after ten days.
How can this be possible? Should not the 13 first days of the 14 days simulation be identical to the corresponding days of the 13 days simulation? Have anyone encountered any similar model behaviour?

Answers (1)

Mischa Kim
Mischa Kim on 12 Jan 2014
In a perfect world, yes, you would get the same results. Numerical integration is everything but perfect though. Just a couple of thoughts:
  • Is there a reason you are using ode15s (typically fairly low accuracy)? Have you tried ode45 , for starters?
  • Try playing around with absolute and relative integration tolerances (> Simulation > Model Configuration Parameters). The default of 1e-3 for relative tolerance is huge, especially for long integration times.

Categories

Find more on Statics and Dynamics in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!