Main Content

Solve System of PDEs with Initial Condition Step Functions

This example shows how to solve a system of partial differential equations that uses step functions in the initial conditions.

Consider the PDEs

nt=x[dnx-ancx]+Srn(N-n),ct=2cx2+S(nn+1-c).

The equations involve the constant parameters d, a, S, r, and N, and are defined for 0x1 and t0. These equations arise in a mathematical model of the first steps of tumor-related angiogenesis [1]. n(x,t) represents the cell density of endothelial cells, and c(x,t) the concentration of a protein they release in response to the tumor.

This problem has a constant, steady state when

[n0c0]=[10.5].

However, a stability analysis predicts evolution of the system to an inhomogeneous solution [1]. So step functions are used as the initial conditions to perturb the steady state and stimulate evolution of the system.

The boundary conditions require that both solution components have zero flux at x=0 and x=1.

xn(0,t)=xn(1,t)=0,xc(0,t)=xc(1,t)=0.

To solve this system of equations in MATLAB®, you need to code the equations, initial conditions, and boundary conditions, then select a suitable solution mesh before calling the solver pdepe. You either can include the required functions as local functions at the end of a file (as done here), or save them as separate, named files in a directory on the MATLAB path.

Code Equation

Before you can code the equation, you need to make sure that it is in the form that the pdepe solver expects:

c(x,t,u,ux)ut=x-mx(xmf(x,t,u,ux))+s(x,t,u,ux).

Since there are two equations in the system of PDEs, the system of PDEs can be rewritten as

[1001]t[nc]=x[dnx-ancxcx]+[Srn(N-n)S(nn+1-c)].

The values of the coefficients in the equation are then

m=0

c(x,t,u,ux)=[11] (diagonal values only)

f(x,t,u,ux)=[dnx-ancxcx]

s(x,t,u,ux)=[Srn(N-n)S(nn+1-c)]

Now you can create a function to code the equation. The function should have the signature [c,f,s] = angiopde(x,t,u,dudx):

  • x is the independent spatial variable.

  • t is the independent time variable.

  • u is the dependent variable being differentiated with respect to x and t. It is a two-element vector where u(1) is n(x,t) and u(2) is c(x,t).

  • dudx is the partial spatial derivative u/x. It is a two-element vector where dudx(1) is n/x and dudx(2) is c/x.

  • The outputs c, f, and s correspond to coefficients in the standard PDE equation form expected by pdepe.

As a result, the equations in this example can be represented by the function:

function [c,f,s] = angiopde(x,t,u,dudx)
d = 1e-3;
a = 3.8;
S = 3;
r = 0.88;
N = 1;

c = [1; 1];
f = [d*dudx(1) - a*u(1)*dudx(2)
     dudx(2)];
s = [S*r*u(1)*(N - u(1));
     S*(u(1)/(u(1) + 1) - u(2))];
end

(Note: All functions are included as local functions at the end of the example.)

Code Initial Conditions

Next, write a function that returns the initial condition. The initial condition is applied at the first time value and provides the value of n(x,t0) and c(x,t0) for any value of x. Use the function signature u0 = angioic(x) to write the function.

This problem has a constant, steady state when

[n0c0]=[10.5].

However, a stability analysis predicts evolution of the system to an inhomogenous solution [1]. So, step functions are used as the initial conditions to perturb the steady state and stimulate evolution of the system.

u(x,0)=[n0c0],u(x,0)={1.05u10.3x0.61.0005u20.3x0.6

The corresponding function is

function u0 = angioic(x)
u0 = [1; 0.5];
if x >= 0.3 && x <= 0.6
  u0(1) = 1.05 * u0(1);
  u0(2) = 1.0005 * u0(2);
end
end

Code Boundary Conditions

Now, write a function that evaluates the boundary conditions

xn(0,t)=xn(1,t)=0,xc(0,t)=xc(1,t)=0.

For problems posed on the interval axb, the boundary conditions apply for all t and either x=a or x=b. The standard form for the boundary conditions expected by the solver is

p(x,t,u)+q(x,t)f(x,t,u,ux)=0.

For x=0, the boundary condition equation is

[00]+[11][dnx-ancxcx]=0.

So the coefficients are:

  • pL(x,t,u)=[00],

  • qL(x,t)=[11].

For x=1 the boundary conditions are the same, so pR(x,t,u)=[00] and qR(x,t)=[11].

The boundary function should use the function signature [pl,ql,pr,qr] = angiobc(xl,ul,xr,ur,t), where:

  • The inputs xl and ul correspond to u and x for the left boundary.

  • The inputs xr and ur correspond to u and x for the right boundary.

  • t is the independent time variable.

  • The outputs pl and ql correspond to pL(x,t,u) and qL(x,t) for the left boundary (x=0 for this problem).

  • The outputs pr and qr correspond to pR(x,t,u) and qR(x,t) for the right boundary (x=1 for this problem).

The boundary conditions in this example are represented by the function:

function [pl,ql,pr,qr] = angiobc(xl,ul,xr,ur,t)
pl = [0; 0];
ql = [1; 1];
pr = pl;
qr = ql;
end

Select Solution Mesh

A long time interval is required to see the limiting behavior of the equations, so use 10 points in the interval 0t200. Also, the limit distribution of c(x,t) varies by only about 0.1% over the interval 0x1, so a relatively fine spatial mesh with 50 points is appropriate.

x = linspace(0,1,50);
t = linspace(0,200,10);

Solve Equation

Finally, solve the equation using the symmetry m, the PDE equation, the initial condition, the boundary conditions, and the meshes for x and t.

m = 0;
sol = pdepe(m,@angiopde,@angioic,@angiobc,x,t);

pdepe returns the solution in a 3-D array sol, where sol(i,j,k) approximates the kth component of the solution uk evaluated at t(i) and x(j). Extract the solution components into separate variables.

n = sol(:,:,1);
c = sol(:,:,2);

Plot Solution

Create a surface plot of the solution components n and c plotted at the selected mesh points for x and t.

surf(x,t,c)
title('c(x,t): Concentration of Fibronectin')
xlabel('Distance x')
ylabel('Time t')

Figure contains an axes object. The axes object with title c(x,t): Concentration of Fibronectin, xlabel Distance x, ylabel Time t contains an object of type surface.

surf(x,t,n)
title('n(x,t): Density of Endothelial Cells')
xlabel('Distance x')
ylabel('Time t')

Figure contains an axes object. The axes object with title n(x,t): Density of Endothelial Cells, xlabel Distance x, ylabel Time t contains an object of type surface.

Now plot just the final distributions of the solutions at tf=200. These plots correspond to Figures 3 and 4 in [1].

plot(x,n(end,:))
title('Final distribution of n(x,t_f)')

Figure contains an axes object. The axes object with title Final distribution of n(x,t indexOf f baseline ) contains an object of type line.

plot(x,c(end,:))
title('Final distribution of c(x,t_f)')

Figure contains an axes object. The axes object with title Final distribution of c(x,t indexOf f baseline ) contains an object of type line.

References

[1] Humphreys, M.E. and M.A.J. Chaplain. "A mathematical model of the first steps of tumour-related angiogenesis: Capillary sprout formation and secondary branching." IMA Journal of Mathematics Applied in Medicine & Biology, 13 (1996), pp. 73-98.

Local Functions

Listed here are the local helper functions that the PDE solver pdepe calls to calculate the solution. Alternatively, you can save these functions as their own files in a directory on the MATLAB path.

function [c,f,s] = angiopde(x,t,u,dudx) % Equation to solve
d = 1e-3;
a = 3.8;
S = 3;
r = 0.88;
N = 1;

c = [1; 1];
f = [d*dudx(1) - a*u(1)*dudx(2)
     dudx(2)];
s = [S*r*u(1)*(N - u(1));
     S*(u(1)/(u(1) + 1) - u(2))];
end
% ---------------------------------------------
function u0 = angioic(x) % Initial Conditions
u0 = [1; 0.5];
if x >= 0.3 && x <= 0.6
  u0(1) = 1.05 * u0(1);
  u0(2) = 1.0005 * u0(2);
end
end
% ---------------------------------------------
function [pl,ql,pr,qr] = angiobc(xl,ul,xr,ur,t) % Boundary Conditions
pl = [0; 0];
ql = [1; 1];
pr = pl;
qr = ql;
end
% ---------------------------------------------

See Also

Related Topics