1170:Lab5 Septempber 18th, 2012

advertisement
1170:Lab5
Septempber 18th, 2012
Goals For This Week
This week will be similar to last week, except that we’ll simulate the heart model in section 1.11 I’ll
briefly describe the model and give a quick guide on how to implement it. It will be similar to last week’s
lab, but will require us to include an if statement.
1
A simple heart model
The mechanisms controlling the coordinated beating of the heart are extremely complicated. We’ll only look
at a simplified version of how each heart beat is initiated.
First, the SA node, which acts as a pacemaker, sends a signal that it’s time for the next beat. The heart
can’t contract properly unless it has had had enough recovery. Therefore, the signal from the SA node first
passes through the AV node. The AV node will only fire if its voltage is below a critical value Vc . Between
beats, the voltage of the AV node decays continuously.
Let Vt be the voltage of the AV node at time t. It takes a time τ for the next signal to arrive from the
SA node, during this time the voltage decays to V̂t = e−ατ Vt . If V̂t < Vc then the AV node fires and the
voltage increases to Vt+1 = e−ατ Vt + u. Otherwise, the AV node fails to fire, so Vt+1 = e−ατ Vt + u.
If we let c = e−ατ , then Vt+1 = cVt + u if cVt < Vc and Vt+1 = cVt otherwise.
2
Implementation in R
To do this assignment, create a new .R file. In this file, we’re going to write two functions.
First, we’ll need to encode the discrete dynamical system.
Start with the skeleton.
f<-function(V,c,u,Vc){
<code goes here>
}
The tricky thing about this function is that it has two different definitions, so we’ll need to use something
called an if statement. Suppose that if cVt < 3 then Vt+1 = u and that otherwise Vt+1 = 16. We’d encode
that like this.
f<-function(V,c,u,Vc){
if(c*V<3){u}
else{16}
}
You’re going to have to change that code so that it matches up with the model.
Next, you’ll need to write a function similar to the ”lungs” function from last week. I’d call this one
heart. It will have the same basic structure as last week except you’ll want to use the function ’f’ in the for
loop. The function heart should take arguments V 0,c,u,Vc and N . N is the number of beats and V 0 is the
initial voltage.
1
3
Assignment for this week
Please include all your code. Let u = 1, Vc = 1. Create plots of the voltage for c = 1/3, 2/3, .4999, .5001.
For each value of c include a plot with N = 10 and N = 30. Describe what is happening to the heart in
each picture and how you can tell based off of your plots. Finally, what happens when you change the value
of V0 .
2
Download