Skip to content

Commit

Permalink
Add probe particle option
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherMayes committed Aug 1, 2023
1 parent 8a209eb commit 7c18bc7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pmd_beamphysics/interfaces/astra.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ def vprint(*a, **k):
sigma = {}
for k in ['x', 'y', 'z', 'px', 'py', 'pz', 't']:
ref_particle[k] = particle_group.avg(k)
sigma[k] = particle_group.std(k)
std = particle_group.std(k)
if std == 0:
std = 1e-12 # Give some size
sigma[k] = std
ref_particle['t'] *= 1e9 # s -> nS

# Make structured array
Expand Down Expand Up @@ -203,6 +206,7 @@ def vprint(*a, **k):
data[5]['x'] = 1.5*sigma['x'];data[5]['t'] = 1.5*sigma['t']
data[6]['y'] = 1.5*sigma['y'];data[6]['t'] = -1.5*sigma['t']
data[1:7]['status'] = -3
data[1:7]['q'] = 0.5e-5 # ? Seems to be required
data[1:7]['pz'] = 0 #? This is what the Astra Generator does

# Save in the 'high_res = T' format
Expand Down
5 changes: 3 additions & 2 deletions pmd_beamphysics/particles.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,8 +759,9 @@ def drift_to_t(self, t=None):
self.t = np.full(self.n_particle, t)

# Writers
def write_astra(self, filePath, verbose=False):
write_astra(self, filePath, verbose=verbose)
@functools.wraps(write_astra)
def write_astra(self, filePath, verbose=False, probe=False):
write_astra(self, filePath, verbose=verbose, probe=probe)

def write_bmad(self, filePath, p0c=None, t_ref=0, verbose=False):
write_bmad(self, filePath, p0c=p0c, t_ref=t_ref, verbose=verbose)
Expand Down

0 comments on commit 7c18bc7

Please sign in to comment.