# # Case 1: # # Case 1 with changes in the: # # Main program: # # Single plot of seven dependent variables vs t # # ODE routine in place of in-line function: # # <- replaced by = # # "return(list)" used to return the derivative vector # # Library of R ODE solvers library("deSolve") # # ODE routine setwd("c:/R/bme_ode/chap1") source("bioreactor_2.R") # # Parameter values for BP10001 k1=8.87e-03; k2=13.18; k3=0.129; k4=0.497; k5=0.027; k6=0.545e-3; km2=87.7; km3=99.9; # # Initial condition yini=c(0.10724,0,0,0,0,0,0) ncall=0; # # t interval nout=51 times=seq(from=0,to=2000,by=40) # # ODE integration out=ode(y=yini,times=times,func=bioreactor_2,parms=NULL) # # ODE numerical solution for(it in 1:nout){ if(it==1){ cat(sprintf( "\n t y1 y2 y3 y4 y5 y6 y7"))} cat(sprintf("\n %8.0f%8.4f%8.4f%8.4f%8.4f%8.4f%8.4f%8.4f", out[it,1],out[it,2],out[it,3],out[it,4], out[it,5],out[it,6],out[it,7],out[it,8])) } # # Calls to bioreactor_2 cat(sprintf("\n ncall = %5d\n\n",ncall)) # # Single plot par(mfrow=c(1,1)) # # y1 plot(out[,1],out[,2],type="l",xlab="t",ylab="y1(t),...,y7(t)", xlim=c(0,2000),ylim=c(0,0.14),lty=1, main="y1(t),...,y7(t) vs t", lwd=2) # # y2 lines(out[,1],out[,3],type="l",lty=2,lwd=2) # # y3 lines(out[,1],out[,4],type="l",lty=3,lwd=2) # # y4 lines(out[,1],out[,5],type="l",lty=4,lwd=2) # # y5 lines(out[,1],out[,6],type="l",lty=5,lwd=2) # # y6 lines(out[,1],out[,7],type="l",lty=6,lwd=2) # # y7 lines(out[,1],out[,8],type="l",lty=7,lwd=2)