Say we have the following equations:
dy1/dt = f(y1, t) [1]
dy2/dt = g(y2, t) [2]
The equations are such that they are "conservative", i.e. The following condition must be met:
dy1/dt + dy2/dt = 0 [3]
Using scipy.odeint, I find that I can integrate conservative equations such as this just fine for simple ODE systems.
However, for larger ones, I get the following problem.
Say this is my derived function:
def deriv_function(y0s, t):
...body defines equations 1, and 2...
print np.sum(ode)
return ode
Pay attention to the printing instructions. A.
I use scipy.odeinton deriv_functionas follows:
odeint(deriv_fun, y0s, [0, 0.5])
Due to the print instruction, the following is printed:
-1.38555833473e-13 <--- note, close to zero
-0.00679107743937
-0.0067907211796
-0.0135814423985
-0.0135810861584
-0.416522145214
-0.416523165887
-0.818209018574
-0.818211056221
-1.21864678558
-1.21864881584
-2.86735888212
-2.8673729885
-2.46855840934
-2.46856658088
-3.70632102566
-3.70631206163
-4.93200749506
-4.93200691488
-6.14577326158
-6.14577268283
-8.53799987128
-8.53799713959
-10.8839304356
-10.8839320212
-13.1845005689
-13.1845021725
-15.4406122011
-15.4406123927
-17.6531469917
-17.653147185
-24.6238415795
-24.6238498033
-31.1628867985
-31.1628947266
-37.2974784594
-37.2974547092
-35.463527103
-35.4635192949
-39.5777426955
-39.5777472677
-43.5137135424
-43.5137108017
-47.2791485087
-47.2791483993
-50.881424906
-50.8814244751
-54.3275507164
-54.3275502654 <--- note, not close to zero
For smaller systems of equations (not identical), the following is printed:
-1.13686837722e-13
0.0
0.0
0.0
-1.13686837722e-13
1.13686837722e-13
0.0
0.0
0.0
0.0
0.0
0.0
0.0
-1.13686837722e-13
0.0
0.0
0.0
1.13686837722e-13
0.0
0.0
0.0
0.0
-1.13686837722e-13
0.0
0.0
-1.13686837722e-13
0.0
0.0
0.0
0.0
0.0
0.0
-1.13686837722e-13
0.0
0.0
5.68434188608e-14
-5.68434188608e-14
-5.68434188608e-14
0.0
, , , , , . , : ode, , , ?
: , . ?
: scicomp.stackexchange.