Figure 3.12:

Concentration versus membrane penetration distance for different reaction rate constants.

Code for Figure 3.12

Text of the GNU GPL.

main.m


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
nzs = 100;
z = linspace(0,1,nzs)';
kvec = [0, 2, 10, 30, 100];
cs = zeros(length(z), length(kvec));

for i = 1: length(kvec)
  k = kvec(i);
  if (k == 0)
    cs(:,i) = 1-z;
  else
    cs(:,i) = sinh(sqrt(k).*(1-z))./sinh(sqrt(k));
  end
end

figure()
plot(z, cs)
store = [z, cs];
save csz.dat store

%
% check out the transient solution also
% jbr; 11/8/2013
%

nk = 3;
k = kvec(nk);
tvec = [0, 0.001, 0.005, 0.01, 0.05, 0.1, 1.0]';
nts = length(tvec);
nterms = 25;
c = zeros(nzs, nts);
for j = 1:nts
  t = tvec(j);
  sum = 0;
  for n = 1:nterms
    n2p2 = n*n*pi*pi + k;
    term = (-1)^n*(n/n2p2)*sin(n*pi*(1-z))*exp(-n2p2*t);
    sum = sum + term;
  end
  c(:,j) = cs(:,nk) + sum*2*pi;
end
figure()
plot(z,c)