import math
print"Introduction to heat transfer by S.K.Som, Chapter 3, Example 1"
#Length and breadth is given as 1 unit (Gemoetry is Square)
L = 1;#length
#Problem can be divided into two modules
#Solution to module 1 is given by Eq. 3.21, considering the first three terms
#n is the looping parameter
#theta is the non dimensional temperature defined as ((T-100)/100) where T is actual temperature in degree Celcius.
#Initialising theta as zero
theta = 0;
for n in range(1,3):
theta = theta+((2/math.pi)*((math.sin((n*math.pi)/2)*math.sinh((n*math.pi)/2))*((-1)**(n+1)+1)))/(n*math.sinh(n*math.pi));
#Solution to module 2 is given by Eq. 3.24, considering the first three terms
for n in range(1,3):
theta2 = theta+(((3*2)/math.pi)*((math.sin((n*math.pi)/2)*math.sinh((n*math.pi)/2))*((-1)**(n+1)+1)))/(n*math.sinh(n*math.pi));
#Calculating value of temperature from the value of theta
#Temperature in degree celcius
print"Temperature at the centre in Degree C is"
T = theta*100+100
print"T=",T
import math
print"Introduction to heat transfer by S.K.Som, Chapter 3, Example 2"
#Temperature in K at four edges are given
#Theta is non dimensional temperature defined as ((T-300)/100) where T is actual temperature in K.
#Given length as well as the breadth of square plate is ''a''
#Problem can be divided into two modules
#Solution to module 1 is given by Eq. 3.23
#Solution of first module is non dimensional temperature theta1
#theta1=2*math.sinh(pi*y/a)*math.sin(pi*x/a)/(math.sinh(pi))
#Solution to module 2 is given by Eq. 3.24
#Solution of second module is non dimensional temperature theta2
#theta2=math.sinh(pi*x/a)*math.sin(pi*y/a)/(math.sinh(pi))
#Therefore
print"Steady state non dimensional temperature is"
print"theta=2*math.sinh(pi*y/a)*math.sin(pi*x/a)/(math.sinh(pi)) + math.sinh(pi*x/a)*math.sin(pi*y/a)/(math.sinh(pi))"
#At the centre, x coordinate and y coordinate in unit are
#x=a/2, y=a/2
#Non dimensional temperature at centre point
theta = (2*math.sinh(math.pi/2))/math.sinh(math.pi)+math.sinh(math.pi/2)/math.sinh(math.pi);
#Temperature in K at centre point
print"theta=",theta
print"Temperature in K at centre point"
T = theta*100+300
print"T=",T
import math
import numpy
print"Introduction to heat transfer by S.K.Som, Chapter 3, Example 3"
#internodal distance in x direction in m
deltax = 1.0/4;
#internodal distance in y direction in m
deltay = 1.0/4;
#Air temperature in degree K
Tinfinity = 400;
#Heat transfer coefficient in W/(m**2*K)
h = 10;
#T1, T2, T3, T4, T5, T6, T7, T8 are nodal temperatures in degree K.
#T is the temperature matrix and is transpose of [T1 T2 T3 T4 T5 T6 T7 T8]
#using Nodal Equations, we have Coefficeint Matrix A as
A = [[-4,1,0,0,1,0,0,0],[1,-4,1,0,0,1,0,0],[0,1,-4,1,0,0,1,0],[2,0,0,0,-4,1,0,0],[0,2,0,0,1,-4,1,0],[0,0,2,0,0,1,-4,1],[0,0,2,-6,0,0,0,1],[0,0,0,2,0,0,2,-6]]#Coefficient matrix B
B = [[-1200],[-600],[-600],[-600],[0],[0],[-1400],[-800]]
#Therefore the temperature matrix is
T = numpy.linalg.inv(A)*B;
#Temperature at nodal points in degree K
print"Temperatures at nodal points in degree K"
print"T1 in degree K"
T1 = T[0]
print T1
print"T2 in degree K"
T2 = T[1]
print T2
print"T3 in degree K"
T3 = T[2]
print T3
print"T4 in degree K"
T4 = T[3]
print T4
print"T5 in degree K"
T5 = T[4]
print T5
print"T6 in degree K"
T6 = T[5]
print T6
print"T7 in degree K"
T7 = T[6]
print T7
print"T8 in degree K"
T8 = T[7]
print T8
import math
import numpy
print"Introduction to heat transfer by S.K.Som, Chapter 3, Example 5"
#Thermal conductivity of aluminium in W/(m*K)
k = 200.0
#Diameter in m
d = 20*(10**(-3));
#Length of fin in m
L = 0.2;
#Wall temperature in degree C
Tw = 400.0;
#Air temperature in degree C
Tinfinity = 30;
#Heat transfer coefficient in W/(m**2*K)
h = 40.0;
#internodal distance in x direction in m
deltax = L/5;
#Node 1 temperature is equal to wall temperature in degree C
T1 = Tw;
#using Nodal Equations, we have Coefficeint Matrix A as
A = [[2.064,-1,0,0,0],[-1,2.064,-1,0,0],[0,-1,2.064,-1,0],[0,0,-1,2.064,-1],[0,0,0,-1,1.032]]
#Coefficient matrix B
B = [401.92,1.92,1.92,1.92,0.96]
#T2, T3, T4, T5, T6 are nodal temperature in degree C
#T is the temperature matrix and is transpose of [T2 T3 T4 T5 T6]
#Therefore the temperature matrix is
T = numpy.linalg.inv(A)**B;
#Temperature at nodal points in degree C
print"Temperatures at nodal points in degree C"
print"T2 in degree C"
T2 = T[0]
print T2
print"T3 in degree C"
T3 = T[1]
print T3
print"T4 in degree C"
T4 = T[2]
print T4
print"T5 in degree C"
T5 = T[3]
print T5
print"T6 in degree C"
T6 = T[4]
print T6
import math
print"Introduction to heat transfer by S.K.Som, Chapter 3, Example 6"
#Thermal conductivity of concrete in W/mK
k = 2;
#Length in m
L = 0.2;
#Breadth in m
b = 0.2;
#Depth in m
d = 0.2;
#Temperature of hot gas in chimney in degree C
Tg = 400;
#Air temperature in degree C
Tinfinity = 20;
#internodal distance in x direction in m
deltax = 0.1;
#internodal distance in y direction in m
deltay = 0.1;
#Heat transfer coefficient in W/(m**2*K)
h = 20;
#T1, T2, T3, T4, T5, T6, T7, T8, T9 are nodal temperatures in degree K.
#T is the temperature matrix and is transpose of [T1 T2 T3 T4 T5 T6 T7 T8 T9]
#using Nodal Equations, we have Coefficeint Matrix A as
A = numpy.array([[1,0,-4,2,0,1,0,0,0],[0,1,1,-4,1,0,1,0,0],[0,0,0,2,-4,0,0,2,0],[-3,1,1,0,0,0,0,0,0],[0,0,1,0,0,-3,1,0,0],[0,0,0,2,0,1,-6,1,0],[0,0,0,0,2,0,1,-6,1],[0,0,0,0,0,0,0,1,-2],[1,-4,0,2,0,0,0,0,0]]);
#Coefficient matrix B
B = numpy.array([0,0,0,-400,-20,-40,-40,-20,-400]);
#Therefore the temperature matrix is
T = numpy.linalg.inv(A)*B;
#Temperature at nodal points in degree C
print"Temperatures at nodal points in degree C"
print"T1 in degree C"
T1 = T[0]
print T1
print"T2 in degree C"
T2 = T[1]
print T2
print"T3 in degree C"
T3 = T[2]
print T3
print"T4 in degree C"
T4 = T[3]
print T4
print"T5 in degree C"
T5 = T[4]
print T5
print"T6 in degree C"
T6 = T[5]
print T6
print"T7 in degree C"
T7 = T[6]
print T7
print"T8 in degree C"
T8 = T[7]
print T8
print"T9 in degree C"
T9 = T[8]
print T9