Week 3 Programming Assignment 2: Expected Learning Outcomes From This Assignment
Week 3 Programming Assignment 2: Expected Learning Outcomes From This Assignment
1) Solve the 1D heat equation for a 1D rod using FTCS method. The length of the rod is
0.5 m. The 1D metal rod with a thermal conductivity of 0.05 W/mK is at an initial
temperature 300 K. The left side of the rod is set to a temperature of 400 K and the
right end of the rod is set to a temperature of 300K. Divide the rod into 5 grid points
(as shown in Figure below). Using the results from the MATLAB program answer the
following questions.
a) Find the temperature at all 5 nodal points for a total time of 1 second and with a
time step of 0.001 and 0.1 seconds.
b) Find the temperature at all 5 nodal point for a total time of 2 seconds and with a
time step of 0.001 and 0.1 seconds.
c) Find the temperature at all 5 nodal point for a total time of 10 seconds and with a
time step of 0.001 and 0.1 seconds.
1 2 3 4 5
Total time Time step Temperature at
(s) (s) Node 1 Node 2 Node 3 Node 4 Node 5
1 0.001
0.1
2 0.001
0.1
10 0.001
0.1
1. Obtain input from the user for the value of initial and working temperature of the
rod.
2. Obtain input from the user for the value of thermal conductivity of the rod, the
length of the rod and number of grid points required for the discretization of the
domain.
3. Set the total time and time step for the problem.
4. Calculate grid spacing from length of the rod and number of grid points.
5. Define temperature matrix for storing initial values (Boundary conditions are
given at the corner nodes and other nodes are populated with initial values),
temporary values (values from previous iteration), and final value.
6. The discretised 1D conduction equation for FTCS is
𝑇𝑛+1
𝑖 = 𝑇𝑛𝑖 +𝛾(𝑇𝑛𝑖+1 ― 2𝑇𝑛𝑖 + 𝑇𝑛𝑖―1), where 𝛾 = 𝑘(𝛥𝑡) (𝛥𝑥)2
7. Solve the discretised equation using a for loop starting at time t=0s till the desired
time.
8. Display Final temperature at each nodal point.
9. Run the code for different total time and time step.
10. The above algorithm is just a guideline and the candidate is encouraged to write
the MATLAB code as per his/ her interest. In fact, such different attempts are
welcomed as the candidates can share their code with their peers for discussion
once the assignment is closed. This will help everyone in learning better.
11. The candidate can also compare the impact of the various discretization schemes,
number of discretisation points and the time step on the accuracy of the solution
obtained.