0% found this document useful (0 votes)
31 views

Institiute of Space Technology Matlab Assignment 03

The document contains two MATLAB assignments for a materials science and engineering student named M.Tayyab Ahsan. The first assignment involves plotting the variation of diffusion coefficient with temperature using inputs for activation energy, diffusivity, and temperature ranges. The second assignment calculates carbon concentration profiles during diffusion using inputs for surface concentration, bulk concentration, diffusion coefficient, case depth, and time, and can also calculate the required time for a heat treatment process.

Uploaded by

Tayyab Ahsan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Institiute of Space Technology Matlab Assignment 03

The document contains two MATLAB assignments for a materials science and engineering student named M.Tayyab Ahsan. The first assignment involves plotting the variation of diffusion coefficient with temperature using inputs for activation energy, diffusivity, and temperature ranges. The second assignment calculates carbon concentration profiles during diffusion using inputs for surface concentration, bulk concentration, diffusion coefficient, case depth, and time, and can also calculate the required time for a heat treatment process.

Uploaded by

Tayyab Ahsan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Institiute of Space Technology

MatLab
Assignment 03

Name:
M.Tayyab Ahsan
Department:
Materials science and Engineering
Submitted To:
Sir Arhum
Date of submission:
21 Dec, 2015
Q1:

Code:
q=input('Enter the activation energy');
d=input('Enter the diffusivity');
t1=input('Enter the first temperature range');
t2=input('Enter the 2nd temperature range');
inc=input('Enter the increment you want in temperature range')
if t2>900;
disp('warning the calculation is irrespective of crystal structure
changes')
end
r=1.987;
t=t1:inc:t2
a=-q./(r.*t);
d1=d.*exp(a);
plot(t,d1)
xlabel('Temperature')
ylabel('Diffusion coefficient')
title('variation of diffusion coefficient with temperature')
Output:
Q2

Code :
cs=input('Enter the concentration of carbon at surface:');
co=input('Enter the concentration of carbon at bulk:');
t=input('Enter the temperature of the system (kelvins):');
d=input('Enter the value of the diffusion coefficient:');
x=input('Enter the case depth of the material (m):');
time=input('Enter the time for diffusion (s):');
x1=0:0.01:x;
p=x1./(2*sqrt(d*t));
cx=cs-(cs-co).*erf(p);
disp('concentration distance from surface(m)')
for i=1:length(xt)
fprintf('%d %d\n',cx(i),xt(i));
end
prompt=input('Do you want to calculate time for heat treatment? Y or N:
','s')
if prompt=='y'
cs1=input('Enter the concentration of carbon at surface:');
co1=input('Enter the concentration of carbon in material:');
cx1=input('Enter the required concentratoin of carbon in material:');

d1=input('Enter the value of diffusion coefficient:');


x1=input('Enter the case depth of material(m):');

b=(cs1-cx1)/(cs1-co1);
for i=-3:0.01:3
if erf(i)==b
break
end
end

time=((x1/(2*i))^2)/d1;
fprintf('The time required is %ds', 'time')
end
Output:

You might also like