修訂 | 321b69036a418c0a078602292c90f1d0be823d17 (tree) |
---|---|
時間 | 2007-03-21 05:54:23 |
作者 | iselllo |
Commiter | iselllo |
I added the code Python-codes/ode2_solver_test.py, which is taken from
the numpy tutorial. This code basically performs the integration of the
Airy equation. It is taken from the scipy tutorial, but I am using
different boundary conditions wrt the example.
@@ -0,0 +1,38 @@ | ||
1 | +#! /usr/bin/env python | |
2 | +from scipy import * | |
3 | +import pylab # used to read the .csv file | |
4 | + | |
5 | + | |
6 | +from scipy.special import * # to be able to use the error function | |
7 | + | |
8 | +def func(y, t): | |
9 | + return [t*y[1],y[0]] | |
10 | + | |
11 | +y0_0=1. | |
12 | +y1_0=1. | |
13 | + | |
14 | +y0 = [y0_0, y1_0] | |
15 | + | |
16 | +x = arange(0,4.0, 0.01) | |
17 | + | |
18 | +t=x | |
19 | +y = integrate.odeint(func, y0, t) | |
20 | + | |
21 | + | |
22 | +print 'the shape of the Lorenz solution is', shape(y) | |
23 | + | |
24 | + | |
25 | +pylab.plot(x,y[:,1]) | |
26 | +pylab.xlabel('Time') | |
27 | +pylab.ylabel('y(t)') | |
28 | +pylab.title('solution') | |
29 | +pylab.grid(True) | |
30 | +pylab.savefig('airy_modified') | |
31 | + | |
32 | +pylab.hold(False) | |
33 | + | |
34 | + | |
35 | + | |
36 | + | |
37 | + | |
38 | +print 'So far so good' | |
\ No newline at end of file |