t_start=0
t_end=10
tn=50
timestep=(t_end-t_start)/tn
t=seq(t_start,t_end,timestep)
n=3
At=TimeMap.new(
t_start,
t_end,
function(t0){
#matrix(nrow=n,ncol=n,byrow=TRUE,
# c(-0.2, 0, 0,
# 0.1, -0.7, 0,
# 0, 1/2, -0.5)
#)
matrix(nrow=n,ncol=n,byrow=TRUE,
c(-0.2, 0, 0,
0 , -0.3, 0,
0, 0, -0.4)
)
}
)
c0=c(0.5, 0.5, 0.5)
#constant inputrate
inputFluxes=TimeMap.new(
t_start,
t_end,
function(t0){matrix(nrow=n,ncol=1,c(0.0,0,0))}
)
mod=GeneralModel(t,At,c0,inputFluxes)
Y=getC(mod)
lt1=1; lt2=2; lt3=3
col1=1; col2=2; col3=3
plot(t,Y[,1],type="l",lty=lt1,col=col1,
ylab="C stocks (arbitrary units)",xlab="Time")
lines(t,Y[,2],type="l",lty=lt2,col=col2)
lines(t,Y[,3],type="l",lty=lt3,col=col3)
legend(
"topright",
c("C in pool 1",
"C in pool 2",
"C in pool 3"
),
lty=c(lt1,lt2,lt3),
col=c(col1,col2,col3)
)
#now compute the accumulated release
Y=getRelease(mod)
plot(t,Y[,1],type="l",lty=lt1,col=col1,ylab="C Release (arbitrary units)",xlab="Time")
lines(t,Y[,2],lt2,type="l",lty=lt2,col=col2)
lines(t,Y[,3],type="l",lty=lt3,col=col3)
legend("topleft",c("R1","R2","R3"),lty=c(lt1,lt2,lt3),col=c(col1,col2,col3))Run the code above in your browser using DataLab