How to solve DAE with a varying input / a time-dep

2019-05-14 19:44发布

问题:

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