Skip to content

Commit

Permalink
This works!
Browse files Browse the repository at this point in the history
  • Loading branch information
giadarol committed Feb 23, 2024
1 parent 80169c9 commit 440ff66
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions examples/coasting/002_try_to_simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
beta1 = tw.beta0 * 1.1
class CoastWrap:

def __init__(self, circumference, id, beta1, at_start=False):
def __init__(self, circumference, id, beta1, at_end=False):
assert id > 10000
self.id = id
self.beta1 = beta1
self.circumference = circumference
self.at_start = at_start
self.at_end = at_end

def track(self, particles):

Expand All @@ -51,7 +51,7 @@ def track(self, particles):
# import pdb; pdb.set_trace()
# particles.reorganize()

if self.at_start:
if not(self.at_end):
mask_alive = particles.state > 0
particles.zeta[mask_alive] -= (
self.circumference * (1 - tw.beta0 / self.beta1))
Expand All @@ -61,7 +61,8 @@ def track(self, particles):
particles.reorganize()

beta0_beta1 = tw.beta0 / self.beta1
zeta_min = particles.s * (1 - beta0_beta1) - beta0_beta1 * self.circumference / 2
# zeta_min = particles.s * (1 - beta0_beta1) - beta0_beta1 * self.circumference / 2
# zeta_min = particles.s * (1 - beta0_beta1) - beta0_beta1 * self.circumference / 2

# Identify particles that need to be stopped
mask_alive = particles.state > 0
Expand Down Expand Up @@ -101,16 +102,16 @@ def zeta_prime_to_zeta(self, zeta_prime, beta0, s, at_turn):
return zeta

circumference = line.get_length()
wrap_end = CoastWrap(circumference=circumference, beta1=beta1, id=10001)
wrap_start = CoastWrap(circumference=circumference, beta1=beta1, id=10002, at_start=True)
wrap_end = CoastWrap(circumference=circumference, beta1=beta1, id=10001, at_end=True)
wrap_start = CoastWrap(circumference=circumference, beta1=beta1, id=10002)

zeta_min = -circumference/2*tw.beta0/beta1
zeta_max = circumference/2*tw.beta0/beta1

num_particles = 10000
p = line.build_particles(
zeta=np.random.uniform(-circumference/2, circumference/2, num_particles),
delta=np.random.uniform(-3e-2, 3e-2, num_particles),
delta=0*np.random.uniform(-1, 1, num_particles),
x_norm=0, y_norm=0
)

Expand All @@ -128,10 +129,6 @@ def zeta_prime_to_zeta(self, zeta_prime, beta0, s, at_turn):

# import pdb; pdb.set_trace()

# wrap_start.at_start = False
# wrap_start.track(p)
# wrap_start.at_start = True

# p.at_turn[:] = 0

line.discard_tracker()
Expand Down

0 comments on commit 440ff66

Please sign in to comment.