dsolve中未知的方程类型

时间:2020-09-15 01:35:17

标签: python sympy ode

我需要解决与化学反应器有关的系统。我使用了sympy,却无法以任何方式解决该错误

我的代码在这里:

private void dispatchEvent (View rootView, float x1, float y1, int actionType){
    MotionEvent motionEvent = MotionEvent.obtain(
        SystemClock.uptimeMillis(),
        SystemClock.uptimeMillis(),
        actionType,        // MotionEvent.ACTION_UP, MotionEvent.ACTION_DOWN, ...
        (float) x1*xRatio, // map touchpad to viewport
        (float) y1*yRatio,
        0 // metastate;
    );
    rootView.dispatchTouchEvent(motionEvent);
    //frameLayout.dispatchTouchEvent(motionEvent); 
}

运行代码后,出现以下错误

from sympy import symbols, Function, dsolve, Eq, Derivative, sin, cos

Pf, Po, Pm, Pc, Ph, Pn = symbols('Pf Po Pm Pc Ph Pn', cls=Function)

#Pf-furfural pressure; Po-oxygen pressure; Pm-maleic anhydride pressure; Pco-carbon dioxide pressure; Ph-steam pressure; Pn-nitrogen pressure*

W, k1, k2, k3, n, m, l, R, T, vt, Pt = symbols('W k1 k2 k3 n m l R T vt Pt')

#W-catalyst mass; k1-kinetic constant first reaction; k2-kinetic constant second reaction; k3-kinetic constant third reaction; n, m y l, reaction orders for oxygen in the first, second and third reaction, respectively; R- universal gas constant, T-temperature, vt-catalyst volume*

A = R*T/vt

Pt = Pf(W)+Pf(W)+Pm(W)+Pc(W)+Ph(W)+Pn(W)

eq=((Eq(Derivative(Pf(W), W), (-A*k1*Pf(W)*(Po(W)**n)-A*k2*Pf(W)*(Po(W)**m)))),
    (Eq(Derivative(Po(W), W), (-A*k1*Pf(W)*(Po(W)**n)-A*k2*Pf(W)*(Po(W)**m)-A*k3*Pm(W)*(Po(W)**l)))),
    (Eq(Derivative(Pm(W), W), (A*k1*Pf(W)*(Po(W)**n)-A*k3*Pm(W)*(Po(W)**l)))),
    (Eq(Derivative(Pc(W), W), (A*k1*Pf(W)*(Po(W)**n)+5*A*k2*Pf(W)*(Po(W)**m)+4*A*k3*Pm(W)*(Po(W)**l)))),
    (Eq(Derivative(Ph(W), W), (A*k1*Pf(W)*(Po(W)**n)+2*A*k2*Pf(W)*(Po(W)**m)+A*k3*Pm(W)*(Po(W)**l)))),
    (Eq(Derivative(Pn(W), W), (0))))

dsolve(eq, [Pf(W), Po(W), Pm(W), Pc(W), Ph(W), Pn(W)], hint="all")

1 个答案:

答案 0 :(得分:1)

用于符号微分方程求解的sympy函数是实验性的,不是很完整,因此您应该以面值获得错误消息,系统不会属于具有求解器方法的任何类别。

此外,一般的微分方程以及更多的DE系统不具有符号解,但这样做的集合非常“薄”,对符号可解方程的微小更改将使其变为不可解。这意味着即使是更完整的符号求解器方法库(例如Mathematica之一)也找不到符号解。

因此,您需要确定自己真正想要的(解决方案图,参数拟合等),然后找到合适的数值方法。