Complete using Python code. Numpy and Sympy preferably. The heat diffusion equat
ID: 3834407 • Letter: C
Question
Complete using Python code. Numpy and Sympy preferably.
The heat diffusion equation can be simplified to the following for a 1-D, steady state with constant generation case: T"(x) + q/k = 0 where T(x) is the temperature distribution as a function of x and q/k is heat generation over conductivity. Define a function, solve_bvp, that will accept the following arguments in the following order: q, k, T_0 (value of T(0)), T_L (value of T(L)), L (length of the 1-D slab of material, i.e., the position at second boundary condition), and N (number of points at which to evaluate the temperature). Your function should return T (a np. array of the temperatures) and x (a np. array of x values at which the temperature is evaluated).Explanation / Answer
The 1-D of the heat diffusion equation is basically helps us to verify and calculate the coefficient which examines the No. of changes occuring over a time.
I have developed the Phyton Code using Numpy and Sympy along with the comments for each part of the program. i have attached an Program over here.
Program:-
# The first step is to import the numpy and sympy Files
import numpy as npa
from sympy.parsing.sympy_parser import parse_expr
import lambdify, implemented_function
# Created an function named "sol_bvp" using the following arguments.
def sol_bvp(q,k,T_0,T_L,L,N):
heatFig = 1DPlot.figure()
heatFig.set_dpi(100)
heatAxis = heatFig.add_subplot(1,1,1)
# Let us assume k heatValues as 3
k = 3
# This is an important factor for visualizing the heat generation
scale = 7
# Let us give the heatValues of Length as PI
L = pi
> T_0 = 0
T_L = 7
q = 0.01
def heatUValue(b,v):
return T_L + scale*npa.exp(-k*v)*npa.sin(v)
def oneDValue(v,b):
return scale*npa.array([npa.exp(x)+npa.(q/k)])
a = []
v = []
for i in range(500):
heatValues = heatUValue(oneDArray,T_0) + oneDValue(oneDArray,T_0)[1]*q
v.append(T_0)
T_0 = T_0 + q
a.append(heatValues)
def findTemp(i):
global k
v = a[k]
k += 1
heatAxis.clear()
1DPlot.plot(oneDArray,v,color='Blue',label='The required temparature is')
1DPlot.grid(True)
1DPlot.ylim([T_L-3,3.7*scale])
1DPlot.xlim([0,L])
1DPlot.title('The final heat equation of the 1-D array is')
1DPlot.legend()
heatExp = animation.FuncAnimation(heatFig,findTemp,frames=360,interval=20)
1DPlot.show()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.