Esempio n. 1
0
print('solving time multigrid ', t_sw_multi)

# build probes for single circle
theta = np.linspace(0., 2 * np.pi, 1000)
n_sigma_probes = 1.
x_probes = n_sigma_probes * bunch.sigma_x() * np.cos(theta)
y_probes = n_sigma_probes * bunch.sigma_y() * np.sin(theta)

# get field at probes
Ex_BE, Ey_BE = pic_BE.gather(x_probes, y_probes)
Ex_singlegrid, Ey_singlegrid = pic_singlegrid.gather(x_probes, y_probes)
Ex_multigrid, Ey_multigrid = pic_multigrid.gather(x_probes, y_probes)

#plots
pl.close('all')
ms.mystyle_arial(fontsz=12)

#electric field at probes
pl.figure(1, figsize=(18, 6)).patch.set_facecolor('w')
pl.subplot(1, 3, 1)
#~ pl.plot(pic_singlegrid.xn, pic_singlegrid.yn,'.y', label = 'Singlegrid')
#~ pl.plot(pic_singlegrid_ext.xn, pic_singlegrid_ext.yn,'.m', label = 'Singlegrid telescope')
for ii in range(pic_multigrid.n_grids):
    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)
pl.plot(bunch.x, bunch.y, '.k')
pl.plot(Vx, Vy, 'k--', label='Chamber')
pl.plot(x_probes, y_probes, 'c--', label='probe')
pl.xlabel('x [m]')
        (Ey_ref - Ey_new)**2)) / np.sqrt(np.sum((Ey_ref)**2))
    erry_rel_old = np.sqrt(np.sum(
        (Ey_ref - Ey_old)**2)) / np.sqrt(np.sum((Ey_ref)**2))

    err_abs_list.append(err_abs)
    err_rel_list.append(err_rel)

    err_abs_list_old.append(err_abs_old)
    err_rel_list_old.append(err_rel_old)

    erry_rel_list_old.append(erry_rel_old)
    erry_rel_list.append(erry_rel)

na = np.array
pl.close('all')
ms.mystyle_arial(fontsz=16, dist_tick_lab=10)
pl.figure(1)
pl.plot(1000 * ob_ref.xmax_test_list, err_abs_list)
pl.xlim(0, 1000 * ob_ref.x_aper)

pl.figure(2)
pl.plot(1000 * (ob_ref.xmax_test_list), 100 * na(err_rel_list))
pl.plot(1000 * (ob_ref.xmax_test_list), 100 * na(err_rel_list_old), 'r')
pl.xlim(0, 1000 * ob_ref.x_aper)

pl.figure(3)
pl.plot(1000 * (ob_ref.x_aper - ob_ref.xmax_test_list), 100 * na(err_rel_list),
        '.-')
pl.plot(1000 * (ob_ref.x_aper - ob_ref.xmax_test_list),
        100 * na(err_rel_list_old), '.-r')
pl.grid(True)