September 20, 2017, Wednesday
University of Colorado at Boulder Search A to Z Campus Map University of Colorado at Boulder CU 
Search Links


Twoeqns.m

From MathBio

Jump to: navigation, search

TwoEquations.m

The following code was used to set up the system of differential equations for a bacteria at starting position x. fourplots.m was used to graph these equations.

   function dxdt = twoeqns(t,x)
   r = 2e-3; %mm
   r1 = 12.5; %radius of aorta = 12.5mm. radius of capillaries = .004 mm
   r3 = 1e-3; %mm = radius of bacteria
   m = 1e-12; %g
   k = 2.2e-7; %N/m
   % r2 = r1 - yd;  
   v_m = 4250; %mm/s maximum velocity. 4.25e3 mm/s http://www.rwc.uc.edu/koehler/biophys/3e.html
   d = 1e-3; %g/mm^3 density of fluid (water)
   % r1 = 0.125 mm. Large radius (of Aorta). http://www.answers.com/topic/blood-vessel
   % r2 = Distance from center of tube radius
   % r3 = 1e-1 mm. Radius of Bacteria. http://physics.bu.edu/~redner/211-sp06/class01/MKS.html
   Cd = 0.48; %drag coefficient for a sphere
   c = v_m/(r1^2); %Constant representing - 1/4n * deltaP/deltax
   %v = c*(r1^2 - r2^2); %Finding the velocity based on Poiseuille's equation
   %Fd = 0.5*d*(v^2)*Cd*(pi*r3^2);   
           dxdt = zeros(5,1);
           dxdt(1) = x(2);
           dxdt(2) = (0.5*d*((c*(r1^2 - (r1 - x(3))^2))^2)*Cd*(pi*r3^2)- cos(atan2(x(3),x(1)))*k*sqrt(x(1)^2 + x(3)^2))/m;
           dxdt(3) = x(4);
           dxdt(4) = -(sin(atan2(x(3),x(1))*k*sqrt(x(1)^2 + x(3)^2)))/m;
           dxdt(5) = (x(1)^2 + x(3)^2)^(1/2);
end