• R/O
  • SSH

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修订版13f9edc99700dc12b2e211e1cc2cb7d0e955f2be (tree)
时间2008-03-07 02:50:37
作者iselllo
Commiteriselllo

Log Message

I added lambda_brownian.py which is a better version of test_kernel.py.
A few things have to be said: I am using a power-law effective density
which does not become a constant for small particles. For fractal
dimension different from 3, I am taking the constant a_0 in the
free-molecular (fractal) kernel as d_0/2, where d_0 is the monomer
diameter. However, it is not clear at all how to extend that to the case
of a constant effective density below a threshold which is NOT the
monomer diameter.

更改概述

差异

diff -r 77a27c4a75fb -r 13f9edc99700 Python-codes/lambda_brownian.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Python-codes/lambda_brownian.py Thu Mar 06 17:50:37 2008 +0000
@@ -0,0 +1,326 @@
1+#! /usr/bin/env python
2+# from scipy import *
3+# import pylab # used to read the .csv file
4+
5+
6+import scipy as s
7+import numpy as n
8+import pylab as p
9+
10+
11+
12+
13+
14+
15+def Brow_ker_fuchs_class_optim_slip(Vlist,diam_seq):
16+ knu=2.*lam_air/diam_seq # vector with the Knudsen numbers
17+ k_B=1.38e-23
18+ #print 'knu is', knu
19+# if (save_knu==1):
20+# pylab.save("knudsen",knu)
21+ if (slip_yannis==0):
22+ #k_B=1.38e-23
23+ Diff=k_B*T_0/(3.*s.pi*mu*diam_seq)
24+ elif (slip_yannis==1):
25+ #k_B=1.38e-23
26+ #print 'k_B is ', k_B
27+ #print 'T is, ', T_0
28+ Diff=k_B*T_0/(3.*s.pi*mu*diam_seq)*(1.+knu*(1.17+0.53*s.exp(-0.78/knu)))
29+ #print 'Diff is', Diff
30+ m=rho_p*Vlist # this holds in general (i.e. for Vlist !=3.)
31+ ## as long as Vlist is the volume of solid
32+ ##and not the space occupied by the agglomerate structure
33+ c=(8.*k_B*T_0/(s.pi*m))**0.5
34+ #print 'c is', c
35+ l=8.*Diff/(s.pi*c)
36+ # if (save_knu==1):
37+# pylab.save("lambda_part",l)
38+ #print 'l is', l
39+ g=1./(3.*diam_seq*l)*((diam_seq+l)**3.-(diam_seq**2.+l**2.)**1.5)-diam_seq
40+
41+ beta=(\
42+ (diam_seq[:,s.newaxis]+diam_seq[s.newaxis,:]) \
43+ /(diam_seq[:,s.newaxis]+diam_seq[s.newaxis,:]\
44+ +2.*(g[:,s.newaxis]**2.+g[s.newaxis,:]**2.)**0.5)\
45+ + 8.*(Diff[:,s.newaxis]+Diff[s.newaxis,:])/\
46+ ((c[:,s.newaxis]**2.+c[s.newaxis,:]**2.)**0.5*\
47+ (diam_seq[:,s.newaxis]+diam_seq[s.newaxis,:]))\
48+ )**(-1.)
49+
50+ #print 'the mean of beta is', mean(beta)
51+
52+ ## now I have all the bits for the kernel matrix
53+ kern_mat=Brow_ker_cont_optim_slip(Vlist,diam_seq)*beta
54+ if (D_f==3. and slip_yannis==1):
55+ p.save("beta_coalescing.dat", s.diag(beta))
56+ elif (D_f !=3. and slip_yannis == 1):
57+ p.save("beta_fractal.dat", s.diag(beta))
58+ #print 'beta is', beta
59+
60+
61+
62+ return kern_mat
63+
64+
65+def Brow_ker_cont_optim_slip(Vlist,diam_seq):
66+ k_B=1.38e-23
67+ # same expression for the kernel in the continuous limit
68+ # as the one used by Maricq.
69+ knu=2.*lam_air/diam_seq # vector with the Knudsen numbers
70+ if (slip_yannis ==0):
71+ Slip=s.zeros(len(knu))
72+ Slip[:]=1.
73+ elif (slip_yannis==1):
74+ Slip=1.+knu*(1.17+0.53*s.exp(-0.78/knu))
75+ kern_mat=2.*k_B*T_0/(3.*mu)*(Vlist[:,s.newaxis]**(1./D_f)+\
76+ Vlist[s.newaxis,:]**(1./D_f))* \
77+ (Slip[:,s.newaxis]/Vlist[:,s.newaxis]**(1./D_f)+\
78+ Slip[s.newaxis,:]/Vlist[s.newaxis,:]**(1./D_f))
79+ return kern_mat
80+
81+def Brow_ker_free_optim(Vlist):
82+ k_B=1.38e-23
83+ a_0=d_0/2.
84+ #a_0=1e-8
85+ lam=2./D_f-0.5
86+ kern_mat=(3./(4.*s.pi))**lam*(6.*k_B*T_0/rho_p)**0.5*a_0**(2.-6./D_f)*\
87+ (1./Vlist[:,s.newaxis]+1./Vlist[s.newaxis,:])**0.5*\
88+ (Vlist[:,s.newaxis]**(1./D_f)+Vlist[s.newaxis,:]**(1./D_f))**2.
89+ return kern_mat
90+
91+
92+
93+
94+def beta_calc(Vlist,diam_seq):
95+ knu=2.*lam_air/diam_seq # vector with the Knudsen numbers
96+ #print 'knu is', knu
97+ if (slip_yannis==0):
98+ Diff=k_B*T_0/(3.*s.pi*mu*diam_seq)*((5.+4.*knu+6.*knu**2.+18.*knu**3.)/\
99+ (5.-knu+(8.+s.pi)*knu**2.))
100+ elif (slip_yannis==1):
101+ #print 'k_B is ', k_B
102+ #print 'T is, ', T_0
103+ Diff=k_B*T_0/(3.*s.pi*mu*diam_seq)*(1.+knu*(1.17+0.53*exp(-0.78/knu)))
104+ #print 'Diff is', Diff
105+ m=rho_p*Vlist # this holds in general (i.e. for Vlist !=3.)
106+ ## as long as Vlist is the volume of solid
107+ ##and not the space occupied by the agglomerate structure
108+ c=(8.*k_B*T_0/(s.pi*m))**0.5
109+ #print 'c is', c
110+ l=8.*Diff/(s.pi*c)
111+ #print 'l is', l
112+ g=1./(3.*diam_seq*l)*((diam_seq+l)**3.-(diam_seq**2.+l**2.)**1.5)-diam_seq
113+
114+ beta=(\
115+ (diam_seq[:,s.newaxis]+diam_seq[s.newaxis,:]) \
116+ /(diam_seq[:,s.newaxis]+diam_seq[s.newaxis,:]\
117+ +2.*(g[:,s.newaxis]**2.+g[s.newaxis,:]**2.)**0.5)\
118+ + 8.*(Diff[:,s.newaxis]+Diff[s.newaxis,:])/\
119+ ((c[:,s.newaxis]**2.+c[s.newaxis,:]**2.)**0.5*\
120+ (diam_seq[:,s.newaxis]+diam_seq[s.newaxis,:]))\
121+ )**(-1.)
122+
123+ #print 'the mean of beta is', mean(beta)
124+
125+ ## now I have all the bits for the kernel matrix
126+
127+
128+ #print 'beta is', beta
129+
130+
131+
132+ return beta
133+
134+
135+
136+
137+
138+def lambda_Brownian(T_0,diam_seq,V_list,rho_p,lam_air):
139+ knu=2.*lam_air/diam_seq
140+ k_B=1.38e-23
141+ Diff=k_B*T_0/(3.*s.pi*mu*diam_seq)*(1.+knu*(1.17+0.53*s.exp(-0.78/knu)))
142+ m=rho_p*V_list
143+ c=(8.*k_B*T_0/(s.pi*m))**0.5
144+ l=8.*Diff/(s.pi*c)
145+
146+ return l
147+
148+
149+def v_th(T):
150+ k_B=1.38e-23
151+ m_air=28.8*1.66e-27
152+ v=s.sqrt((2.*k_B*T)/m_air)
153+ return v
154+
155+
156+
157+T_0=300.
158+
159+d_0=50.e-9 # primary size in m
160+
161+
162+D_f=3.
163+diam_seq=s.logspace(s.log10(1.),s.log10(1000.),1000)
164+diam_seq=diam_seq*1e-9 #to go from nm to m
165+V_list=s.pi/6.*diam_seq**D_f
166+rho_p=1300. # kg/m^3
167+mu=184.6e-7
168+v_thermal=v_th(T_0)
169+rho_air=1.16 #kg/m^3
170+lam_air=2.*mu/(rho_air*v_thermal)
171+
172+print "V_thermal is, ", v_thermal
173+
174+
175+lam_br=lambda_Brownian(T_0,diam_seq,V_list,rho_p,lam_air)
176+
177+
178+p.loglog(diam_seq*1e9,lam_br*1e9,linewidth=2.)
179+p.xlabel('Particle Diameter [nm]',fontsize=20.)
180+p.ylabel('Lambda Brownian [nm]',fontsize=20.)
181+#pylab.legend(('prey population','predator population'))
182+p.title('Lambda Brownian particle',fontsize=20.)
183+p.grid(True)
184+p.savefig('lambda_brownian.pdf')
185+p.hold(False)
186+p.clf()
187+
188+
189+
190+slip_yannis=1
191+
192+
193+
194+my_kernel=Brow_ker_fuchs_class_optim_slip(V_list,diam_seq)
195+
196+
197+
198+
199+
200+free_kernel=Brow_ker_free_optim(V_list)
201+
202+cont_kernel=Brow_ker_cont_optim_slip(V_list,diam_seq)
203+
204+slip_yannis=0
205+
206+cont_kernel_no_slip=Brow_ker_cont_optim_slip(V_list,diam_seq)
207+
208+
209+
210+
211+
212+
213+
214+
215+p.loglog(diam_seq*1e9,s.diag(my_kernel),diam_seq*1e9,s.diag(free_kernel)\
216+ ,diam_seq*1e9,s.diag(cont_kernel),diam_seq*1e9,s.diag(cont_kernel_no_slip))
217+#pylab.axvline(x=select_diam*1e9)
218+p.xlabel('diameter [nm]')
219+p.ylabel('kernel value along diagonal')
220+p.legend(('Fuchs','Free Molecular','Continuum','continuum no slip'))
221+p.title('Kernel number vs diameter')
222+p.grid(True)
223+p.savefig('test_kernel_diagonal_coalescing_particles.pdf')
224+p.hold(False)
225+p.clf()
226+
227+
228+
229+
230+
231+
232+
233+
234+
235+
236+
237+D_f=2.1 #I now use a non-trivial fractal dimension
238+
239+
240+#V_list=s.pi/6.*diam_seq**3.*(diam_seq/d_0)**(D_f-3.)*(diam_seq>=d_0)+ \
241+ #s.pi/6.*diam_seq**3.*(diam_seq<d_0)
242+
243+V_list=s.pi/6.*diam_seq**3.*(diam_seq/d_0)**(D_f-3.)
244+
245+
246+lam_br=lambda_Brownian(T_0,diam_seq,V_list,rho_p,lam_air)
247+
248+
249+p.loglog(diam_seq*1e9,lam_br*1e9,linewidth=2.)
250+#p.ylim(4.,120.)
251+p.xlabel('Particle Diameter [nm]',fontsize=20.)
252+p.ylabel('Lambda Brownian [nm]',fontsize=20.)
253+#pylab.legend(('prey population','predator population'))
254+p.title('Lambda Fractal Brownian particle',fontsize=20.)
255+p.grid(True)
256+p.savefig('lambda_brownian_fractal.pdf')
257+p.hold(False)
258+p.clf()
259+
260+
261+slip_yannis=1
262+
263+
264+
265+my_kernel=Brow_ker_fuchs_class_optim_slip(V_list,diam_seq)
266+
267+
268+
269+
270+
271+free_kernel=Brow_ker_free_optim(V_list)
272+
273+cont_kernel=Brow_ker_cont_optim_slip(V_list,diam_seq)
274+
275+slip_yannis=0
276+
277+cont_kernel_no_slip=Brow_ker_cont_optim_slip(V_list,diam_seq)
278+
279+
280+
281+
282+
283+p.loglog(diam_seq*1e9,s.diag(my_kernel),diam_seq*1e9,s.diag(free_kernel)\
284+ ,diam_seq*1e9,s.diag(cont_kernel),diam_seq*1e9,s.diag(cont_kernel_no_slip))
285+#pylab.axvline(x=select_diam*1e9)
286+p.xlabel('diameter [nm]')
287+p.ylabel('kernel value along diagonal')
288+p.legend(('Fuchs','Free Molecular','Continuum','continuum no slip'))
289+p.title('Kernel number vs diameter')
290+p.grid(True)
291+p.savefig('test_kernel_diagonal_fractal_particles.pdf')
292+p.hold(False)
293+p.clf()
294+
295+beta_coal=p.load("beta_coalescing.dat")
296+
297+
298+p.loglog(diam_seq*1e9,beta_coal, linewidth=2.)
299+#pylab.axvline(x=select_diam*1e9)
300+p.xlabel('diameter [nm]')
301+p.ylabel('beta')
302+#p.legend(('Fuchs','Free Molecular','Continuum','continuum no slip'))
303+p.title('Beta vs diameter for coalescing Particles')
304+p.grid(True)
305+p.savefig('beta_coalescing_particles.pdf')
306+p.hold(False)
307+p.clf()
308+
309+
310+
311+beta_frac=p.load("beta_fractal.dat")
312+
313+
314+p.loglog(diam_seq*1e9,beta_frac, linewidth=2.)
315+#pylab.axvline(x=select_diam*1e9)
316+p.xlabel('diameter [nm]')
317+p.ylabel('beta')
318+#p.legend(('Fuchs','Free Molecular','Continuum','continuum no slip'))
319+p.title('Beta vs diameter for fractal Particles')
320+p.grid(True)
321+p.savefig('beta_fractal_particles.pdf')
322+p.hold(False)
323+p.clf()
324+
325+
326+print "So far so good"