Skip to content

Commit 6584f96

Browse files
authored
check len(refpts) > 2 after removing zero length elements in get_lifetime() (#801)
* check len(refpts) > 2 after removing zero length elements * use _Complex_I * restore I * update to master * update to master
1 parent 07c85d0 commit 6584f96

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

atintegrators/atimplib.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <mpi4py/mpi4py.h>
99
#endif
1010

11+
1112
int binarySearch(double *array,double value,int upper,int lower,int nStep){
1213
int pivot = (int)(lower+upper)/2;
1314
if ((upper-lower)<=1){
@@ -297,7 +298,7 @@ static void compute_kicks_longres(int nslice,int nbunch,int nturns, double *turn
297298

298299
int rank=0;
299300
int size=1;
300-
int i,ii,ib,loopstart,loopend;
301+
int i,ii,ib;
301302
double ds,wi,wii;
302303
double *turnhistoryZ = turnhistory+nslice*nbunch*nturns*2;
303304
double *turnhistoryW = turnhistory+nslice*nbunch*nturns*3;
@@ -375,7 +376,8 @@ static void compute_kicks_longres(int nslice,int nbunch,int nturns, double *turn
375376
static void compute_kicks_phasor(int nslice, int nbunch, int nturns, double *turnhistory,
376377
double normfact, double *kz,double freq, double qfactor,
377378
double rshunt, double *vbeam, double circumference,
378-
double energy, double beta, double *vbeamk, double *vbunch){
379+
double energy, double beta, double *vbeamk, double *vbunch){
380+
379381
#ifndef _MSC_VER
380382
int i,ib,is;
381383
double wi;

pyat/at/acceptance/touschek.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ def _init_ma_rp(ring, refpts=None, offset=None, momap=None,
181181
zerolength_warning = ('zero-length elements removed '
182182
'from lifetime calculation')
183183
warnings.warn(AtWarning(zerolength_warning))
184+
assert len(refpts[mask]) > 2, \
185+
'After removing zero-length elements: len(refpts)<2'
184186

185187
refpts = refpts[mask]
186188
if offset is not None:

0 commit comments

Comments
 (0)