Skip to content

Commit

Permalink
release-script: Merge branch 'release/v1.12.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
aoeftiger committed Oct 31, 2017
2 parents 646092f + a11544d commit 4302cd5
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 30 deletions.
2 changes: 1 addition & 1 deletion PyHEADTAIL/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.12.1'
__version__ = '1.12.2'
1 change: 1 addition & 0 deletions PyHEADTAIL/feedback/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .. import __version__
from .. import Element
20 changes: 16 additions & 4 deletions PyHEADTAIL/feedback/transverse_damper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,31 @@
from scipy.special import k0
from scipy.constants import c, e

from . import Element

class TransverseDamper(object):
class TransverseDamper(Element):

def __init__(self, dampingrate_x, dampingrate_y):
self.gain_x = 2/dampingrate_x
self.gain_y = 2/dampingrate_y
def __init__(self, dampingrate_x, dampingrate_y, *args, **kwargs):

if dampingrate_x and not dampingrate_y:
self.gain_x = 2/dampingrate_x
self.track = self.track_horizontal
self.prints('Damper in V active')
elif not dampingrate_x and dampingrate_y:
self.gain_y = 2/dampingrate_y
self.track = self.track_vertical
self.prints('Damper in Y active')
elif not dampingrate_x and not dampingrate_y:
self.prints('Dampers not active')
else:
self.gain_x = 2/dampingrate_x
self.gain_y = 2/dampingrate_y
self.track = self.track_all
self.prints('Dampers active')

# will be overwritten at initialisation
def track(self, beam):
pass

def track_horizontal(self, beam):
beam.xp -= self.gain_x * beam.mean_xp()
Expand Down
18 changes: 9 additions & 9 deletions PyHEADTAIL/general/contextmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
@data 30.09.2015
'''
import numpy as np

class UnknownContextManagerError(Exception):
'''Raise if context manager is not found, e.g. cannot determine
whether on CPU or on GPU.
'''
def __init__(self, message='Failed to determine current context, e.g. '
'whether pmath.device is "CPU" or "GPU".'):
self.message = message

import pmath as pm
from ..gpu import gpu_utils
try:
Expand Down Expand Up @@ -104,15 +113,6 @@ def _patch_binop(self, other):
pycuda.gpuarray.GPUArray.__truediv__ = pycuda.gpuarray.GPUArray.__div__


class UnknownContextManagerError(Exception):
'''Raise if context manager is not found, e.g. cannot determine
whether on CPU or on GPU.
'''
def __init__(self, message='Failed to determine current context, e.g. '
'whether pmath.device is "CPU" or "GPU".'):
self.message = message


class Context(object):
'''
Example contextmanager class providing enter and exit methods
Expand Down
9 changes: 7 additions & 2 deletions PyHEADTAIL/spacecharge/pypic_spacecharge.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,13 @@ def track(self, beam):

# update field?
if self.sigma_rtol is not None:
if (np.abs(pm.ensure_CPU(beam.sigma_x()) - self.sigma_x)
> self.sigma_rtol * self.sigma_x):
x_too_large = (
np.abs(pm.ensure_CPU(beam.sigma_x()) - self.sigma_x)
> self.sigma_rtol * self.sigma_x)
y_too_large = (
np.abs(pm.ensure_CPU(beam.sigma_y()) - self.sigma_y)
> self.sigma_rtol * self.sigma_y)
if x_too_large or y_too_large:
self.prints('FrozenGaussianSpaceCharge25D: '
'updating field maps...')
self.update_field(beam)
Expand Down
2 changes: 1 addition & 1 deletion PyHEADTAIL/testing/unittests/test_gpu_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def test_transverse_damper(self):
bunch_gpu = self.create_all1_bunch()
dampingrate_x = 0.01
dampingrate_y = 0.05
damp = TransverseDamper(dampingrate_x, dampingrate_y)
damp = TransverseDamper(dampingrate_x, dampingrate_y, printer=SilentPrinter())
self.assertTrue(self._track_cpu_gpu([damp], bunch_cpu, bunch_gpu),
'Tracking TransverseDamper CPU/GPU differs')

Expand Down
35 changes: 24 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,27 @@ PyHEADTAIL
CERN PyHEADTAIL numerical n-body simulation code
for simulating macro-particle beam dynamics with collective effects.

Installation
------------
PyHEADTAIL is written in C and Python.
Currently, PyHEADTAIL is compatible with Python v2.7.

Installation for Users
----------------------

For using PyHEADTAIL without modifying the source code,
we recommend to install the latest version via PyPI:

$ pip install PyHEADTAIL

Installation for Developers
---------------------------

For developers of PyHEADTAIL, we recommend to install a stand-alone
package from the source code using git. For GPU usage, the developer
version is required (the Makefile is included in the source code
version only).

We recommend to use the Anaconda package manager (for Python 2.7) to simplify installing.
You can obtain it from anaconda.org .

Installation of PyHEADTAIL on linux (having git installed)
is straight forward.
Expand Down Expand Up @@ -36,13 +55,7 @@ And there you go, start using PyHEADTAIL!
In [1]: import PyHEADTAIL
PyHEADTAIL v1.11.2
-------------------------------------------------------------------------------

Please use the pre-push script ``prepush.py`` if you want to contribute
to the repository. It only lets you push to the develop and master branch if
no unit tests fail.
PyHEADTAIL v1.12.2
To install (creates a symlink): ``ln -s ../../prepush.py .git/hooks/pre-push``
For a single installation of PyHEADTAIL we recommended to add
the PyHEADTAIL path to your PYTHONPATH.
4 changes: 2 additions & 2 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ def finalise_release():
release_failed = subprocess.call(
['gothub', 'release', '-u', github_user, '-r', github_repo,
'-t', 'v' + new_version,
'-n', '"PyHEADTAIL v{}"'.format(new_version),
'-d', '"{}"'.format(message),
'-n', 'PyHEADTAIL v{}'.format(new_version),
'-d', '{}'.format(message),
'-c', 'master'])
if release_failed:
print ('*** Drafting the release via gothub failed. '
Expand Down

0 comments on commit 4302cd5

Please sign in to comment.