Skip to content

Commit 9b1eae5

Browse files
committed
Merge pull request #9 from PyCOMPLETE/develop
PyHEADTAIL v1.3.0 New features: - RFBucket Hamiltonian supports other potentials and fields (like space charge) - Multiturn wakefields - higher-order chromaticities (arbitrary order) - dispersion supported - unit tests - beam optics (optics functions like the beta function as inferred from the beam solely via statistical methods) - full phase advance for each segment (in addition to previous smoothed phase advance) - new SliceSet interface with statistics saved at creation for the slices and slice profile / derivative profile, also beam properties are taken over - Bassetti Erskine space charge - performance optimisation
2 parents 19add83 + bc0ea69 commit 9b1eae5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+28264
-6621
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ scripts/
1313
*.h5
1414
*.h5part
1515
.ipynb_checkpoints
16+
.DS_Store
1617
*.__afs*

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
PyHEADTAIL
22
==========
33

4-
CERN PyHEADTAIL simulation code for simulation of multi-particle beam dynamics and collective effects
4+
CERN PyHEADTAIL numerical n-body simulation code for simulating macro-particle beam dynamics with collective effects

_version.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
__version__ = "1.2.0"
2-
1+
import os, subprocess
2+
worktree = os.path.dirname(os.path.abspath(__file__))
3+
gitdir = worktree + '/.git/'
4+
__version__ = subprocess.check_output(
5+
'git --git-dir=' + gitdir + ' --work-tree=' +
6+
worktree + ' describe --long --dirty --abbrev=10 --tags', shell=True)
7+
__version__ = __version__.rstrip() # remove trailing \n
8+
__version__ = __version__[1:] # remove leading v

aperture/aperture.pyx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ class Aperture(Element):
4343
change its (longitudinal) state. '''
4444
alive = self.tag_lost_particles(beam)
4545

46-
if not np.all(alive):
47-
# Move lost particles to the end of the beam.u arrays.
48-
n_alive = relocate_lost_particles(beam, alive)
4946

47+
if not np.all(alive):
48+
# check whether all particles are lost, it's not safe to call
49+
# relocate_all_particles in this case
50+
if not np.any(alive):
51+
self.warns('ALL particles were lost')
52+
n_alive = 0
53+
else :
54+
# Move lost particles to the end of the beam.u arrays.
55+
n_alive = relocate_lost_particles(beam, alive)
5056
# Update beam.u arrays, i.e. remove lost particles.
5157
beam.macroparticlenumber = n_alive
5258
beam.x = beam.x[:n_alive]
@@ -191,6 +197,10 @@ def relocate_lost_particles(beam, int[::1] alive):
191197
z, ...). Returns the number of alive particles n_alive_post after
192198
considering the losses.
193199
200+
Precondition:
201+
- At least one particle must be tagged as alive, otherwise bad things
202+
might happen...
203+
194204
Description of the algorithm:
195205
(1) Starting from the end of the numpy array 'alive', find the index
196206
of the last particle in the array which is still alive. Store its

0 commit comments

Comments
 (0)