ode无法运行-DINTDY- T(= R1)非法

时间:2019-04-05 23:36:40

标签: r ode

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

我尝试更改模拟的起始值和持续时间,但是似乎无效。我还尝试通过运行单个时间步来调试ode,但是没有运气。

加载相关软件包

图书馆(解救)

# 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)



我希望获得焦点参数C,H,D的结果列表

0 个答案:

没有答案