Ask Your Question
0

how to solve a ode systems of size of four?

asked 2011-10-02 14:26:38 +0100

Nan gravatar image

I want to solve the chemistry reaction rate. Here I got the 4 differential equatiobs.

dE/dt=-k1ES+k2ES+kiES dES/dt=k1ES-kiES-k2ES dS/dt=-k1ES+kiES dP/dt=k2ES

Here is my code?

k1,k2,ki,t=var('k1 k2 ki t') E=function('E',t) ES=function('ES',t) S=function('S',t) P=function('P',t)

des=(diff(E,t)==-k1ES+k2ES+kiES,diff(ES,t)==k1ES-kiES-k2ES diff(S,t)==-k1ES+kiES diff(P,t)==k2ES)

desolve_system(des,[E,ES,S,P],ivar=t,ics=[0,1,1,1,1])

The above is my code. But I just cannot execute it. I am a rookie with this kind of coding style.

Thanks for answering.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

answered 2011-10-02 16:39:42 +0100

DSM gravatar image

Hi! "But I just cannot execute it" isn't very specific-- could you cut and paste the error message? Your code seems to work for me:

sage: k1,k2,ki,t=var('k1 k2 ki t') 
sage: E=function('E',t)
sage: ES=function('ES',t)
sage: S=function('S',t) 
sage: P=function('P',t)
sage: des=(diff(E,t)==-k1*ES+k2*ES+ki*ES,
....:      diff(ES,t)==k1*ES-ki*ES-k2*ES,
....:      diff(S,t)==-k1*ES+ki*ES, diff(P,t)==k2*ES)
sage: desolve_system(des, [E, ES, S, P], ivar=t, ics=[0,1,1,1,1])
[E(t) == -e^((k1 - k2 - ki)*t) + 2, ES(t) == e^((k1 - k2 - ki)*t), S(t) == -(k1 - ki)*e^((k1 - k2 - ki)*t)/(k1 - k2 - ki) + (2*k1 - k2 - 2*ki)/(k1 - k2 - ki), P(t) == k2*e^((k1 - k2 - ki)*t)/(k1 - k2 - ki) + (k1 - 2*k2 - ki)/(k1 - k2 - ki)]

although I did have to insert some commas which seemed missing from your des line. [Note that the above is a cut-and-paste from the console; you wouldn't actually enter "sage:" or "....:".]

edit flag offensive delete link more
0

answered 2011-10-03 04:44:21 +0100

Nan gravatar image

updated 2011-10-04 08:10:56 +0100

Jason Grout gravatar image

the four ode should be:

sage: de1=diff(E,t)==-k1*E*S+k2*ES+ki*ES
sage: de2=diff(ES,t)==k1*E*S-ki*ES-k2*ES
sage: de3=diff(S,t)==-k1*E*S+ki*ES
sage: de4=diff(P,t)==k2*ES
edit flag offensive delete link more
0

answered 2011-10-03 04:47:27 +0100

Nan gravatar image

oh,this page cannot be post the symbol like the star which means multiplication...

edit flag offensive delete link more

Comments

In order to get code formatted correctly, select some code and then hit the little button above the text box which reads "101010". It should show up in the preview box like mine did (note that I used the *.) But we still need to see the error message to figure out what's going wrong. Could you post that?

DSM gravatar imageDSM ( 2011-10-03 10:10:52 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-10-02 14:26:38 +0100

Seen: 421 times

Last updated: Oct 04 '11