How to solve DAE with a varying input / a time-dependent input function?

2 views (last 30 days)
Hey!
I'm solving a DAE problem with ode15i solver. I have 8 variables and 8 equations, and the system is complex that the only working solver so far is ode15i.
I've used the guide: http://se.mathworks.com/help/symbolic/set-up-your-dae-problem.html. However, this guide doesn't help me to solve the problem with a varying input.
My system has a time-dependent input, a function. The function itself is quite simple, but the problem is that the time t in DAE system is in symbolic form, and my input function can't solve the corresponding input value, because it can't compute symbolic time value t.
here is my input function for the DAE system:
function [delta] = delta(t)
t=vpa(t)
if t <= 1.01
delta = 0;
elseif t <= 3.61
delta = 0.1222;
elseif t <= 4.33
delta = 0;
elseif t <= 7.21
delta = -0.1222;
else
delta = 0;
end
The Dae problem:
syms v1(t) r1(t) r2(t) r3(t) r4(t) fii(t) sig(t) psi(t);
tspan = 0:0.01:10;
....
a11 = delta(t)-(v1(t)+r1(t)*l_1_1)/u;
....
eqs = [...]
vars [...]
f = daeFunction(eqs,vars);
y0est = zeros(8,1);
yp0est = zeros(8,1);
opt = odeset('RelTol',10.0^(-7),'Abstol',10.0^(-7));
[y0,yp0] = decic(f,0,y0est, [], yp0est, [], opt);
[t,y] = ode15i(f,tspan, y0, yp0, opt);
The error I receive is as follows:
Conversion to logical from sym is not possible.
Error in delta (line 3)
if t <= 1.01
Error in Nonlin_painonsiirto_DUO2 (line 181)
a11 = delta(t)-(v1(t)+r1(t)*l_1_1)/u;
The system works if the delta input is a constant number or a trigonometric function of (t) such as:
delta = 0.0175;
delta = sin(t)*0.0175;
I've tried the delta function also without the vpa(t) command and with command double(t), but it does nothing. I also tried to use my system's time vector tspan=0:0.01:10 as the input, which is given as the timespan for the ode15i:
delta(tspan)
However, then it tries to compute the whole vector tspan, which results in an error, because the matrix dimensions don't agree.
Hopefully the problem here is understandable, thanks.
-Jere

Answers (1)

Torsten
Torsten on 2 Sep 2015
Maybe
syms t
delta(t)=0.1222*((t>1.01)&(t<=3.61))-0.1222*((t>4.33)&(t<=7.21));
works ?
Best wishes
Torsten.
  1 Comment
Jere Lehtinen
Jere Lehtinen on 2 Sep 2015
Hey Torsten.
Thank you for your response. However, this doesn't work. The following errors appear:
Error using symengine (line 59)
An arithmetical expression is expected.
Error in sym/privUnaryOp (line 909)
Csym = mupadmex(op,args{1}.s,varargin{:});
Error in sym/atan (line 8)
Z = privUnaryOp(Y, 'symobj::map', 'atan');
Best regards,
Jere

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!