function TGrowthQ1D
%
% Evolution of the tumor cell population under the Fisher-Kolmogorov law:
%
% u_t - D u_{xx} = \rho u(1-u)
%
% together with Dirichlet and initial conditions
%

format short;
% format long;
close all;

global D RHO IPLOT NX1 T U0 NT1 XNUMER HX NX THER GAM

%
% THE DATA OF THE PROBLEM
%

T=10.;                         % FINAL TIME
Lmax=1.;                       % HALF-LENGTH

D=.1; RHO=.9;                 % MOBILITY AND PROLIFERATION PARAMETERS

u0max=.01; sigma0=.15;         % DATA FOR INITIAL CELL POPULATION

NX=50;                         % FOR SPATIAL APPROXIMATION
% NX=20;                         % FOR SPATIAL APPROXIMATION
NT=50;                         % NUMBER OF TIME STEPS
% NT=20;                         % NUMBER OF TIME STEPS

IPLOT=2;                       % FIGURE REPRESENTATION LEVEL
% IDISP=1;                       % PRINT LEVEL

%
% PREPARING COMPUTATIONS
%

HX=2.*Lmax/NX;                  % SPACE STEP
NX1=NX+1; 
XNUMER=linspace(-Lmax,Lmax,NX1);% THE x_j

% HT=T/Ntt;

coef0=.5/sigma0;                
U0=u0max*exp(-coef0*XNUMER.*XNUMER);

THER=10.;
GAM=2.;

% PIS2=.5*pi;
% U0=u0max*(sin(PIS2*(XNUMER+1.)));

NT1=NT+1;

%

tnumer=linspace(0.,T,NT1);
sol=pdepe(0,@PDEfun,@ICfun,@BCfun,XNUMER,tnumer);
    
if (IPLOT > 0)
    figure(1);
    surf(XNUMER,tnumer,sol);
    xlabel('x: SPACE');
    ylabel('t: TIME');
    zlabel('u: CELL DENSITY');
    shg;
end

% format long;

end

function [w]=therapy(t)

%

global D RHO IPLOT NX1 T U0 NT1 XNUMER HX NX THER GAM

w=THER*exp(-GAM*t);
end

function [c,f,s]=PDEfun(~,t,u,Du)

% [C,F,S]=PDEFUN(X,T,U,DUDX)

global D RHO IPLOT NX1 T U0 NT1 XNUMER HX NX THER GAM

c=1.;
f=D*Du;
s=RHO*u.*(1.-u)-therapy(t)*u;
end

function [u]=ICfun(x)

%

global D RHO IPLOT NX1 T U0 NT1 XNUMER HX NX THER GAM

u=interp1(XNUMER,U0,x);
end

function [pl,ql,pr,qr]=BCfun(~,ul,~,ur,~)

% [PL,QL,PR,QR]=BCFUN(XL,UL,XR,UR,T)

pl=ul; ql=0.;
pr=ur; qr=0.;
end
