Skip to content

Commit 536fc78

Browse files
committed
Some cleanup in tests
1 parent 40e7b1e commit 536fc78

13 files changed

+56
-125
lines changed

tests/000_test_round_chamber.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import sys
2-
sys.path.append('..')
3-
41
import PyPIC.FiniteDifferences_ShortleyWeller_SquareGrid as PIC_FDSW
52
import PyPIC.FiniteDifferences_Staircase_SquareGrid as PIC_FD
63
import PyPIC.FFT_OpenBoundary as PIC_FFT
@@ -45,7 +42,7 @@
4542
if PIC_FPPS: picFPPS = PIC_FPPS(200,200,a=R_cham,solverType='Uniform')
4643
# build dual grid
4744
pic_main = PIC_FDSW.FiniteDifferences_ShortleyWeller_SquareGrid(chamb = chamber, Dh = Dh_main)
48-
pic_dualgrid = AddInternalGrid(pic_main, x_min_internal, x_max_internal, y_min_internal,
45+
pic_dualgrid = AddInternalGrid(pic_main, x_min_internal, x_max_internal, y_min_internal,
4946
y_max_internal, Dh_internal, N_nodes_discard)
5047

5148
# generate particles

tests/002_test_rect_chamber.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import sys, os
2-
BIN=os.path.expanduser('../')
3-
sys.path.append(BIN)
4-
51
import PyPIC.FiniteDifferences_ShortleyWeller_SquareGrid as PIC_FDSW
62
import PyPIC.FiniteDifferences_Staircase_SquareGrid as PIC_FD
73
import PyPIC.FFT_PEC_Boundary_SquareGrid as PIC_PEC_FFT

tests/003_Xmas_tree.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import sys
2-
sys.path.append('..')
3-
41
import pylab as pl
52
import numpy as np
63
from scipy import rand
@@ -29,7 +26,7 @@
2926
[1,9],
3027
[2,9],
3128
[0,11]]
32-
29+
3330
tree=np.array(tree)
3431
x_tree = tree[:,0]
3532
y_tree = tree[:,1]
@@ -43,9 +40,6 @@
4340
y_tree = np.array([-y_aper]+ list(y_tree)+[y_aper])
4441

4542

46-
47-
48-
4943
x_part = x_aper*(2.*rand(N_part_gen)-1.)
5044
y_part = y_aper*(2.*rand(N_part_gen)-1.)
5145

@@ -58,14 +52,11 @@
5852
nel_part = 0*x_part+1.
5953

6054

61-
62-
63-
6455
chamber = poly.polyg_cham_geom_object({'Vx':na([x_aper, -x_aper, -x_aper, x_aper]),
6556
'Vy':na([y_aper, y_aper, -y_aper, -y_aper]),
6657
'x_sem_ellip_insc':0.99*x_aper,
6758
'y_sem_ellip_insc':0.99*y_aper})
68-
59+
6960
picFDSW = PIC_FDSW.FiniteDifferences_ShortleyWeller_SquareGrid(chamb = chamber, Dh = Dh)
7061
picFFTPEC = PIC_PEC_FFT.FFT_PEC_Boundary_SquareGrid(x_aper = chamber.x_aper, y_aper = chamber.y_aper, Dh = Dh)
7162
picFFT = PIC_FFT.FFT_OpenBoundary_SquareGrid(x_aper = chamber.x_aper, y_aper = chamber.y_aper, Dh = Dh)
@@ -135,7 +126,7 @@
135126
pl.colorbar()
136127
pl.savefig('Xmas_efield_open_boudary.png', dpi=200)
137128

138-
if PIC_FPPS:
129+
if PIC_FPPS:
139130
x = np.arange(-chamber.x_aper,chamber.x_aper,2*chamber.x_aper/300)
140131
y = np.arange(-chamber.y_aper,chamber.y_aper,2*chamber.y_aper/300)
141132
X,Y = np.meshgrid(x,y)

tests/004_test_gaussian.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import sys
2-
sys.path.append('..')
3-
41
import PyPIC.FiniteDifferences_ShortleyWeller_SquareGrid as PIC_FDSW
52
import PyPIC.FiniteDifferences_Staircase_SquareGrid as PIC_FD
63
import PyPIC.FFT_OpenBoundary_SquareGrid as PIC_FFT

tests/005_testfftw.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import sys
2-
sys.path.append('..')
3-
41
import pylab as pl
52
import numpy as np
63
from scipy import rand
@@ -26,7 +23,7 @@
2623
[1,9],
2724
[2,9],
2825
[0,11]]
29-
26+
3027
tree=np.array(tree)
3128
x_tree = tree[:,0]
3229
y_tree = tree[:,1]
@@ -40,9 +37,6 @@
4037
y_tree = np.array([-y_aper]+ list(y_tree)+[y_aper])
4138

4239

43-
44-
45-
4640
x_part = x_aper*(2.*rand(N_part_gen)-1.)
4741
y_part = y_aper*(2.*rand(N_part_gen)-1.)
4842

@@ -55,15 +49,10 @@
5549
nel_part = 0*x_part+1.
5650

5751

58-
59-
60-
6152
chamber = poly.polyg_cham_geom_object({'Vx':na([x_aper, -x_aper, -x_aper, x_aper]),
6253
'Vy':na([y_aper, y_aper, -y_aper, -y_aper]),
6354
'x_sem_ellip_insc':0.99*x_aper,
6455
'y_sem_ellip_insc':0.99*y_aper})
65-
66-
6756

6857
picFFT = PIC_FFT.FFT_OpenBoundary_SquareGrid(x_aper = chamber.x_aper, y_aper = chamber.y_aper, Dh = Dh)
6958

@@ -79,7 +68,7 @@
7968
for _ in range(N_rep):
8069
transf = np.fft.fft2(data)
8170
itransf = np.real(np.fft.ifft2(transf*data))
82-
71+
8372
t_stop_npfft = time.mktime(time.localtime())
8473
t_npfft = t_stop_npfft-t_start_npfft
8574
print('t_npfft', t_npfft)

tests/006_time_solve.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import sys
2-
sys.path.append('..')
3-
41
import pylab as pl
52
import numpy as np
63
from scipy import rand
@@ -25,7 +22,7 @@
2522
[1,9],
2623
[2,9],
2724
[0,11]]
28-
25+
2926
tree=np.array(tree)
3027
x_tree = tree[:,0]
3128
y_tree = tree[:,1]
@@ -39,9 +36,6 @@
3936
y_tree = np.array([-y_aper]+ list(y_tree)+[y_aper])
4037

4138

42-
43-
44-
4539
x_part = x_aper*(2.*rand(N_part_gen)-1.)
4640
y_part = y_aper*(2.*rand(N_part_gen)-1.)
4741

@@ -54,14 +48,11 @@
5448
nel_part = 0*x_part+1.
5549

5650

57-
58-
59-
6051
chamber = poly.polyg_cham_geom_object({'Vx':na([x_aper, -x_aper, -x_aper, x_aper]),
6152
'Vy':na([y_aper, y_aper, -y_aper, -y_aper]),
6253
'x_sem_ellip_insc':0.99*x_aper,
6354
'y_sem_ellip_insc':0.99*y_aper})
64-
55+
6556
picFDSW = PIC_FDSW.FiniteDifferences_ShortleyWeller_SquareGrid(chamb = chamber, Dh = Dh)
6657
picFFTPEC = PIC_PEC_FFT.FFT_PEC_Boundary_SquareGrid(x_aper = chamber.x_aper, y_aper = chamber.y_aper, Dh = Dh, fftlib='pyfftw')
6758
picFFT = PIC_FFT.FFT_OpenBoundary_SquareGrid(x_aper = chamber.x_aper, y_aper = chamber.y_aper, Dh = Dh, fftlib='pyfftw')

tests/007_test_separately.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import sys
2-
sys.path.append('..')
3-
41
import PyPIC.FiniteDifferences_ShortleyWeller_SquareGrid as PIC_FDSW
52
import PyPIC.FiniteDifferences_Staircase_SquareGrid as PIC_FD
63
import PyPIC.FFT_OpenBoundary_SquareGrid as PIC_FFT

tests/008a_check_interpolation_near_borders.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import sys
2-
sys.path.append('..')
3-
41
import numpy as np
52
from PyPIC.geom_impact_ellip import ellip_cham_geom_object
63

@@ -50,12 +47,11 @@
5047
pic.solve(rho = rho_mat)
5148
except ValueError as err:
5249
print('Got ValueError:', err)
53-
54-
50+
5551
Ex_list = []
5652
Ey_list = []
57-
for xmax_test in xmax_test_list:
58-
53+
for xmax_test in xmax_test_list:
54+
5955
sc_test = xmax_test/x_aper
6056
x_test = sc_test*x_aper*np.cos(thp)
6157
y_test = sc_test*y_aper*np.sin(thp)
@@ -64,7 +60,7 @@
6460

6561
Ex_list.append(Ex)
6662
Ey_list.append(Ey)
67-
63+
6864
Ex_list = np.array(Ex_list)
6965
Ey_list = np.array(Ey_list)
7066

tests/008b_check_interpolation_near_borders_plots.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import sys
2-
sys.path.append('..')
3-
41
import numpy as np
52
import pylab as pl
63

@@ -28,37 +25,37 @@
2825
erry_rel_list_old = []
2926
erry_rel_list = []
3027

31-
for ii in range(N_points):
28+
for ii in range(N_points):
3229

3330
Ex_ref = ob_ref.Ex[ii,:]
3431
Ey_ref = ob_ref.Ey[ii,:]
35-
32+
3633
Ex_new = ob_new.Ex[ii,:]
3734
Ey_new = ob_new.Ey[ii,:]
38-
35+
3936
Ex_old= ob_old.Ex[ii,:]
4037
Ey_old= ob_old.Ey[ii,:]
4138

4239
err_abs = np.sqrt(np.sum((Ex_ref-Ex_new)**2+(Ey_ref-Ey_new)**2))
4340
err_rel = err_abs/np.sqrt(np.sum((Ex_ref)**2+(Ey_ref)**2))
44-
41+
4542
err_abs_old = np.sqrt(np.sum((Ex_ref-Ex_old)**2+(Ey_ref-Ey_old)**2))
4643
err_rel_old = err_abs_old/np.sqrt(np.sum((Ex_ref)**2+(Ey_ref)**2))
47-
44+
4845
erry_rel = np.sqrt(np.sum((Ey_ref-Ey_new)**2))/np.sqrt(np.sum((Ey_ref)**2))
4946
erry_rel_old = np.sqrt(np.sum((Ey_ref-Ey_old)**2))/np.sqrt(np.sum((Ey_ref)**2))
50-
47+
5148
err_abs_list.append(err_abs)
5249
err_rel_list.append(err_rel)
53-
50+
5451
err_abs_list_old.append(err_abs_old)
5552
err_rel_list_old.append(err_rel_old)
56-
53+
5754
erry_rel_list_old.append(erry_rel_old)
5855
erry_rel_list.append(erry_rel)
59-
56+
6057
na = np.array
61-
pl.close('all')
58+
pl.close('all')
6259
ms.mystyle_arial(fontsz=16, dist_tick_lab=10)
6360
pl.figure(1)
6461
pl.plot(1000*ob_ref.xmax_test_list, err_abs_list)
@@ -181,4 +178,4 @@
181178
pl.savefig(fname+'.png', dpi=200)
182179

183180
pl.show()
184-
181+

tests/009_test_round_chamber_for_new_interp_devel.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import sys
2-
sys.path.append('..')
3-
41
import PyPIC.FiniteDifferences_ShortleyWeller_SquareGrid as PIC_FDSW
52
import PyPIC.FFT_OpenBoundary_SquareGrid as PIC_FFT
63
import PyPIC.geom_impact_ellip as ell

0 commit comments

Comments
 (0)