import pyProbeParticle.GridUtils      as GU

from optparse import OptionParser


parser = OptionParser()
parser.add_option(      "--dfrange", action="store", type="float", help="Range of plotted frequency shift (df)", nargs=2)
parser.add_option( "--npy" , action="store_true" ,  help="load and save fields in npy instead of xsf"     , default=False)
(options, args) = parser.parse_args()

if options.npy:
    format ="npy"
else:
    format ="xsf"

dfs,lvec,nDim=GU.load_scal_field('df',format=format)
#print lvec
#print nDim

print " # ============  Plot Relaxed Scan 3D "
slices = range( 0, len(dfs) )
#print slices
extent=( 0.0, lvec[1][0], 0.0, lvec[2][1])

for ii,i in enumerate(slices):
	print " plotting ", i
	plt.figure( figsize=( 10,10 ) )
	if(options.dfrange != None):
		fmin = options.dfrange[0]
		fmax = options.dfrange[1]
		plt.imshow( dfs[i], origin='image', interpolation='bicubic', vmin=fmin, vmax=fmax,  cmap='gray', extent=extent)
Example #2
0
for i in range(len(Voltages)):
    if didv_b:
        print("Importing dIdV data for V:", namez[i])
        #print("DEBUG:WF:", WorkFunction , "Voltages[i]:", Voltages[i], "WF_decay", WF_decay  )
        name_file1 = 'didv_' + namez[
            i] + "_tip_" + tip_type + "-" + tip_orb1 + "_WF_" + str(
                WorkFunction - Voltages[i] * WF_decay
            ) + "_eta_" + str(
                eta
            )  # WorkFunction gets higher with lower (higher negative) sample bias
        name_file2 = 'didv_' + namez[
            i] + "_tip_" + tip_type + "-" + tip_orb2 + "_WF_" + str(
                WorkFunction - Voltages[i] * WF_decay) + "_eta_" + str(eta)
        #print ("DEBUG: name_file1", name_file1)
        tmp_dIdV1, lvec1, nDim1 = GU.load_scal_field(files_path + name_file1,
                                                     data_format=data_format)
        didv1 = np.array([tmp_dIdV1]) if i == 0 else np.append(
            didv1, np.array([tmp_dIdV1]), axis=0)
        #print "DEBUG: name_file2", name_file2
        tmp_dIdV2, lvec2, nDim2 = GU.load_scal_field(files_path + name_file2,
                                                     data_format=data_format)
        didv2 = np.array([tmp_dIdV2]) if i == 0 else np.append(
            didv2, np.array([tmp_dIdV2]), axis=0)
        assert np.array(lvec1).all() == np.array(
            lvec2).all(), "lvec1 != lvec2 control your input files"
        assert np.array(nDim2).all() == np.array(
            nDim2).all(), "nDim1 != nDim2 control your input files"
        print("dIdV for V:", namez[i], " imported")
        #print "DEBUG: didv1.shape", didv1.shape
    if STM_b:
        print("Importing STM data for V:", namez[i])
Example #3
0
# Amps
if opt_dict['arange'] is not None:
    Amps = np.linspace(opt_dict['arange'][0], opt_dict['arange'][1],
                       opt_dict['arange'][2])
elif opt_dict['a'] is not None:
    Amps = [opt_dict['a']]
else:
    Amps = [PPU.params['Amplitude']]

for iq, Q in enumerate(Qs):
    for ik, K in enumerate(Ks):
        dirname = "Q%1.2fK%1.2f" % (Q, K)

        print "Working in {} directory".format(dirname)

        fzs, lvec, nDim = GU.load_scal_field(dirname + '/OutFz',
                                             data_format=data_format)
        dfs = PPU.Fz2df(fzs,
                        dz=dz,
                        k0=PPU.params['kCantilever'],
                        f0=PPU.params['f0Cantilever'],
                        n=Amp / dz)
        #                print "TYT", fzs.shape

        for p in options.points:
            xmin = float(p[0].split('x')[0])
            ymin = float(p[0].split('x')[1])
            zmin = float(p[0].split('x')[2])
            xmax = float(p[1].split('x')[0])
            ymax = float(p[1].split('x')[1])
            zmax = float(p[1].split('x')[2])
            npoints = float(p[2])
Example #4
0
                        slices=list(range(0, len(denomin))))
         GU.saveWSxM_3D(dirname + "/IETS",
                        IETS,
                        extent,
                        slices=list(range(0, len(IETS))))
     del eigvalK
     del Evib
     del IETS
     del denomin
     #except:
     #    print "error: ", sys.exc_info()
     #    print "cannot load : " + ( dirname+'/eigvalKs_?.' + data_format )
 if ((opt_dict['df'] or opt_dict['save_df'] or opt_dict['WSxM']
      or opt_dict['2Dnp'])):
     try:
         fzs, lvec, nDim = GU.load_scal_field(dirname + '/OutFz',
                                              data_format=data_format)
         if not ((len(TbQs) == 1) and (TbQs[0] == 0.0)):
             print("loading tip_base forces")
             try:
                 fzt, lvect, nDimt = GU.load_scal_field(
                     './OutFzTip_base', data_format=data_format)
             except:
                 print("error: ", sys.exc_info())
                 print("cannot load : ",
                       './OutFzTip_base.' + data_format)
         for iA, Amp in enumerate(Amps):
             for iT, TbQ in enumerate(TbQs):
                 if (TbQ == 0.0):
                     AmpStr = "/Amp%2.2f" % Amp
                     print("Amp= ", AmpStr)
                     dirNameAmp = dirname + AmpStr
Example #5
0
parser.add_option( "--npy" , action="store_true" ,  help="load and save fields in npy instead of xsf"     , default=False)
(options, args) = parser.parse_args()

try:
    points = np.genfromtxt( options.p ,dtype='int')
    print("plotting in points", points)
except:
    print(options.p+" not found => exiting ...")
    sys.exit()

if options.npy:
    data_format ="npy"
else:
    data_format ="xsf"

fzs,lvec,nDim=GU.load_scal_field(options.i,data_format=data_format)
#xs = lvec[3,2]/*np.array( range(nDim[0]) )
xs = np.linspace( 0, lvec[3,2], nDim[0] )

#print nDim
print(xs)

plt.imshow( fzs[options.iz], origin='imgage', cmap='gray' )
for point in points:
    plt.plot(point[0],point[1],'o')
plt.xlim(0,nDim[2])
plt.ylim(0,nDim[1])
plt.savefig( options.i+'_zcurves_legend.png', bbox_inches='tight')

plt.figure()
curves = np.zeros((len(points)+1,len(xs)))
if opt_dict['arange'] is not None:
	Amps = np.linspace( opt_dict['arange'][0], opt_dict['arange'][1], opt_dict['arange'][2] )
elif opt_dict['a'] is not None:
	Amps = [ opt_dict['a'] ]
else:
	Amps = [ PPU.params['Amplitude'] ]



for iq,Q in enumerate( Qs ):
	for ik,K in enumerate( Ks ):
		dirname = "Q%1.2fK%1.2f" %(Q,K)

                print "Working in {} directory".format(dirname)

                fzs,lvec,nDim=GU.load_scal_field(dirname+'/OutFz',format=format)
                dfs = PPU.Fz2df( fzs, dz = dz, k0 = PPU.params['kCantilever'], f0=PPU.params['f0Cantilever'], n=Amp/dz )
#                print "TYT", fzs.shape

                for p in options.points:
                    xmin=float(p[0].split('x')[0])
                    ymin=float(p[0].split('x')[1])
                    zmin=float(p[0].split('x')[2])
                    xmax=float(p[1].split('x')[0])
                    ymax=float(p[1].split('x')[1])
                    zmax=float(p[1].split('x')[2])
                    npoints=float(p[2])
                    
                    print opt_dict['disp']
                    if opt_dict['disp'] :
                        print "Displacment {}".format(opt_dict['disp'][0])
Example #7
0
extent = (lvec[0,0],lvec[0,0]+xl,lvec[0,1],lvec[0,1]+yl)

tip_r2 = RS.mkSpaceGrid(lvec[0,0],lvec[0,0]+xl,dx,lvec[0,1],lvec[0,1]+yl,dy,lvec[0,2],lvec[0,2]+zl,dz)

# --- specification on which voltages the STM (dI/dV ...) calculations are performed - two methods - direct specification or sequence of voltages

Voltages=[-0.338, -0.09406976,  0., 2.422684]
namez=['H**O-3-2','H**O-1','H**O','LUMO++1']
#Voltages=np.arange(-1.0,+1.0+0.01,0.1) # this part is important for scans over slabs at different voltages
#namez = []
#for V in Voltages:
#    namez.append(str(round(V,1)))

# --- downloading the df data

df, lvec2, nDim2 = GU.load_scal_field( path_df+'df' ,data_format=data_format)

# --- the Main Loop - for different WorkFunction (exponential z-decay of current), sample bias Voltages & eta - lorentzian FWHM

i=0;
for V in Voltages:
    current0 = PS.dIdV( V, WorkFunction, eta, eigEn, tip_r2, Ratin, coefs, orbs=orbs, s=1.0, px=0.0, py=0.0, pz = 0.0)
    current1 = PS.dIdV( V, WorkFunction, eta, eigEn, tip_r1, Ratin, coefs, orbs=orbs, s=1.0, px=0.0, py=0.0, pz = 0.0)
    current2 = PS.dIdV( V, WorkFunction, eta, eigEn, tip_r1, Ratin, coefs, orbs=orbs, s=0.0, px=0.5, py=0.5, pz = 0.0)
    # --- plotting part here, plots all calculated signals:
    print(" plotting ")
    for k in [3,11]:
        dff = np.array(df[k,:,:]).copy()
        curr0 = np.array(current0[k,:,:]).copy()
        curr1 = np.array(current1[k,:,:]).copy()
        curr2 = np.array(current2[k,:,:]).copy()
			nx=PPdisp.shape[2]
			ny=PPdisp.shape[1]
			nz=PPdisp.shape[0]
			test=np.meshgrid(xTips,yTips,zTips)
			#print "TEST SHAPE", np.array(test).shape
			#print nx,ny,nz
			i=0
			while i<nx:
				j=0
				while j<ny:
				    k=0
				    while k<nz:
				        PPdisp[k][j][i]-=np.array([xTips[i],xTips[j],zTips[k]])+ np.array([PPU.params['r0Probe'][0],PPU.params['r0Probe'][1],-PPU.params['r0Probe'][2]])
				        k+=1
				    j+=1
				i+=1
			GU.save_vec_field( dirname+'/PPdisp', PPdisp, lvecScan, format=format )
		if opt_dict['pos']:
			GU.save_vec_field( dirname+'/PPpos', PPpos, lvecScan, format=format )
		if options.bI:
			print "Calculating current from tip to the Boltzmann particle:"
			I_in, lvec, nDim = GU.load_scal_field('I_boltzmann', format=format)
			I_out = GU.interpolate_cartesian( I_in, PPpos, cell=lvec[1:,:], result=None ) 
			del I_in;
			GU.save_scal_field( dirname+'/OutI_boltzmann', I_out, lvecScan, format=format)
		# the rest is done in plot_results.py; For df, go to plot_results.py

print " ***** ALL DONE ***** "

#plt.show()
Example #9
0
beta = 1/(kBoltz*T)   # [eV]
print("T= ", T, " [K] => beta ", beta/1000.0, "[meV] ") 

#E_cutoff = 32.0 * beta
E_cutoff = 18.0 * beta

wGauss =  2.0
Egauss = -0.01


# =============== main

if options.noProbab :
    print(" ==== calculating probabilties ====")
    # --- tip
    V_tip,   lvec, nDim = GU.load_scal_field('tip/VLJ',data_format=data_format)
    #cell   = np.array( [ lvec[1],lvec[2],lvec[3] ] ); print "nDim ", nDim, "\ncell ", cell
    #X,Y,Z  = getXYZ( nDim, cell )
    #V_tip = V_tip*0 + Egauss * getProbeDensity( (cell[0,0]/2.+cell[1,0]/2.,cell[1,1]/2,cell[2,2]/2.-3.8), X, Y, Z, wGauss ) # works for tip (the last flexible tip apex atom) in the middle of the cell
    limitE( V_tip,  E_cutoff ) 
    W_tip  = np.exp( -beta * V_tip  )
    #W_tip = W_cut(W_tip,nz=95,side='down',sm=5)
    del V_tip;
    GU.save_scal_field ( 'W_tip',  W_tip,    lvec, data_format=data_format)

    # --- sample
    V_surf,  lvec, nDim = GU.load_scal_field('sample/VLJ',data_format=data_format)
    limitE( V_surf, E_cutoff ) 
    W_surf = np.exp( -beta * V_surf )
    #W_surf=W_cut(W_surf,nz=50,side='up',sm=1)
    del V_surf; 
Example #10
0
                           data_format=data_format)
 #print "SHAPE", PPpos.shape, xTips.shape, yTips.shape, zTips.shape
 if opt_dict['disp']:
     GU.save_vec_field(dirname + '/PPdisp',
                       rPPs - rTips + PPU.params['r0Probe'][0],
                       lvecScan,
                       data_format=data_format)
 if (opt_dict['pos'] or opt_dict['stm']):
     GU.save_vec_field(dirname + '/PPpos',
                       rPPs,
                       lvecScan,
                       data_format=data_format)
     # Please do not change this procedure, especialy the lvecScan - it is important for the STM calculations!
 if options.bI:
     print("Calculating current from tip to the Boltzmann particle:")
     I_in, lvec, nDim = GU.load_scal_field('I_boltzmann',
                                           data_format=data_format)
     I_out = GU.interpolate_cartesian(I_in,
                                      rPPs,
                                      cell=lvec[1:, :],
                                      result=None)
     del I_in
     GU.save_scal_field(dirname + '/OutI_boltzmann',
                        I_out,
                        lvecScan,
                        data_format=data_format)
 if tip_base:
     print(
         "Interpolating FFel_tip_z in position of the tip_base. Beware, this is higher than the PP."
     )
     Ftip_in, lvec, nDim = GU.load_scal_field('FFel_tip',
                                              data_format=data_format)
beta = 1/(kBoltz*T)   # [eV]
print "T= ", T, " [K] => beta ", beta/1000.0, "[meV] " 

#E_cutoff = 32.0 * beta
E_cutoff = 18.0 * beta

wGauss =  2.0
Egauss = -0.01


# =============== main

if options.noProbab :
	print " ==== calculating probabilties ===="
	# --- tip
	V_tip,   lvec, nDim = GU.load_scal_field('tip/VLJ',format=format)
	#cell   = np.array( [ lvec[1],lvec[2],lvec[3] ] ); print "nDim ", nDim, "\ncell ", cell
	#X,Y,Z  = getXYZ( nDim, cell )
	#V_tip = V_tip*0 + Egauss * getProbeDensity( (cell[0,0]/2.+cell[1,0]/2.,cell[1,1]/2,cell[2,2]/2.-3.8), X, Y, Z, wGauss ) # works for tip (the last flexible tip apex atom) in the middle of the cell
	limitE( V_tip,  E_cutoff ) 
	W_tip  = np.exp( -beta * V_tip  )
	#W_tip = W_cut(W_tip,nz=95,side='down',sm=5)
	del V_tip;
	GU.save_scal_field ( 'W_tip',  W_tip,    lvec, format=format)

	# --- sample
	V_surf,  lvec, nDim = GU.load_scal_field('sample/VLJ',format=format)
	limitE( V_surf, E_cutoff ) 
	W_surf = np.exp( -beta * V_surf )
	#W_surf=W_cut(W_surf,nz=50,side='up',sm=1)
	del V_surf; 
for iq,Q in enumerate( Qs ):
	for ik,K in enumerate( Ks ):
		dirname = "Q%1.2fK%1.2f" %(Q,K)
		if opt_dict['pos']:
			try:
				PPpos, lvec, nDim = GU.load_vec_field( dirname+'/PPpos' ,format=format)
				print " plotting PPpos : "
				PPPlot.plotDistortions( dirname+"/xy"+atoms_str+cbar_str, PPpos[:,:,:,0], PPpos[:,:,:,1], slices = range( 0, len(PPpos) ), BG=PPpos[:,:,:,2], extent=extent, atoms=atoms, bonds=bonds, atomSize=atomSize, markersize=2.0, cbar=opt_dict['cbar'] )
				del PPpos
			except:
				print "error: ", sys.exc_info()
				print "cannot load : " + ( dirname+'/PPpos_?.' + format ) 
		if ( ( opt_dict['df'] or opt_dict['save_df'] or opt_dict['WSxM'] ) ):
			try :
				fzs, lvec, nDim = GU.load_scal_field( dirname+'/OutFz' , format=format)
				for iA,Amp in enumerate( Amps ):
					AmpStr = "/Amp%2.2f" %Amp
					print "Amp= ",AmpStr
					dirNameAmp = dirname+AmpStr
					if not os.path.exists( dirNameAmp ):
						os.makedirs( dirNameAmp )
					dfs = PPU.Fz2df( fzs, dz = dz, k0 = PPU.params['kCantilever'], f0=PPU.params['f0Cantilever'], n=Amp/dz )
					if opt_dict['save_df']:
						GU.save_scal_field( dirNameAmp+'/df', dfs, lvec, format=format )
					if opt_dict['df']:
						print " plotting df : "
						PPPlot.plotImages(
                                                dirNameAmp+"/df"+atoms_str+cbar_str,
                                                dfs,  slices = range( 0,
                                                len(dfs) ), zs=zTips, extent=extent, atoms=atoms, bonds=bonds, atomSize=atomSize, cbar=opt_dict['cbar'] )
Example #13
0
                  action="store",
                  type="float",
                  help="Range of plotted frequency shift (df)",
                  nargs=2)
parser.add_option("--npy",
                  action="store_true",
                  help="load and save fields in npy instead of xsf",
                  default=False)
(options, args) = parser.parse_args()

if options.npy:
    data_format = "npy"
else:
    data_format = "xsf"

dfs, lvec, nDim = GU.load_scal_field('df', data_format=data_format)
#print lvec
#print nDim

print " # ============  Plot Relaxed Scan 3D "
slices = range(0, len(dfs))
#print slices
extent = (0.0, lvec[1][0], 0.0, lvec[2][1])

for ii, i in enumerate(slices):
    print " plotting ", i
    plt.figure(figsize=(10, 10))
    if (options.dfrange != None):
        fmin = options.dfrange[0]
        fmax = options.dfrange[1]
        plt.imshow(dfs[i],
parser.add_option( "--npy" , action="store_true" ,  help="load and save fields in npy instead of xsf"     , default=False)
(options, args) = parser.parse_args()

try:
	points = np.genfromtxt( options.p )
	print "plotting in points", points
except:
	print options.p+" not found => exiting ..."
	sys.exit()

if options.npy:
    format ="npy"
else:
    format ="xsf"

fzs,lvec,nDim=GU.load_scal_field(options.i,format=format)
#xs = lvec[3,2]/*np.array( range(nDim[0]) )
xs = np.linspace( 0, lvec[3,2], nDim[0] )

#print nDim
print xs

plt.imshow( fzs[options.iz], origin='imgage', cmap='gray' )
for point in points:
	plt.plot(point[0],point[1],'o')
plt.xlim(0,nDim[2])
plt.ylim(0,nDim[1])
plt.savefig( options.i+'_zcurves_legend.png', bbox_inches='tight')

plt.figure()
curves = np.zeros((len(points)+1,len(xs)))