Beispiel #1
0
 def run(self,Nz=100,iZv=None):
     if not iZv:iZv = Nz
     mp0 = np.zeros(self.bzs.shape,dtype=object)
     pattern = [self.x0,self.z0,self.fv]
     for i,bz in enumerate(self.bzs):
         mp0[i] = MS2D.Multi2D(pattern,self.ax,bz,self.keV,
                 Nx=1,dz=bz,nz=Nz,#nz=int(Nz/bz),
                 ppopt='',iZs=1,iZv=iZv,eps=self.eps,copt=0)
     self.mp0 = mp0
Beispiel #2
0
def apply_padding(p1, npad, nx, name='pad', **kwargs):
    x0, z0 = np.linspace(-npad * ax, (nx + npad) * ax,
                         ndeg), np.linspace(0, bz, nzx)
    x, z = np.meshgrid(x0, z0)
    Xv = np.stack([x.flatten(), z.flatten()]).T
    f = np.sum(np.array(
        [pg.fv(Xv, X0, int(Za)) for X0, Za in zip(p1.Xa, p1.fa)]),
               axis=0)
    f = np.reshape(f, (nzx, ndeg))
    pattern = [x0, z0, f]

    mp0 = ms.Multi2D(pattern,
                     ax,
                     bz,
                     keV=200,
                     Nx=1,
                     dz=bz,
                     nz=0,
                     ppopt='',
                     iZs=1,
                     iZv=10,
                     eps=1)
    # mp0.V_show(opt='p')
    mp0.Tz_show(iSz=slice(0, None, 1),
                Vopt='VT',
                lw=2,
                name=figpath + name + 'Tz.svg',
                **kwargs)
    mp0.propagate(201)
    # mp0.Xxz_show()#iZs=1,iXs=2)
    # mp0.Bz_show(iBs=np.arange(1,20,4),tol=1e-2,cmap='jet',lw=2,name=figpath+name+'Bz.svg',**kwargs)
    mp0.Qz_show(iZs=50,
                lw=2,
                opts='Nl',
                name=figpath + name + 'Qz.svg',
                xylims=['x', -3, 3],
                **kwargs)
    return mp0
Beispiel #3
0
                scat=[Xa[0], Xa[1], 15, 'k'],
                labs=[r'$x(\AA)$', r'$z(\AA)$'],
                name=path + 'fv.png',
                opt='ps')

else:
    x, z, f = np.load('dat/2_beam.npy')

if 'M' in opts:

    ms0 = ms.Multi2D([x[0], z.T[0], f],
                     ax1,
                     bz1,
                     keV=keV,
                     Nx=Nx,
                     nz=Nz,
                     dz=bz1 / (2 * n),
                     eps=0.01,
                     sg=-1,
                     iZs=1,
                     iZv=np.inf)
    # ms0.Bz_show(np.arange(-3,3)*n,lw=2  ,name=path+'Iz.svg',opt='ps')
    # ms0.Qz_show(slice(0,-1,100),opts='O' ,name=path+'Iq.svg',opt='ps',xylims=['x',-5,5])

    # if 'D' in opts:
    #     iM = -n*4
    #     fig,ax = ms0.Bz_show(iM)
    #     m = ms0.psi_qz[:,iM].max()/ms0.nx**2/ms0.dq
    #
    #     fj = lambda ti,j:np.sqrt(np.pi*Ai[j])*np.exp(-(np.pi*Ai[j]*K*np.sin(ti))**2)
    #     pg.fv()
Beispiel #4
0
ndeg = 2**8  # number of pixels
pptype, ax, bz, angle, Za = 'p1', 5, 10, 90, 2
pattern = np.array([[2.5, 5, Za]])
eps = 0.1
opt = 'p'

### Structure definition
p1 = pg.Wallpaper(pptype, ax, bz, angle, pattern, ndeg=ndeg)
potential = p1.get_potential_grid()

### Run multislice
ms0 = ms.Multi2D(potential,
                 ax,
                 bz,
                 keV=keV,
                 Nx=1,
                 nz=Nz,
                 dz=bz,
                 eps=eps,
                 iZs=1,
                 iZv=1)
dq = ms0.q[1] - ms0.q[0]
# Ims = ms0.psi_qz[-1,:].copy()/(ms0.nx**2*ms0.dq**2)
# print('MS Inorm:%.2f' %(Ims.sum()*ms0.dq))
ms0.Bz_show(iBs=2, tol=1e-2, cmap='jet', lw=2)

### Run near bragg
npts = 2049  #4097 #61
q0s = np.linspace(-3, 3, npts)
nbG = nb.NearBragg(pattern.T,
                   ax,
                   bz,
Beispiel #5
0
    ri,ir = np.zeros(T.shape),np.zeros(T.shape)
    for j in range(0,x.size,1): #loop over observation points
        rr[j] = trapz(TrGr(xx,x[j]),xx)
        ri[j] = trapz(TrGi(xx,x[j]),xx)
        ir[j] = trapz(TiGr(xx,x[j]),xx)
        ii[j] = trapz(TiGi(xx,x[j]),xx)
        psi_fr[j]=rr[j]-ii[j]+1J*(ri[j]+ir[j])
    # plts0  = [[mp0.x,rr,'b'  ,'rr']      ,[mp0.x,ri,'r'  ,'ri']]
    # plts0 += [[mp0.x,ii,'b--','ii']      ,[mp0.x,ir,'r--','ir']]
    # dsp.stddisp(plts0,labs=['$x$','$\Psi(x)$'],lw=2,name=path+'fresnelTG.svg',opt='p')
    return psi_fr

#multislice 1 slice
print('...ms...')
mp0 = MS2D.Multi2D(pattern,a,b,keV=200,
        Nx=1,dz=b,nz=1,ppopt='',#XQZTP
        iZs=1,iZv=1,sg=-1,eps=eps,copt=1)
psi_cv = mp0.Psi_x

#manual convolution
print('...convolution...')
angle = 10*mp0.q.max()/mp0.k0/2
psi_fr = manual_convolution(x=mp0.x,T=mp0.T[0], k0=mp0.k0,angle=angle,Dz=b)


####real space
frr = psi_fr.real/psi_fr.real[0]
fri = psi_fr.imag/psi_fr.real[0]
ftr = psi_cv.real/psi_cv.real[0]
fti = psi_cv.imag/psi_cv.real[0]
Beispiel #6
0
pattern = [[2, 3, 2], [4, 6, 4], [1.5, 2.0, 1], [2.5, 1.5, 1]]
ndeg = 2**10
keV = 200

Nx, nTDS = 32, 32
file = 'dat/TDS_Nx%d_nTDS%d.pkl' % (Nx, nTDS)
if 'r' in opts:
    mp = MS2D.Multi2D(
        pattern,
        ax,
        bz,
        keV=keV,
        Nx=Nx,
        dz=2,
        nz=10,
        eps=0.25,
        nx=ndeg,
        TDS=True,
        nTDS=nTDS,
        wobble=np.array([0.002, 0.025, 0.025, 0.025, 0.05]) *
        2,  #[0.01,1:0.025,2:0.025,4:0.05},
        ppopt='',
        opts='q',
        v=1)
    mp.save(file)
else:
    mp = pyms.load(file)

mp.Za_show()
mp.Qz_show(iZs=[-1], title='with TDS', xylims=['x', -2, 2])