Good day Jose,
Here is the code:
rm(list=ls())
library(ReacTran)
N <-200
alpha12<-0.0034
alpha21<-0.05
omega<-0.7
sigma<-1.2
rho<-1.5
mu<-0.02
gamma<-0.01
Grid <- setup.grid.1D(x.up = 0, x.down = 1, N = N)
Xini<-rep(x= 1, times= N)
Yini <- rep(x = 3, times = N)
Zini<-rep(x=4, times=N)
yini <- c(Xini, Yini, Zini)
Predator_prey <- function(t, y, parms) {
X <- y[1:N]
Y <- y[(N+1):(2*N)]
Z <- y[(2*N+1):(3*N)]
dX <- X*(1-X-alpha12*Y)-omega*X^2*Z/(1+X^2)+
tran.1D (C = X, C.up = 0, C.down = 1,
D = 0.1, dx = Grid)$dC+tran.1D (C = Z, C.up = NULL, C.down =
NULL,
D = 1, dx = Grid)$dC
dY <- rho*Y*(1-Y-alpha21*X)+
tran.1D (C = Y, C.up = NULL, C.down = NULL,
D = 0.1, dx = Grid)$dC
dZ <- sigma*X^2*Z/(1+X^2)-mu*Z-gamma*Z
tran.1D (C = Z, C.up = NULL, C.down = NULL, flux.up = NULL, flux.down =
NULL,
D = 0.1, dx = Grid)$dC+tran.1D (C = X, C.up = NULL, C.down =
NULL,
D= -1, dx = Grid)$dC
list(c(dX, dY, dZ))
}
times <- seq(from = 0, to = 100, by = 0.01)
print(system.time(
out <- ode.1D(y = yini, func = Predator_prey,
times = times, parms = NULL, nspec = 3,
names = c("X", "Y","Z"), dimens = N)
))
matplot(out[,"time"], out[,2], type = "l", xlab = "time", ylab = "",
main = "", lwd = 2)
Regards
Titus Kassem
On Thu, Jul 7, 2016 at 11:00 AM, <r-sig-dynamic-models-request at r-project.org
wrote:
Send R-sig-dynamic-models mailing list submissions to
r-sig-dynamic-models at r-project.org
To subscribe or unsubscribe via the World Wide Web, visit
https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models
or, via email, send a message with subject or body 'help' to
r-sig-dynamic-models-request at r-project.org
You can reach the person managing the list at
r-sig-dynamic-models-owner at r-project.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-sig-dynamic-models digest..."
Today's Topics:
1. Spatial Model (Titus Kassem)
2. Re: Spatial Model (Flores, Jose)
----------------------------------------------------------------------
Message: 1
Date: Wed, 6 Jul 2016 12:52:52 +0100
From: Titus Kassem <gtkassem at gmail.com>
To: r-sig-dynamic-models at r-project.org
Subject: [R-sig-dyn-mod] Spatial Model
Message-ID:
<
CAG92UYB9ecG4Qh1eoedrZnErLjuefTraOcX4N9duT_FZpEkbTA at mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
Hi Karline,
I have a predator-prey model model with competition that I have trying to
simulated. I added a diffusion term but i seem to be having problem as the
figure is not impressive enough. I think something must be wrong with the
code. Please can you help out?
Attached is the code and the model.
Thanks
Titus Kassem
University of Jos
------------------------------
Message: 2
Date: Wed, 6 Jul 2016 14:10:08 +0000
From: "Flores, Jose" <Jose.Flores at usd.edu>
To: Special Interest Group for Dynamic Simulation Models in R
<r-sig-dynamic-models at r-project.org>
Subject: Re: [R-sig-dyn-mod] Spatial Model
Message-ID: <0704B4BB-15B5-4C6F-9A49-3E12CC4241E3 at usd.edu>
Content-Type: text/plain; charset="us-ascii"
Where is the code to take a look at it?
Jose
On Jul 6, 2016, at 6:52 AM, Titus Kassem <gtkassem at gmail.com> wrote:
Hi Karline,
I have a predator-prey model model with competition that I have trying to
simulated. I added a diffusion term but i seem to be having problem as
the
figure is not impressive enough. I think something must be wrong with the
code. Please can you help out?
Attached is the code and the model.
Thanks
Titus Kassem
University of Jos
_______________________________________________
R-sig-dynamic-models mailing list
R-sig-dynamic-models at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models
------------------------------
Subject: Digest Footer
_______________________________________________
R-sig-dynamic-models mailing list
R-sig-dynamic-models at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models
------------------------------
End of R-sig-dynamic-models Digest, Vol 106, Issue 1
****************************************************