def main(): 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 ) fzs = PP.relaxedScan3D( xTips, yTips, zTips ) PP.saveXSF( dirname+'/OutFz.xsf', headScan, lvecScan, fzs ) for iA,Amp in enumerate( Amps ): AmpStr = "/Amp%2.2f" %Amp print "Amp= ",AmpStr os.makedirs( dirname+AmpStr ) dfs = PP.Fz2df( fzs, dz = dz, k0 = PP.params['kCantilever'], f0=PP.params['f0Cantilever'], n=Amp/dz ) PP.plotImages( dirname+AmpStr+"/df", dfs, slices = range( 0, len(dfs) ) )
def main(): 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) fzs = PP.relaxedScan3D(xTips, yTips, zTips) PP.saveXSF(dirname + '/OutFz.xsf', headScan, lvecScan, fzs) for iA, Amp in enumerate(Amps): AmpStr = "/Amp%2.2f" % Amp print("Amp= ", AmpStr) os.makedirs(dirname + AmpStr) dfs = PP.Fz2df(fzs, dz=dz, k0=PP.params['kCantilever'], f0=PP.params['f0Cantilever'], n=Amp / dz) PP.plotImages(dirname + AmpStr + "/df", dfs, slices=list(range(0, len(dfs))))
def relaxedScan3D( xTips, yTips, zTips ): ntips = len(zTips); print " zTips : ",zTips rTips = np.zeros((ntips,3)) rs = np.zeros((ntips,3)) fs = np.zeros((ntips,3)) rTips[:,0] = 1.0 rTips[:,1] = 1.0 rTips[:,2] = zTips fzs = np.zeros(( len(zTips), len(yTips ), len(xTips ) )); 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() return fzs
def relaxedScan3D(xTips, yTips, zTips): ntips = len(zTips) print(" zTips : ", zTips) rTips = np.zeros((ntips, 3)) rs = np.zeros((ntips, 3)) fs = np.zeros((ntips, 3)) rTips[:, 0] = 1.0 rTips[:, 1] = 1.0 rTips[:, 2] = zTips fzs = np.zeros((len(zTips), len(yTips), len(xTips))) 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() return fzs
X, Y, Z = getMGrid(dims, dd) print '--- Get Probe Density ---' rho = getProbeDensity(sampleSize, X, Y, Z, sigma, dd, {'dz2':1.0}) 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', elements.ELEMENT_DICT ) iZs,Rs,Qs = PP.parseAtoms( atoms, autogeom = False, PBC = True ) FFLJ = PP.computeLJ( Rs, iZs, FFLJ=None, FFparams=None) 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)
default=0.0) parser.add_option("--arange", action="store", type="float", help="amplitude range", nargs=3) (options, args) = parser.parse_args() Ks = [0.3, 0.5, 0.7] Qs = [-0.2, -0.1, 0.0, 0.1, 0.2] Amps = [1.0] print(" ============= RUN ") print(" >> WARNING!!! OVEWRITING SETTINGS by params.ini ") PP.loadParams('params.ini') PPPlot.params = PP.params print(" load Electrostatic Force-field ") FFel, lvec, nDim, head = GU.loadVecFieldXsf("FFel") print(" load Lenard-Jones Force-field ") FFLJ, lvec, nDim, head = GU.loadVecFieldXsf("FFLJ") PP.lvec2params(lvec) PP.setFF(FFel) xTips, yTips, zTips, lvecScan = PP.prepareScanGrids() #Ks = [ 0.25, 0.5, 1.0 ] #Qs = [ -0.2, 0.0, +0.2 ] #Amps = [ 2.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") ] makeclean( ) # force to recompile import ProbeParticle as PP print " >> WARNING!!! OVEWRITING SETTINGS by params.ini " PP.loadParams( 'params_watter.ini' ) #Fx,lvec,nDim,head=XSFutils.loadXSF('Fx.xsf') #Fy,lvec,nDim,head=XSFutils.loadXSF('Fy.xsf') #Fz,lvec,nDim,head=XSFutils.loadXSF('Fz.xsf') Fx,lvec,nDim,head=PP.loadXSF('Fx.xsf') Fy,lvec,nDim,head=PP.loadXSF('Fy.xsf') Fz,lvec,nDim,head=PP.loadXSF('Fz.xsf') PP.params['gridA'] = lvec[ 1,: ].copy() PP.params['gridB'] = lvec[ 2,: ].copy() PP.params['gridC'] = lvec[ 3,: ].copy() PP.params['gridN'] = nDim.copy() FFLJ = np.zeros( (nDim[0],nDim[1],nDim[2],3) )
try: sys.argv[1] except IndexError: print "Please specify a file with coordinates" exit(1) parser = OptionParser() parser.add_option( "--dfrange", action="store", type="float", help="Range of plotted frequency shift (df)", nargs=2) parser.add_option( "--df", action="store_true", help="Write AFM frequency shift in df.xsf file", default=False) (options, args) = parser.parse_args() print "Reading coordinates from the file {}".format(sys.argv[1]) print " >> WARNING!!! OVERWRITING SETTINGS by params.ini " PP.loadParams( 'params.ini' ) Fx,lvec,nDim,head=GU.loadXSF('FFel_x.xsf') Fy,lvec,nDim,head=GU.loadXSF('FFel_y.xsf') Fz,lvec,nDim,head=GU.loadXSF('FFel_z.xsf') PP.params['gridA'] = lvec[ 1,: ].copy() PP.params['gridB'] = lvec[ 2,: ].copy() PP.params['gridC'] = lvec[ 3,: ].copy() PP.params['gridN'] = nDim.copy() FF = np.zeros( (nDim[0],nDim[1],nDim[2],3) ) FFLJ = np.zeros( np.shape( FF ) ) FFel = np.zeros( np.shape( FF ) )
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)
parser = OptionParser() parser.add_option( "-i", "--input", action="store", type="string", help="format of input file", default='vasp.locpot.xsf') (options, args) = parser.parse_args() num = len(sys.argv) if (num < 2): sys.exit("Number of arguments = "+str(num-1)+". This script shoudl have at least one argument. I am terminating...") finput = sys.argv[num-1] # --- initialization --- sigma = 1.0 # [ Angstroem ] print " >> OVEWRITING SETTINGS by params.ini " PPU.loadParams( 'params.ini' ) print " ========= get electrostatic forcefiled from hartree " # TODO with time implement reading a hartree potential generated by different software print " loading Hartree potential from disk " if(options.input == 'vasp.locpot.xsf'): V, lvec, nDim, head = GU.loadXSF(finput) elif(options.input == 'aims.cube'): V, lvec, nDim, head = GU.loadCUBE(finput) print " computing convolution with tip by FFT " Fel_x,Fel_y,Fel_z = LFF. potential2forces( V, lvec, nDim, sigma = 1.0 )
print(" # ========== make & load ProbeParticle C++ library ") LWD = '/home/prokop/git/ProbeParticleModel/code' sys.path = [LWD] import basUtils import elements import GridUtils as GU import ProbeParticle as PP print(" ============= RUN ") print(" >> WARNING!!! OVEWRITING SETTINGS by params.ini ") PP.loadParams('params.ini') print(" load Electrostatic Force-field ") FFel, lvec, nDim, head = loadVecFieldXsf("FFel") print(" load Lenard-Jones Force-field ") FFLJ, lvec, nDim, head = loadVecFieldXsf("FFLJ") PP.params['gridA'] = lvec[1, :].copy() PP.params['gridB'] = lvec[2, :].copy() PP.params['gridC'] = lvec[3, :].copy() PP.params['gridN'] = nDim.copy() xTips, yTips, zTips, lvecScan = prepareGrids() #Ks = [ 0.25, 0.5, 1.0 ] #Qs = [ -0.2, 0.0, +0.2 ] #Amps = [ 2.0 ]
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")] makeclean() # force to recompile import ProbeParticle as PP print(" >> WARNING!!! OVEWRITING SETTINGS by params.ini ") PP.loadParams('params_watter.ini') #Fx,lvec,nDim,head=XSFutils.loadXSF('Fx.xsf') #Fy,lvec,nDim,head=XSFutils.loadXSF('Fy.xsf') #Fz,lvec,nDim,head=XSFutils.loadXSF('Fz.xsf') Fx, lvec, nDim, head = PP.loadXSF('Fx.xsf') Fy, lvec, nDim, head = PP.loadXSF('Fy.xsf') Fz, lvec, nDim, head = PP.loadXSF('Fz.xsf') PP.params['gridA'] = lvec[1, :].copy() PP.params['gridB'] = lvec[2, :].copy() PP.params['gridC'] = lvec[3, :].copy() PP.params['gridN'] = nDim.copy() FFLJ = np.zeros((nDim[0], nDim[1], nDim[2], 3))
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")] #makeclean( ) # force to recompile import ProbeParticle as PP print " # ========== server interface file I/O " PP.loadParams('params.ini') print " # ============ define atoms " #bas = basUtils.loadBas('surf.bas')[0] #bas = basUtils.loadBas('PTCDA_Ruslan_1x1.bas')[0] #bas = basUtils.loadBas('GrN6x6.bas')[0] #atoms = basUtils.loadAtoms('GrN6x6.bas', elements.ELEMENT_DICT ) #atoms = basUtils.loadAtoms('GrN6x6.xyz', elements.ELEMENT_DICT ) atoms = basUtils.loadAtoms('input.xyz', elements.ELEMENT_DICT) Rs = np.array([atoms[1], atoms[2], atoms[3]]) iZs = np.array(atoms[0]) if not PP.params['PBC']:
default='vasp.locpot.xsf') (options, args) = parser.parse_args() num = len(sys.argv) if (num < 2): sys.exit( "Number of arguments = " + str(num - 1) + ". This script shoudl have at least one argument. I am terminating...") finput = sys.argv[num - 1] # --- initialization --- sigma = 1.0 # [ Angstroem ] print " >> OVEWRITING SETTINGS by params.ini " PPU.loadParams('params.ini') print " ========= get electrostatic forcefiled from hartree " # TODO with time implement reading a hartree potential generated by different software print " loading Hartree potential from disk " if (options.input == 'vasp.locpot.xsf'): V, lvec, nDim, head = GU.loadXSF(finput) elif (options.input == 'aims.cube'): V, lvec, nDim, head = GU.loadCUBE(finput) print " computing convolution with tip by FFT " Fel_x, Fel_y, Fel_z = LFF.potential2forces(V, lvec, nDim, sigma=1.0) print " saving electrostatic forcefiled " GU.saveXSF('FFel_x.xsf', Fel_x, lvec, head)
print "Please specify a file with coordinates" exit(1) filename = sys.argv[1] if not os.path.exists(filename): print "File {} with coordinates doesn't exist!!! Exiting".format(filename) exit(1) ProjName = filename[:-4] # Working with parameters file ParamFilename = ProjName + ".ini" if os.path.exists(ParamFilename): PP.loadParams(ParamFilename) else: print "File {} with parameters doesn't exist!!! Using defaults".format( ParamFilename) cell = np.array([ PP.params['gridA'], PP.params['gridB'], PP.params['gridC'], ]).copy() lvec = PP.params2lvec() atoms = basUtils.loadAtoms(filename, elements.ELEMENT_DICT) iZs, Rs, Qs = PP.parseAtoms(atoms, autogeom=False, PBC=True) # Lennard Jonnes contribution to the force field
print " load Electrostatic Force-field " FFel_x,lvec,nDim,head=GU.loadXSF('FFel_x.xsf') 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('geom.bas') 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 = parseAtoms( atoms, autogeom = False, PBC = True, FFparams=FFparams ) FFLJ = PP.computeLJ( iZs, Rs, FFLJ=None, cell=None, autogeom = False, PBC = True, FFparams=FFparams) print "impose 4fold symmetry on FFLJ " FFLJ4 = np.zeros(np.shape( FFLJ )) FFLJ4[:,:,:,0] = 0.25*( FFLJ[:,:,:,0] - FFLJ[:,:,::-1,0] + FFLJ[:,::-1,:,0] - FFLJ[:,::-1,::-1,0] ) FFLJ4[:,:,:,1] = 0.25*( FFLJ[:,:,:,1] + FFLJ[:,:,::-1,1] - FFLJ[:,::-1,:,1] - FFLJ[:,::-1,::-1,1] ) FFLJ4[:,:,:,2] = 0.25*( FFLJ[:,:,:,2] + FFLJ[:,:,::-1,2] + FFLJ[:,::-1,:,2] + FFLJ[:,::-1,::-1,2] ) print "save FFLJ to .xsf " GU.saveVecFieldXsf( 'FFLJ', FFLJ4, lvec, head ) print " ***** ALL DONE ***** " #plt.show()
# NOTE: Data for COCu4 tip example are on tarkil /auto/praha1/prokop/STHM/vasp/COCu4 # ============== load reference grid V, lvec, nDim, head = GU.loadXSF( WORK_DIR + 'LOCPOT.xsf' ) cell = np.array( [ lvec[1], lvec[2], lvec[3] ]); MP.setGrid( V, cell ); # ============== prepare atoms atom_types,atom_pos = GU.getFromHead_PRIMCOORD( head ) # load atoms from header of xsf file # set sample region around atom atom_Rmin, atom_Rmax spacies = PP.loadSpecies( './defaults/atomtypes.ini' ) 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 " # ========== make & load ProbeParticle C++ library " LWD = '/home/prokop/git/ProbeParticleModel/code' sys.path = [ LWD ] import basUtils import elements import GridUtils as GU import ProbeParticle as PP print " ============= RUN " print " >> WARNING!!! OVEWRITING SETTINGS by params.ini " PP.loadParams( 'params.ini' ) print " load Electrostatic Force-field " FFel, lvec, nDim, head = loadVecFieldXsf( "FFel" ) print " load Lenard-Jones Force-field " FFLJ, lvec, nDim, head = loadVecFieldXsf( "FFLJ" ) PP.params['gridA'] = lvec[ 1,: ].copy() PP.params['gridB'] = lvec[ 2,: ].copy() PP.params['gridC'] = lvec[ 3,: ].copy() PP.params['gridN'] = nDim.copy() xTips,yTips,zTips,lvecScan = prepareGrids( ) #Ks = [ 0.25, 0.5, 1.0 ] #Qs = [ -0.2, 0.0, +0.2 ] #Amps = [ 2.0 ]
# ============== load reference grid V, lvec, nDim, head = GU.loadXSF(WORK_DIR + 'LOCPOT.xsf') cell = np.array([lvec[1], lvec[2], lvec[3]]) MP.setGrid(V, cell) # ============== prepare atoms atom_types, atom_pos = GU.getFromHead_PRIMCOORD( head) # load atoms from header of xsf file # set sample region around atom atom_Rmin, atom_Rmax spacies = PP.loadSpecies('./defaults/atomtypes.ini') 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
parser.add_option( "--krange", action="store", type="float", help="k parameter range", nargs=3) parser.add_option( "-q", action="store", type="float", help="charge", default=0.0) parser.add_option( "--qrange", action="store", type="float", help="charge range", nargs=3) parser.add_option( "-a", action="store", type="float", help="amplitude", default=0.0) parser.add_option( "--arange", action="store", type="float", help="amplitude range", nargs=3) (options, args) = parser.parse_args() Ks = [ 0.3 ] Qs = [ 0.0] Amps = [ 1.0 ] print " ============= RUN " print " >> WARNING!!! OVEWRITING SETTINGS by params.ini " PP.loadParams( 'params.ini' ) PPPlot.params = PP.params print " load Electrostatic Force-field " FFel, lvec, nDim, head = GU.loadVecFieldXsf( "FFel" ) print " load Lenard-Jones Force-field " FFLJ, lvec, nDim, head = GU.loadVecFieldXsf( "FFLJ" ) PP.lvec2params( lvec ) PP.setFF( FFel ) xTips,yTips,zTips,lvecScan = PP.prepareScanGrids( ) #Ks = [ 0.25, 0.5, 1.0 ] #Qs = [ -0.2, 0.0, +0.2 ] #Amps = [ 2.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") ] #makeclean( ) # force to recompile import ProbeParticle as PP print " # ========== server interface file I/O " PP.loadParams( 'params.ini' ) print " # ============ define atoms " #bas = basUtils.loadBas('surf.bas')[0] #bas = basUtils.loadBas('PTCDA_Ruslan_1x1.bas')[0] #bas = basUtils.loadBas('GrN6x6.bas')[0] atoms = basUtils.loadAtoms('input.xyz') Rs = np.array([atoms[1],atoms[2],atoms[3]]); iZs = np.array( atoms[0]) if not PP.params['PBC' ]: print " NO PBC => autoGeom " PP.autoGeom( Rs, shiftXY=True, fitCell=True, border=3.0 ) print " NO PBC => params[ 'gridA' ] ", PP.params[ 'gridA' ]
filename = sys.argv[1] if not os.path.exists(filename): print "File {} with coordinates doesn't exist!!! Exiting".format(filename) exit(1) ProjName = filename[:-4] # Working with parameters file ParamFilename = ProjName + ".ini" if os.path.exists(ParamFilename): PP.loadParams(ParamFilename) else: print "File {} with parameters doesn't exist!!! Using defaults".format(ParamFilename) cell = np.array([PP.params["gridA"], PP.params["gridB"], PP.params["gridC"]]).copy() lvec = PP.params2lvec() atoms = basUtils.loadAtoms(filename, elements.ELEMENT_DICT) iZs, Rs, Qs = PP.parseAtoms(atoms, autogeom=False, PBC=True) # Lennard Jonnes contribution to the force field if PP.params["useLJ"]: # checking if files exist: