ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 01 Mar 2017 12:26:28 +0100Differential equations system solving with boundarieshttps://ask.sagemath.org/question/36763/differential-equations-system-solving-with-boundaries/Dear all,
being a newbie in the practice of Sage I hope this question won't be silly, but unfortunately I cannot find anything helpful in the the forum neither in the documentation.
I am handling a system of 6 differential equations as follows, using `desolve_system`:
............................................
var ('t a b c d e g')
a = function('a')(t)
b = function('b')(t)
c = function('c')(t)
d = function('d')(t)
e = function('e')(t)
g = function('g')(t)
dea = diff(a,t) == -10*a + 2*b + 3*c + 3*d + 2*e + 5*g
deb = diff(b,t) == -9*b + e
dec = diff(c,t) == -9*c + d + e
ded = diff(d,t) == -9*d + 2*a + 2*b + 2*c + 3*e + 2*g
dee = diff(e,t) == -10*e
deg = diff(g,t) == -9*g + 9*a + 2*b + 3*c + 3*d + 3*e
sol = desolve_system([dea, deb, dec, ded, dee, deg], [a,b,c,d,e,g], ics=[0,1,1,1,1,1,1])
f(t,a,b,c,d,e,g) = sol
f = f(t)
var('sola,solb,solc,sold,sole,solg')
sola=f[0].rhs()
solb=f[1].rhs()
solc=f[2].rhs()
sold=f[3].rhs()
sole=f[4].rhs()
solg=f[5].rhs()
............................................
The thing goes fine and solutions are provided.
However, I need and extra boundary condition which is necessary for properly solving the problem (which is related to chemical kinetics, BTW, hence some conditions are mandatory for heading to a physical meaning of the solutions), i.e.:
a + b + c + d + e + g == 6
However, I cannot understand from the on line manual and its examples how to handle this condition, but I am only able to impose the initial conditions a0 = 1, b0 = 1 etc ...
Could anyone suggest a possible solution to my problem and/or the good syntax for imposing such conditions to my equations?
Thanks in advance.
LucaTue, 28 Feb 2017 16:35:18 +0100https://ask.sagemath.org/question/36763/differential-equations-system-solving-with-boundaries/Comment by mforets for <p>Dear all,</p>
<p>being a newbie in the practice of Sage I hope this question won't be silly, but unfortunately I cannot find anything helpful in the the forum neither in the documentation.
I am handling a system of 6 differential equations as follows, using <code>desolve_system</code>: </p>
<p>............................................</p>
<pre><code>var ('t a b c d e g')
a = function('a')(t)
b = function('b')(t)
c = function('c')(t)
d = function('d')(t)
e = function('e')(t)
g = function('g')(t)
dea = diff(a,t) == -10*a + 2*b + 3*c + 3*d + 2*e + 5*g
deb = diff(b,t) == -9*b + e
dec = diff(c,t) == -9*c + d + e
ded = diff(d,t) == -9*d + 2*a + 2*b + 2*c + 3*e + 2*g
dee = diff(e,t) == -10*e
deg = diff(g,t) == -9*g + 9*a + 2*b + 3*c + 3*d + 3*e
sol = desolve_system([dea, deb, dec, ded, dee, deg], [a,b,c,d,e,g], ics=[0,1,1,1,1,1,1])
f(t,a,b,c,d,e,g) = sol
f = f(t)
var('sola,solb,solc,sold,sole,solg')
sola=f[0].rhs()
solb=f[1].rhs()
solc=f[2].rhs()
sold=f[3].rhs()
sole=f[4].rhs()
solg=f[5].rhs()
</code></pre>
<p>............................................</p>
<p>The thing goes fine and solutions are provided.
However, I need and extra boundary condition which is necessary for properly solving the problem (which is related to chemical kinetics, BTW, hence some conditions are mandatory for heading to a physical meaning of the solutions), i.e.:</p>
<pre><code>a + b + c + d + e + g == 6
</code></pre>
<p>However, I cannot understand from the on line manual and its examples how to handle this condition, but I am only able to impose the initial conditions a0 = 1, b0 = 1 etc ...
Could anyone suggest a possible solution to my problem and/or the good syntax for imposing such conditions to my equations?</p>
<p>Thanks in advance.</p>
<p>Luca</p>
https://ask.sagemath.org/question/36763/differential-equations-system-solving-with-boundaries/?comment=36772#post-id-36772but this is a [DAE](https://en.wikipedia.org/wiki/Differential_algebraic_equation), right? I'm not sure if [desolvers](http://doc.sagemath.org/html/en/reference/calculus/sage/calculus/desolvers.html) can handle those ones. Maybe relevant: [PySDTool](http://www.ni.gsu.edu/~rclewley/PyDSTool/FrontPage.html), see also [SciPy's topical software](https://www.scipy.org/topical-software.html) page.Wed, 01 Mar 2017 12:26:28 +0100https://ask.sagemath.org/question/36763/differential-equations-system-solving-with-boundaries/?comment=36772#post-id-36772