DifferentialEquation.jl DDE running problem:
using DifferentialEquations, Plots
function dde(du,u,h,p,t)
M_A, M_B = u;
tau, mu, n, P0, b = p;
hist_A = h(p, t-tau)[1];
hist_B = h(p, t-tau)[2];
du[1] = -mu*M_A + (1+b)*(1/1+(hist_B/P0)^n);
du[2] = -mu*M_B + (1/1+(hist_A/P0)^n);
end
h(p, t) = ones(2)
tau = 100;
P0 = 0.1; n = 5;
mu = 0.03; b = 0.01;
p = (tau, mu, n, P0, b)
tspan = (0, 5000)
u0 = [0, 0]
prob = DDEProblem(dde, u0, h, tspan, p; constant_lags = (p[1], ))
sol = solve(prob, MethodOfSteps(BS3()))
plot(sol)
The corresponding Matlab code:
function osc_switch
%%parameters
mu=0.03; %degradation rate
n=5; %Hill coefficient
p0=0.1; %Hill threshold
tau=100; %time delay
b=0.01; %bias
%%simulation details
t0=0; %start time
tend=5000; %end time
npts=10000; %number of reporting points
tout=linspace(t0,tend,npts); %reporting times
history=[0;0]; %initial history
%%solver call
sol=dde23(@ddes,tau,history,tout);
x=deval(sol,tout); %solution
%%plot solution
figure(22)
plot(tout,x,'LineWidth',2) %time course
xlabel('time')
ylabel('amount')
figure(23)
plot(x(1,:),x(2,:),'LineWidth',2) %phase plane
grid on
axis equal
xlabel('x')
ylabel('y')
%%DDE function
function dydt=ddes(t,y,z)
dydt=[-mu*y(1)+(1+b)*f(z(2));-mu*y(2)+f(z(1))];
end
%%Regulation function
function out=f(x)
out=1./(1+(x/p0).^n);
end
end