Skip to content

Commit 9d09513

Browse files
committed
fix particle beam for N=1
1 parent ad7df20 commit 9d09513

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/billiards/particles.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,15 @@ The particle element type is `T`.
150150
"""
151151
function particlebeam(x0, y0, φ, N, dx, ω = nothing, T = eltype(x0))
152152
n = cossin(φ)
153-
xyφs = [
154-
T.((x0 - i*dx*n[2]/N, y0 + i*dx*n[1]/N, φ)) for i in range(-N/2, N/2; length = N)
155-
]
153+
if N > 1
154+
xyφs = [
155+
T.((x0 - i*dx*n[2]/N, y0 + i*dx*n[1]/N, φ)) for i in range(-N/2, N/2; length = N)
156+
]
157+
elseif N == 1
158+
xyφs = [T.((x0, y0, φ))]
159+
else
160+
error("must be N ≥ 1")
161+
end
156162
if isnothing(ω)
157163
ps = [Particle(z...) for z in xyφs]
158164
else

src/billiards/standard_billiards.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ function billiard_mushroom(stem_length = 1.0, stem_width=0.2, cap_radious=1.0,
245245

246246
abs(sloc) + sw/2 > cr && error("Stem is outside the mushroom cap!")
247247

248+
sl, sw, cr, sloc = promote(sl, sw, cr, sloc)
249+
T = eltype(sl)
248250
leftcorn = SV(-sw/2 + sloc, 0)
249251
rightcorn = SV(sw/2 + sloc, 0)
250252
upleftcorn = SV(-sw/2 + sloc, sl)
@@ -263,8 +265,7 @@ function billiard_mushroom(stem_length = 1.0, stem_width=0.2, cap_radious=1.0,
263265
capbotright = FiniteWall(
264266
uprightcorn, farright, SV(0, sw), false, "Cap bottom right")
265267

266-
cap = Semicircle([0.0, sl], cr, [0.0, -1.0], "Mushroom cap")
267-
268+
cap = Semicircle([0, sl], cr, [0, -T(1.0)], "Mushroom cap")
268269
return Billiard(stembot, stemright, capbotright, cap, capbotleft, stemleft)
269270
end
270271

0 commit comments

Comments
 (0)