0

I have been trying to solve the following system of delay differential equations using JiTCDDE:

Model equations

And this is my code:

from jitcdde import y, t
from jitcdde import jitcdde
import matplotlib.pyplot as plt
import numpy as np
from pylab import *

N1=30290000
a1=0.98*N1
eps=1/5
b1=0.000024246
eta=0.3
B1=0.7
m=0.0005
chi=0.071 
k1=0.185
alpha1=0.1155 
delta=0.0225 
phi1=0.26
omega1=0.26
d=3

model=[b1-((y(0)*B1*(y(2)+y(3)+(eta*y(5))))/a1)-b1*y(0)-m*y(0,t-d),
       ((y(0)*B1*(y(2)+y(3)+(eta*y(5))))/a1)-(k1+eps)*y(1)-m*y(1,t-d), 
       k1*eps*y(1)-(alpha1+chi)*y(2)-m*y(2,t-d),
       (1-k1)*eps*y(1)-(phi1+omega1)*y(3)-m*y(3,t-d),
       k1*y(1)+alpha1*y(2)-chi*y(4),
       (phi1+omega1)*y(3)-(chi+delta)*y(5),
       chi*(y(4)+y(5))-b1*y(6)-m*y(6,t-d),
       delta*y(5)]

I=jitcdde(model)
I.constant_past([(0.98*N1-13),0,5,7,0,1,0,0], time=0.0)
I.step_on_discontinuities()
e=[]
for i in range(50):
    e.append(I.integrate(i)[1])
print(e)

The problem is, for the second array of the solution (which I am trying to access), the first few values are negative values when I have specified that for t<0, the value is is 0. I have tried out this same model using ddeint and it gives a monotonically increasing curve with positive values, which is what I expect. I want jitcdde to work though, since this model should run even when there is no delay term. The first array seems fine and I have checked my model to see if I had made any typos but everything looks good to me. I have also tried using adjust_diff and integrate_blindly, but the issue remains.

Wrzlprmft
  • 4,234
  • 1
  • 28
  • 54
Kira1234
  • 1
  • 1
  • In the second-to-last line, I would expect `chi*(y(3)+y(4)+y(5))` instead of `chi*(y(4)+y(5))`. Also your implementation uses `b1` for both *b*₁ and *d*₁ from your equations. That being said, the result is a “monotonically increasing curve with positive values”, so I am not sure what could be wrong. Also nothing in the code seems off to me. – Wrzlprmft Feb 18 '21 at 19:47
  • As a general recommendation, try to make your code more readable, so you can spot errors more easily: 1) Assign aliases to the dynamical variables (e.g. `S=y(0)`). 2) Uses spaces at the outmost level of calculation to have a clearly visible structure in your equations. 3) Don’t use more parentheses than necessary. – Wrzlprmft Feb 18 '21 at 19:49

0 Answers0