APPM 2360 Lab #2: Diffusion

APPM 2360
Lab #2: Diffusion
1
Instructions
Labs may be done in groups of 3 or less. One report must be turned in for each group and must
be in PDF format. Labs must include each student’s:
• Name
• Student number
• Section number
This lab is due on Friday, March 21, 2014 at 5pm. Each lab must be turned in through D2L
on the course page. When you submit the lab please include each group members information
(name, student number and section number) in the comments. This allows us to search for a
students lab. Late labs will not be accepted. Once the labs are graded you need to specifically
check that your grade was entered. If you are missing a grade please bring the issue up with your
TA within a week of grading.
The report must be typed (including equations). Simply answering the lab questions will
not earn you a good grade. Please take time to write your report as up to 20% of your grade may
be based on organization, structure, style, grammar, and spelling.
Note: Instead of Recitation number we are now requiring Section number
1
2
Introduction
This lab demonstrates the use of linear systems to model physical processes. Many linear and
nonlinear systems of first-order differential equations are used to analyze modern physical problems
such as the spread of viruses (hepatitis c virus (HCV) and human immunodeficiency virus (HIV)),
fluid flow through porous media, diffusive systems, and countless other physical situations.
In this lab, we will use techniques from linear algebra to solve a system of differential equations
modeling a diffusive system. The steps taken to determine the solution to the system will
incorporate all of your knowledge of linear algebra. Individually each step is a relatively
straightforward problem from linear algebra, but combined, these steps form a very powerful
method for solving linear systems of differential equations. This method will be further addressed
during the course of the semester.
3
The Diffusive System
Consider three containers separated by a semi-permeable membrane as demonstrated below:
Assume that the containers have the same volume, V, and that they each contain some chemical in
a solution with water. The boundaries between these containers are semi-permeable, that is, the
chemical is allowed to pass through the membrane by the process of diffusion, but no water is
allowed to pass between the containers. Further assume that the chemical is not saturated and
remains in solution. We will investigate the diffusion of a chemical in this system using a system of
first order differential equations.
4
Derivation of the Model
Using conservation laws, we can derive a system of differential equations to model the flow of the
chemical through the membranes. The change in concentration of the chemical in one of the
2
containers is proportional to the difference between the concentration of the adjacent containers.
Let y1 (t), y2 (t), and y3 (t) be the concentrations of the chemical in the containers 1, 2, 3,
respectively. Using the conservation law and concentration defined by mass divided by volume of
solution, we have the following system of differential equations:
y10 = k(−y1 + y2 )
y20 = k(y1 − 2y2 + y3 )
y30 = k(y2 − y3 )
where the constant of proportionality, k, depends upon the type of membrane.
5
Questions and Issues to Address
Your report should answer the following questions and address the following issues. For problems
that require a lot of calculations you may scan your handwritten work and incorporate it in your
report:
1. Write the system in matrix form (see page 132 of section 3.2 in Farlow et al.). Call the
coefficient matrix A, let x = [y1 (t), y2 (t), y3 (t)]T .
2. Create a function that takes and input matrix A and outputs the Reduced Row Echelon
Form of A. Use the following template.
function [A] = ReducedRowEchelon(A)
[n,m] = size(A)
for i = 1:n-1
if (A(i,i)==0)
% Interchage row i with row i+1.
end
% Divide piviot row such that the pivot element is one.
for k=1:n
if k~=i
% Use row operations to get the rest of the column elements
% to be zero
end
end
end
end
3
Note that we are assuming that the reduced row echelon form of A has only one zero row.
Save the function in a script file. Then to call the function use the following commands in
the command window.
A = rand(4); %random 4x4 matrix.
R = ReducedRowEchelon(A)
3. Find all equilibrium solutions for this system, that is, solve Ax = 0, where A is the
coefficient matrix and x is as in problem 1. Use Gauss-Jordan Algorithm and your Reduced
Row Echelon function to solve the linear system. Explain the physical meaning of the
equilibrium solution. Is this system consistent or inconsistent? (For help see page 137 of
Section 3.2 in Farlow et al.) Be sure to explain your answer.
4. Calculate the determinant of A. You should do this by hand and show your work in the
appendix, but you may refer to a software program to check your work. What does this say
about the matrix A?
5. For the remainder of this lab, set k = 5. Solve det(A − λI) = 0. To do this, first calculate the
determinant. This will yield a cubic polynomial. Set the polynomial equal to zero and solve
for the roots. These roots are called eigenvalues and are important for determining the
analytical solution to the system.
6. The next step in determining the analytical solution to this system is to find the
corresponding eigenvectors. Eigenvectors are linearly independent vectors that make up one
component of the analytical solution. In this case we must find three eigenvectors. To do
this, we use Gauss-Jordan elimination to find the reduced row echelon form for three
problems, i.e., we solve Bv = 0 for three different coefficient matrices corresponding to the
three eigenvalues determined in the previous problem. The first system is Bv1 = 0, where
B = (A + 5I).
(a) Determine the column vector v1 .
(b) Be sure to clearly show the steps in Gauss-Jordan elimination in the appendix- no
credit will be given without the work.
(c) Check your work by using Matlab and your Reduce Row Echelon function.
(d) Classify this system as consistent or inconsistent?
(e) Choose one solution, that is, fix the arbitrary parameter in eigenvector, v1 .
7. Next find v2 by solving Bv2 = 0, this time where B = (A + 15I). Follow the same guidelines
as in the previous problem.
4
8. One last time, determine v3 by solving Bv3 = 0, where B = A. Again, follow the same
guidelines as before.
9. Determine if the three column vectors, v1 , v2 , and v3 , are linearly independent or not. Be
sure to discuss your methodology for testing for linear independence and include any
necessary calculations and checks using Matlab.
10. The general solution to this system of differential equations is given by the following:
Y (t) = C1 v1 e−5t + C2 v2 e−15t + C3 v3
where Y (t) = [y1 (t), y2 (t), y3 (t)]T . Use this to determine the general solution to the system
by substituting the eigenvectors, that is v1,2,3 , you found in the previous problems. Note
that, since there are infinitely many choices for each of the three eigenvectors, your results
may not agree exactly with other students’ results. Your choice depends on the scalar factor
you chose when determining the column vectors v1,2,3 .
11. Use the initial condition Y (0) = [1, 2, 4]T to determine the arbitrary constants C1,2,3 . What
happens to Y (t) as t → ∞? What does this mean physically? What is happening to the
concentration of the chemical in the containers?
12. Define M (t) = y1 (t) + y2 (t) + y3 (t), and use the following
y1 (t) = (1/6)e−15t (1 − 9e10t + 14e15t )
y2 (t) = (1/3)e−15t (−1 + 7e15t )
y3 (t) = (1/6)e−15t (1 + 9e10t + 14e15t )
Compute M (t) and M 0 (t).
13. Produce a graph of each of the functions y1 (t), y2 (t), and y3 (t) from question 11. Discuss the
behavior for each function as t → ∞. Be sure to
• Label the graph and axes.
• Choose an appropriate domain to adequately explore the function (make sure you don’t
miss anything!).
14. What are M (t) and M 0 (t)? Give a physical interpretation for these quantities. Based on
your discussion, are the results of your computation expected? Explain.
15. In this analysis, we chose a specific value for the parameter k in order to carry out
calculations. What is the physical meaning of k? What effect will changing the value of k
have on the analysis we performed? Explain your reasoning.
5
16. In our discussion of this diffusive system, we made several assumptions that simplified the
model. For instance, we assumed that the semi-permeable membrane was the same between
the containers and that only the chemical could pass through the membrane. Address any
issues that you feel may improve the model. Be sure to discuss your assertions and provide
justification for your claims.
6