为什么这个ode系统解算器不工作?

时间:2014-03-27 05:49:26

标签: matlab ode

syms a(t) b(t) c(t) d(t) e(t) f(t)

S = dsolve(
        diff(a) == -kd*a*b^2, ...
        diff(b) == -kf*b*c^2, ...
        diff(c) == kd*a*b^2 - ke*a*d, ...
        diff(d) == kd*a*b^2, ...
        diff(e) == -ke*a*d, ...
        diff(f) == kf*b*c^2)

它返回此错误:

Warning: Explicit solution could not be found. 
> In dsolve at 194
  In hw8 at 14 

S =     
   [ empty sym ]

1 个答案:

答案 0 :(得分:4)

这种ODE的非线性系统is not easily solved analytically。如果你有它,你可以尝试Mathematica(它在符号数学方面比MATLAB' s MuPad更好):

DSolve[{a'(t) = -k*d(t)*a(t)*b(t)^2, b'(t) = -k*f(t)*b(t)*c(t)^2, c'(t) = k*d(t)*a(t)*b(t)^2 - k*e(t)*a(t)*d(t), d'(t) = k*d(t)*a(t)*b(t)^2, e'(t) = -k*e(t)*a(t)*d(t), f(t) = k*f(t)*b(t)*c(t)^2}, {a(t),b(t),c(t),d(t),e(t),f(t)}, t]

(我无法对此进行测试,因为Wolfram|Alpha的免费版本的输入太长了:)

无论如何,在MATLAB中用数字方式很容易做到这一点:

function top

    %// Initial values (random for this example)
    y0 = 125*randn(6,1);

    %// Time span to simulate
    tspan = [0 +1];

    %// Solve system numerically
    [t,y] = ode45(@deriv, tspan, y0);

    %// Make a nice plot
    plot(t,y)
    xlabel('t'), ylabel('function values')
    legend('a(t)', 'b(t)', 'c(t)', 'd(t)', 'e(t)', 'f(t)')

end

function dydt = deriv(~,y)

    %// Set the value for your 'k'
    k = 1e-4;

    %// rename the variables for clarity
    [a,b,c,d,e,f] = deal(y(1),y(2),y(3),y(4),y(5),y(6));

    %// Compute the derivative
    dydt = k * [
        -d*a*b^2
        -f*b*c^2
        +a*(d*b^2 - e*d)
        +d*a*b^2
        -e*a*d
        +f*b*c^2
    ];

end

我得到的一个更有趣的解决方案:

enter image description here

出于好奇:这些等式描述了什么?我说的是经历化学反应的物质浓度,但它很奇怪(对于一些初始值,你会发现浓度,奇点等等,你不会在这样的系统中期待的东西,所以......我的好奇心被触发了:)