方程组的解决方案返回空集

时间:2019-03-26 09:35:36

标签: python sympy

我有一个包含五个未知数的五个方程组。返回的解决方案是EmptySet()。仅求解两个变量,例如Ta2,Tb2返回正确的解,但仅作为其他3个变量的参数形式{(0.0400930157966482 * Va2 * pk,0.0240558094779889 * Vb2 * pk)}。有没有办法返回所有五个未知数的数值?

对电子表格中的方程组进行求解可获得以下结果:pk = 246.274,Ta2 = 223.752,Tb2 = 280.451,Vb2 = 47.339,Va2 = 22.661。将它们替换为sympy输出0.0400930157966482 * Va2 * pk替换为Ta2,得到的预期值为223.752。

from sympy.core.symbol import symbols
from sympy.solvers.solveset import nonlinsolve

Va, Ta, na = symbols('Va Ta na')
Vb, Tb, nb = symbols('Vb Tb nb')
pa, pb = symbols('pa pb')
R = symbols('R')
Ta2 , Tb2 = symbols('Ta2 Tb2')
Va2 , Vb2 = symbols('Va2 Vb2')
pk = symbols('pk')

R = 8.314

Va = 30.
Vb = 40.

Ta = 200.
Tb = 300.

na = 3.
nb = 5.

pa = na*R*Ta/Va
pb = nb*R*Tb/Vb

SumV = Va + Vb


eq1 = pa**5 * Va**7 - pk**5 * Va2**7
eq2 = pb**5 * Vb**7 - pk**5 * Vb2**7
eq3 = pk * Va2 - na * R * Ta2
eq4 = pk * Vb2 - nb * R * Tb2
eq5 = Va2 + Vb2 - SumV

system = [eq1,eq2,eq3,eq4,eq5]
solvefor = [Ta2, Tb2, pk, Va2, Vb2]

res = nonlinsolve(system, solvefor)
res

0 个答案:

没有答案