Using 'Events' in ode15i/s with symbolic functions
1 view (last 30 days)
Show older comments
Hi everyone,
I'm trying to solve a system of differential-algebraic equations (DAE). I followed Matlab's guide ( http://uk.mathworks.com/help/symbolic/set-up-your-dae-problem.html ) step by step, expressed my system of equations using symbolic functions and got a solution to my DAE's.
The trouble is that, past a certain point in z (the independent variable), I need to modify my DAE's. Previously, when solving ODE's, I would specify an 'Event' to cease integration at that point. I tried specifying an event in ode15s/i too, however, inside the event function my symbolic functions do not get evaluated.
So my question is: how can I set up a system of DAE's that stops when a particular condition is reached? how should I write my event function so that it evaluates the symbolic functions?
Here's a snippet from the code which, hopefully, should make it clear what I mean:
M = odeFunction(M, vars, Fr, c);
F = odeFunction(F, vars, Fr, c); % Fr, c: parameters
% create function handles for ode15s
M = @(z,y) M(z, y, Fr, c);
F = @(z,y) F(z, y, Fr, c);
% get initial conditions y0 and yp0 from decic... then:
ode15s(F, [0 4.4], y0, options);
with options
options = odeset('Mass',M,'InitialSlope',yp0,...
'RelTol',1e-7,'AbsTol',1e-7 ,...
'Events',@stop_condition);
and event function of the type
function [value, isterminal, direction] = stop_condition(z,y,L_D) % L_D: parameter
A = y(7);
B = y(6);
value = A-B;
direction = -1;
isterminal = 1;
Here A(z) and B(z) are symbolic variables! They are not evaluated at z, which prevents the event function from running.
Thanks a lot in advance,
Antoine.
0 Comments
Answers (0)
See Also
Categories
Find more on Equation Solving 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!