[go: up one dir, main page]

0% found this document useful (0 votes)
39 views3 pages

CFD Explicit Unsteady Code

This document contains a Python script that simulates the temperature variation in a wall over time using the Finite Volume Method (FVM). It initializes parameters such as wall length, thermal conductivity, and boundary conditions, and iteratively calculates temperature at various time intervals. The results are visualized using matplotlib to plot temperature distributions at different time steps.

Uploaded by

Moges
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views3 pages

CFD Explicit Unsteady Code

This document contains a Python script that simulates the temperature variation in a wall over time using the Finite Volume Method (FVM). It initializes parameters such as wall length, thermal conductivity, and boundary conditions, and iteratively calculates temperature at various time intervals. The results are visualized using matplotlib to plot temperature distributions at different time steps.

Uploaded by

Moges
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

# -*- coding: utf-8 -*-

"""
Created on Thu May 16 18:57:15 2019

@author: FRIE SENAY


"""

from numpy import*


from matplotlib import pylab
L=1.0 #the length of the wall
k=20.0
m=10000.0 #m=roh*c
q=50000.0
qint=200.0
h=20.0
Tinf=288.0 #the serounding teperature in degree kelvien
n=20 #the number of node
T0=293.0 # the temprature at t=0 in degree kelvien
dx=L/(n-1)
dt=0.6
ttot1=5
ttot2=10
ttot3=50
ttot4=100
ttot5=1000
aP=m*dx
aP1=m*dx/2
aE=(k*dt)/dx
aP0=(m*dx)-((2*k*dt)/dx)
dt1=(m*dx**2)/(2*k);dt2=(m*dx**2)/(2*k);dt2=(m*dx**2)/(2*k)#stablity
condition(dt<=dt1,anddt<=dt2,dt<=dt3 )
dt2=(m*dx**2)/(2*k)
dt3=(m*dx)/(2*((k/dx)+h))
aP01=((m*dx)/2)-((k*dt)/dx)
aP02=((m*dx)/2)-((k*dt/dx)+(h*dt))
b0=q*dt*dx
b01=(qint*dt)+((q*dx*dt)/2)
b02=(h*dt*Tinf)+((q*dt*dx)/2)
T=array([T0]*n)
Tnew=array([T0]*n)
t=0
#Ttran=[]
#Tmid=[];mid=int(n/2)
x=linspace(0.0,L,n)
while t<ttot1:
t=t+dt
for i in range(1,n-1):
Tnew[i]=((aE*(T[i+1]+T[i-1])+aP0*T[i]+b0))/aP
Tnew[0]=(aE*(T[i+1])+(aP01*T[i]+b01))/aP1
Tnew[n-1]=(aE*(T[i-1])+((aP0*T[i])+b02))/aP1
T=Tnew.copy()
pylab.plot(x,Tnew,)
pylab.xlabel('length of wall in(meter)')
pylab.ylabel(r'$T,^{\circ}k$')
pylab.title('Explicit T varation wall for t =5 second with FVM')
pylab.grid()
pylab.legend(loc=0)
pylab.show()
while t<=ttot2:
t=t+dt
for i in range(1,n-1):
Tnew[i]=(aE*(T[i+1]+T[i-1])+aP0*T[i]+b0)/aP
#Tnew[1:n-1]=(aE*(T[2:n]+T[0:n-2])+ap0*T[1:n-1]+b)/ap
Tnew[0]=T0
Tnew[n-1]=T0
# Ttran.append(Tnew[:])
T=Tnew.copy()
pylab.plot(x,Tnew,)
pylab.xlabel('length of wall in(meter)')
pylab.ylabel(r'$T,^{\circ}k$')
pylab.title('Explicit T varation wall for t =10 second with FVM')
pylab.grid()
pylab.legend(loc=0)
pylab.show()
pylab.show()
while t<=ttot3:
t=t+dt
for i in range(1,n-1):
Tnew[i]=(aE*(T[i+1]+T[i-1])+aP0*T[i]+b0)/aP
#Tnew[1:n-1]=(aE*(T[2:n]+T[0:n-2])+ap0*T[1:n-1]+b)/ap
Tnew[0]=T0
Tnew[n-1]=T0
# Ttran.append(Tnew[:])
T=Tnew.copy()
pylab.plot(x,Tnew,)
pylab.xlabel('length of wall in(meter)')
pylab.ylabel(r'$T,^{\circ}k$')
pylab.title('Explicit T varation wall for t =50 second with FVM')
pylab.grid()
pylab.legend(loc=0)
pylab.show()
pylab.show()
while t<=ttot4:
t=t+dt
for i in range(1,n-1):
Tnew[i]=(aE*(T[i+1]+T[i-1])+aP0*T[i]+b0)/aP
#Tnew[1:n-1]=(aE*(T[2:n]+T[0:n-2])+ap0*T[1:n-1]+b)/ap
Tnew[0]=T0
Tnew[n-1]=T0
# Ttran.append(Tnew[:])
T=Tnew.copy()
pylab.plot(x,Tnew,)
pylab.xlabel('length of wall in(meter)')
pylab.ylabel(r'$T,^{\circ}k$')
pylab.title('Explicit T varation wall for t =100 second with FVM')
pylab.grid()
pylab.legend(loc=0)
pylab.show()
pylab.show()
while t<=ttot5:
t=t+dt
for i in range(1,n-1):
Tnew[i]=(aE*(T[i+1]+T[i-1])+aP0*T[i]+b0)/aP
#Tnew[1:n-1]=(aE*(T[2:n]+T[0:n-2])+ap0*T[1:n-1]+b)/ap
Tnew[0]=T0
Tnew[n-1]=T0
# Ttran.append(Tnew[:])
T=Tnew.copy()
pylab.plot(x,Tnew,)
pylab.xlabel('length of wall in(meter)')
pylab.ylabel(r'$T,^{\circ}k$')
pylab.title('Explicit T varation wall for t =1000 second with FVM')
pylab.grid()
pylab.legend(loc=0)
pylab.show()
pylab.show()

You might also like