Sie sind auf Seite 1von 3

Advanced Modelling Tools for Transport Phenomena. Exercise 1.

John Bruzzo. 15.01.2014


Calculate and plot concentration C versus position x at different times t=0.001,0.01,0.1,1 for the diffusion
of a spot. The concentration distribution is given as:

Introduction.............................................................................................................................................1
Methods..................................................................................................................................................1
Results.....................................................................................................................................................2
Conclusions..............................................................................................................................................3

Introduction
In this exercise, a concentration formula based on two variables, time and the x direction is calculated for
a set of different values of t = 0.001,0.01,0.1, and 1. The diffusion coefficient used for this example is D =
1 and the concentration C0 is 1. After obtaining all the values for these times, the results are plot on a C
vs. X graph.

Methods
In this part of the exercise, all the MatLab commands needed to accomplish the task are presented and
commented at almost every line.

The main feature of this code is the use of two "for" loops to perform the desired calculations.

% Preparing the workspace

clear all % Clears all the variables from the workspace


clc % Clears the output screen.

% Definition of the initial and boundary conditions.


D=1; % Difussion coefficient.
C0=1; % Concentration.

xmax = 10; dx = 0.01; % Maximun length and step size.

nt=0; % Initialization of the time cycle counter to zero.

% Calculation of the concentration

for t=[0.001,0.01,0.1,1] % Desired time to investigate the C.


nt=nt+1; % Increment the counter as the for loop progress.
T(nt)=t; % Store the value of the time used in the array T.
nx=0; % Initialization of the x parameter counter.

for x=0:dx:xmax % Desired x values to investigate the C.


nx=nx+1; % Increment of the x cycle counter.
X(nx)=x; % Save the values of x in the X array.
C(nt,nx)=C0/(2*sqrt(pi*D*t))*exp(-x*x/(4*D*t)); % Calculation of the concentration.
end

end

Results
Next, the results already the concentration stored in matrix C is plot vs. the values store in the X array.

figure(1) % Creates a figure window.


plot(X,C) % Plots the concentration vs. x direction.
grid on % Turns on the grid in the plot.
title('Concentration Vs. X direction') % Sets the title of the graph.
xlabel('X') % Sets the namen of the horizontal axis.
ylabel('C') % Sets the name of the vertical axis.
legend('t=0.001','t=0.01','t=0.1','t=1') % Includes the legeng in the plot.
Conclusions
The calculation of the concentration at different times was performed completely. It can be seen that at
time t = 0.001, the higher concentration is found close to the wall and not reaching a long extension
along the x direction. For the next step, t = 0.01, a lower concentration is found however it is more
diffused along the length. Finally, at t = 1, it is possible to find the lowest value of concentration and a
higher value of diffusion along x.

From the plot, it is also seen that we are not in the presence of a constant source as the concentration at
the vicinity of the wall decreases as the time progress. The results seem coherent with the scope of the
problem.

Published with MATLAB® R2013a

Das könnte Ihnen auch gefallen