Skip to content
Prev 360 / 696 Next

[R-sig-dyn-mod] NA error in deSolve

Hi All:
            I figured that the numbers were not updated during the
integration, so I added a few lines inside the integration. The P_diss
function seems to work, but I got another issue:

Warning messages:
1: In lsoda(y, times, func, parms, ...) :
  repeated convergence test failures on a step, but integration was
successful - inaccurate Jacobian matrix?
2: In lsoda(y, times, func, parms, ...) :
  Returning early. Results are accurate, as far as they go


        There are NAs in the output, How do I remove the NAs? Thanks,

rm(list=ls())
library (deSolve)


      W_frac <- rep(0.2,5)# the weight fraction
      R_size <- seq(10,50,10) # the weight fraction corresponding size in um

Dose <- 50 # initial dose in mg

Particle <- rep(0,5)

Size <- R_size

Y <- 0

Tablet <- Dose

state <- c(Tablet,Particle,Y,Size)



S = 0.1 # solubility in mg/ml
den = 1300 # density unit mg/ml
Diff = 7E-6   # diffusion coeffiecient cm2/s
V= 900 # volume of dissolution medium


P_diss <- function(X,X0,r){

  thick <- r
  thick[thick >= 30] <- 30
  disso <-
3*60*Diff*(X0)^(1/3)*X^(2/3)/(den*(thick/10000)*(r/10000))*(S-Y/V)
  result <- -pmin(disso,X)

  result[(X<=0)|(S<=Y/V)]<- 0

  return(result)
}



P_size <- function(X,X0){


    result <- (X/X0)^(1/3)
    result[X0<=0] <- 0
    return(result)
}


Lorenz <- function(t, state, para){
with (as.list(c(state, para)), {

          Tablet <- state[1]
          Particle <- state[2:6]
          Y <- state[7]
          Size<- state[8:12]

           ddisinte <- 0.02  # rate of tablet disintegration

           dTablet <- -ddisinte*Tablet
           dParticle <- ddisinte*Tablet*W_frac +
P_diss(Particle,(Dose-Tablet)*W_frac,Size)
           dY <- -sum(P_diss(Particle,(Dose-Tablet)*W_frac,Size))
           dSize <- -P_size(dParticle,(Dose-Tablet)*W_frac)*Size


list (c(dTablet, dParticle, dY,dSize))

})
}

times <- seq(0,1440, by = 1)

out <- ode(y = state, t = times, func = Lorenz, parms = 0)

write.csv(out, file = "out.csv")
On Fri, Jan 16, 2015 at 4:36 PM, Dabing Chen <dabing.c at gmail.com> wrote: