@@ -126,36 +126,67 @@ end
126
126
127
127
billiards_testset (" RAY Stays inside" , identity; caller = inside_antidot)
128
128
129
- @testset " FiniteSplitterWall" begin
130
- bdr = billiard_rectangle (1.0 , 1.0 )
131
- splitter = FiniteSplitterWall ([0.5 ,0.0 ], [0.5 ,1.0 ], [- 1.0 ,0.0 ])
132
- bd = Billiard (splitter, bdr... )
133
-
134
- refraction (ϕ, pflag, ω) = pflag ? 0.5 ϕ : 2.0 ϕ
135
- transmission (ϕ, pflag, ω) = begin
129
+ test_refraction (ϕ, pflag, ω) = pflag ? 0.5 ϕ : 2.0 ϕ
130
+ test_transmission (ϕ, pflag, ω) = begin
136
131
if pflag
137
132
0.5 * exp (- (ϕ)^ 2 / 2 (π/ 8 )^ 2 )
138
133
else
139
134
abs (ϕ) < π/ 4 ? 0.5 * exp (- (ϕ)^ 2 / 2 (π/ 4 )^ 2 ) : 0.0
140
135
end
141
136
end
142
137
143
- N = 500
144
- rs = (RaySplitter ([1 ], transmission, refraction),)
145
- ps = particlebeam (0.01 , 0.5 , 0 , N, 0 )
146
- positions = []
138
+ @testset " FiniteSplitterWall" begin
139
+ bdr = billiard_rectangle (1.0 , 1.0 )
140
+ splitter = FiniteSplitterWall ([0.5 ,0.0 ], [0.5 ,1.0 ], [- 1.0 ,0.0 ])
141
+ bd = Billiard (splitter, bdr... )
142
+
143
+ N = 500
144
+ rs = (RaySplitter ([1 ], test_transmission, test_refraction),)
145
+ ps = particlebeam (0.01 , 0.5 , 0 , N, 0 )
146
+ positions = []
147
+
148
+ for p in ps
149
+ ct, pos, vel = evolve! (p, bd, 2 , rs)
150
+ push! (positions, pos[end ][1 ])
151
+ reset_billiard! (bd)
152
+ end
153
+
154
+ particles_on_left = length (filter (x -> x < 0.4 , positions))
155
+ particles_on_right = length (filter (x -> x > 0.6 , positions))
156
+ particles_in_middle = length (filter (x -> 0.4 <= x <= 0.6 , positions))
147
157
148
- for p in ps
149
- ct, pos, vel = evolve! (p, bd, 2 , rs)
150
- push! (positions, pos[end ][1 ])
151
- reset_billiard! (bd)
158
+ @test 0.3 N < particles_on_left < 0.7 N
159
+ @test 0.3 N < particles_on_right < 0.7 N
160
+ @test particles_in_middle == 0
152
161
end
153
162
154
- particles_on_left = length (filter (x -> x < 0.4 , positions))
155
- particles_on_right = length (filter (x -> x > 0.6 , positions))
156
- particles_in_middle = length (filter (x -> 0.4 <= x <= 0.6 , positions))
163
+ @testset " Ray-splitting escapetime" begin
164
+ verts = [[0.0 ,0.0 ], [0.0 ,1.0 ], [1.0 ,1.0 ], [1.0 ,0.0 ]]
165
+ bdr = []
166
+
167
+ # create rect billiard where vertical walls are doors
168
+ for i in eachindex (verts)
169
+ s = verts[i]
170
+ e = verts[mod1 (i+ 1 , length (verts))]
171
+ w = s - e
172
+ n = [- w[2 ], w[1 ]]
173
+ push! (bdr, FiniteWall (s, e, n, mod1 (i, 2 )== 1 ))
174
+ end
175
+
176
+ splitter = FiniteSplitterWall ([0.75 ,0.0 ], [0.75 ,1.0 ], [- 1.0 ,0.0 ])
177
+ bd = Billiard (splitter, bdr... )
178
+
179
+ N = 500
180
+ rs = (RaySplitter ([1 ], test_transmission, test_refraction),)
181
+ ps = particlebeam (0.01 , 0.5 , 0 , N, 0 )
182
+ ts = []
183
+
184
+ for p in ps
185
+ push! (ts, escapetime! (p, bd, 3 , rs))
186
+ reset_billiard! (bd)
187
+ end
157
188
158
- @test 0.3 N < particles_on_left < 0.7 N
159
- @test 0.3 N < particles_on_right < 0.7 N
160
- @test particles_in_middle == 0
189
+ mean_t = + (ts ... ) / N
190
+ expected_mean_t = 0.5 * 1 + 0.5 * 0.75 * 2
191
+ @test abs (expected_mean_t - mean_t) < 0.2
161
192
end
0 commit comments