I need to solve the attached equation for "theta2" given the attached values. There should be 56 results because there are 7 different insulation thicknesses(Linsluation/d2/hc), 4 different temperatures (theta1), and 2 e values (em, ec) which must be tested.
Given data:
k = .5
d1 = 20/12
Linsulation = [2/12,3/12,4/12,5/12,6/12,7/12,8/12]
em = .09
ec = .9
sigma = .171*10**(-8)
theta1 = [800, 900, 1000, 1100]
theta3 = 70
d2 = []
for i in range(len(Linsulation)):
di = (d1+(2*Linsulation[i]))
d2.append(di)
pi=math.pi
theta2 = sym.symbols("theta2")
hc=[]
for i in range(len(d2)):
hi = .270*((theta2-theta3)**(.25))*(d2[i]**(-.25))
hc.append(hi)
[enter image description here](https://i.stack.imgur.com/MgBrp.png)
I tried:
import math
import sympy as sym
from sympy import symbols, Eq, solve
import scipy
from scipy.optimize import fsolve
from math import pi
k = .5
d1 = 20/12
Linsulation = [2/12,3/12,4/12,5/12,6/12,7/12,8/12]
em = .09
ec = .9
sigma = .171*10**(-8)
theta1 = [800, 900, 1000, 1100]
theta3 = 70
d2 = []
for i in range(len(Linsulation)):
di = (d1+(2*Linsulation[i]))
d2.append(di)
pi=math.pi
theta2 = sym.symbols("theta2")
hc=[]
for i in range(len(d2)):
hi = .270*((theta2-theta3)**(.25))*(d2[i]**(-.25))
hc.append(hi)
def fun(e):
for i in range(len(Linsulation)):
for j in range(len(theta1)):
return (pi)*d2[i]*hc[i]*(theta2-theta3)+(pi)*d2[i]*e*sigma*(((theta2+460)**4)-((theta3+460)**4))-(2*(pi)*k*(theta1[j]-theta2))/ln(d2[i]/d1)
theta2 = fsolve(fun(em))
print(theta2)
I don't understand how fsolve should work in this context. What is the best way I can solve the equation for multiple values and when the variables cannot be separated?
Attempt 2:
import math
import sympy as sym
from sympy import symbols, Eq, solve
import scipy
from scipy.optimize import fsolve
from math import pi
k = .5
d1 = 20/12
Linsulation = [2/12,3/12,4/12,5/12,6/12,7/12,8/12]
em = .09
ec = .9
sigma = .171*10**(-8)
theta1 = [800, 900, 1000, 1100]
theta3 = 70
d2 = []
for i in range(len(Linsulation)):
di = (d1+(2*Linsulation[i]))
d2.append(di)
pi=math.pi
theta2 = sym.symbols("theta2")
hc=[]
for i in range(len(d2)):
hi = .270*((theta2-theta3)**(.25))*(d2[i]**(-.25))
hc.append(hi)
def fcn(theta2):
for i in range(len(Linsulation)):
for j in range(len(theta1)):
LHS = (pi)*d2[i]*hc[i]*(theta2-theta3)+(pi)*d2[i]*em*sigma*(((theta2+460)**4)-((theta3+460)**4))-(2*(pi)*k*(theta1[j]-theta2))/ln(d2[i]/d1)
return LHS
theta2_initial = 300 # Your inital guess
result = fsolve(fcn, [theta2_initial,])
Resulted in: error: Result from function call is not a proper array of floats.