Environmental Engineering Reference
In-Depth Information
1
2
i-1
i
i+1
...
...
Fig. 4.3 Cells in series
Imagine a series of cells of equal geometry, as depicted in Fig. 4.3 , representing
an idealized situation in an environmental compartment. It is assumed that there is a
constant flow with velocity v through all cells. When an increased concentration c in
enters the first cell with the flow, how does that affect the concentration distribution
in the entire system? To keep it simple it is assumed that the concentration in each
cell has a single value: the concentration in the i -th cell is designated as c i . The
transport problem is to compute the concentrations c i , depending on time and the
transport parameters.
A simple algorithm is developed in the sequel to mimic the major processes,
advection and dispersion. Let's start with advection: after an appropriate time step
D t the entire system will be shifted by one cell. The time step depends on the
velocity v and the spatial extension of the cells in flow direction
D x . The formula is:
D t ¼ D x=v . In MATLAB
we start with some settings in the command window:
®
and the following command sequence in the editor:
Store the m-file under the name 'advection.m' . The first commands specify the
number of cells N and the initial concentration, which holds for all cells c0 . In the
first row of the m-file the initial concentration is set for all cells. In MATLAB
it is
convenient to work with vectors and thus the concentration distribution in the
system of cells is represented by a row vector c . In the next row the concentration
is shifted by one position to the right. For such an operation MATLAB
®
offers the
circshift command. Parameters of the command are the vector and the number of
positions to be shifted. One has to use the transpose- ' , because circshift operates
on column vectors, only. Additionally the circular shift puts the concentration from
the last cell into the first cell, which is not the intention here. The concentration in
the first cell should be the inflow value c in . This setting is performed in the next
command, which overrides the preceding value in that cell.
In the final row the concentration is plotted. The hold on command ensures that
the new graph is plotted in the same figure-window and that the old graph is not
deleted. Run the small m-file several times, and plots similar to Fig. 4.4 will be
visible on the display:
A front of increased concentration is passing from the left to the right. This
animation is user-controlled, as it is the user who initiates each step with a mouse-
®
 
Search WWH ::




Custom Search