ode45 integration issues for some choices of physical parameters,
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi there!
I have a simple, two-dimensional, ode model that solves for the trajectory of a flat plate falling through a fluid flow. Within my ode model, I have also modeled the aerodynamic lift and drag forces on the plate ('wing'). When I go to solve this ode model using ode45, I notice that for certain choices of density, say, that of paper for the wing, and that of still air for the fluid, ode45 seems to happy to solve my equations, for as long of a time interval as I want to specify. However, when I change the densities to be that of aluminum for the wing, and that of still water for the fluid, ode45 is not happy, and gives me the integration tolerance error message:
Warning: Failure at t=2.240647e+00. Unable to meet integration tolerances without reducing the step size below the smallest value allowed
(7.105427e-15) at time t.
In trying to troubleshoot this error, I commented out my new lift and drag force models and instead used very simple lift and drag expressions. However, I still get the above integration tolerance error, which suggests that the issues are not with my fluid force model, and that the issue is somewhere else.
How could I best troubleshoot this issue?
Here are some thoughts of mine:
- I'm not aware of any division by zero being performed;
- the simulations for paper density and still air density look pretty sensible and pass a number of basic sanity checks;
- the simulations with a background moving flow field also look pretty sensible and pass a number of basic sanity checks;
- the fluid force model is possibly, perhaps likely, non-differentiable at two corner points; and
- when I significantly reduce the fluid density, and keep the wing density to be that of aluminum, then the integration seems fine.
Why would changing densities make my ode model hard to integrate by ode45?
Does fluid density, say, that of still water, cause issues for integration? I would have to guess that this is not the real issue.
Update: I fixed the above issue, but still get integration tolerance issues, when I go to vary other parameters.
So, the above question is truly about varying parameters in general (I think), and less specifically about fluid density or wing density.
Thanks in advance,
2 commentaires
Réponse acceptée
Star Strider
le 21 Oct 2024
‘I'm not aware of any division by zero being performed;’
The denominator does not have to be equal to zero, it just has to be sufficiently small to reesult in a singularity. That is simply a property of the representation of floating-point numbers. (I am not certain that your system could be ‘stiff’ with a several orders-of-magnitude difference in the system parameters, however if that is the situaiion, usiing an appropriate stiff solver such as ode15s or ode23s could be appropriate, although it may not prevent the singularity.)
6 commentaires
Plus de réponses (1)
John D'Errico
le 21 Oct 2024
Modifié(e) : John D'Errico
le 21 Oct 2024
This is an absolutely classic case for a stiff system, where for some sets of system parmeters, you have two or more things happening with significantly different time scales. 1000:1 is probably adequate. And that may not even need to be always the case, but at SOME times, the equations may enter a regime where they become stiff. And so you can see the integration perform adequately, but then suddenly, things go to hell.
A classic example might be a model of a system at night, and then the sun rises, introducing rapid temperature transients. And your problem, of a flat plate falling through a fluid medium is surely one I would fear to be stiff. That is, change the viscosity of the medium, or change the attitude of the plate to where it is no longer acting as a parachute. Turbulence can be nasty of course, so under some conditions, you have vortices form around the edges, etc. I have no idea how complex is your model, but I'd expect it to be stiff.
ODE45, being an adaptive routine, will try to reduce the time step to properly handle the rapid transients your model may experience. However, the common symptom is ODE45 fails, because it can't reduce the time step any further. What did it say?
Warning: Failure at t=2.240647e+00. Unable to meet integration tolerances without reducing the step size below the smallest value allowed
(7.105427e-15) at time t.
Absolutely classic for a stiff system. No problems for a while, but then ... it gives up.
(Sorry, but how can you possibly be trying to solve this class of problem, and not even consider if your problem is a stiff one?)
The solution in MATLAB is usually to switch to a solver designed to solve stiff problems. This is also the best way to test IF stiffness is the issue. If a stiff solver fixes it, then it was almost surely stiff. That means you want to use any ode solver with a name that ends in s, so ode15s, ode23s are the ones you would look to immediately. (ODE23T is another, one that can handle moderately stiff problems.)
The very nice thing is, USUALLY this resolves the problem, though sometimes even those solvers are inadequate. And the very nice thing is, for the most part, swapping solvers requires you to do little more than change your call to ODE23S or ODE15S from ODE45. Just change the function name.
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!