如何获得DAE的分析解决方案?

时间:2018-09-08 20:32:43

标签: solution analytical

我正在尝试运行matlab代码来求解DAE(2个多变量二阶ODE与3个代数多变量方程式耦合)。该代码结合了solve和dsolve。它遵循以下方法:

结合solve和dsolve求解具有微分和代数方程的方程组

运行它时,我得到一个空输出。

Code

    function WaterLiquidFilmProfilesAnalytical

syms a b c e f t A B C E F G H K

dEq1 = 'A * D2a + B * D2b + C * D2c = 0';

dEq2 = 'E * D2e - B * D2b - 2 * C * D2c - F * D2f = 0';

    Eq1 = ('G * a = e * b'); 

            Eq2 = str2sym(Eq1);

                [dEq3, initEq3] = TurnEqIntoDEq(Eq2, [G a e b], t, 0);

dEq3_char = SymArray2CharCell(dEq3);
                            initEq3_char = SymArray2CharCell(initEq3);

      Eq4 = ('H * b = e * c'); 

            Eq5 = str2sym(Eq4);

                [dEq4, initEq4] = TurnEqIntoDEq(Eq5, [H b e c], t, 0);

dEq4_char = SymArray2CharCell(dEq4);
                            initEq4_char = SymArray2CharCell(initEq4);

            Eq6 = ('K = e * f'); 

                    Eq7 = str2sym(Eq6);

                [dEq5, initEq5] = TurnEqIntoDEq(Eq7, [K e f], t, 0);

dEq5_char = SymArray2CharCell(dEq5);
                            initEq5_char = SymArray2CharCell(initEq5);

[a, b, c, e, f] = dsolve(dEq1, dEq2, dEq3_char{:},  dEq4_char{:},  dEq5_char{:},'a(0)=0','b(0)=0','c(0)=0','e(0)=0','f(0)=0',initEq3_char{:},initEq4_char{:}, initEq5_char{:},'t')
end

function [D_Eq, initEq] = TurnEqIntoDEq(eq, depVars, indepVar, initialVal)
% eq = equations
% depVars = dependent variables
% indepVar = independent variable
% initialVal = initial value of indepVar

depVarsLong = sym(zeros(size(depVars)));
for k = 1:numel(depVars)
  % Making the variables functions
  % eg. a becomes a(t)
  % This is so that diff(a, t) does not become 0
  depVarsLong(k) = str2sym([char(depVars(k)) '(' char(indepVar) ')']);
end

% Next making the equation in terms of these functions
eqLong = subs(eq, depVars, depVarsLong);

% Now find the ODE corresponding to the equation
D_EqLong = diff(eqLong, indepVar);

% Now replace all the long terms like 'diff(a(t), t)'
% with short terms like 'Da'

D_depVarsShort = sym(zeros(size(depVars)));
for k = 1:numel(depVars)
  D_depVarsShort(k) = str2sym(['D' char(depVars(k))]);
end
% Next make the long names like 'diff(a(t), t)'
D_depVarsLong = diff(depVarsLong, indepVar);
% Finally replace
D_Eq = subs(D_EqLong, D_depVarsLong, D_depVarsShort);

% Finally determine the equation
% governing the initial values
initEq = subs(eqLong, indepVar, initialVal);
end

function cc = SymArray2CharCell(sa)
cc = cell(size(sa));
for k = 1:numel(sa)
  cc{k} = char(sa(k));
end

end

我该怎么做才能获得这些DAE的分析解决方案?

亲切问候

冲浪者

0 个答案:

没有答案