Python Sympy: Simple operations busy running even after a day - python

Objective
I am trying to symbolically solve an integral that has constant coefficients (a_w, b_IN_w, c_IN_w), which are composed of simple algebraic expressions.
What I Tried
I have tried running the code given below for an entire day, but it was still running when I checked it after a day. I have used Sympy before and I understand it may not be able to solve some complex operations, where it throws some kind of message or error indicating the problem. However, in the case described below, the program is busy running even after a day, which seems unreasonable for this problem with simple expressions. Is it possible to get the solution for the below-given expression (for q_IN_w)?
I updated Sympy to its most recent version using conda before I ran this problem.
import sympy as sym
def deg_to_rad(theta_deg):
from numpy import pi
theta_rad = (pi/180)*theta_deg
return theta_rad
r, a_w, a_o, a_g, b_IN_w, b_IN_o, b_IN_g, c_IN_2w, c_IN_2o, c_IN_2g, r_1, r_2, R, \
sigma_dia, IFT_ow, theta_IN_CA_deg, D_IN_ads_coeff, nablaP, mu_w, deltaP = \
sym.symbols('r, a_w, a_o, a_g, b_IN_w, b_IN_o, b_IN_g, c_IN_2w, c_IN_2o, c_IN_2g, r_1, r_2, R, \
sigma_dia, IFT_ow, theta_IN_CA_deg, D_IN_ads_coeff, nablaP, mu_w, deltaP')
l_IN_slip = sigma_dia/((sym.pi - deg_to_rad(theta_IN_CA_deg))**4)
W_IN_egy = IFT_ow*(1 + sym.cos(deg_to_rad(theta_IN_CA_deg)))
u_IN_s = (l_IN_slip*R*nablaP)/(2*mu_w)
u_IN_ads = (D_IN_ads_coeff/W_IN_egy)*deltaP
u_IN_s_eff = (u_IN_s - u_IN_ads)
b_IN_g = 0
b_IN_o = 2*(a_g - a_o)*(r_1**2)
b_IN_w = b_IN_o + 2*(a_o - a_w)*(r_2**2)
c_IN_2w = u_IN_s_eff - a_w*(R**2) - b_IN_w*sym.log(R)
q_IN_w = sym.integrate((a_w*(r**2) + b_IN_w*(sym.log(r)) + c_IN_2w)*(2*sym.pi*r), (r, r_2, R))

Here it finished in 30s, but it's quite the answer with the sym.pi
pi*R**4*a_w/2 - R**2*(pi**4*D_IN_ads_coeff*deltaP*mu_w*theta_IN_CA_deg**4 - 720*pi**4*D_IN_ads_coeff*deltaP*mu_w*theta_IN_CA_deg**3 + 194400*pi**4*D_IN_ads_coeff*deltaP*mu_w*theta_IN_CA_deg**2 - 23328000*pi**4*D_IN_ads_coeff*deltaP*mu_w*theta_IN_CA_deg + 1049760000*pi**4*D_IN_ads_coeff*deltaP*mu_w + pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg**4*cos(pi*theta_IN_CA_deg/180) + pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg**4 - 720*pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg**3*cos(pi*theta_IN_CA_deg/180) - 720*pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg**3 + 194400*pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg**2*cos(pi*theta_IN_CA_deg/180) + 194400*pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg**2 - 23328000*pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg*cos(pi*theta_IN_CA_deg/180) - 23328000*pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg + 1049760000*pi**4*IFT_ow*R**2*a_w*mu_w*cos(pi*theta_IN_CA_deg/180) + 1049760000*pi**4*IFT_ow*R**2*a_w*mu_w - 524880000*IFT_ow*R*nablaP*sigma_dia*cos(pi*theta_IN_CA_deg/180) - 524880000*IFT_ow*R*nablaP*sigma_dia + 2*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**4*log(R)*cos(pi*theta_IN_CA_deg/180) + 2*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**4*log(R) + pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**4*cos(pi*theta_IN_CA_deg/180) + pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**4 - 1440*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**3*log(R)*cos(pi*theta_IN_CA_deg/180) - 1440*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**3*log(R) - 720*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**3*cos(pi*theta_IN_CA_deg/180) - 720*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**3 + 388800*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**2*log(R)*cos(pi*theta_IN_CA_deg/180) + 388800*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**2*log(R) + 194400*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**2*cos(pi*theta_IN_CA_deg/180) + 194400*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**2 - 46656000*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg*log(R)*cos(pi*theta_IN_CA_deg/180) - 46656000*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg*log(R) - 23328000*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg*cos(pi*theta_IN_CA_deg/180) - 23328000*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg + 2099520000*pi**4*IFT_ow*a_g*mu_w*r_1**2*log(R)*cos(pi*theta_IN_CA_deg/180) + 2099520000*pi**4*IFT_ow*a_g*mu_w*r_1**2*log(R) + 1049760000*pi**4*IFT_ow*a_g*mu_w*r_1**2*cos(pi*theta_IN_CA_deg/180) + 1049760000*pi**4*IFT_ow*a_g*mu_w*r_1**2 - 2*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**4*log(R)*cos(pi*theta_IN_CA_deg/180) - 2*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**4*log(R) - pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**4*cos(pi*theta_IN_CA_deg/180) - pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**4 + 1440*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**3*log(R)*cos(pi*theta_IN_CA_deg/180) + 1440*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**3*log(R) + 720*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**3*cos(pi*theta_IN_CA_deg/180) + 720*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**3 - 388800*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**2*log(R)*cos(pi*theta_IN_CA_deg/180) - 388800*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**2*log(R) - 194400*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**2*cos(pi*theta_IN_CA_deg/180) - 194400*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**2 + 46656000*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg*log(R)*cos(pi*theta_IN_CA_deg/180) + 46656000*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg*log(R) + 23328000*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg*cos(pi*theta_IN_CA_deg/180) + 23328000*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg - 2099520000*pi**4*IFT_ow*a_o*mu_w*r_1**2*log(R)*cos(pi*theta_IN_CA_deg/180) - 2099520000*pi**4*IFT_ow*a_o*mu_w*r_1**2*log(R) - 1049760000*pi**4*IFT_ow*a_o*mu_w*r_1**2*cos(pi*theta_IN_CA_deg/180) - 1049760000*pi**4*IFT_ow*a_o*mu_w*r_1**2 + 2*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**4*log(R)*cos(pi*theta_IN_CA_deg/180) + 2*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**4*log(R) + pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**4*cos(pi*theta_IN_CA_deg/180) + pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**4 - 1440*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**3*log(R)*cos(pi*theta_IN_CA_deg/180) - 1440*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**3*log(R) - 720*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**3*cos(pi*theta_IN_CA_deg/180) - 720*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**3 + 388800*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**2*log(R)*cos(pi*theta_IN_CA_deg/180) + 388800*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**2*log(R) + 194400*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**2*cos(pi*theta_IN_CA_deg/180) + 194400*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**2 - 46656000*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg*log(R)*cos(pi*theta_IN_CA_deg/180) - 46656000*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg*log(R) - 23328000*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg*cos(pi*theta_IN_CA_deg/180) - 23328000*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg + 2099520000*pi**4*IFT_ow*a_o*mu_w*r_2**2*log(R)*cos(pi*theta_IN_CA_deg/180) + 2099520000*pi**4*IFT_ow*a_o*mu_w*r_2**2*log(R) + 1049760000*pi**4*IFT_ow*a_o*mu_w*r_2**2*cos(pi*theta_IN_CA_deg/180) + 1049760000*pi**4*IFT_ow*a_o*mu_w*r_2**2 - 2*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**4*log(R)*cos(pi*theta_IN_CA_deg/180) - 2*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**4*log(R) - pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**4*cos(pi*theta_IN_CA_deg/180) - pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**4 + 1440*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**3*log(R)*cos(pi*theta_IN_CA_deg/180) + 1440*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**3*log(R) + 720*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**3*cos(pi*theta_IN_CA_deg/180) + 720*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**3 - 388800*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**2*log(R)*cos(pi*theta_IN_CA_deg/180) - 388800*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**2*log(R) - 194400*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**2*cos(pi*theta_IN_CA_deg/180) - 194400*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**2 + 46656000*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg*log(R)*cos(pi*theta_IN_CA_deg/180) + 46656000*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg*log(R) + 23328000*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg*cos(pi*theta_IN_CA_deg/180) + 23328000*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg - 2099520000*pi**4*IFT_ow*a_w*mu_w*r_2**2*log(R)*cos(pi*theta_IN_CA_deg/180) - 2099520000*pi**4*IFT_ow*a_w*mu_w*r_2**2*log(R) - 1049760000*pi**4*IFT_ow*a_w*mu_w*r_2**2*cos(pi*theta_IN_CA_deg/180) - 1049760000*pi**4*IFT_ow*a_w*mu_w*r_2**2)/(pi**3*IFT_ow*mu_w*theta_IN_CA_deg**4*cos(pi*theta_IN_CA_deg/180) + pi**3*IFT_ow*mu_w*theta_IN_CA_deg**4 - 720*pi**3*IFT_ow*mu_w*theta_IN_CA_deg**3*cos(pi*theta_IN_CA_deg/180) - 720*pi**3*IFT_ow*mu_w*theta_IN_CA_deg**3 + 194400*pi**3*IFT_ow*mu_w*theta_IN_CA_deg**2*cos(pi*theta_IN_CA_deg/180) + 194400*pi**3*IFT_ow*mu_w*theta_IN_CA_deg**2 - 23328000*pi**3*IFT_ow*mu_w*theta_IN_CA_deg*cos(pi*theta_IN_CA_deg/180) - 23328000*pi**3*IFT_ow*mu_w*theta_IN_CA_deg + 1049760000*pi**3*IFT_ow*mu_w*cos(pi*theta_IN_CA_deg/180) + 1049760000*pi**3*IFT_ow*mu_w) - pi*a_w*r_2**4/2 + r_2**2*(pi**4*D_IN_ads_coeff*deltaP*mu_w*theta_IN_CA_deg**4 - 720*pi**4*D_IN_ads_coeff*deltaP*mu_w*theta_IN_CA_deg**3 + 194400*pi**4*D_IN_ads_coeff*deltaP*mu_w*theta_IN_CA_deg**2 - 23328000*pi**4*D_IN_ads_coeff*deltaP*mu_w*theta_IN_CA_deg + 1049760000*pi**4*D_IN_ads_coeff*deltaP*mu_w + pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg**4*cos(pi*theta_IN_CA_deg/180) + pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg**4 - 720*pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg**3*cos(pi*theta_IN_CA_deg/180) - 720*pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg**3 + 194400*pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg**2*cos(pi*theta_IN_CA_deg/180) + 194400*pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg**2 - 23328000*pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg*cos(pi*theta_IN_CA_deg/180) - 23328000*pi**4*IFT_ow*R**2*a_w*mu_w*theta_IN_CA_deg + 1049760000*pi**4*IFT_ow*R**2*a_w*mu_w*cos(pi*theta_IN_CA_deg/180) + 1049760000*pi**4*IFT_ow*R**2*a_w*mu_w - 524880000*IFT_ow*R*nablaP*sigma_dia*cos(pi*theta_IN_CA_deg/180) - 524880000*IFT_ow*R*nablaP*sigma_dia + 2*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**4*log(R)*cos(pi*theta_IN_CA_deg/180) + 2*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**4*log(R) + pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**4*cos(pi*theta_IN_CA_deg/180) + pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**4 - 1440*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**3*log(R)*cos(pi*theta_IN_CA_deg/180) - 1440*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**3*log(R) - 720*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**3*cos(pi*theta_IN_CA_deg/180) - 720*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**3 + 388800*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**2*log(R)*cos(pi*theta_IN_CA_deg/180) + 388800*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**2*log(R) + 194400*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**2*cos(pi*theta_IN_CA_deg/180) + 194400*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg**2 - 46656000*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg*log(R)*cos(pi*theta_IN_CA_deg/180) - 46656000*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg*log(R) - 23328000*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg*cos(pi*theta_IN_CA_deg/180) - 23328000*pi**4*IFT_ow*a_g*mu_w*r_1**2*theta_IN_CA_deg + 2099520000*pi**4*IFT_ow*a_g*mu_w*r_1**2*log(R)*cos(pi*theta_IN_CA_deg/180) + 2099520000*pi**4*IFT_ow*a_g*mu_w*r_1**2*log(R) + 1049760000*pi**4*IFT_ow*a_g*mu_w*r_1**2*cos(pi*theta_IN_CA_deg/180) + 1049760000*pi**4*IFT_ow*a_g*mu_w*r_1**2 - 2*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**4*log(R)*cos(pi*theta_IN_CA_deg/180) - 2*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**4*log(R) - pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**4*cos(pi*theta_IN_CA_deg/180) - pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**4 + 1440*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**3*log(R)*cos(pi*theta_IN_CA_deg/180) + 1440*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**3*log(R) + 720*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**3*cos(pi*theta_IN_CA_deg/180) + 720*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**3 - 388800*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**2*log(R)*cos(pi*theta_IN_CA_deg/180) - 388800*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**2*log(R) - 194400*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**2*cos(pi*theta_IN_CA_deg/180) - 194400*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg**2 + 46656000*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg*log(R)*cos(pi*theta_IN_CA_deg/180) + 46656000*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg*log(R) + 23328000*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg*cos(pi*theta_IN_CA_deg/180) + 23328000*pi**4*IFT_ow*a_o*mu_w*r_1**2*theta_IN_CA_deg - 2099520000*pi**4*IFT_ow*a_o*mu_w*r_1**2*log(R)*cos(pi*theta_IN_CA_deg/180) - 2099520000*pi**4*IFT_ow*a_o*mu_w*r_1**2*log(R) - 1049760000*pi**4*IFT_ow*a_o*mu_w*r_1**2*cos(pi*theta_IN_CA_deg/180) - 1049760000*pi**4*IFT_ow*a_o*mu_w*r_1**2 + 2*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**4*log(R)*cos(pi*theta_IN_CA_deg/180) + 2*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**4*log(R) + pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**4*cos(pi*theta_IN_CA_deg/180) + pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**4 - 1440*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**3*log(R)*cos(pi*theta_IN_CA_deg/180) - 1440*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**3*log(R) - 720*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**3*cos(pi*theta_IN_CA_deg/180) - 720*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**3 + 388800*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**2*log(R)*cos(pi*theta_IN_CA_deg/180) + 388800*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**2*log(R) + 194400*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**2*cos(pi*theta_IN_CA_deg/180) + 194400*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg**2 - 46656000*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg*log(R)*cos(pi*theta_IN_CA_deg/180) - 46656000*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg*log(R) - 23328000*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg*cos(pi*theta_IN_CA_deg/180) - 23328000*pi**4*IFT_ow*a_o*mu_w*r_2**2*theta_IN_CA_deg + 2099520000*pi**4*IFT_ow*a_o*mu_w*r_2**2*log(R)*cos(pi*theta_IN_CA_deg/180) + 2099520000*pi**4*IFT_ow*a_o*mu_w*r_2**2*log(R) + 1049760000*pi**4*IFT_ow*a_o*mu_w*r_2**2*cos(pi*theta_IN_CA_deg/180) + 1049760000*pi**4*IFT_ow*a_o*mu_w*r_2**2 - 2*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**4*log(R)*cos(pi*theta_IN_CA_deg/180) - 2*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**4*log(R) - pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**4*cos(pi*theta_IN_CA_deg/180) - pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**4 + 1440*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**3*log(R)*cos(pi*theta_IN_CA_deg/180) + 1440*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**3*log(R) + 720*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**3*cos(pi*theta_IN_CA_deg/180) + 720*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**3 - 388800*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**2*log(R)*cos(pi*theta_IN_CA_deg/180) - 388800*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**2*log(R) - 194400*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**2*cos(pi*theta_IN_CA_deg/180) - 194400*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg**2 + 46656000*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg*log(R)*cos(pi*theta_IN_CA_deg/180) + 46656000*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg*log(R) + 23328000*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg*cos(pi*theta_IN_CA_deg/180) + 23328000*pi**4*IFT_ow*a_w*mu_w*r_2**2*theta_IN_CA_deg - 2099520000*pi**4*IFT_ow*a_w*mu_w*r_2**2*log(R)*cos(pi*theta_IN_CA_deg/180) - 2099520000*pi**4*IFT_ow*a_w*mu_w*r_2**2*log(R) - 1049760000*pi**4*IFT_ow*a_w*mu_w*r_2**2*cos(pi*theta_IN_CA_deg/180) - 1049760000*pi**4*IFT_ow*a_w*mu_w*r_2**2)/(pi**3*IFT_ow*mu_w*theta_IN_CA_deg**4*cos(pi*theta_IN_CA_deg/180) + pi**3*IFT_ow*mu_w*theta_IN_CA_deg**4 - 720*pi**3*IFT_ow*mu_w*theta_IN_CA_deg**3*cos(pi*theta_IN_CA_deg/180) - 720*pi**3*IFT_ow*mu_w*theta_IN_CA_deg**3 + 194400*pi**3*IFT_ow*mu_w*theta_IN_CA_deg**2*cos(pi*theta_IN_CA_deg/180) + 194400*pi**3*IFT_ow*mu_w*theta_IN_CA_deg**2 - 23328000*pi**3*IFT_ow*mu_w*theta_IN_CA_deg*cos(pi*theta_IN_CA_deg/180) - 23328000*pi**3*IFT_ow*mu_w*theta_IN_CA_deg + 1049760000*pi**3*IFT_ow*mu_w*cos(pi*theta_IN_CA_deg/180) + 1049760000*pi**3*IFT_ow*mu_w) + (2*pi*R**2*a_g*r_1**2 - 2*pi*R**2*a_o*r_1**2 + 2*pi*R**2*a_o*r_2**2 - 2*pi*R**2*a_w*r_2**2)*log(R) - (2*pi*a_g*r_1**2*r_2**2 - 2*pi*a_o*r_1**2*r_2**2 + 2*pi*a_o*r_2**4 - 2*pi*a_w*r_2**4)*log(r_2)

Related

Error trying to perform nonlinear regression using scipy.optimize.least_squares

I have a system of 28 nonlinear equations with 27 dependent variables.
x0 = np.ones(27)
def one_VI_set_012(x):
gamma1 = x[0] + 1j*x[1]
Zw1 = x[2] + 1j*x[3]
gamma0 = x[4] + 1j*x[5]
Zw0 = x[6] + 1j*x[7]
len1 = x[8]
len2 = len - x[8]
I_left_f1 = x[9] * np.exp(1j*x[10]*np.pi/180)
I_right_f1 = x[11] * np.exp(1j * x[12]*np.pi/180)
V_f1 = x[13] * np.exp(1j * x[14]*np.pi/180)
I_left_f2 = x[15] * np.exp(1j*x[16]*np.pi/180)
I_right_f2 = x[17] * np.exp(1j * x[18]*np.pi/180)
V_f2 = x[19] * np.exp(1j * x[20]*np.pi/180)
I_left_f0 = x[21] * np.exp(1j*x[22]*np.pi/180)
I_right_f0 = x[23] * np.exp(1j * x[24]*np.pi/180)
V_f0 = x[25] * np.exp(1j * x[26]*np.pi/180)
return [ \
np.real(V_f1 - (Vbeg_1*np.cosh(gamma1*len1) - Ibeg_1*Zw1*np.sinh(gamma1*len1))),
np.real(I_left_f1 - (-Vbeg_1*np.sinh(gamma1*len1)/Zw1 + Ibeg_1*np.cosh(gamma1*len1))),
np.real(Vend_1 - (V_f1*np.cosh(gamma1*len2) - I_right_f1*Zw1*np.sinh(gamma1*len2))),
np.real(Iend_1 - (-V_f1*np.sinh(gamma1*len2)/Zw1 + I_right_f1*np.cosh(gamma1*len2))),
np.real(V_f2 - (Vbeg_2*np.cosh(gamma1*len1) - Ibeg_2*Zw1*np.sinh(gamma1*len1))),
np.real(I_left_f2 - (-Vbeg_2*np.sinh(gamma1*len1)/Zw1 + Ibeg_2*np.cosh(gamma1*len1))),
np.real(Vend_2 - (V_f2*np.cosh(gamma1*len2) - I_right_f2*Zw1*np.sinh(gamma1*len2))),
np.real(Iend_2 - (-V_f2*np.sinh(gamma1*len2)/Zw1 + I_right_f2*np.cosh(gamma1*len2))),
np.real(V_f0 - (Vbeg_0*np.cosh(gamma0*len1) - Ibeg_0*Zw0*np.sinh(gamma0*len1))),
np.real(I_left_f0 - (-Vbeg_0*np.sinh(gamma0*len1)/Zw0 + Ibeg_0*np.cosh(gamma0*len1))),
np.real(Vend_0 - (V_f0*np.cosh(gamma0*len2) - I_right_f0*Zw0*np.sinh(gamma0*len2))),
np.real(Iend_0 - (-V_f0*np.sinh(gamma0*len2)/Zw0 + I_right_f0*np.cosh(gamma0*len2))),
np.real((I_left_f1 - I_right_f1) - (I_left_f0 - I_right_f0)),
np.real((I_left_f1 - I_right_f1) - (I_left_f2 - I_right_f2)),
np.imag(V_f1 - (Vbeg_1*np.cosh(gamma1*len1) - Ibeg_1*Zw1*np.sinh(gamma1*len1))),
np.imag(I_left_f1 - (-Vbeg_1*np.sinh(gamma1*len1)/Zw1 + Ibeg_1*np.cosh(gamma1*len1))),
np.imag(Vend_1 - (V_f1*np.cosh(gamma1*len2) - I_right_f1*Zw1*np.sinh(gamma1*len2))),
np.imag(Iend_1 - (-V_f1*np.sinh(gamma1*len2)/Zw1 + I_right_f1*np.cosh(gamma1*len2))),
np.imag(V_f2 - (Vbeg_2*np.cosh(gamma1*len1) - Ibeg_2*Zw1*np.sinh(gamma1*len1))),
np.imag(I_left_f2 - (-Vbeg_2*np.sinh(gamma1*len1)/Zw1 + Ibeg_2*np.cosh(gamma1*len1))),
np.imag(Vend_2 - (V_f2*np.cosh(gamma1*len2) - I_right_f2*Zw1*np.sinh(gamma1*len2))),
np.imag(Iend_2 - (-V_f2*np.sinh(gamma1*len2)/Zw1 + I_right_f2*np.cosh(gamma1*len2))),
np.imag(V_f0 - (Vbeg_0*np.cosh(gamma0*len1) - Ibeg_0*Zw0*np.sinh(gamma0*len1))),
np.imag(I_left_f0 - (-Vbeg_0*np.sinh(gamma0*len1)/Zw0 + Ibeg_0*np.cosh(gamma0*len1))),
np.imag(Vend_0 - (V_f0*np.cosh(gamma0*len2) - I_right_f0*Zw0*np.sinh(gamma0*len2))),
np.imag(Iend_0 - (-V_f0*np.sinh(gamma0*len2)/Zw0 + I_right_f0*np.cosh(gamma0*len2))),
np.imag((I_left_f1 - I_right_f1) - (I_left_f0 - I_right_f0)),
np.imag((I_left_f1 - I_right_f1) - (I_left_f2 - I_right_f2))]
root = least_squares(one_VI_set_012,x0)
Vbeg_1, Ibeg_1 etc. here are the complex numbers which are given in the rest of the code. I've tried to perform regression on a simple system of 3 equations and all was good, but in real abovemetioned task I receive an error:
Exception has occurred: TypeError
ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Thank you very much in advance.

solution system of linear equations in sympy

Can you please tell me, I need to symbolically solve a system of linear equations using sympy in python. I have programmed the automatic creation of a system of linear equations, the number of equations is determined by the number n (predefined). I set the variables too.
it turns out the following:
########## system of linear equations ##########
[-mui0*exp(Ea0**2/(T0*k)) - mui0*exp(Ea1**2/(T0*k)) - mui0*exp(Ea2**2/(T0*k)) - mui0*exp(Ea3**2/(T0*k)) + (Eb0**2/(T0*k) - 2*Ec0)*exp(Ea0**2/(T0*k)) + (Eb1**2/(T0*k) - 2*Ec1)*exp(Ea1**2/(T0*k)) + (Eb2**2/(T0*k) - 2*Ec2)*exp(Ea2**2/(T0*k)) + (Eb3**2/(T0*k) - 2*Ec3)*exp(Ea3**2/(T0*k)), -mui1*exp(Ea0**2/(T1*k)) - mui1*exp(Ea1**2/(T1*k)) - mui1*exp(Ea2**2/(T1*k)) - mui1*exp(Ea3**2/(T1*k)) + (Eb0**2/(T1*k) - 2*Ec0)*exp(Ea0**2/(T1*k)) + (Eb1**2/(T1*k) - 2*Ec1)*exp(Ea1**2/(T1*k)) + (Eb2**2/(T1*k) - 2*Ec2)*exp(Ea2**2/(T1*k)) + (Eb3**2/(T1*k) - 2*Ec3)*exp(Ea3**2/(T1*k)), -mui2*exp(Ea0**2/(T2*k)) - mui2*exp(Ea1**2/(T2*k)) - mui2*exp(Ea2**2/(T2*k)) - mui2*exp(Ea3**2/(T2*k)) + (Eb0**2/(T2*k) - 2*Ec0)*exp(Ea0**2/(T2*k)) + (Eb1**2/(T2*k) - 2*Ec1)*exp(Ea1**2/(T2*k)) + (Eb2**2/(T2*k) - 2*Ec2)*exp(Ea2**2/(T2*k)) + (Eb3**2/(T2*k) - 2*Ec3)*exp(Ea3**2/(T2*k)), -mui3*exp(Ea0**2/(T3*k)) - mui3*exp(Ea1**2/(T3*k)) - mui3*exp(Ea2**2/(T3*k)) - mui3*exp(Ea3**2/(T3*k)) + (Eb0**2/(T3*k) - 2*Ec0)*exp(Ea0**2/(T3*k)) + (Eb1**2/(T3*k) - 2*Ec1)*exp(Ea1**2/(T3*k)) + (Eb2**2/(T3*k) - 2*Ec2)*exp(Ea2**2/(T3*k)) + (Eb3**2/(T3*k) - 2*Ec3)*exp(Ea3**2/(T3*k))]
###### vars ######
[Ea0, Ea1, Ea2, Ea3, Ea4, Eb0, Eb1, Eb2, Eb3, Eb4, Ec0, Ec1, Ec2, Ec3, Ec4]
###### ###### ###### ###### ###### ###### ###### ######
now when i write : a = linsolve(list_eq,list_var)
the error gets out : SympifyError: Sympify of expression 'could not parse '['' failed, because of exception being raised:
TokenError: ('EOF in multi-line statement', (2, 0))
how to be For sympy to find a solution to a system of linear equations
this is my full code :
from sympy import exp,symbols
from sympy import Float,linsolve
def chis_znam_construct(T,i_eq,n):
En1 = symbols('Eb:' + str(n+1))
En0 = symbols('Ea:' + str(n+1))
En2 = symbols('Ec:' + str(n+1))
mui = symbols('mui:' + str(n+1))
k = symbols('k')
chis=0
znam=0
i_levels=0
eq=[]
varS=[]
dictvanfleck=dict({})
dictvanfleck['eq']=[]
dictvanfleck['vars']=[]
def getvars(f,varS):
i_var=0
while i_var<=(len(f)-1):
varS.append(f[i_var])
i_var+=1
return varS
variable=getvars(En0,varS)
variable=getvars(En1,varS)
variable=getvars(En2,varS)
for i_levels in range(n):
chis+=((En1[i_levels]**2)/(k*T)-
(En2[i_levels]+En2[i_levels]))*exp((En0[i_levels]**2)/(k*T))
znam+=mui[i_eq]*exp((En0[i_levels]**2)/(k*T))
i_levels+=1
print('')
print('')
eq.append(chis-znam)
dictvanfleck['vars']=variable
dictvanfleck['eq']=eq
return dictvanfleck
def eq_construct(T,n):
i_eq=0
eq=[]
for i_eq in range(n):
eq.append(chis_znam_construct(T[i_eq],i_eq,n))
i_eq+=1
return eq
print('')
print('')
def solve_eq(T,n):
equations=eq_construct(T,n)
eqA=equations[1]
var=eqA['vars']
i=0
equat=[]
while i<=(n-1):
eqA=equations[i]
eqq=eqA['eq']
equat.append(eqq[0])
i+=1
list_eq=str(equat)
list_var=str(var)
print('')
print('list_eq',list_eq)
print('')
print('list_var',list_var)
a = linsolve(list_eq,list_var)
return a
n = 4
T = symbols('T:' + str(n+1))
equations=solve_eq(T,n)
you will laugh, but an error was found: firstly, I made a tuple from list, some of the errors were gone; but the most interesting thing is that when I explicitly set equations and variables, simpi cannot solve the equations :
n = 4
T = sp.symbols('T:' + str(n+1))
Ea0, Ea1, Ea2, Ea3, Ea4, Eb0, Eb1, Eb2, Eb3, Eb4, Ec0, Ec1, Ec2, Ec3, Ec4, T0, T1, T2,
T3, T4, mui0, mui1, mui2, mui3, mui4 = sp.symbols('Ea0, Ea1, Ea2, Ea3, Ea4, Eb0, Eb1,
Eb2, Eb3, Eb4, Ec0, Ec1, Ec2, Ec3, Ec4, T0, T1, T2, T3, T4, mui0, mui1, mui2, mui3,
mui4')
eq_one=sp.Eq(-mui0*exp(Ea0**2/(T0*k)) - mui0*exp(Ea1**2/(T0*k)) -
mui0*exp(Ea2**2/(T0*k)) -
mui0*exp(Ea3**2/(T0*k)) + (Eb0**2/(T0*k) - 2*Ec0)*exp(Ea0**2/(T0*k)) +
(Eb1**2/(T0*k) - 2*Ec1)*exp(Ea1**2/(T0*k)) + (Eb2**2/(T0*k) -
2*Ec2)*exp(Ea2**2/(T0*k)) +
(Eb3**2/(T0*k) - 2*Ec3)*exp(Ea3**2/(T0*k)))
eq_two=sp.Eq(-mui1*exp(Ea0**2/(T1*k)) - mui1*exp(Ea1**2/(T1*k)) -
mui1*exp(Ea2**2/(T1*k)) - mui1*exp(Ea3**2/(T1*k)) +
(Eb0**2/(T1*k) - 2*Ec0)*exp(Ea0**2/(T1*k)) + (Eb1**2/(T1*k) -
2*Ec1)*exp(Ea1**2/(T1*k)) + (Eb2**2/(T1*k) - 2*Ec2)*exp(Ea2**2/(T1*k)) +
(Eb3**2/(T1*k) - 2*Ec3)*exp(Ea3**2/(T1*k)))
eq_three=sp.Eq(-mui2*exp(Ea0**2/(T2*k)) - mui2*exp(Ea1**2/(T2*k)) -
mui2*exp(Ea2**2/(T2*k)) -
mui2*exp(Ea3**2/(T2*k)) + (Eb0**2/(T2*k) - 2*Ec0)*exp(Ea0**2/(T2*k)) +
(Eb1**2/(T2*k) - 2*Ec1)*exp(Ea1**2/(T2*k)) + (Eb2**2/(T2*k) -
2*Ec2)*exp(Ea2**2/(T2*k)) +
(Eb3**2/(T2*k) - 2*Ec3)*exp(Ea3**2/(T2*k)))
eq_four=sp.Eq(-mui3*exp(Ea0**2/(T3*k)) - mui3*exp(Ea1**2/(T3*k)) -
mui3*exp(Ea2**2/(T3*k)) - mui3*exp(Ea3**2/(T3*k)) + (Eb0**2/(T3*k) -
2*Ec0)*exp(Ea0**2/(T3*k)) +
(Eb1**2/(T3*k) - 2*Ec1)*exp(Ea1**2/(T3*k)) + (Eb2**2/(T3*k) -
2*Ec2)*exp(Ea2**2/(T3*k)) +
(Eb3**2/(T3*k) - 2*Ec3)*exp(Ea3**2/(T3*k)))
ans = sp.solve((eq_one, eq_two,eq_three,eq_four), (Ea0, Ea1, Ea2, Ea3))
print('ответ :', ans)
raise NotImplementedError('could not solve %s' % eq2)
NotImplementedError: could not solve ....

Solving linear equation system with sympy takes forever

I have a linear equation system consisting of 3 equations as a result of a matrix multiplication. The equation system has 3 unknowns and 24 input variables. In theory, it should be solvable, however, linsolve takes forever (roughly a day so far) to calculate a solution.
Here is my sympy input:
from sympy import Matrix, symbols, pprint, Eq, linsolve
from sympy.utilities.lambdify import lambdastr
n2_x, n2_y, n2_z, o2_x, o2_y, o2_z, a2_x, a2_y, a2_z, p2_x, p2_y, p2_z = symbols('n2_x n2_y n2_z o2_x o2_y o2_z a2_x a2_y a2_z p2_x p2_y p2_z', real=True)
T_2 = Matrix([[n2_x, o2_x, a2_x, p2_x], [n2_y, o2_y, a2_y, p2_y], [n2_z, o2_z, a2_z, p2_z], [0,0,0,1]])
n3_x, n3_y, n3_z, o3_x, o3_y, o3_z, a3_x, a3_y, a3_z, p3_x, p3_y, p3_z = symbols('n3_x n3_y n3_z o3_x o3_y o3_z a3_x a3_y a3_z p3_x p3_y p3_z', real=True)
T_3 = Matrix([[n3_x, o3_x, a3_x, p3_x], [n3_y, o3_y, a3_y, p3_y], [n3_z, o3_z, a3_z, p3_z], [0,0,0,1]])
p_x, p_y, p_z = symbols('p_x p_y p_z', real=True)
R_p = Matrix([[0, 0, 0, p_x], [0, 0, 0, p_y], [0, 0, 0, p_z], [0,0,0,1]])
eq1 = (Matrix.eye(4)-T_2*T_3**-1)*R_p
eq2 = Eq(eq1[0, 3], 0)
eq3 = Eq(eq1[1, 3], 0)
eq4 = Eq(eq1[2, 3], 0)
res = linsolve([eq1[0, 3], eq1[1, 3], eq1[2, 3]], (p_x, p_y, p_z))
pprint(res)
print(res)
How can I speed up solving the problem, or what am I doing wrong?
Thanks in advance.
EDIT: As background information: T_2 and T_3 are transformation matrices, R_p is also a transformation matrix, but with (known) zero rotation. We are looking for the translation only.
I do concur with JohanC that it might be worth considering a different way of approaching this since the expressions you are asking for are enormous. If you know anything more specific about any relationship between the symbols then it can be better to use that information up front.
Looking at the answer (below) there seems to be a clear repetitive structure to it that would suggest that there could be a more intelligent way of computing that result rather than just slinging the whole system of arbitrary symbols into sympy. I expect that finding an expression for the i,j element of your matrix would lead to a shorter result involving indices and summations.
That being said there have been a lot of improvements in the performance of linsolve in sympy 1.7 and since (i.e. the current master branch that will at some point become 1.8). I expect further improvements after 1.8 as well.
With the (almost-)current sympy master branch I tried this and got a solution in around 1 minute:
In [33]: %time res = linsolve([eq1[0, 3], eq1[1, 3], eq1[2, 3]], (p_x, p_y, p_z))
CPU times: user 42.7 s, sys: 1.23 s, total: 43.9 s
Wall time: 51.2 s
Note that the first time I tried it took 1 minute. When I tried again after quitting Python and updating to the absolute latest sympy master it took a lot longer (not sure how long). I don't think anything should have changed but it's possible that the time taken is non-deterministic somehow.
The answer I found is:
In [41]: str(res)
Out[41]: 'FiniteSet(((a2_x*n2_y*o2_z*p3_x - a2_x*n2_y*o3_x*p2_z + a2_x*n2_y*o3_x*p3_z - a2_x*n2_y*o3_z*p3_x - a2_x*n2_z*o2_y*p3_x + a2_x*n2_z*o3_x*p2_y - a2_x*n2_z*o3_x*p3_y + a2_x*n2_z*o3_y*p3_x + a2_x*n3_x*o2_y*p2_z - a2_x*n3_x*o2_y*p3_z - a2_x*n3_x*o2_z*p2_y + a2_x*n3_x*o2_z*p3_y - a2_x*n3_x*o3_y*p2_z + a2_x*n3_x*o3_y*p3_z + a2_x*n3_x*o3_z*p2_y - a2_x*n3_x*o3_z*p3_y - a2_x*n3_y*o2_z*p3_x + a2_x*n3_y*o3_x*p2_z - a2_x*n3_y*o3_x*p3_z + a2_x*n3_y*o3_z*p3_x + a2_x*n3_z*o2_y*p3_x - a2_x*n3_z*o3_x*p2_y + a2_x*n3_z*o3_x*p3_y - a2_x*n3_z*o3_y*p3_x - a2_y*n2_x*o2_z*p3_x + a2_y*n2_x*o3_x*p2_z - a2_y*n2_x*o3_x*p3_z + a2_y*n2_x*o3_z*p3_x + a2_y*n2_z*o2_x*p3_x - a2_y*n2_z*o3_x*p2_x - a2_y*n3_x*o2_x*p2_z + a2_y*n3_x*o2_x*p3_z + a2_y*n3_x*o2_z*p2_x - a2_y*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*o2_y*p3_x + a3_z*n2_x*o3_x*p2_y - a3_z*n2_x*o3_x*p3_y + a3_z*n2_x*o3_y*p3_x + a3_z*n2_y*o2_x*p3_x - a3_z*n2_y*o3_x*p2_x - a3_z*n3_x*o2_x*p2_y + a3_z*n3_x*o2_x*p3_y + a3_z*n3_x*o2_y*p2_x - a3_z*n3_x*o3_y*p2_x - a3_z*n3_y*o2_x*p3_x + a3_z*n3_y*o3_x*p2_x)/(a2_x*n2_y*o2_z - a2_x*n2_y*o3_z - a2_x*n2_z*o2_y + a2_x*n2_z*o3_y - a2_x*n3_y*o2_z + a2_x*n3_y*o3_z + a2_x*n3_z*o2_y - a2_x*n3_z*o3_y - a2_y*n2_x*o2_z + a2_y*n2_x*o3_z + a2_y*n2_z*o2_x - a2_y*n2_z*o3_x + a2_y*n3_x*o2_z - a2_y*n3_x*o3_z - a2_y*n3_z*o2_x + a2_y*n3_z*o3_x + a2_z*n2_x*o2_y - a2_z*n2_x*o3_y - a2_z*n2_y*o2_x + a2_z*n2_y*o3_x - a2_z*n3_x*o2_y + a2_z*n3_x*o3_y + a2_z*n3_y*o2_x - a2_z*n3_y*o3_x - a3_x*n2_y*o2_z + a3_x*n2_y*o3_z + a3_x*n2_z*o2_y - a3_x*n2_z*o3_y + a3_x*n3_y*o2_z - a3_x*n3_y*o3_z - a3_x*n3_z*o2_y + a3_x*n3_z*o3_y + a3_y*n2_x*o2_z - a3_y*n2_x*o3_z - a3_y*n2_z*o2_x + a3_y*n2_z*o3_x - a3_y*n3_x*o2_z + a3_y*n3_x*o3_z + a3_y*n3_z*o2_x - a3_y*n3_z*o3_x - a3_z*n2_x*o2_y + a3_z*n2_x*o3_y + a3_z*n2_y*o2_x - a3_z*n2_y*o3_x + a3_z*n3_x*o2_y - a3_z*n3_x*o3_y - a3_z*n3_y*o2_x + a3_z*n3_y*o3_x), (a2_x*n2_y*o2_z*p3_y - a2_x*n2_y*o3_y*p2_z + a2_x*n2_y*o3_y*p3_z - a2_x*n2_y*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*p2_z + a3_x*n3_y*o2_y*p3_z + a3_x*n3_y*o2_z*p2_y - a3_x*n3_y*o3_z*p2_y - a3_x*n3_z*o2_y*p3_y + a3_x*n3_z*o3_y*p2_y - a3_y*n2_x*o2_y*p2_z + a3_y*n2_x*o2_y*p3_z + a3_y*n2_x*o2_z*p2_y - a3_y*n2_x*o3_z*p2_y + a3_y*n2_y*o2_x*p2_z - a3_y*n2_y*o2_x*p3_z - a3_y*n2_y*o2_z*p2_x + a3_y*n2_y*o2_z*p3_x - a3_y*n2_y*o3_x*p2_z + a3_y*n2_y*o3_x*p3_z + a3_y*n2_y*o3_z*p2_x - a3_y*n2_y*o3_z*p3_x - a3_y*n2_z*o2_x*p2_y + a3_y*n2_z*o2_y*p2_x - a3_y*n2_z*o2_y*p3_x + a3_y*n2_z*o3_x*p2_y + a3_y*n3_x*o2_y*p2_z - a3_y*n3_x*o2_y*p3_z - a3_y*n3_x*o2_z*p2_y + a3_y*n3_x*o3_z*p2_y + a3_y*n3_z*o2_x*p2_y - a3_y*n3_z*o2_y*p2_x + a3_y*n3_z*o2_y*p3_x - a3_y*n3_z*o3_x*p2_y - a3_z*n2_x*o2_y*p3_y + a3_z*n2_x*o3_y*p2_y + a3_z*n2_y*o2_x*p3_y - a3_z*n2_y*o3_x*p3_y - a3_z*n2_y*o3_y*p2_x + a3_z*n2_y*o3_y*p3_x + a3_z*n3_x*o2_y*p3_y - a3_z*n3_x*o3_y*p2_y - a3_z*n3_y*o2_x*p2_y + a3_z*n3_y*o2_y*p2_x - a3_z*n3_y*o2_y*p3_x + a3_z*n3_y*o3_x*p2_y)/(a2_x*n2_y*o2_z - a2_x*n2_y*o3_z - a2_x*n2_z*o2_y + a2_x*n2_z*o3_y - a2_x*n3_y*o2_z + a2_x*n3_y*o3_z + a2_x*n3_z*o2_y - a2_x*n3_z*o3_y - a2_y*n2_x*o2_z + a2_y*n2_x*o3_z + a2_y*n2_z*o2_x - a2_y*n2_z*o3_x + a2_y*n3_x*o2_z - a2_y*n3_x*o3_z - a2_y*n3_z*o2_x + a2_y*n3_z*o3_x + a2_z*n2_x*o2_y - a2_z*n2_x*o3_y - a2_z*n2_y*o2_x + a2_z*n2_y*o3_x - a2_z*n3_x*o2_y + a2_z*n3_x*o3_y + a2_z*n3_y*o2_x - a2_z*n3_y*o3_x - a3_x*n2_y*o2_z + a3_x*n2_y*o3_z + a3_x*n2_z*o2_y - a3_x*n2_z*o3_y + a3_x*n3_y*o2_z - a3_x*n3_y*o3_z - a3_x*n3_z*o2_y + a3_x*n3_z*o3_y + a3_y*n2_x*o2_z - a3_y*n2_x*o3_z - a3_y*n2_z*o2_x + a3_y*n2_z*o3_x - a3_y*n3_x*o2_z + a3_y*n3_x*o3_z + a3_y*n3_z*o2_x - a3_y*n3_z*o3_x - a3_z*n2_x*o2_y + a3_z*n2_x*o3_y + a3_z*n2_y*o2_x - a3_z*n2_y*o3_x + a3_z*n3_x*o2_y - a3_z*n3_x*o3_y - a3_z*n3_y*o2_x + a3_z*n3_y*o3_x), (a2_x*n2_y*o2_z*p3_z - a2_x*n2_y*o3_z*p2_z - a2_x*n2_z*o2_y*p3_z + a2_x*n2_z*o3_y*p3_z + a2_x*n2_z*o3_z*p2_y - a2_x*n2_z*o3_z*p3_y - a2_x*n3_y*o2_z*p3_z + a2_x*n3_y*o3_z*p2_z + a2_x*n3_z*o2_y*p2_z - a2_x*n3_z*o2_z*p2_y + a2_x*n3_z*o2_z*p3_y - a2_x*n3_z*o3_y*p2_z - a2_y*n2_x*o2_z*p3_z + a2_y*n2_x*o3_z*p2_z + a2_y*n2_z*o2_x*p3_z - a2_y*n2_z*o3_x*p3_z - a2_y*n2_z*o3_z*p2_x + a2_y*n2_z*o3_z*p3_x + a2_y*n3_x*o2_z*p3_z - a2_y*n3_x*o3_z*p2_z - a2_y*n3_z*o2_x*p2_z + a2_y*n3_z*o2_z*p2_x - a2_y*n3_z*o2_z*p3_x + a2_y*n3_z*o3_x*p2_z + a2_z*n2_x*o2_y*p3_z - a2_z*n2_x*o3_y*p3_z - a2_z*n2_x*o3_z*p2_y + a2_z*n2_x*o3_z*p3_y - a2_z*n2_y*o2_x*p3_z + a2_z*n2_y*o3_x*p3_z + a2_z*n2_y*o3_z*p2_x - a2_z*n2_y*o3_z*p3_x - a2_z*n3_x*o2_y*p3_z + a2_z*n3_x*o3_y*p3_z + a2_z*n3_x*o3_z*p2_y - a2_z*n3_x*o3_z*p3_y + a2_z*n3_y*o2_x*p3_z - a2_z*n3_y*o3_x*p3_z - a2_z*n3_y*o3_z*p2_x + a2_z*n3_y*o3_z*p3_x + a2_z*n3_z*o2_x*p2_y - a2_z*n3_z*o2_x*p3_y - a2_z*n3_z*o2_y*p2_x + a2_z*n3_z*o2_y*p3_x - a2_z*n3_z*o3_x*p2_y + a2_z*n3_z*o3_x*p3_y + a2_z*n3_z*o3_y*p2_x - a2_z*n3_z*o3_y*p3_x - a3_x*n2_y*o2_z*p3_z + a3_x*n2_y*o3_z*p2_z + a3_x*n2_z*o2_y*p3_z - a3_x*n2_z*o3_y*p3_z - a3_x*n2_z*o3_z*p2_y + a3_x*n2_z*o3_z*p3_y + a3_x*n3_y*o2_z*p3_z - a3_x*n3_y*o3_z*p2_z - a3_x*n3_z*o2_y*p2_z + a3_x*n3_z*o2_z*p2_y - a3_x*n3_z*o2_z*p3_y + a3_x*n3_z*o3_y*p2_z + a3_y*n2_x*o2_z*p3_z - a3_y*n2_x*o3_z*p2_z - a3_y*n2_z*o2_x*p3_z + a3_y*n2_z*o3_x*p3_z + a3_y*n2_z*o3_z*p2_x - a3_y*n2_z*o3_z*p3_x - a3_y*n3_x*o2_z*p3_z + a3_y*n3_x*o3_z*p2_z + a3_y*n3_z*o2_x*p2_z - a3_y*n3_z*o2_z*p2_x + a3_y*n3_z*o2_z*p3_x - a3_y*n3_z*o3_x*p2_z - a3_z*n2_x*o2_y*p2_z + a3_z*n2_x*o2_z*p2_y - a3_z*n2_x*o2_z*p3_y + a3_z*n2_x*o3_y*p2_z + a3_z*n2_y*o2_x*p2_z - a3_z*n2_y*o2_z*p2_x + a3_z*n2_y*o2_z*p3_x - a3_z*n2_y*o3_x*p2_z - a3_z*n2_z*o2_x*p2_y + a3_z*n2_z*o2_x*p3_y + a3_z*n2_z*o2_y*p2_x - a3_z*n2_z*o2_y*p3_x + a3_z*n2_z*o3_x*p2_y - a3_z*n2_z*o3_x*p3_y - a3_z*n2_z*o3_y*p2_x + a3_z*n2_z*o3_y*p3_x + a3_z*n3_x*o2_y*p2_z - a3_z*n3_x*o2_z*p2_y + a3_z*n3_x*o2_z*p3_y - a3_z*n3_x*o3_y*p2_z - a3_z*n3_y*o2_x*p2_z + a3_z*n3_y*o2_z*p2_x - a3_z*n3_y*o2_z*p3_x + a3_z*n3_y*o3_x*p2_z)/(a2_x*n2_y*o2_z - a2_x*n2_y*o3_z - a2_x*n2_z*o2_y + a2_x*n2_z*o3_y - a2_x*n3_y*o2_z + a2_x*n3_y*o3_z + a2_x*n3_z*o2_y - a2_x*n3_z*o3_y - a2_y*n2_x*o2_z + a2_y*n2_x*o3_z + a2_y*n2_z*o2_x - a2_y*n2_z*o3_x + a2_y*n3_x*o2_z - a2_y*n3_x*o3_z - a2_y*n3_z*o2_x + a2_y*n3_z*o3_x + a2_z*n2_x*o2_y - a2_z*n2_x*o3_y - a2_z*n2_y*o2_x + a2_z*n2_y*o3_x - a2_z*n3_x*o2_y + a2_z*n3_x*o3_y + a2_z*n3_y*o2_x - a2_z*n3_y*o3_x - a3_x*n2_y*o2_z + a3_x*n2_y*o3_z + a3_x*n2_z*o2_y - a3_x*n2_z*o3_y + a3_x*n3_y*o2_z - a3_x*n3_y*o3_z - a3_x*n3_z*o2_y + a3_x*n3_z*o3_y + a3_y*n2_x*o2_z - a3_y*n2_x*o3_z - a3_y*n2_z*o2_x + a3_y*n2_z*o3_x - a3_y*n3_x*o2_z + a3_y*n3_x*o3_z + a3_y*n3_z*o2_x - a3_y*n3_z*o3_x - a3_z*n2_x*o2_y + a3_z*n2_x*o3_y + a3_z*n2_y*o2_x - a3_z*n2_y*o3_x + a3_z*n3_x*o2_y - a3_z*n3_x*o3_y - a3_z*n3_y*o2_x + a3_z*n3_y*o3_x)))'
Expanded that looks like:
FiniteSet(((a2_x*n2_y*o2_z*p3_x - a2_x*n2_y*o3_x*p2_z + a2_x*n2_y*o3_x*p3_z -
a2_x*n2_y*o3_z*p3_x - a2_x*n2_z*o2_y*p3_x + a2_x*n2_z*o3_x*p2_y -
a2_x*n2_z*o3_x*p3_y + a2_x*n2_z*o3_y*p3_x + a2_x*n3_x*o2_y*p2_z -
a2_x*n3_x*o2_y*p3_z - a2_x*n3_x*o2_z*p2_y + a2_x*n3_x*o2_z*p3_y -
a2_x*n3_x*o3_y*p2_z + a2_x*n3_x*o3_y*p3_z + a2_x*n3_x*o3_z*p2_y -
a2_x*n3_x*o3_z*p3_y - a2_x*n3_y*o2_z*p3_x + a2_x*n3_y*o3_x*p2_z -
a2_x*n3_y*o3_x*p3_z + a2_x*n3_y*o3_z*p3_x + a2_x*n3_z*o2_y*p3_x -
a2_x*n3_z*o3_x*p2_y + a2_x*n3_z*o3_x*p3_y - a2_x*n3_z*o3_y*p3_x -
a2_y*n2_x*o2_z*p3_x + a2_y*n2_x*o3_x*p2_z - a2_y*n2_x*o3_x*p3_z +
a2_y*n2_x*o3_z*p3_x + a2_y*n2_z*o2_x*p3_x - a2_y*n2_z*o3_x*p2_x -
a2_y*n3_x*o2_x*p2_z + a2_y*n3_x*o2_x*p3_z + a2_y*n3_x*o2_z*p2_x -
a2_y*n3_x*o3_z*p2_x - a2_y*n3_z*o2_x*p3_x + a2_y*n3_z*o3_x*p2_x +
a2_z*n2_x*o2_y*p3_x - a2_z*n2_x*o3_x*p2_y + a2_z*n2_x*o3_x*p3_y -
a2_z*n2_x*o3_y*p3_x - a2_z*n2_y*o2_x*p3_x + a2_z*n2_y*o3_x*p2_x +
a2_z*n3_x*o2_x*p2_y - a2_z*n3_x*o2_x*p3_y - a2_z*n3_x*o2_y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a3_z*n3_y*o3_x*p2_x)/(a2_x*n2_y*o2_z - a2_x*n2_y*o3_z - a2_x*n2_z*o2_y +
a2_x*n2_z*o3_y - a2_x*n3_y*o2_z + a2_x*n3_y*o3_z + a2_x*n3_z*o2_y -
a2_x*n3_z*o3_y - a2_y*n2_x*o2_z + a2_y*n2_x*o3_z + a2_y*n2_z*o2_x -
a2_y*n2_z*o3_x + a2_y*n3_x*o2_z - a2_y*n3_x*o3_z - a2_y*n3_z*o2_x +
a2_y*n3_z*o3_x + a2_z*n2_x*o2_y - a2_z*n2_x*o3_y - a2_z*n2_y*o2_x +
a2_z*n2_y*o3_x - a2_z*n3_x*o2_y + a2_z*n3_x*o3_y + a2_z*n3_y*o2_x -
a2_z*n3_y*o3_x - a3_x*n2_y*o2_z + a3_x*n2_y*o3_z + a3_x*n2_z*o2_y -
a3_x*n2_z*o3_y + a3_x*n3_y*o2_z - a3_x*n3_y*o3_z - a3_x*n3_z*o2_y +
a3_x*n3_z*o3_y + a3_y*n2_x*o2_z - a3_y*n2_x*o3_z - a3_y*n2_z*o2_x +
a3_y*n2_z*o3_x - a3_y*n3_x*o2_z + a3_y*n3_x*o3_z + a3_y*n3_z*o2_x -
a3_y*n3_z*o3_x - a3_z*n2_x*o2_y + a3_z*n2_x*o3_y + a3_z*n2_y*o2_x -
a3_z*n2_y*o3_x + a3_z*n3_x*o2_y - a3_z*n3_x*o3_y - a3_z*n3_y*o2_x +
a3_z*n3_y*o3_x), (a2_x*n2_y*o2_z*p3_y - a2_x*n2_y*o3_y*p2_z +
a2_x*n2_y*o3_y*p3_z - a2_x*n2_y*o3_z*p3_y - a2_x*n2_z*o2_y*p3_y +
a2_x*n2_z*o3_y*p2_y + a2_x*n3_y*o2_y*p2_z - a2_x*n3_y*o2_y*p3_z -
a2_x*n3_y*o2_z*p2_y + a2_x*n3_y*o3_z*p2_y + a2_x*n3_z*o2_y*p3_y -
a2_x*n3_z*o3_y*p2_y - a2_y*n2_x*o2_z*p3_y + a2_y*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o2_y*p2_x - a3_z*n2_z*o2_y*p3_x + a3_z*n2_z*o3_x*p2_y -
a3_z*n2_z*o3_x*p3_y - a3_z*n2_z*o3_y*p2_x + a3_z*n2_z*o3_y*p3_x +
a3_z*n3_x*o2_y*p2_z - a3_z*n3_x*o2_z*p2_y + a3_z*n3_x*o2_z*p3_y -
a3_z*n3_x*o3_y*p2_z - a3_z*n3_y*o2_x*p2_z + a3_z*n3_y*o2_z*p2_x -
a3_z*n3_y*o2_z*p3_x + a3_z*n3_y*o3_x*p2_z)/(a2_x*n2_y*o2_z -
a2_x*n2_y*o3_z - a2_x*n2_z*o2_y + a2_x*n2_z*o3_y - a2_x*n3_y*o2_z +
a2_x*n3_y*o3_z + a2_x*n3_z*o2_y - a2_x*n3_z*o3_y - a2_y*n2_x*o2_z +
a2_y*n2_x*o3_z + a2_y*n2_z*o2_x - a2_y*n2_z*o3_x + a2_y*n3_x*o2_z -
a2_y*n3_x*o3_z - a2_y*n3_z*o2_x + a2_y*n3_z*o3_x + a2_z*n2_x*o2_y -
a2_z*n2_x*o3_y - a2_z*n2_y*o2_x + a2_z*n2_y*o3_x - a2_z*n3_x*o2_y +
a2_z*n3_x*o3_y + a2_z*n3_y*o2_x - a2_z*n3_y*o3_x - a3_x*n2_y*o2_z +
a3_x*n2_y*o3_z + a3_x*n2_z*o2_y - a3_x*n2_z*o3_y + a3_x*n3_y*o2_z -
a3_x*n3_y*o3_z - a3_x*n3_z*o2_y + a3_x*n3_z*o3_y + a3_y*n2_x*o2_z
- a3_y*n2_x*o3_z - a3_y*n2_z*o2_x + a3_y*n2_z*o3_x - a3_y*n3_x*o2_z +
a3_y*n3_x*o3_z + a3_y*n3_z*o2_x - a3_y*n3_z*o3_x
- a3_z*n2_x*o2_y + a3_z*n2_x*o3_y + a3_z*n2_y*o2_x - a3_z*n2_y*o3_x +
a3_z*n3_x*o2_y - a3_z*n3_x*o3_y - a3_z*n3_y*o2_x + a3_z*n3_y*o3_x)))

How to convert symbolic expressions to float in Python?

Now i m trying to solve 6th order of nonlinear equations.
For solving this problem, 'fsolve' is the best module for my situation.
But i have a problem for using this 'fsolve'.
My Equations below : eq1, eq2, eq3, eq4, eq5, eq6
U = (E*h/32)*(pi**4*K3+8*pi**2*K4+16*J2-pi**4/b*K1**2-8*pi**2/b*K1*J1)+pi**2/2*D*((K1*K2)**0.5+(1-v)*K5-v*K6)+F/(4*b)*pi**2*K1
eq1 = diff(U,b_1)
eq2 = diff(U,b_2)
eq3 = diff(U,b_3)
eq4 = diff(U,b_4)
eq5 = diff(U,b_5)
eq6 = diff(U,b_6)
Now i m gonna try to define functions:
def functions(v):
b_1 = v[0]
b_2 = v[1]
b_3 = v[2]
b_4 = v[3]
b_5 = v[4]
b_6 = v[5]
return eq1,eq2,eq3,eq4,eq5,eq6
Until now, all of code is perfectly completed.
But next, I got a error code for 'fsolve'
x0 = [0.1,0.1,0.1,0.1,0.1,0.1]
solutions = fsolve(functions,x0)
Traceback (most recent call last):
File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\sympy\core\expr.py", line 327, in __float__
raise TypeError("can't convert expression to float")
TypeError: can't convert expression to float
Traceback (most recent call last):
File "C:\Users\user\Desktop\-----\trial.py", line 97, in <module>
solutions = fsolve(functions,x0)
File "C:\Users\user\anaconda3\lib\site-packages\scipy\optimize\minpack.py", line 147, in fsolve
res = _root_hybr(func, x0, args, jac=fprime, **options)
File "C:\Users\user\anaconda3\lib\site-packages\scipy\optimize\minpack.py", line 225, in _root_hybr
ml, mu, epsfcn, factor, diag)
error: Result from function call is not a proper array of floats.
Actually i don't know exactly meaning about 'array of floats'.
The eq1~eq6 is really complicated expressions. For example (eq1):
519749583.393768*b_1**3 + 519749583.393768*b_1**2*b_2 + 311849750.036261*b_1**2*b_3 + 222749821.454472*b_1**2*b_4 + 173249861.131256*b_1**2*b_5 + 141749886.380119*b_1**2*b_6 + 589049527.846271*b_1*b_2**2 + 920699262.011818*b_1*b_2*b_3 + 742499404.84824*b_1*b_2*b_4 + 619499503.439037*b_1*b_2*b_5 + 530653420.807624*b_1*b_2*b_6 + 395009683.379264*b_1*b_3**2 + 672299461.117134*b_1*b_3*b_4 + 581053380.409443*b_1*b_3*b_5 + 510299590.968427*b_1*b_3*b_6 + 296183828.527375*b_1*b_4**2 + 524699579.42609*b_1*b_4*b_5 + 469323153.224931*b_1*b_4*b_6 + 236661575.009363*b_1*b_5**2 + 429394392.660243*b_1*b_5*b_6 + 196977114.839905*b_1*b_6**2 + 39642.9110110422*b_1 + 193049845.260542*b_2**3 + 482129613.548124*b_2**2*b_3 + 406949673.808743*b_2**2*b_4 + 350618949.729969*b_2**2*b_5 + 307488215.070719*b_2**2*b_6 + 420149663.228267*b_2*b_3**2 + 732095017.5835*b_2*b_3*b_4 + 645437944.186494*b_2*b_3*b_5 + 575987321.121736*b_2*b_3*b_6 + 326318969.207663*b_2*b_4**2 + 585464236.60242*b_2*b_4*b_5 + 529609601.687166*b_2*b_4*b_6 + 266189415.118358*b_2*b_5**2 + 486862510.0121*b_2*b_5*b_6 + 224616040.694387*b_2*b_6**2 - 29192.3833775011*b_2 + 125272976.510293*b_3**3 + 334349732.001359*b_3**2*b_4 + 299655189.675087*b_3**2*b_5 + 270932940.727941*b_3**2*b_6 + 302393649.018531*b_3*b_4**2 + 549176644.826696*b_3*b_4*b_5 + 501838635.183477*b_3*b_4*b_6 + 252001834.206563*b_3*b_5**2 + 464613445.578031*b_3*b_5*b_6 + 215729827.081362*b_3*b_6**2 - 28558.195613361*b_3 + 92286363.2746599*b_4**3 + 253972873.350655*b_4**2*b_5 + 234063996.922265*b_4**2*b_6 + 234970783.525745*b_4*b_5**2 + 436229928.976872*b_4*b_5*b_6 + 203716223.26551*b_4*b_6**2 - 24903.5955817128*b_4 + 72968765.0411644*b_5**3 + 204424758.743579*b_5**2*b_6 + 191897759.069662*b_5*b_6**2 - 21706.6337724143*b_5 + 60314467.7838601*b_6**3 - 19178.52782655*b_6 + 52.9828871992195*((35.720610813872*b_2**2 + 142.882443255488*b_2*b_3 + 214.323664883232*b_2*b_4 + 285.764886510976*b_2*b_5 + 357.20610813872*b_2*b_6 + 257.188397859878*b_3**2 + 918.529992356708*b_3*b_4 + 1333.56947038455*b_3*b_5 + 1753.55725813553*b_3*b_6 + 893.0152703468*b_4**2 + 2727.7557348775*b_4*b_5 + 3709.44804605594*b_4*b_6 + 2154.22760600582*b_5**2 + 6001.0626167305*b_5*b_6 + 4254.9551116524*b_6**2)*(0.482*b_1**2 + 0.321333333333333*b_1*b_2 + 0.1928*b_1*b_3 + 0.137714285714286*b_1*b_4 + 0.107111111111111*b_1*b_5 + 0.0876363636363637*b_1*b_6 + 0.0964*b_2**2 + 0.137714285714286*b_2*b_3 + 0.107111111111111*b_2*b_4 + 0.0876363636363637*b_2*b_5 + 0.0741538461538462*b_2*b_6 + 0.0535555555555556*b_3**2 + 0.0876363636363637*b_3*b_4 + 0.0741538461538462*b_3*b_5 + 0.0642666666666667*b_3*b_6 + 0.0370769230769231*b_4**2 + 0.0642666666666667*b_4*b_5 + 0.0567058823529412*b_4*b_6 + 0.0283529411764706*b_5**2 + 0.0507368421052632*b_5*b_6 + 0.022952380952381*b_6**2))**0.5*(0.964*b_1 + 0.321333333333333*b_2 + 0.1928*b_3 + 0.137714285714286*b_4 + 0.107111111111111*b_5 + 0.0876363636363637*b_6)/(0.482*b_1**2 + 0.321333333333333*b_1*b_2 + 0.1928*b_1*b_3 + 0.137714285714286*b_1*b_4 + 0.107111111111111*b_1*b_5 + 0.0876363636363637*b_1*b_6 + 0.0964*b_2**2 + 0.137714285714286*b_2*b_3 + 0.107111111111111*b_2*b_4 + 0.0876363636363637*b_2*b_5 + 0.0741538461538462*b_2*b_6 + 0.0535555555555556*b_3**2 + 0.0876363636363637*b_3*b_4 + 0.0741538461538462*b_3*b_5 + 0.0642666666666667*b_3*b_6 + 0.0370769230769231*b_4**2 + 0.0642666666666667*b_4*b_5 + 0.0567058823529412*b_4*b_6 + 0.0283529411764706*b_5**2 + 0.0507368421052632*b_5*b_6 + 0.022952380952381*b_6**2) + (-1.28102213260338e-7*b_2 - 3.20255533150846e-8*b_3 - 3.20255533150846e-8*b_4 - 1.60127766575423e-8*b_6)*(0.482*b_1**2 + 0.321333333333333*b_1*b_2 + 0.1928*b_1*b_3 + 0.137714285714286*b_1*b_4 + 0.107111111111111*b_1*b_5 + 0.0876363636363637*b_1*b_6 + 0.0964*b_2**2 + 0.137714285714286*b_2*b_3 + 0.107111111111111*b_2*b_4 + 0.0876363636363637*b_2*b_5 + 0.0741538461538462*b_2*b_6 + 0.0535555555555556*b_3**2 + 0.0876363636363637*b_3*b_4 + 0.0741538461538462*b_3*b_5 + 0.0642666666666667*b_3*b_6 + 0.0370769230769231*b_4**2 + 0.0642666666666667*b_4*b_5 + 0.0567058823529412*b_4*b_6 + 0.0283529411764706*b_5**2 + 0.0507368421052632*b_5*b_6 + 0.022952380952381*b_6**2) + (1.18477228028269e-9*b_1 + 6.14508444130024e-10*b_2 + 4.60881333097518e-10*b_3 + 1.53627111032506e-10*b_4 + 1.53627111032506e-10*b_5)*(78.9568352087149*b_1**2 + 52.6378901391433*b_1*b_2 + 31.582734083486*b_1*b_3 + 22.5590957739185*b_1*b_4 + 17.5459633797144*b_1*b_5 + 14.3557882197663*b_1*b_6 + 15.791367041743*b_2**2 + 22.5590957739185*b_2*b_3 + 17.5459633797144*b_2*b_4 + 14.3557882197663*b_2*b_5 + 12.1472054167254*b_2*b_6 + 8.77298168985721*b_3**2 + 14.3557882197663*b_3*b_4 + 12.1472054167254*b_3*b_5 + 10.5275780278287*b_3*b_6 + 6.07360270836269*b_4**2 + 10.5275780278287*b_4*b_5 + 9.2890394363194*b_4*b_6 + 4.6445197181597*b_5**2 + 8.31124581144368*b_5*b_6 + 3.75984929565309*b_6**2) + (0.964*b_1 + 0.321333333333333*b_2 + 0.1928*b_3 + 0.137714285714286*b_4 + 0.107111111111111*b_5 + 0.0876363636363637*b_6)*(-1.28102213260338e-7*b_1*b_2 - 3.20255533150846e-8*b_1*b_3 - 3.20255533150846e-8*b_1*b_4 - 1.60127766575423e-8*b_1*b_6 - 1.60127766575423e-8*b_2**2 - 3.20255533150846e-8*b_2*b_3 - 1.60127766575423e-8*b_2*b_5 - 8.00638832877115e-9*b_3**2 + 1.60127766575423e-8*b_3*b_4 - 8.00638832877115e-9*b_3*b_6 - 8.00638832877115e-9*b_4*b_5 + 8.00638832877115e-9*b_4*b_6 + 4.00319416438558e-9*b_5**2 - 8.00638832877115e-9*b_5*b_6 + 4.00319416438558e-9*b_6**2 + 41123.3516712057) - 129937395.848442*(4*b_1 + 1.33333333333333*b_2 + 0.8*b_3 + 0.571428571428572*b_4 + 0.444444444444445*b_5 + 0.363636363636364*b_6)*(b_1**2 + 0.666666666666667*b_1*b_2 + 0.4*b_1*b_3 + 0.285714285714286*b_1*b_4 + 0.222222222222222*b_1*b_5 + 0.181818181818182*b_1*b_6 + 0.2*b_2**2 + 0.285714285714286*b_2*b_3 + 0.222222222222222*b_2*b_4 + 0.181818181818182*b_2*b_5 + 0.153846153846154*b_2*b_6 + 0.111111111111111*b_3**2 + 0.181818181818182*b_3*b_4 + 0.153846153846154*b_3*b_5 + 0.133333333333333*b_3*b_6 + 0.076923076923077*b_4**2 + 0.133333333333333*b_4*b_5 + 0.117647058823529*b_4*b_6 + 0.0588235294117647*b_5**2 + 0.105263157894737*b_5*b_6 + 0.0476190476190477*b_6**2) + (157.91367041743*b_1 + 52.6378901391433*b_2 + 31.582734083486*b_3 + 22.5590957739185*b_4 + 17.5459633797144*b_5 + 14.3557882197663*b_6)*(5.92386140141343e-10*b_1**2 + 6.14508444130024e-10*b_1*b_2 + 4.60881333097518e-10*b_1*b_3 + 1.53627111032506e-10*b_1*b_4 + 1.53627111032506e-10*b_1*b_5 + 2.30440666548759e-10*b_2**2 + 1.53627111032506e-10*b_2*b_3 + 1.53627111032506e-10*b_2*b_4 + 1.53627111032506e-10*b_2*b_6 + 7.6813555516253e-11*b_3**2 - 7.6813555516253e-11*b_3*b_4 + 7.6813555516253e-11*b_3*b_6 + 7.6813555516253e-11*b_4*b_5 + 7.6813555516253e-11*b_4*b_6 + 3.84067777581265e-11*b_5**2 - 251.041666666667)
I must solve such theses 6 equations.
But " Result from function call is not a proper array of floats. " error message comes out.
Is there anyone who help my code?
I'm Python beginning, so Plz understane me

Avoiding value Error into fsolve from scipy.optimize

I'm trying to solve a long block of equations from an EES implementation using the scipy.optimze.fsolve. But in this block of equations there are CoolProp calls that have a range of validation, and sometimes it yields ValueError. I want to know if there is a strategy to avoid ValueError and let fsolve try another guesses.
This is my code:
def block1(x):
def cp_gas(Ti, Tj):
return (1000/(Tj - Ti)*(x[6]*1.25 + x[1]*(0.45 *(((Tj + 273.15)/1000)
-((Ti + 273.15)/1000)) + 1.67*(((Tj + 273.15)/1000)**2 - ((Ti + 273.15)/1000)**2)/2
- 1.27*(((Tj + 273.15)/1000)**3 - ((Ti + 273.15)/1000)**3)/3
+ 0.39*(((Tj + 273.15)/1000)**4 - ((Ti + 273.15)/1000)**4)/4)
+ x[2]*(1.79 *(((Tj + 273.15)/1000) - ((Ti + 273.15)/1000))
+ 0.107*(((Tj + 273.15)/1000)**2 - ((Ti + 273.15)/1000)**2)/2
+ 0.586*(((Tj + 273.15)/1000)**3 - ((Ti + 273.15)/1000)**3)/3
- 0.2*(((Tj + 273.15)/1000)**4 -((Ti + 273.15)/1000)**4)/4)
+ x[3]*(1.11*(((Tj + 273.15)/1000) - ((Ti + 273.15)/1000))
- 0.48*(((Tj + 273.15)/1000)**2 - ((Ti + 273.15)/1000)**2)/2
+ 0.96*(((Tj + 273.15)/1000)**3 - ((Ti + 273.15)/1000)**3)/3
- 0.42*(((Tj + 273.15)/1000)**4 - ((Ti + 273.15)/1000)**4)/4)
+ x[4]*(0.88*(((Tj + 273.15)/1000) - ((Ti + 273.15)/1000))
- 0.0001*(((Tj + 273.15)/1000)**2 - ((Ti + 273.15)/1000)**2)/2
+ 0.54*(((Tj + 273.15)/1000)**3 - ((Ti + 273.15)/1000)**3)/3
- 0.33*(((Tj + 273.15)/1000)**4 - ((Ti + 273.15)/1000)**4)/4)
+ x[5]*(0.37*(((Tj + 273.15)/1000) - ((Ti + 273.15)/1000))
+ 1.05*(((Tj + 273.15)/1000)**2 - ((Ti + 273.15)/1000)**2)/2
- 0.77*(((Tj + 273.15)/1000)**3 - ((Ti + 273.15)/1000)**3)/3
+ 0.21*(((Tj + 273.15)/1000)**4 - ((Ti + 273.15)/1000)**4)/4)))
f = np.zeros(26)
# x[24] = T_out_vent
f[0] = x[0] - cp_gas(T0, Tgas5)
f[1] = m_gas_teoria_conferindo*x[8] - x[9]*0.8 - x[7]
f[2] = x[10] + x[8] - (x[7] + x[9]*0.8)
f[3] = x[9] - x[8]*Z
f[4] = x[12] + x[13] + x[14] + x[15] + x[16] + x[17] - x[11]
f[5] = x[12] - M_CO2*x[8]/x[7]
f[6] = x[13] - M_H2O*x[8]/x[7]
f[7] = x[14] - M_N2*x[8]/x[7]
f[8] = x[15] - M_O2*x[8]/x[7]
f[9] = x[16] - M_SO2*x[8]/x[7]
f[10] = x[17] - (M_Cz*x[8] - 0.8*x[9])/x[7]
f[11] = x[18] - (e*a*((1-omega_ar) + 3.76*(1-omega_ar) + omega_ar)*(MM_ar_CBG)/(MM_CBG)*x[19])
f[12] = x[1] - ((m_gas5-x[7])*FM_g_CO2+x[7]*x[12])/(x[7]*x[11]+(m_gas5-x[7])*FM_g)
f[13] = x[2] - ((m_gas5-x[7])*FM_g_H2O+x[7]*x[13])/(x[7]*x[11]+(m_gas5-x[7])*FM_g)
f[14] = x[3] - ((m_gas5-x[7])*FM_g_N2+x[7]*x[14])/(x[7]*x[11]+(m_gas5-x[7])*FM_g)
f[15] = x[4] - ((m_gas5-x[7])*FM_g_O2+x[7]*x[15])/(x[7]*x[11]+(m_gas5-x[7])*FM_g)
f[16] = x[5] - (x[7]*x[16])/(x[7]*x[11]+(m_gas5-x[7])*FM_g)
f[17] = x[6] - (x[7]*x[17])/(x[7]*x[11]+(m_gas5-x[7])*FM_g)
f[18] = x[20] - x[21]/rho_ar_in
f[19] = (1/3600)*x[21] - (x[10]+x[18])
f[20] = ((x[10]+x[18])*h_in_vent + x[22]) - (x[10] + x[18])*x[23]
f[21] = x[23] - HAPropsSI('H', 'T', x[24] + 273.15, 'P', P_out_vent*1e3, 'W', omega_ar)/1e3
f[22] = x[22] - (0.000012523*x[20] + 0.054570445)
f[23] = x[25] - HAPropsSI('C', 'T', x[24] + 273.15, 'P', P_out_vent*1e3, 'W', omega_ar)/1e3
f[24] = m_gas5 - (x[7]+x[19]+x[18])
f[25] = eta_total - ((m_gas5*x[0]*(Tgas5-T0) - (x[10]+x[18])*x[25]*(x[24]-T0))
/(x[8]*PCI_RSU + x[19]*PCI_CBG))
return f
x = fsolve(block1, np.ones(26))
The code yields ValueError depending on constant values that are previously defined.
ValueError example:
ValueError: The output for key (8) with value (-nan) is outside the range of validity: (0) to (0.94145) :: inputs were:"H","T",1.3025950731911414e+02,"P",2.0132500000000000e+05,"W",1.0890000000000000e-02
If anyone can help me I will be grateful.
Thank in advance
The function you are running doesn't handle NaN values.
You can use try/except blocks to deal with it.
Or change the NaN values to a 0 (or any suitable number of your choice).
Here is a toy example to help you fix your code. You have to decide what should be the correct behavior and use one of the proposed strategies to deal with NaNs.
import bumpy as np
def f(x):
if np.isnan(x):
raise ValueError('NaN is not supported')
return x**x
test_cases = [1, 2, 3, 4, np.nan, 6, 7]
print('skip in case of error')
for x in test_cases:
try:
print(f(x))
except ValueError:
pass
print()
print('fix X in case of NaN')
for x in test_cases:
if np.isnan(x):
x = 0
print(f(x))
Output:
skip in case of error
1
4
27
256
46656
823543
fix X in case of NaN
1
4
27
256
1
46656
823543

Categories

Resources