修訂 | 1d1ed12bad090edd5f47c0228b16921329292842 (tree) |
---|---|
時間 | 2007-05-29 21:39:58 |
作者 | iselllo |
Commiter | iselllo |
I added the file Python-codes/self_similarity.py. This simple code
solves a first order ODE giving the time evolution of the number
concentration for a self-similar distribution for a Brownian kernel in
the continuun limit.
@@ -0,0 +1,54 @@ | ||
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 self_similar(y, t): | |
9 | + return -myconst*y**2. | |
10 | + | |
11 | + | |
12 | + | |
13 | + | |
14 | +t = arange(0,4.0, 0.01) | |
15 | + | |
16 | + | |
17 | +y0 = 1.55e14 # initial total number concentration | |
18 | + | |
19 | +a=0.9046 | |
20 | +b=1.248 | |
21 | + | |
22 | +mu=2e-5 | |
23 | +k_B=1.38e-23 | |
24 | +T=400. | |
25 | +rho_p=1300. | |
26 | + | |
27 | +myconst=2.*k_B*T/(3.*mu)*(1.+a*b) | |
28 | +print 'myconst is',myconst | |
29 | + | |
30 | + | |
31 | +y = integrate.odeint(self_similar, y0, t,printmessg=1) | |
32 | + | |
33 | + | |
34 | +print 'solution is', y | |
35 | + | |
36 | + | |
37 | +pylab.plot(t,y[:,0]) | |
38 | +pylab.xlabel('Time') | |
39 | +pylab.ylabel('Total Number Concentration') | |
40 | +pylab.title('Self-Similar Evolution Number Concentration') | |
41 | +pylab.grid(True) | |
42 | +pylab.savefig('self_similar_number_concentration_cont_kernel') | |
43 | + | |
44 | +pylab.hold(False) | |
45 | + | |
46 | + | |
47 | +results=zeros((len(t),2)) | |
48 | +results[:,0]=t | |
49 | +results[:,1]=y[:,0] | |
50 | + | |
51 | +pylab.save("self_similar_pop.txt",results) | |
52 | + | |
53 | + | |
54 | +print 'So far so good' | |
\ No newline at end of file |