From 5ee883a2e7929b52c2ca768b4b65bc6efdcd436a Mon Sep 17 00:00:00 2001 From: Adrian Oeftiger Date: Fri, 11 Aug 2017 17:37:04 +0200 Subject: [PATCH 1/8] release-script: removing quotes "" Previously, the release was drafted with "" around the name and "" around the message. --- release.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release.py b/release.py index 042c7414..d105202e 100755 --- a/release.py +++ b/release.py @@ -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. ' From 8e0c10b636b22d42ca816d489a4cf6435dc16fc0 Mon Sep 17 00:00:00 2001 From: Adrian Oeftiger Date: Fri, 1 Sep 2017 16:04:06 +0200 Subject: [PATCH 2/8] contextmanager: need to define error message above import of pmath otherwise pmath imports the error message before it is defined. --- PyHEADTAIL/general/contextmanager.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/PyHEADTAIL/general/contextmanager.py b/PyHEADTAIL/general/contextmanager.py index 37200d3f..b706c767 100644 --- a/PyHEADTAIL/general/contextmanager.py +++ b/PyHEADTAIL/general/contextmanager.py @@ -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: @@ -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 From 9c8b4024896317686f6d47e9d85a6083b99b8360 Mon Sep 17 00:00:00 2001 From: Adrian Oeftiger Date: Wed, 27 Sep 2017 09:35:21 +0200 Subject: [PATCH 3/8] FrozenSpaceCharge25D: bug fix, also update field on Y change. --- PyHEADTAIL/spacecharge/pypic_spacecharge.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/PyHEADTAIL/spacecharge/pypic_spacecharge.py b/PyHEADTAIL/spacecharge/pypic_spacecharge.py index 2395e913..c765d3b5 100644 --- a/PyHEADTAIL/spacecharge/pypic_spacecharge.py +++ b/PyHEADTAIL/spacecharge/pypic_spacecharge.py @@ -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) From 859685d67a613c4b7b20bb58303195099dc9ef59 Mon Sep 17 00:00:00 2001 From: mariobeck Date: Tue, 24 Oct 2017 12:15:55 +0200 Subject: [PATCH 4/8] feedback: include damping rate 0 treatment Modified transverse_damper class for dampingrate 0 --- PyHEADTAIL/feedback/transverse_damper.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/PyHEADTAIL/feedback/transverse_damper.py b/PyHEADTAIL/feedback/transverse_damper.py index ded9f75f..a37f4b9b 100644 --- a/PyHEADTAIL/feedback/transverse_damper.py +++ b/PyHEADTAIL/feedback/transverse_damper.py @@ -14,15 +14,23 @@ class TransverseDamper(object): def __init__(self, dampingrate_x, dampingrate_y): - self.gain_x = 2/dampingrate_x - self.gain_y = 2/dampingrate_y if dampingrate_x and not dampingrate_y: + self.gain_x = 2/dampingrate_x self.track = self.track_horizontal + print('Damper in V active') elif not dampingrate_x and dampingrate_y: + self.gain_y = 2/dampingrate_y self.track = self.track_vertical + print('Damper in Y active') + elif not dampingrate_x and not dampingrate_y: + print('Dampers not active') + self.track = lambda x: 0 else: + self.gain_x = 2/dampingrate_x + self.gain_y = 2/dampingrate_y self.track = self.track_all + print('Dampers active') def track_horizontal(self, beam): beam.xp -= self.gain_x * beam.mean_xp() From d83bd03309acb13dfaecfbf8d57387d775e1c39d Mon Sep 17 00:00:00 2001 From: mariobeck Date: Tue, 24 Oct 2017 12:19:44 +0200 Subject: [PATCH 5/8] feedback: make transverse damper compatible with Element --- PyHEADTAIL/feedback/__init__.py | 1 + PyHEADTAIL/feedback/transverse_damper.py | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/PyHEADTAIL/feedback/__init__.py b/PyHEADTAIL/feedback/__init__.py index d2d966e2..b4d82c9b 100644 --- a/PyHEADTAIL/feedback/__init__.py +++ b/PyHEADTAIL/feedback/__init__.py @@ -1 +1,2 @@ from .. import __version__ +from .. import Element diff --git a/PyHEADTAIL/feedback/transverse_damper.py b/PyHEADTAIL/feedback/transverse_damper.py index a37f4b9b..969bf293 100644 --- a/PyHEADTAIL/feedback/transverse_damper.py +++ b/PyHEADTAIL/feedback/transverse_damper.py @@ -10,27 +10,28 @@ 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): + 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 - print('Damper in V active') + self.prints('Damper in V active') elif not dampingrate_x and dampingrate_y: self.gain_y = 2/dampingrate_y self.track = self.track_vertical - print('Damper in Y active') + self.prints('Damper in Y active') elif not dampingrate_x and not dampingrate_y: - print('Dampers not active') + self.prints('Dampers not active') self.track = lambda x: 0 else: self.gain_x = 2/dampingrate_x self.gain_y = 2/dampingrate_y self.track = self.track_all - print('Dampers active') + self.prints('Dampers active') def track_horizontal(self, beam): beam.xp -= self.gain_x * beam.mean_xp() From 933420541fab471b346f606c19db4336ae5bdb19 Mon Sep 17 00:00:00 2001 From: Adrian Oeftiger Date: Tue, 31 Oct 2017 14:28:04 +0100 Subject: [PATCH 6/8] Readme update --- README.rst | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index 2180a838..bf115e6b 100644 --- a/README.rst +++ b/README.rst @@ -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. @@ -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. From c1a2174755bc9366da61be68fcc00366031a8545 Mon Sep 17 00:00:00 2001 From: Adrian Oeftiger Date: Tue, 31 Oct 2017 14:45:55 +0100 Subject: [PATCH 7/8] fixing test for damper --- PyHEADTAIL/feedback/transverse_damper.py | 5 ++++- PyHEADTAIL/testing/unittests/test_gpu_interface.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/PyHEADTAIL/feedback/transverse_damper.py b/PyHEADTAIL/feedback/transverse_damper.py index 969bf293..4ea00125 100644 --- a/PyHEADTAIL/feedback/transverse_damper.py +++ b/PyHEADTAIL/feedback/transverse_damper.py @@ -26,13 +26,16 @@ def __init__(self, dampingrate_x, dampingrate_y, *args, **kwargs): self.prints('Damper in Y active') elif not dampingrate_x and not dampingrate_y: self.prints('Dampers not active') - self.track = lambda x: 0 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() diff --git a/PyHEADTAIL/testing/unittests/test_gpu_interface.py b/PyHEADTAIL/testing/unittests/test_gpu_interface.py index 972207de..5af35f3c 100644 --- a/PyHEADTAIL/testing/unittests/test_gpu_interface.py +++ b/PyHEADTAIL/testing/unittests/test_gpu_interface.py @@ -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') From a11544d8fc76789eb4ba5d0a48a3ba5f69ff51b4 Mon Sep 17 00:00:00 2001 From: Adrian Oeftiger Date: Tue, 31 Oct 2017 14:50:19 +0100 Subject: [PATCH 8/8] release-script: bumping version file. --- PyHEADTAIL/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyHEADTAIL/_version.py b/PyHEADTAIL/_version.py index fe70fa28..96ddfeb7 100644 --- a/PyHEADTAIL/_version.py +++ b/PyHEADTAIL/_version.py @@ -1 +1 @@ -__version__ = '1.12.1' +__version__ = '1.12.2'