ode无法运行-第二天-T(=R1)非法

ode无法运行-第二天-T(=R1)非法,r,ode,R,Ode,我试图更改模拟的起始值和持续时间,但这些似乎不起作用。我还试着通过运行一个时间步来调试ode,但没有成功 加载相关包 图书馆(deSolve) 参数及其定义 paramsCan检查您的模型和参数?在t=15.944122处有一个超指数爆炸…在C组件中,没有进一步的时间步长,因此不可能在t=16,17,…处插值。然而,在时间t=1.27462169545时,计算值[C,D,H]=[134.4961397,2.47760126,1.58399192]似乎不合理。这些值很快就消失了,在t=2.0108

我试图更改模拟的起始值和持续时间,但这些似乎不起作用。我还试着通过运行一个时间步来调试ode,但没有成功

加载相关包 图书馆(deSolve)

参数及其定义
paramsCan检查您的模型和参数?在
t=15.944122处有一个超指数爆炸…
C
组件中,没有进一步的时间步长,因此不可能在
t=16,17,…
处插值。然而,在时间
t=1.27462169545
时,计算值
[C,D,H]=[134.4961397,2.47760126,1.58399192]
似乎不合理。这些值很快就消失了,在
t=2.01082843748
我们可以得到
[C,D,H]=[3.61471281e+03,3.08565920e+00,1.63965295e+00]
等等。fwiw我找到了我在珊瑚方程中没有密度影响死亡率的地方,所以它像巴拿纳一样增长。你能检查一下你的模型和参数吗?在
t=15.944122处有一个超指数爆炸…
C
组件中,没有进一步的时间步长,因此不可能在
t=16,17,…
处插值。然而,在时间
t=1.27462169545
时,计算值
[C,D,H]=[134.4961397,2.47760126,1.58399192]
似乎不合理。这些值很快就消失了,在
t=2.01082843748
我们得到
[C,D,H]=[3.61471281e+03,3.08565920e+00,1.63965295e+00]
等等。我发现珊瑚方程中没有密度影响死亡率,所以它像香蕉一样生长
result from ODE 
DINTDY-  T (=R1) illegal      
In above message, R1 = 16
 
      T not in interval TCUR - HU (= R1) to TCUR (=R2)      
In above message, R1 = 15.9441, R2 = 15.9441
 
DINTDY-  T (=R1) illegal      
In above message, R1 = 17
 
      T not in interval TCUR - HU (= R1) to TCUR (=R2)      
In above message, R1 = 15.9441, R2 = 15.9441
 
DLSODA-  Trouble in DINTDY.  ITASK = I1, TOUT = R1
In above message, I1 = 1
 
In above message, R1 = 17
# C = coral, measured as the biomass of a single head
# D = damselfish, a fish that dwells inside the coral, eats plankton, and
#     fertilizes the coral with its waste products
# H = hawkfish, a fish that dwells on the outside of the coral, is an
#     aggressive predator and can competitively displace P
# U = uberpredator, a fish that lives outside the coral and preys upon both
#     P and H
params<- c(
  # CORAL:
  g_0 = 0.1, #fertilization-enhancement to coral growth rate
  g_1 = 1, #base growth rate of coral
  #n_D = .02,     # Excretion rate of damselfish
  #n_H = .005, # Excretion rate of hawkfish
  #h_N = 10*n_D,   # Half-saturation of excretion
  #nu = n_H/n_D,  # Scaling of hawkfish benefits relative to damselfish
  #eta = h_N/n_D,  # Scaling of half-saturation to damselfish
  m = .01, #mortality of coral
  
  # DAMSELFISH:
  r_D = .3, # base growth rate of planktivore
  k_D = 1, #carrying capacity per unit coral biomass of damselfish
  #exp_D = 1, #how carrying capacity of damselfish scales with coral size 
  alpha_DH = 2, # competitive effects of damselfish on hawkfish
  a_D = 0, #attack rate of uberpredator on damselfish
  
  # HAWKFISH
  r_H = .2, #base growth rate of hawkfish
  k_H = 1, #carrying capacity per unit coral surface area of hawkfish
  #exp_H = 1, #how carrying capcity of the hawkfish scales with coral size
  alpha_HD = .1, #competitive effects of hawkfish on planktivore
  a_H = .15 #attack rate of uberpredator on hawkfish
)


#this model has no uberpredator 

cmod <- function(t,y,params)
{
  C <- y[1] #coral biomass
  D <- y[2] #damselfish biomass
  H <- y[3] #hawkfish biomass
  
with(as.list(params), {
  
  # modified for saturating growth rate and density dependence:
  dCdt = C*(g_1*(D+H)+g_0-m)
  
  #Second equation: Damselfish biomass
  dDdt = r_D*D*(k_D*C-D-alpha_HD*H)/(k_D*C)-a_D*D
        
  #Third equation: Hawkfish biomass
  dHdt = r_H*H*(k_H*C-H-alpha_DH*D)/(k_H*C)-a_H*H
  
  return(list(c(dCdt,dDdt,dHdt)))
})
}

#simulation details
t <- seq(0,10000,by=1) #duration of simulation 
N.init <- c(C=1,D=2,H=2)

sim1 <- ode(N.init,t,cmod,params)