Hi all,
I try to assess the parameters (K1,K2) of a model that describes the
adsorption of a molecule onto on adsorbent.
equation: dq/dt = K1*C*(qm-q)-K2*q
I know the value of 'qm' and I experimentally measure the variables
'q',
'C', and the time 't'.
t C q
1 0 144.05047 0.0000000
2 565 99.71492 0.1105625
3 988 74.99426 0.1722100
4 1415 58.65572 0.2129545
5 1833 48.34586 0.2386649
6 2257 40.29413 0.2587440
7 2675 32.92470 0.2771216
8 3105 29.57162 0.2854834
9 3552 28.01424 0.2893672
10 3986 25.62167 0.2953337
11 4415 23.62612 0.3003101
12 4841 21.95523 0.3044769
13 5264 21.08464 0.3066480
14 5698 19.68040 0.3101498
15 6509 18.31788 0.3135476
16 6950 17.65868 0.3151915
17 7403 17.00206 0.3168290
18 8130 16.38856 0.3183589
19 9001 15.58544 0.3203617
20 9928 15.27882 0.3211263
21 11899 14.46415 0.3231579
22 16354 13.91779 0.3245204
23 18926 13.82630 0.3247485
24 21602 13.66776 0.3251439
25 24413 13.98560 0.3243513
26 27056 13.87143 0.3246360
27 29844 13.64881 0.3251912
It's a differential equation, thus I had a look on the command 'ode'
from
the deSolve package.
I'm early stuck on the use of the function 'ode' cause I don't
get how to
define the function 'func' required by 'ode'
Any help would be appreciated.
Regards/Cordialement
-------------
Benoit Boulinguiez
Ph.D student
Ecole de Chimie de Rennes (ENSCR) Bureau 1.20
Equipe CIP UMR CNRS 6226 "Sciences Chimiques de Rennes"
Avenue du G?n?ral Leclerc
CS 50837
35708 Rennes CEDEX 7
Tel 33 (0)2 23 23 80 83
Fax 33 (0)2 23 23 81 20
http://www.ensc-rennes.fr/ <http://www.ensc-rennes.fr/>
Benoit Boulinguiez <benoit.boulinguiez <at> ensc-rennes.fr> writes:> I try to assess the parameters (K1,K2) of a model that describes the > adsorption of a molecule onto on adsorbent. > > equation: dq/dt = K1*C*(qm-q)-K2*q > > I know the value of 'qm' and I experimentally measure the variables 'q', > 'C', and the time 't'. > > I'm early stuck on the use of the function 'ode' cause I don't get how to > define the function 'func' required by 'ode'Have a look at the lsoda documentation of the earlier package odesolve, which has easier to understand examples. Dieter
As I do not thoroughly understand the way 'lsoda' works, I face some
difficulties to 'get' myself into the function(), though I changed the
code
as follows:
------------------------------
require(deSolve)
qm<-0.36
y0<-c(0)
parms<-c("K1","K2")
times<-seq(0,10000,1)
kinetic.model<-function(t,y,parms){
dq.dt = K1*C0 - (K1*m/V+ K2)*q
list(dq.dt)
}
foo<-lsoda(y0,times,kinetic.model,parms)
Error in func(time, state, parms, ...) : object 'K1' not found
------------------------------
'K1' and 'K2' are parameters but 'C' is not a parameter,
it's a dependant
variable of the time.
I actually express it as a function of q(t) to get this new equation
dq/dt= K1*C0 - (K1*m/V+ K2)*q(t)
where K1 and K2 are the unknown but desired parameters and {C0,m,V} are
constant known values.
Nevertheless, I still get this 'Error about object 'K1' not
found'.
Regards/Cordialement
Benoit Boulinguiez
-----Message d'origine-----
De : Dieter Menne [mailto:dieter.menne at menne-biomed.de]
Envoy? : jeudi 14 mai 2009 12:12
? : 'Benoit Boulinguiez'
Objet : RE: [R] ode first step
Try to hide yourself inside the function(). What would you see? No K1, for
sure, no C, no K2.
These are passed through parms, so parms["K1"] would work, but not for
C,
you should add it.
-----Original Message-----
From: Benoit Boulinguiez [mailto:benoit.boulinguiez at ensc-rennes.fr]
Sent: Thursday, May 14, 2009 11:53 AM
To: 'Dieter Menne'
Subject: RE: [R] ode first step
------------------------------
qm<-0.36
y0<-c(0)
parms<-c(K1=1,K2=1)
times<-seq(0,10000,1)
kinetic.model<-function(t,y,parms){
dq.dt<- K1*C*(qm-q)-K2*q
list(dq.dt)
}
require(deSolve)
nls(foo<-lsoda(y0,times,kinetic.model,parms)