from scipy.optimize import fsolve
import math
# Steady Heat Conduction in a Large Uranium Plate
# Variables
L = 0.04 #Thickness of plate[m]
k = 28 #Thermal conductivity[W/m.degree Celcius]
e_gen = 5*(10**6) #Rate of heat generation per unit volume[W/m**3]
h = 45 #Heat transfer coefficient[W/m**2]
T_ambient = 30 #Ambient temperature[degree Celcius]
# Calculations
M = 3 #No of nodes
#These nodes are chosen to be at the two surfaces of the plate and the mid point
del_x = L/(M-1) #Nodal Spacing[m]
#Let the nodes be 0,1 and 2. and temperatures at these nodes are
T0 = 0 #Temperature at node 0[degree Celcius]
#Finding temperatures at other two nodes umath.sing finite difference method
c1 = e_gen*(del_x**2)/k;
c2 = (-h*del_x*T_ambient/k)-(c1/2);
def f1(T):
temp = [0,0]
temp[0] = 2*T[0]-T[1]-c1;
temp[1] = T[0]-1.032*T[1]-c2;
#To find the solution assume an initial value x0 = [a,b]
#then equate [xs,fxs,m] = fsolve(f1,x0')
import math
# Heat transfer from triangular fins
# Variables
k = 180 #Thermal conductivity of aluminium alloy[W/m.degree Celcius]
L = 0.05 #length of fin[m]
b = 0.01 #Base thickness of fin[m]
T_surr = 25 #Temperature of surrounding[degree Celcius
h = 15 #heat transfer coefficient[W/m**2.degree Celcius]
M = 6 #No of equally spaced nodes along the fin
# Calculations and Results
del_x = L/(M-1) #Nodal Spacing[m]
T0 = 200 #Temperature at node 0[degree Celcius]
theta = math.tan(b/2*L);
#sigmaQ_all_sides = kA_left((T_(m-1)-T_m)/del_X)+((T_(m+1)-T_m)/del_x)+(hA_conv(T_surr-T_m)) = 0
#Simplifying above equation we get
print ("((5.5-m)T_(m-1))-((10.008-2m)Tm)+((4.5-m)T_m+1) = -0.29")
#Putting m = 1,2,3,4 we get five equations in five unknowns
#Solving these five equations we get temperatures at node 1,2,3,4 and 5 respectively
def f5(T):
node1 = -8.008*T[0]+3.5*T[1]+0*T[2]+0*T[3]+0*T[4]+900.209;
node2 = 3.5*T[0]-6.008*T[1]+2.5*T[2]+0*T[3]+0*T[4]+0.209;
node3 = 0*T[0]+2.5*T[1]-4.008*T[2]+1.5*T[3]+0*T[4]+0.209;
node4 = 0*T[0]+0*T[1]+1.5*T[2]-2.008*T[3]+0.5*T[4]+0.209;
node5 = 0*T[0]+0*T[1]+0*T[2]+1*T[3]-1.008*T[4]+0.209;
return node1
#Solution(b)
#T1 = T[0],T2 = T[1],T3 = T[2],T4 = T[3],T5 = T[4];
# w = 1 #width[m]
# Q_fin = (h*w*del_x/math.cos(theta))*[(T0+2*(T1+T2+T3+T4)+T5-10*T_surr)] #[W]
# print "The total rate of heat transfer from the fin is",Q_fin,"W"
#Solution(c)
# Q_max = (h*2*w*L/math.cos(theta)*(T0-T_surr)) #[W]
#neta = Q_fin/Q_max;
#print "Efficiency of the fin is",neta
import math
# SteadLy Two-Dimensional Heat Conduction in L-Bars
# Variables
e_gen = 2*(10**6) #Heat generated per unit volume[W/m**3]
k = 15 #Thermal heat conductivity[W/m.degree Celcius]
T_ambient = 25 #Temperature of ambient air[degree Celcius]
T_surface = 90 #Temperature of the bottom surface[degree Celcius]
h = 80#convection coefficient[W/m**2]
q_R = 5000 #Heat flux to which right surface is subjected[W/m**2]
del_x = 0.012
del_y = 0.012 #Dismath.tance between equally spaced nodes[m]
# Calculations
#After substituing values in equations of all nodal points finally we have nine equation and nine unknowns
def f9(T):
temp[0] = -2.064*T[0]+1*T[1]+0*T[2]+1*T[3]+0*T[4]+0*T[5]+0*T[6]+0*T[7]+0*T[8]+11.2;
temp[1] = 1*T[0]-4.128*T[1]+1*T[2]+0*T[3]+2*T[4]+0*T[5]+0*T[6]+0*T[7]+0*T[8]+22.4;
temp[2] = 0*T[0]+1*T[1]-2.128*T[2]+0*T[3]+0*T[4]+1*T[5]+0*T[6]+0*T[7]+0*T[8]+12.8;
temp[3] = 1*T[0]+0*T[1]+0*T[2]-4*T[3]+2*T[4]+109.2;
temp[4] = 0*T[0]+1*T[1]+0*T[2]+1*T[3]-4*T[4]+1*T[5]+0*T[6]+0*T[7]+0*T[8]+109.2;
temp[5] = 0*T[0]+0*T[1]+1*T[2]+0*T[3]+2*T[4]-6.128*T[5]+1*T[6]+0*T[7]+0*T[8]+212.0;
temp[6] = 0*T[0]+0*T[1]+0*T[2]+0*T[3]+0*T[4]+1*T[5]-4.128*T[6]+1*T[7]+0*T[8]+202.4;
temp[7] = 0*T[0]+0*T[1]+0*T[2]+0*T[3]+0*T[4]+0*T[5]+1*T[6]-4.128*T[7]+T[8]+202.4;
temp[8] = 0*T[0]+0*T[1]+0*T[2]+0*T[3]+0*T[4]+0*T[5]+0*T[6]+1*T[7]-2.064*T[8]+105.2;
import math
from numpy import zeros
# Heat Loss through Chimneys
# Variablesa
k = 1.4 #Thermal conductivity of concrete[W/m.degree Celcius]
A = 0.2*0.2 #Area of flow section[m**2]
t = 0.2 #Thickness of the wall[m]
Ti = 300+273 #Average temperature of gases[K]
hi = 70 #Convection heat transfer coefficient inside the chimney[W/m**2]
ho = 21 #Convection heat transfer coefficient outside the chimney[W/m**2]
To = 20+273 #Temperature od outer air[Kelvin]
e = 0.9 #Emissivity
delx = 0.1
dely = 0.1 #Nodal spacing [m]
# Calculations
#Substituing values in all nodal equations and and solving these equations we get temperature at all nodes
def fu9(T):
temp = zeros(8)
temp[0] = 7*T[0]-T[1]-T[2]-2865;
temp[1] = -T[0]+8*T[1]-2*T[3]-2865;
temp[2] = -T[0]+4*T[2]-2*T[3]-T[5];
temp[3] = -T[1]-T[2]+4*T[3]-T[4]-T[6];
temp[4] = -2*T[3]+4*T[4]-2*T[7];
temp[5] = -T[1]-T[2]+3.5*T[5]+(0.3645*(10**(-9))*(T[5]**4))-456.2;
temp[6] = -2*T[3]-T[5]+7*T[6]+(0.729*(10**(-9))*(T[6]**4))-T[7]-912.4;
temp[7] = -2*T[4]-T[6]+7*T[7]+(0.729*(10**(-9))*(T[7]**4))-912.4;
temp[8] = -T[7]+2.5*T[8]+(0.3645*(10**(-9))*(T[8]**4))-456.2;
#T1 = T[0],T2 = T[1],T3 = T[2],T4 = T[3],T5 = T[4],T6 = T[5],T7 = T[6],T8 = T[7],T9 = T[8];
#T_wall = (0.5*T6+T7+T8+0.5*T9)/(0.5+1+1+0.5);
# Results
#print "The average temperature at the outer surface of the chimney weighed by the surface area is",T_wall,"Kelvin"
#Q_chimney = (ho*4*0.6*1*(T_wall-To))+(e*5.67*(10**-8)*0.6*1*((T_wall**4)-((260**4)))) #[W]
#print "The heat transfer is",Q_chimney,"W"
import math
# Transient Heat Conduction in a Large Uranium Plate
# Variables
k = 28 #[W/m.degree Celcius]
a = 12.5*10**(-6) #Thermal diffusivity[m**2/s]
T1_0 = 200
T2_0 = 200 #Initial Temperature[degree Celcius]
e_gen = 5*10**6 #Heat generated per unit volume[W/m**3]
h = 45 #heat transfer coefficient[W/m**2.degree Celcius]
T0 = 0 #Temperature at node 0[degree Celcius]
L = 0.04 #[m]
M = 3 #No of nodes
t = 15 #[seconds]
# Calculations
delx = L/(M-1) #[m]
#The nodes are 0,1 and 2
tau = (a*t)/(delx**2) #Fourier no
#Substituing this value of tau in nodal equations
#The nodal temperatures T1_1 and T2_1 at t = 15sec
T1_1 = 0.0625*T1_0+0.46875*T2_0+33.482 #[degree Celcius]
T2_1 = 0.9375*T1_0+0.032366*T2_0+34.386 #[degree Celcius]
#Similarly the nodal themperatures T1_2,T2_2 at t1 = 2*t = 30sec are
T1_2 = 0.0625*T1_1+0.46875*T2_1+33.482 #[degree Celcius]
T2_2 = 0.9375*T1_1+0.032366*T2_1+34.386 #[degree Celcius]
# Results
print "Temperatures at node 1 and 2 are respectively",T1_1,T2_1,"and",T1_2,T2_2,"degree Celcius"
import math
# Solar Energy Storage in Trombe Walls
# Variables
hin = 10 #[W/m**2]
A = 3*75 #[m**2]
Tin = 21 #[degree Celcius]
k = 0.69 #[W/m.degree Celcius]
a = 4.44*10**(-7) #diffusivity[m**2/s]
kappa = 0.77;
delx = 0.06 #The nodal spacing[m]
L = 0.3 #Length of wall[m]
Tout = 0.6
q_solar = 360 #Ambient temperature in degree Celcius and Solar Radiation between 7am to 10 am
# Calculations and Results
M = (L/delx)+1;
print "No of nodes are",M
#Stability Criterion
del_t = (delx**2)/(3.74*a) #[seconds]
print "The maximum allowable value of the time step is",del_t,"s"
#Therefore any step less than del_t can be used to solve this problem,for convinience let's choose
delt = 900 #[seconds]
tao = a*delt/(delx**2);
print "The mesh Fourier number is",tao
#Initially at 7am or t = 0,the temperature of the wall is said to vary linearly between 21 degree Celcius at node 0 and -1 at node 5
#Temp between two neighbouring nodes is
temp = (21-(-1))/5. #[degree Celcius]
T0_0 = Tin;
T1_0 = T0_0-temp;
T2_0 = T1_0-temp;
T3_0 = T2_0-temp;
T4_0 = T3_0-temp;
T5_0 = T4_0-temp;
T0_1 = ((1-3.74*tao)*T0_0)+(tao*(2*T1_0+36.5));
T1_1 = (tao*(T0_0+T2_0))+(T1_0*(1-(2*tao)));
T2_1 = (tao*(T1_0+T3_0))+(T2_0*(1-(2*tao)));
T3_1 = (tao*(T2_0+T4_0))+(T3_0*(1-(2*tao)));
T4_1 = (tao*(T3_0+T5_0))+(T4_0*(1-(2*tao)));
T5_1 = (T5_0*(1-(2.70*tao)))+(tao*((2*T4_0)+(0.70*Tout)+(0.134*q_solar)));
print ("Nodal temperatures at 7:15am are")
print "Node0:",T0_1,"degree Celcius"
print "Node1:",T1_1,"degree Celcius"
print "Node2:",T2_1,"degree Celcius"
print "Node3:",T3_1,"degree Celcius"
print "Node4:",T4_1,"degree Celcius"
print "Node5:",T5_1,"degree Celcius"
Q_wall = hin*A*delt*(((round(T0_1)+T0_0)/2)-Tin) #[J]
print "The amount of heat transfer during the first time step or during the first 15 min period is",Q_wall,"J"
#Similarly using values from the table given we can find temperature at various nodes after required time interval