Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
Assignment 5: One-Dimensional Transient Heat Conduction
Overview
You will start from the partial differential equation (PDE) derived from Fourier’s Law in 1D as introduced in MATH-2400 Introduction to Differential Equations that models the temperature distribution through the stainless steel:
where
T(x, t) is the temperature [⁰C] at position x [m] and at time t [s] α is the thermal diffusivity [m2/s] of stainless steel
The left boundary (touching the stove) is at constant temperature: T(0, t) = TLBC
The right boundary (in the pan) is assumed to remain at constant temperature: T(L, t) = TRBC where L is the length of the material (i.e., the thickness of the pan)
In this problem the thermal diffusivity, α, is a function of temperature. This function is a Lagrange polynomial computed from data in a comma separated values (.csv) file provided with this assignment.
There will be five deliverables in this assignment:
The temperature distribution array
The columns of the array correspond to the spatial nodes across the length of the material. E.g., if you use five spatial nodes (probably too few!), this temperature array will have five columns. All of the elements in the first column, including in the first row (the initial condition row) will be set to the left boundary condition temperature, TLBC. Similarly, all of the elements in the last column, including in the first row, will be set to the right boundary condition temperature, TRBC.
Thus, initially this temperature distribution array will look as follows:
Discretizing the PDE
Index n refers to a time step: if time n is the present, then time n+1 is one time step of duration dt into the future. You will choose dt to satisfy a stability criterion, discussed later. Notice that you can solve the discretized equation for This means that you can predict the future one time step of duration dt at a time. For example, given an initial time of 0.0 seconds and a final time of 0.1 seconds, you can loop through this discretized solution (0.1–0.0)/dt times to get the temperatures in the second row of the temperature distribution array. Note that this number of steps will need to be an integer quantity. NumPy function np.ceil() will return a rounded-up integer.
If too-large a time step dt is chosen this numerical method becomes numerically “unstable”, meaning that the solution will increasingly overcorrect its solution at every step to produce chaotic useless results. Analysis that we leave to other courses gives the following stability criterion: where Δt is dt and Δx is L/(nx-1). Thus, your choice of nx will determine your choice of dt to not exceed some value that also depends on the thermal diffusivity, α. However, arbitrarily choosing dt to be unnecessarily small will increase your computation time to potentially annoying durations.
By not specifying a color or line type, matplotlib will display the curves in different colors which can be labelled in a legend with a string built for each curve to specify the time that the curve corresponds to; e.g., something like:
Your plot should conform to all of the specifications for a well presented informative plot.
Code Requirements and Deliverables
o nt is a scalar integer number of rows, the number of curves (6 in this problem)o nx is a scalar integer number of columns, the number of spatial nodeso T 0 is the scalar float initial temperature of the materialo TLBC is the scalar float left boundary condition temperatureo TRBC is the scalar float right boundary condition temperature
This function returns the initial matrix shown previously.
o T_old is a 1D ndarray of floats that are the temperatures at a previous time step.o t_initial is the time to start a calculation from.o t_final is the time to stop the calculation. E.g., to go from 0.3 to 1.0 sections,t_initial = 0.3 seconds and t_final = 1.0 seconds.o dt is the time step you specify, and dx=L/(nx-1) based on the nx you specify.o Right before you compute a time step (to compute ) you must test the dt you selected in module hw05.py to verify that it satisfies the stability criterion for an alpha evaluated at . If it does not, raise a ValueError with a useful error message.
o filename is a string with the name of a .csv file to read data fromo You may add optional keyword parameters (e.g., “print_debug=False”), as long as they are optional parameters. You are not required to do so, and Submitty will not look for them.
o The function should return
a 1D ndarray of float temperature data in degrees C, followed by a 1D ndarray of float thermal diffusivity data in m2/s
o You should look at the file to figure out how to access the correct data.o After you read the data, you must assert that the first temperature is 0.0 and that the last temperature is 1000.0, indicating that you read the data correctly.
o Next you must assert that all of the alphas that you read are less than 1.0e-5, indicating that you read the correct column of thermal diffusivity data. - After you define function read_data, you should set three module variableso One is the name of the file to read in as a string. For this assignment the filename of the data file is “ss304_thermal_diffusivity_data.csv”.o The other two are the two variables returned from invoking read_data. This is why read_data must be defined first: so the function exists before you create these two module variables by calling the function.
o T is a scalar float temperature in degrees [C]o This function returns the scalar float thermal diffusivity [m2/s] for stainless steel at the given temperature in degrees [C]o It does so by using a Lagrange interpolating polynomial to compute alpha for the given temperature based on the data read in and saved in the module variables.o Note that your function interpolate in module lagrange.py has parameter xeval as a 1D ndarray. However, this function alpha has a scalar parameter. You will need to convert the scalar to a one-element ndarray to use interpolate.o Test the user input temperature to verify that it is a scalar. Function np.ndim should return zero if it is a scalar. If it is not a scalar, raise a TypeError with a useful message.o Test the user input temperature to verify that it is between 0.0 and 1000.0, the range of the data used to make the Lagrange polynomial. If it is not, raise a ValueError with a useful message.
lagrange.py
o This function is identical or nearly identical to what you wrote for ICE14_1.o A difference may be in how you tested for a possible division by zero. In the version for this assignment you must verify that the denominator is larger than 1.0e-12 or raise a ZeroDivisionError with a useful message.
The plot
You have learned everything you need to know to solve the problem in this assignment according to the specifications above. You are encouraged to reuse code you have written for other assignments and ICEs, making modifications to it as needed. Plan, organize, test small chunks of code, and use your debugging skills well. Finally, you are encouraged to think about what the results you get mean physically.