print('--- Get Forces ---')
Fx, Fy, Fz = getForces( V, rho, sampleSize, dims, dd, X, Y, Z)
print('Fx.max(), Fx.min() = ', Fx.max(), Fx.min())


PP.params['gridA'] = lvec[ 1,:  ].copy()
PP.params['gridB'] = lvec[ 2,:  ].copy()
PP.params['gridC'] = lvec[ 3,:  ].copy()
PP.params['gridN'] = nDim.copy()

print("--- Compute Lennard-Jones Force-filed ---")
atoms     = basUtils.loadAtoms('input.xyz')
if os.path.isfile( 'atomtypes.ini' ):
    print(">> LOADING LOCAL atomtypes.ini")  
    FFparams=PPU.loadSpecies( 'atomtypes.ini' ) 
else:
    FFparams = PPU.loadSpecies( cpp_utils.PACKAGE_PATH+'/defaults/atomtypes.ini' )

iZs,Rs,Qs = PP.parseAtoms(atoms, autogeom = False, PBC = True,
                          FFparams=FFparams)
FFLJ      = PP.computeLJ( Rs, iZs, FFLJ=None, FFparams=FFparams)

print("--- Saving ---")

GU.saveXSF('FFel_x.xsf', Fx, lvec, head)
GU.saveXSF('FFel_y.xsf' , Fy, lvec, head)
GU.saveXSF('FFel_z.xsf' , Fz, lvec, head)

GU.saveVecFieldXsf( 'FFLJ', FFLJ, lvec, head)

Exemple #2
0
xTips, yTips, zTips, lvecScan = PP.prepareScanGrids()

#Ks   = [ 0.25, 0.5, 1.0 ]
#Qs   = [ -0.2, 0.0, +0.2 ]
#Amps = [ 2.0 ]

for iq, Q in enumerate(Qs):
    FF = FFLJ + FFel * Q
    PP.setFF_Pointer(FF)
    for ik, K in enumerate(Ks):
        dirname = "Q%1.2fK%1.2f" % (Q, K)
        os.makedirs(dirname)
        PP.setTip(kSpring=np.array((K, K, 0.0)) / -PP.eVA_Nm)
        #GU.saveVecFieldXsf( 'FFtot', FF, lvec, head )
        fzs = PP.relaxedScan3D(xTips, yTips, zTips)
        GU.saveXSF(dirname + '/OutFz.xsf', fzs, lvecScan, GU.XSF_HEAD_DEFAULT)
        for iA, Amp in enumerate(Amps):
            AmpStr = "/Amp%2.2f" % Amp
            print("Amp= ", AmpStr)
            os.makedirs(dirname + AmpStr)
            dz = PP.params['scanStep'][2]
            dfs = PP.Fz2df(fzs,
                           dz=dz,
                           k0=PP.params['kCantilever'],
                           f0=PP.params['f0Cantilever'],
                           n=Amp / dz)
            extent = (xTips[0], xTips[-1], yTips[0], yTips[-1])
            PPPlot.plotImages(dirname + AmpStr + "/df",
                              dfs,
                              slices=list(range(0, len(dfs))),
                              extent=extent)
#Ks   = [ 0.25, 0.5, 1.0 ]
#Qs   = [ -0.2, 0.0, +0.2 ]
#Amps = [ 2.0 ]



for iq,Q in enumerate( Qs ):
	FF = FFLJ + FFel * Q
	PP.setFF_Pointer( FF )
	for ik,K in enumerate( Ks ):
		dirname = "Q%1.2fK%1.2f" %(Q,K)
		os.makedirs( dirname )
		PP.setTip( kSpring = np.array((K,K,0.0))/-PP.eVA_Nm )
		#GU.saveVecFieldXsf( 'FFtot', FF, lvec, head )
		fzs = PP.relaxedScan3D( xTips, yTips, zTips )
		GU.saveXSF( dirname+'/OutFz.xsf', fzs, lvecScan, GU.XSF_HEAD_DEFAULT )
		for iA,Amp in enumerate( Amps ):
			AmpStr = "/Amp%2.2f" %Amp
			print "Amp= ",AmpStr
			os.makedirs( dirname+AmpStr )
			dz  = PP.params['scanStep'][2]
			dfs = PP.Fz2df( fzs, dz = dz, k0 = PP.params['kCantilever'], f0=PP.params['f0Cantilever'], n=Amp/dz )
			extent=( xTips[0], xTips[-1], yTips[0], yTips[-1] )
			PPPlot.plotImages( dirname+AmpStr+"/df", dfs, slices = range( 0, len(dfs) ), extent=extent )

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

#plt.show()


print '--- Preprocessing ---'

sampleSize = getSampleDimensions(lvec)
dims = (nDim[2], nDim[1], nDim[0])

xsize, dx = getSize('x', dims, sampleSize)
ysize, dy = getSize('y', dims, sampleSize)
zsize, dz = getSize('z', dims, sampleSize)

dd = (dx, dy, dz)

X, Y, Z = getMGrid(dims, dd)

print '--- Get Probe Density ---'

rho = getProbeDensity(sampleSize, X, Y, Z, sigma, dd)

print '--- Get Forces ---'

Fx, Fy, Fz = getForces( V, rho, sampleSize, dims, dd, X, Y, Z)
print 'Fx.max(), Fx.min() = ', Fx.max(), Fx.min()

print "--- Saving ---"

GU.saveXSF('FFel_x.xsf', Fx, lvec, head)
GU.saveXSF('FFel_y.xsf' , Fy, lvec, head)
GU.saveXSF('FFel_z.xsf' , Fz, lvec, head)
    
#show()

# mask atoms which should not to be included into the expansion
natoms = len(atom_types)
atom_mask = np.array([True] * natoms)
atom_mask[2:] = False

# set basiset for each atom
atom_basis = MP.make_bas_list([len(atom_pos)], basis=[['s', 'px', 'py', 'pz']])

#print "atom_pos:   ", atom_pos
#print "atom_Rmin:  ", atom_Rmin
#print "atom_Rmax:  ", atom_Rmax
#print "atom_mask:  ", atom_mask
#print "atom_basis: ", atom_basis

# ============== do the fitting

coefs, basis_assignment = MP.fitMultipolesPotential(atom_pos,
                                                    atom_basis,
                                                    atom_Rmin,
                                                    atom_Rmax,
                                                    atom_mask=atom_mask,
                                                    show_where=True)

# ============== output results

for i in range(len(coefs)):
    print basis_assignment[i], coefs[i]

print "saving LOCPOT_debug.xsf "
GU.saveXSF(WORK_DIR + 'LOCPOT_debug.xsf', V, lvec, head)
R_type               = spacies[:,0]
atom_Rmin, atom_Rmax = MP.make_Ratoms( atom_types, R_type ) 

# mask atoms which should not to be included into the expansion 
natoms          = len( atom_types )
atom_mask       = np.array( [ True ] * natoms ); 
atom_mask[ 2: ] = False

# set basiset for each atom 
atom_basis = MP.make_bas_list( [ len( atom_pos ) ],  basis=[ ['s','px','py','pz'] ] )

#print "atom_pos:   ", atom_pos
#print "atom_Rmin:  ", atom_Rmin
#print "atom_Rmax:  ", atom_Rmax
#print "atom_mask:  ", atom_mask
#print "atom_basis: ", atom_basis

# ============== do the fitting

coefs, basis_assignment   =   MP.fitMultipolesPotential( atom_pos, atom_basis, atom_Rmin, atom_Rmax, atom_mask=atom_mask, show_where=True );

# ============== output results

for i in range( len( coefs ) ):
	print basis_assignment[i], coefs[i]

print "saving LOCPOT_debug.xsf "
GU.saveXSF( WORK_DIR + 'LOCPOT_debug.xsf', V, lvec, head );


for ix,x in enumerate( xTips  ):
	print "relax ix:", ix
	rTips[:,0] = x
	for iy,y in enumerate( yTips  ):
		rTips[:,1] = y
		itrav = PP.relaxTipStroke( rTips, rs, fs ) / float( len(zTips) )
		fzs[:,iy,ix] = fs[:,2].copy()
		

print " # ============  convert Fz -> df "

dfs = PP.Fz2df( fzs, dz = dz, k0 = PP.params['kCantilever'], f0=PP.params['f0Cantilever'], n=int(PP.params['Amplitude']/dz) )


if(options.df == True):
	GU.saveXSF('df.xsf', dfs, lvec, head)

print " # ============  Plot Relaxed Scan 3D "
slices = range( 0, len(dfs) )
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=PP.params['imageInterpolation'], vmin=fmin, vmax=fmax, cmap=PP.params['colorscale'], extent=extent )
	else:
		plt.imshow( dfs[i], origin='image', interpolation=PP.params['imageInterpolation'], cmap=PP.params['colorscale'], extent=extent )
	z = zTips[i]
#	z = zTips[i] - PP.params['moleculeShift' ][2]
	z = zTips[i]
Exemple #8
0
    rTips[:, 0] = x
    for iy, y in enumerate(yTips):
        rTips[:, 1] = y
        itrav = PP.relaxTipStroke(rTips, rs, fs) / float(len(zTips))
        fzs[:, iy, ix] = fs[:, 2].copy()

print " # ============  convert Fz -> df "

dfs = PP.Fz2df(fzs,
               dz=dz,
               k0=PP.params['kCantilever'],
               f0=PP.params['f0Cantilever'],
               n=int(PP.params['Amplitude'] / dz))

if (options.df == True):
    GU.saveXSF('df.xsf', dfs, lvec, head)

print " # ============  Plot Relaxed Scan 3D "
slices = range(0, len(dfs))
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=PP.params['imageInterpolation'],
                   vmin=fmin,
                   vmax=fmax,
                   cmap=PP.params['colorscale'],
Exemple #9
0
print " # ========== make & load  ProbeParticle C++ library " 

def makeclean( ):
	import os
	[ os.remove(f) for f in os.listdir(".") if f.endswith(".so") ]
	[ os.remove(f) for f in os.listdir(".") if f.endswith(".o") ]
	[ os.remove(f) for f in os.listdir(".") if f.endswith(".pyc") ]

CWD = os.getcwd()
os.chdir(LWD);       print " >> WORKDIR: ", os.getcwd()
makeclean( )
sys.path.insert(0, "./")
import GridUtils as GU
import ProbeParticle as PP
os.chdir(CWD);  print " >> WORKDIR: ", os.getcwd()

print " ============= RUN  "

F,lvec,nDim,head=GU.loadXSF('LOCPOT.xsf')

F4 = 0.25*( F + F[:,:,::-1] + F[:,::-1,:] + F[:,::-1,::-1] )

#GU.saveXSF('LOCPOT_4sym.xsf', GU.XSF_HEAD_DEFAULT, lvec, F4 )
GU.saveXSF('LOCPOT_4sym.xsf', head, lvec, F4 )

plt.show()