Skip to content

Commit ee76b87

Browse files
committed
fixed bug with newest numba version
1 parent 7b4466d commit ee76b87

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

demos/ebeam/csr_ex.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@
108108
plt.grid(True)
109109
plt.show()
110110

111+
start = time.time()
111112
show_e_beam(p_array)
113+
print(time.time() - start, " sec")
112114
plt.show()
113115
show_e_beam(p_array, inverse_tau=True, headtail=False)
114116
plt.show()

ocelot/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
general ocelot description
33
"""
44

5-
__version__ = '19.06.1'
5+
__version__ = '19.06.2'
66

77

88
__all__ = ['Twiss', 'twiss', "Beam", "Particle", "get_current", "get_envelope", # beam

ocelot/cpbd/beam.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ def sortrows(x, col):
959959
return x[:, x[col].argsort()]
960960

961961

962-
def convmode(A, B, mode):
962+
def convmode_py(A, B, mode):
963963

964964
if mode == 2:
965965
C = np.convolve(A, B)
@@ -970,9 +970,19 @@ def convmode(A, B, mode):
970970
C1 = np.convolve(A, B)
971971
C[:n] = C1[i:n+i]
972972
return C
973+
convmode = convmode_py if not nb_flag else nb.jit(nopython=True)(convmode_py)
973974

975+
def s2cur_auxil_py(A, xiA, C, N, I):
976+
for k in range(len(A)):
977+
i = I[k]
978+
if i > N-1:
979+
i = N-1
980+
C[i] = C[i] + xiA[k]
981+
C[i+1] = C[i+1] + (1 - xiA[k])
982+
983+
s2cur_auxil = s2cur_auxil_py if not nb_flag else nb.jit(nopython=True)(s2cur_auxil_py)
974984

975-
def s_to_cur_py(A, sigma, q0, v):
985+
def s_to_cur(A, sigma, q0, v):
976986
"""
977987
Function to calculate beam current
978988
@@ -993,26 +1003,21 @@ def s_to_cur_py(A, sigma, q0, v):
9931003
C = np.zeros(N+1)
9941004

9951005
B[:, 0] = np.arange(0, (N+0.5)*s, s) + a
996-
N = N+1 #np.shape(B)[0]
1006+
N = N + 1 #np.shape(B)[0]
9971007
cA = (A - a)/s
9981008
I = np.int_(np.floor(cA))
9991009
xiA = 1 + I - cA
1000-
for k in range(len(A)):
1001-
i = I[k]
1002-
if i > N-1:
1003-
i = N-1
1004-
C[i] = C[i] + xiA[k]
1005-
C[i+1] = C[i+1] + (1 - xiA[k])
1010+
s2cur_auxil(A, xiA, C, N, I)
10061011

10071012
K = np.floor(Nsigma*sigma/s + 0.5)
10081013
G = np.exp(-0.5*(np.arange(-K, K+1)*s/sigma)**2)
10091014
G = G/np.sum(G)
10101015
B[:, 1] = convmode(C, G, 1)
1011-
koef = q0*v/(s*np.sum(B[:, 1]))
1012-
B[:, 1] = koef*B[:, 1]
1016+
koef = q0 * v / (s*np.sum(B[:, 1]))
1017+
B[:, 1] = koef * B[:, 1]
10131018
return B
10141019

1015-
s_to_cur = s_to_cur_py if not nb_flag else nb.jit(s_to_cur_py)
1020+
#s_to_cur = s_to_cur_py if not nb_flag else nb.jit(s_to_cur_py)
10161021

10171022
def slice_analysis_py(z, x, xs, M, to_sort):
10181023
"""
@@ -1028,7 +1033,7 @@ def slice_analysis_py(z, x, xs, M, to_sort):
10281033
z = z[indx]
10291034
x = x[indx]
10301035
xs = xs[indx]
1031-
P=[]
1036+
10321037
N=len(x)
10331038
mx = np.zeros(N)
10341039
mxs= np.zeros(N)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name='ocelot',
13-
version='19.06.1',
13+
version='19.06.2',
1414
description='Accelerator, radiation and x-ray optics simulation framework',
1515
author='ocelot-collab',
1616
author_email='tomin.sergey@gmail.com',

0 commit comments

Comments
 (0)