Skip to content

Commit 960de9c

Browse files
committed
Python 3 version of PyPIC v2.4.4
1 parent 59c369f commit 960de9c

Some content is hidden

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

48 files changed

+268
-270
lines changed

000_test_round_chamber.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
try:
88
from CyFPPS import PyFPPS as PIC_FPPS
99
except ImportError:
10-
print "Not possible to import PyFPPS, replaced with FFT_Open"
10+
print("Not possible to import PyFPPS, replaced with FFT_Open")
1111
PIC_FPPS = None
1212
from PyPIC.MultiGrid import AddInternalGrid
1313

@@ -83,7 +83,7 @@
8383
Ex_FFTSq, Ey_FFTSq = picFFTSq.gather(x_probes, y_probes)
8484
if PIC_FPPS: Ex_FPPS,Ey_FPPS = picFPPS.gather(x_probes,y_probes)
8585
Ex_dualgrid, Ey_dualgrid = pic_dualgrid.gather(x_probes, y_probes)
86-
E_r_th = map(lambda x: -np.sum(x_part**2+y_part**2<x**2)*qe/eps0/(2*np.pi*x), x_probes)
86+
E_r_th = [-np.sum(x_part**2+y_part**2<x**2)*qe/eps0/(2*np.pi*x) for x in x_probes]
8787

8888

8989
import pylab as pl

003_Xmas_tree.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
try:
1212
from CyFPPS import PyFPPS as PIC_FPPS
1313
except ImportError:
14-
print "Not possible to import PyFPPS, replaced with FFT_Open"
14+
print("Not possible to import PyFPPS, replaced with FFT_Open")
1515
PIC_FPPS = None
1616

1717
na = np.array
@@ -142,7 +142,7 @@
142142
E = np.zeros_like(X)
143143
for i in range(np.shape(X)[0]):
144144
Ex_FPPS,Ey_FPPS = picFPPS.gather(X[i,:],Y[i,:])
145-
print(np.shape(Ex_FPPS))
145+
print((np.shape(Ex_FPPS)))
146146
E[i,:] = Ex_FPPS**2+Ey_FPPS**2
147147
pl.figure(303)
148148
pl.pcolor(X,Y,E)

004_test_gaussian.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#~ Ex_FDSW, Ey_FDSW = picFDSW.gather(x_probes, y_probes)
4848
Ex_FFT, Ey_FFT = picFFT.gather(x_probes, y_probes)
4949

50-
E_r_th = map(lambda x: np.sum(rho_mat[:][XX[:]**2+YY[:]**2<x**2])/eps0/(2*np.pi*x)*Dh*Dh, x_probes)
50+
E_r_th = [np.sum(rho_mat[:][XX[:]**2+YY[:]**2<x**2])/eps0/(2*np.pi*x)*Dh*Dh for x in x_probes]
5151

5252

5353
import pylab as pl

005_testfftw.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@
7676

7777

7878
t_start_npfft = time.mktime(time.localtime())
79-
for _ in xrange(N_rep):
79+
for _ in range(N_rep):
8080
transf = np.fft.fft2(data)
8181
itransf = np.real(np.fft.ifft2(transf*data))
8282

8383
t_stop_npfft = time.mktime(time.localtime())
8484
t_npfft = t_stop_npfft-t_start_npfft
85-
print 't_npfft', t_npfft
85+
print('t_npfft', t_npfft)
8686

8787

8888

@@ -93,11 +93,11 @@
9393
ifftobj = pyfftw.builders.ifft2(temptransf)
9494

9595
t_start_npfftw = time.mktime(time.localtime())
96-
for _ in xrange(N_rep):
96+
for _ in range(N_rep):
9797
transfw = fftobj(data)
9898
itransfw = ifftobj(transfw)
9999
t_stop_npfftw = time.mktime(time.localtime())
100100
t_npfftw = t_stop_npfftw-t_start_npfftw
101-
print 't_npfftw', t_npfftw
101+
print('t_npfftw', t_npfftw)
102102

103103

006_time_solve.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,26 @@
7474

7575
import time
7676
t_start_sw = time.mktime(time.localtime())
77-
for _ in xrange(N_rep):
77+
for _ in range(N_rep):
7878
picFDSW.solve()
7979
t_stop_sw = time.mktime(time.localtime())
8080
t_sw = t_stop_sw-t_start_sw
81-
print 't_sw', t_sw
81+
print('t_sw', t_sw)
8282

8383

8484
t_start_fftpec = time.mktime(time.localtime())
85-
for _ in xrange(N_rep):
85+
for _ in range(N_rep):
8686
picFFTPEC.solve()
8787
t_stop_fftpec = time.mktime(time.localtime())
8888
t_fftpec = t_stop_fftpec-t_start_fftpec
89-
print 't_fftpec', t_fftpec
89+
print('t_fftpec', t_fftpec)
9090

9191

9292
t_start_fftopen = time.mktime(time.localtime())
93-
for _ in xrange(N_rep):
93+
for _ in range(N_rep):
9494
picFFT.solve()
9595
t_stop_fftopen = time.mktime(time.localtime())
9696
t_fftopen = t_stop_fftopen-t_start_fftopen
97-
print 't_fftopen', t_fftopen
97+
print('t_fftopen', t_fftopen)
9898

9999

007_test_separately.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#pic gather
4646
Ex_FFT, Ey_FFT = picFFT.gather(x_probes, y_probes)
4747

48-
E_r_th = map(lambda x: -np.sum(x_part**2+y_part**2<x**2)*qe/eps0/(2*np.pi*x), x_probes)
48+
E_r_th = [-np.sum(x_part**2+y_part**2<x**2)*qe/eps0/(2*np.pi*x) for x in x_probes]
4949

5050

5151
import pylab as pl
@@ -79,8 +79,8 @@
7979
pl.figure(100)
8080
pl.semilogy(np.abs(fftphi.flatten()))
8181

82-
print 'type(fftphi[0,0])', type(fftphi[0,0])
83-
print 'type(self.fgreentr[0,0])',type(self.fgreentr[0,0])
82+
print('type(fftphi[0,0])', type(fftphi[0,0]))
83+
print('type(self.fgreentr[0,0])',type(self.fgreentr[0,0]))
8484
tmpphi = np.fft.ifft2(fftphi)
8585
pl.figure(101)
8686
pl.semilogy(np.abs(tmpphi.flatten()))

008a_check_interpolation_near_borders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
try:
5050
pic.solve(rho = rho_mat)
5151
except ValueError as err:
52-
print 'Got ValueError:', err
52+
print('Got ValueError:', err)
5353

5454

5555
Ex_list = []

008b_check_interpolation_near_borders_plots.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
erry_rel_list_old = []
2929
erry_rel_list = []
3030

31-
for ii in xrange(N_points):
31+
for ii in range(N_points):
3232

3333
Ex_ref = ob_ref.Ex[ii,:]
3434
Ey_ref = ob_ref.Ey[ii,:]

009_test_round_chamber_for_new_interp_devel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#pic gather
4747
Ex_FDSW, Ey_FDSW = picFDSW.gather(x_probes, y_probes)
4848

49-
E_r_th = map(lambda x: -np.sum(x_part**2+y_part**2<x**2)*qe/eps0/(2*np.pi*x), x_probes)
49+
E_r_th = [-np.sum(x_part**2+y_part**2<x**2)*qe/eps0/(2*np.pi*x) for x in x_probes]
5050

5151

5252
import pylab as pl

011_LHC_multigrid_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,22 @@
8080
#pic solve timing
8181
import time
8282
N_rep_test_single = 1000
83-
print 'Solving PIC single %d times'%N_rep_test_single
83+
print('Solving PIC single %d times'%N_rep_test_single)
8484
t_start = time.mktime(time.localtime())
85-
for _ in xrange(N_rep_test_single):
85+
for _ in range(N_rep_test_single):
8686
pic_singlegrid.solve()
8787
t_stop = time.mktime(time.localtime())
8888
t_sw_single = (t_stop-t_start)/N_rep_test_single
89-
print 'solving time singlegrid ', t_sw_single
89+
print('solving time singlegrid ', t_sw_single)
9090

9191
N_rep_test_multi = 10000
92-
print 'Solving PIC multi %d times'%N_rep_test_multi
92+
print('Solving PIC multi %d times'%N_rep_test_multi)
9393
t_start = time.mktime(time.localtime())
94-
for _ in xrange(N_rep_test_multi):
94+
for _ in range(N_rep_test_multi):
9595
pic_multigrid.solve()
9696
t_stop = time.mktime(time.localtime())
9797
t_sw_multi = (t_stop-t_start)/N_rep_test_multi
98-
print 'solving time multigrid ', t_sw_multi
98+
print('solving time multigrid ', t_sw_multi)
9999

100100

101101
# build probes for single circle
@@ -119,7 +119,7 @@
119119
pl.subplot(1,3,1)
120120
#~ pl.plot(pic_singlegrid.xn, pic_singlegrid.yn,'.y', label = 'Singlegrid')
121121
#~ pl.plot(pic_singlegrid_ext.xn, pic_singlegrid_ext.yn,'.m', label = 'Singlegrid telescope')
122-
for ii in xrange(pic_multigrid.n_grids):
122+
for ii in range(pic_multigrid.n_grids):
123123
pl.plot(pic_multigrid.pic_list[ii].pic_internal.chamb.Vx, pic_multigrid.pic_list[ii].pic_internal.chamb.Vy, '.-', label = 'Internal grid %d'%ii)
124124
pl.plot(bunch.x, bunch.y, '.k')
125125
pl.plot(Vx, Vy, 'k--', label = 'Chamber')

0 commit comments

Comments
 (0)