Ask Your Question

Revision history [back]

There are two problems here: you're trying to use lmd as an initial condition for the system of differential equations but then defining it in terms of the solution, and you don't have enough initial conditions. Assuming the initial conditions should be given in terms of the initial value of lmd, here's an example that works without error messages:

@interact
def interactive_function(nu = slider(0.01, 0.1, 0.005, default=0.03125),
                         d = slider(0, 1, 0.05, default=1),
                         B = slider(500, 30000, 250, default=13333),
                         v = slider(0, 1, 0.05, default=0.2),
                         c = slider(0, 50, 1, default=4),
                         p = slider(0, 1, 0.05, default=0.3),
                         beta = slider(0, 1, 0.002, default=0.014)):

  def f_1(t,y,params) :
    return [ -params[2]-params[0]*y[0]-y[4]*params[4]*y[0],
              y[4]*params[4]*y[0]-(params[3]+params[0])*y[1],
              (1-params[5])*params[3]*y[1]-params[0]*y[2],
              params[5]*params[3]*y[1]-(params[1]+params[0])*y[3],
              (params[6]*y[1])/(y[0]+y[1]+y[2]) ]

  lmd0 = 1

  T = ode_solver()
  T.function = f_1
  T.algorithm="rk8pd"
  T.ode_solve( y_0=[lmd0,0,1-lmd0,0,lmd0] , t_span=[0,150] , params=[nu,d,B,v,c,p,beta] , num_points=1000)

  f = T.solution
  X = [(x[0],x[1][0]) for x in f]
  Y = [(x[0],x[1][1]) for x in f]
  Z = [(x[0],x[1][2]) for x in f]
  A = [(x[0],x[1][3]) for x in f]
  lmd = [(x[0],x[1][4]) for x in f]

  P1 = line(X, rgbcolor='green')
  P2 = line(Y, rgbcolor='pink')
  P3 = line(Z, rgbcolor='red')
  P4 = line(A, rgbcolor='brown')
  P5 = line(lmd, rgbcolor='green')
  show(P1+P2+P3+P4+P5)

Here's a live example with which you can experiment.