Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Numerical The numerical solutions compered well with the analytical solution.

This is thought to be due to a linear profile being simple to approximate. And it is thought that if the numerical solution was overlapped that the difference would be negligible/non-existent. The quality of the image did not improve much with an increase in data points used, although the line became crisper. This in turn leads to a greater accuracy in the final result

Numerical

Analytical

Clear Clc LX =1; % Length of the brick 1. NX =1000; % Number of data points. DX =LX/(NX-1); %Spacing between each point. C(NX,NX)=0; % Seeding the matrix of coefficients with 0. D(NX) =0; % Seeding the result matrix with 0. for i=2:NX-1; % Loop inside points for first equilibrium state. C(i,i) =(-2/DX^2); % Coefficients of inside points (central difference formula). C(i,i+1) =(1/DX^2); % Coefficients of inside points (central difference formula). C(i,i-1) =(1/DX^2); % Coefficients of inside points (central difference formula). end

C(1,1) =1; % Boundary condition to 1. C(NX,NX) =1;

D(NX) =45; % Initial condition at first equilibrium state. D(1) =300; % Initial condition at first equilibrium state. sol=inv(C)*D.'; % Inverting coefficient matrix and multiplying the result matrix. x=0:DX:LX; % Range of values. plot(x,sol,'red'); % Plotting the profile using red. hold on; % Holds previous plot. C(NX,NX) =0; % Seeding the matrix of coefficients with 0. D(NX) =0; % Seeding the result matrix with 0.

for i=2:NX-1; % Loop inside points for equilibrium state. C(i,i) =(-2/DX^2); % Coefficients of inside points (central difference formula). C(i,i+1) =(1/DX^2); % Coefficients of inside points (central difference formula). C(i,i-1) =(1/DX^2); % Coefficients of inside points (central difference formula). end C(1,1) =1; % Boundary condition to 1. C(NX,NX) =1;

D(NX) =45; % Initial condition at equilibrium state. D(1) =0; % Initial condition at equilibrium state. soln=inv(C)*D.'; % Initial condition at equilibrium state. x=0:DX:LX; % Range of values. plot(x,soln,'blue'); % Plots the profile using blue. Numerical profiles of each equilibrium states on one window. figure % Opens another window and plots the theoretical profiles for the 2 equilibrium states. y=45*x; % Theoretical profile for second equilibrium state. plot(x,y,'green'); % Plots the profile using green. hold on; % Holds on to the previous plot. z=300-(255*x); % Theoretical profile for the 1st equilibrium state. plot(x,z,'black'); % Plots the profile using black.

You might also like