def setup_pic(fname, magnify=2., N_nodes_discard=10, symmetric_slice_2D=True):

    ob = mfm.myloadmat_to_obj(fname)
    Dh_magnify = (ob.xg[1] - ob.xg[0]) / magnify
    x_magnify = -ob.xg[N_nodes_discard]
    y_magnify = -ob.yg[N_nodes_discard]

    if symmetric_slice_2D:
        pic_rho = symmetrize(ob.rho[0, :, :])
        pic_phi = symmetrize(ob.phi[0, :, :])
    else:
        pic_rho = ob.rho[0, :, :].copy()
        pic_phi = ob.phi[0, :, :].copy()
    xg_out = ob.xg.copy()
    yg_out = ob.yg.copy()
    zg_out = ob.zg.copy()
    del ob

    chamb = poly.polyg_cham_geom_object({
        'Vx':
        np.array([xg_out[-1], xg_out[0], xg_out[0], xg_out[-1]]),
        'Vy':
        np.array([yg_out[-1], yg_out[-1], yg_out[0], yg_out[0]]),
        'x_sem_ellip_insc':
        1e-3,
        'y_sem_ellip_insc':
        1e-3
    })

    pic = PyPICSC.PyPIC_Scatter_Gather(xg=xg_out, yg=yg_out)
    pic.phi = pic_phi
    #pic.efx = ob.Ex[0, :, :]
    #pic.efy = ob.Ey[0, :, :]
    pic.rho = pic_rho
    pic.chamb = chamb

    #Ex_picint, _ = pic.gather(x_tint, y_tint)

    # Internal pic
    picdg = AddInternalGrid(pic,
                            x_min_internal=-x_magnify,
                            x_max_internal=x_magnify,
                            y_min_internal=-y_magnify,
                            y_max_internal=y_magnify,
                            Dh_internal=Dh_magnify,
                            N_nodes_discard=N_nodes_discard)
    picinside = picdg.pic_internal

    picinside.rho = np.reshape(pic.gather_rho(picinside.xn, picinside.yn),
                               (picinside.Nxg, picinside.Nyg))
    picinside.solve(flag_verbose=True, pic_external=pic)

    #rho_insideint = picinside.gather_rho(x_tint, y_tint)
    #Ex_inside, _ = picinside.gather(x_tint, y_tint)
    #phi_inside = picinside.gather_phi(x_tint, y_tint)

    return pic, picinside, zg_out
예제 #2
0
def setup_pic(fname, magnify=2., N_nodes_discard=10, symmetric_slice_2D=True):

    grid = kfm.h5_to_obj(fname, group='grid')
    ob0 = kfm.h5_to_obj(fname, group='slices/slice0')
    Dh_magnify = (grid.xg[1] - grid.xg[0]) / magnify
    x_magnify = -grid.xg[N_nodes_discard]
    y_magnify = -grid.yg[N_nodes_discard]

    if symmetric_slice_2D:
        pic_rho = symmetrize(ob0.rho)
        pic_phi = symmetrize(ob0.phi)
    else:
        pic_rho = ob0.rho.copy()
        pic_phi = ob0.phi.copy()
    xg_out = grid.xg.copy()
    yg_out = grid.yg.copy()
    zg_out = grid.zg.copy()
    del grid
    del ob0

    chamb = PyPICpoly.polyg_cham_geom_object({
        'Vx':
        np.array([xg_out[-1], xg_out[0], xg_out[0], xg_out[-1]]),
        'Vy':
        np.array([yg_out[-1], yg_out[-1], yg_out[0], yg_out[0]]),
        'x_sem_ellip_insc':
        1e-3,
        'y_sem_ellip_insc':
        1e-3
    })

    pic = PyPICSC.PyPIC_Scatter_Gather(xg=xg_out, yg=yg_out)
    pic.phi = pic_phi
    pic.rho = pic_rho
    pic.chamb = chamb

    # Internal pic
    picdg = PyPICMG.AddInternalGrid(pic,
                                    x_min_internal=-x_magnify,
                                    x_max_internal=x_magnify,
                                    y_min_internal=-y_magnify,
                                    y_max_internal=y_magnify,
                                    Dh_internal=Dh_magnify,
                                    N_nodes_discard=N_nodes_discard)
    picinside = picdg.pic_internal

    picinside.rho = np.reshape(pic.gather_rho(picinside.xn, picinside.yn),
                               (picinside.Nxg, picinside.Nyg))
    picinside.solve(flag_verbose=True, pic_external=pic)

    return pic, picinside, zg_out
예제 #3
0
x_on_tree = np.interp(y_part, y_tree, x_tree)

mask_keep = np.logical_and(
    np.abs(x_part) < x_on_tree,
    np.abs(x_part) > x_on_tree * 0.8)
x_part = x_part[mask_keep]
y_part = y_part[mask_keep]

nel_part = 0 * x_part + 1.

chamber = poly.polyg_cham_geom_object({
    'Vx':
    na([x_aper, -x_aper, -x_aper, x_aper]),
    'Vy':
    na([y_aper, y_aper, -y_aper, -y_aper]),
    'x_sem_ellip_insc':
    0.99 * x_aper,
    'y_sem_ellip_insc':
    0.99 * y_aper
})

picFDSW = PIC_FDSW.FiniteDifferences_ShortleyWeller_SquareGrid(chamb=chamber,
                                                               Dh=Dh)
picFFTPEC = PIC_PEC_FFT.FFT_PEC_Boundary_SquareGrid(x_aper=chamber.x_aper,
                                                    y_aper=chamber.y_aper,
                                                    Dh=Dh,
                                                    fftlib='pyfftw')
picFFT = PIC_FFT.FFT_OpenBoundary_SquareGrid(x_aper=chamber.x_aper,
                                             y_aper=chamber.y_aper,
                                             Dh=Dh,
                                             fftlib='pyfftw')
예제 #4
0
x_tint = np.linspace(-4.5e-4, 4.5e-4, 1000)
y_tint = 0.*x_tint
z_tint = 0.*x_tint + z_obs

phi_tint = 0.*x_tint
Ex_tint = 0.*x_tint

for ii, (xx, yy, zz) in enumerate(zip(x_tint, y_tint, z_tint)):
    phi_tint[ii] = tinterp.val(xx, yy, zz)
    Ex_tint[ii] = -tinterp.ddx(xx, yy, zz)

# 2D PIC
assert((ob.xg[1] - ob.xg[0]) == (ob.yg[1] - ob.yg[0]))
na = np.array
chamb = poly.polyg_cham_geom_object({'Vx':na([ob.xg[-1], ob.xg[0], ob.xg[0], ob.xg[-1]]),
                                       'Vy':na([ob.yg[-1], ob.yg[-1], ob.yg[0],ob.yg[0]]),
                                       'x_sem_ellip_insc':1e-3,
                                       'y_sem_ellip_insc':1e-3})

pic = PyPICSC.PyPIC_Scatter_Gather(xg=ob.xg, yg=ob.yg)
pic.phi = ob.phi[i_slice, :, :]
pic.efx = ob.Ex[i_slice, :, :]
pic.efy = ob.Ey[i_slice, :, :]
pic.rho = ob.rho[i_slice, :, :]
pic.chamb = chamb

Ex_picint, _ = pic.gather(x_tint, y_tint)


# Internal pic
picdg = AddInternalGrid(pic, 
        x_min_internal=-x_magnify,