How to add “nonnegative” to DAE
Show older comments
I have solved the DAE solution using ODE15i, but the data in the result is negative. I need to solve for the angle and I need the angle and the velocity to be non-negative. But you can not apply the "non-negative" option when solving DAE problems. And I have tried to reduce "ReTol" and "AbsTol", but I still do not get ideal results. Do you have any other plans?

26 Comments
Torsten
on 22 Apr 2022
Totally differentiate the algebraic equations twice with respect to t and set up your system as an ODE system of 16 ODEs instead of a DAE system.
Linux Jia
on 22 Apr 2022
Linux Jia
on 22 Apr 2022
Torsten
on 22 Apr 2022
Do your initial values for phi1,...,phi8,phidot1,...,phidot8 satisfy your algebraic constraints (also in differentiated form) and your implicit differential equations ?
Linux Jia
on 23 Apr 2022
Torsten
on 23 Apr 2022
You mean you verified this using "decic" ?
Linux Jia
on 23 Apr 2022
Torsten
on 23 Apr 2022
Just out of interest:
How is it possible to fix initial conditions for phi1,...,phi8,phi1dot,...,phi8dot that guarantee that angle and velocity remain positive throughout the integration and additionally satisfy the algebraic constraints ?
Linux Jia
on 24 Apr 2022
Torsten
on 24 Apr 2022
But you are sure that for your system, there should be initial values for phi and phidot that guarantee that angle and angular velocity remain positive during integration ? If yes: why can you be sure about this ? From the physics of the problem ?
Linux Jia
on 24 Apr 2022
Torsten
on 24 Apr 2022
Ok, then the initial conditions are either not unique so that they don't represent the physical state correctly or there is a mistake in your code.
Linux Jia
on 24 Apr 2022
Torsten
on 24 Apr 2022
And what makes the results "unphysical" then in your opinion ?
Linux Jia
on 24 Apr 2022
Torsten
on 24 Apr 2022
In all cases when I used the non-negative option, this option couldn't help the solution to remain positive.
The reason is that if the equations don't permit something else but a negative solution, also this option cannot prevent the solution to become negative.
In my opinion, it's very unlikely that amplified rounding errors can lead to massive negativity. And you said you already reduced the default tolerances of the implicit integrator. That's all you can do from the solver's side. Or you could try a different implicit integrator, e.g. dassl, radau5 or similar ones.
Jeffrey Clark
on 24 Apr 2022
Angles are funny things:
- Generally every negative has its positive when dealing with trig functions, so are you also saying that combinations of angles that would result in different signs of the trig function combinations (or the one) is invalid?
- Is it possible that your solution that finds negative angles and velocity isn't really valid when concidering the angle may be pointing directly opposite what you would expect, which would also therefore have a negative velocity and be a valid mathematical solution, but would need to be interpreted correctly to agree with your apperatus?
- Is the system of equations and functions such that there has to be some 'unwrap'-like done?
Linux Jia
on 25 Apr 2022
Torsten
on 25 Apr 2022
What is the segmentation function ?
Linux Jia
on 25 Apr 2022
Torsten
on 25 Apr 2022
Is this a different question or does it have to do with the problem from above ? Since I don't see where piecewise function come into play here.
Linux Jia
on 26 Apr 2022
Torsten
on 26 Apr 2022
You can try, but if the negative value is more than just a slight numerical error that is corrected in the next iteration, I don't think this will lead you somewhere.
Linux Jia
on 26 Apr 2022
Bruno Luong
on 26 Apr 2022
Edited: Bruno Luong
on 26 Apr 2022
It looks to me that the system might have multiple solutions, and it is hard to catch the solution that is positive.
I would suggest then to start with a positve state phi_{k=0), then slowly iterate until your target DAE meets. Here is a pseudo code:
phi_{k=0) >= 0; % and also the 3 last equations
alpha = some value in (0,1)
for k=1,2,...
Qp = ComputeQ(phi{k-1})
% Use phi{k-1} as first guess solve DAE with RHS set to
d(xxx)/dt ... = (1-alpha)*Qp + alpha*Q;
if phi_{k} < 0
alpha = (0+alpha)/2; % reduce alpha;
else
alpha = (1+alpha)/2; % eventually increase alpha
end
if alpha ~= 1
% we solve the DAE approximately
break
end
end
Accepted Answer
More Answers (1)
Categories
Find more on Ordinary Differential Equations 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!