修订版 | 1bffebdee900c9341a13c692f061cc4c8352b92f (tree) |
---|---|
时间 | 2008-12-03 10:06:44 |
作者 | iselllo |
Commiter | iselllo |
I updated the code and written a fortran module to import. Now I am able to calculate the shielding
factors for circles in 2D.
@@ -4,12 +4,8 @@ | ||
4 | 4 | import numpy as n |
5 | 5 | import pylab as p |
6 | 6 | |
7 | - | |
8 | -# Give 2D coordinates of the centres of two monomers in 2D | |
7 | +import ray_count as rc | |
9 | 8 | |
10 | -r_1=s.zeros(2) #coordinates of the first monomer | |
11 | -r_2=s.zeros(2) | |
12 | -r_2[1]=1. #now the two monomers are in touch | |
13 | 9 | |
14 | 10 | |
15 | 11 | class particle_2D: |
@@ -103,23 +99,55 @@ | ||
103 | 99 | |
104 | 100 | |
105 | 101 | |
106 | -x_0=0. | |
107 | -y_0=0. | |
108 | - | |
109 | -part1=particle_2D(x_0,y_0) | |
110 | -print "part1 position is, ", part1.position() | |
111 | 102 | |
112 | 103 | |
113 | 104 | |
114 | -x_1=1. | |
105 | +#Coordinates of the centre of the monomer I want to study | |
106 | + | |
107 | +x_0=0. | |
108 | +y_0=0. | |
109 | + | |
110 | +r1=1. #sphere radius | |
111 | + | |
112 | + | |
113 | + | |
114 | +part0=particle_2D(x_0,y_0) | |
115 | +print "part0 position is, ", part0.position() | |
116 | + | |
117 | + | |
118 | +#Coordinates of the centres of neighboring spheres | |
119 | + | |
120 | +x_1=2. | |
115 | 121 | y_1=0. |
116 | 122 | |
117 | -part2=particle_2D(x_1,y_1) | |
118 | -print "part2 position is, ", part1.position() | |
123 | + | |
124 | +x_2=-2. | |
125 | +y_2=0. | |
119 | 126 | |
120 | 127 | |
121 | -R=3. #radius of the circle | |
122 | -N=20 #number of pts along the circle | |
128 | +x_3=0. | |
129 | +y_3=2. | |
130 | + | |
131 | + | |
132 | +x_4=2. | |
133 | +y_4=0. | |
134 | + | |
135 | + | |
136 | +R=3.5 #radius of the circle | |
137 | +N=100 #number of pts along the circle (which is also the number or rays!!!) | |
138 | + | |
139 | +N_on_ray=50 # number of pts on each ray | |
140 | + | |
141 | +#arrays with the x and y coordinates of the centres of the neighboring spheres | |
142 | + | |
143 | +# x_arr=s.array([x_1,x_2,x_3,x_4]) | |
144 | +# y_arr=s.array([y_1,y_2,y_3,y_4]) | |
145 | + | |
146 | + | |
147 | +x_arr=s.array([x_1,x_2,x_3]) | |
148 | +y_arr=s.array([y_1,y_2,y_3]) | |
149 | + | |
150 | + | |
123 | 151 | |
124 | 152 | my_circle=circle_2D(x_0,y_0,R,N) |
125 | 153 |
@@ -127,13 +155,20 @@ | ||
127 | 155 | |
128 | 156 | print "the points on circle are, ", points |
129 | 157 | |
130 | -N_on_ray=20 | |
158 | + | |
159 | + | |
131 | 160 | |
132 | 161 | my_rays=ray_trace(x_0, y_0, R, N, N_on_ray, points) |
133 | 162 | |
134 | 163 | ray_arr=my_rays.rays() |
135 | 164 | |
136 | 165 | |
166 | + | |
167 | +my_ratio=rc.ray_count(ray_arr, x_arr, y_arr, r1) | |
168 | + | |
169 | +print "the shielding factor is, ", my_ratio | |
170 | + | |
171 | + | |
137 | 172 | #See that I am really covering a circle |
138 | 173 | |
139 | 174 | fig = p.figure() |