def prepareForceFields( store = True, storeXsf = False, autogeom = False, FFparams=None ): newEl = False newLJ = False head = None # --- try to load FFel or compute it from LOCPOT.xsf if ( os.path.isfile('FFel_x.xsf') ): print " FFel_x.xsf found " FFel, lvecEl, nDim, head = GU.loadVecField('FFel', FFel) lvec2params( lvecEl ) else: print "FFel_x.xsf not found " if ( xsfLJ and os.path.isfile('LOCPOT.xsf') ): print " LOCPOT.xsf found " V, lvecEl, nDim, head = GU.loadXSF('LOCPOT.xsf') lvec2params( lvecEl ) FFel_x,FFel_y,FFel_z = libFFTfin.potential2forces( V, lvecEl, nDim, sigma = 1.0 ) FFel = GU.packVecGrid( FFel_x,FFel_y,FFel_z ) del FFel_x,FFel_y,FFel_z GU.saveVecFieldXsf( 'FFel', FF, lvecEl, head = head ) else: print " LOCPOT.xsf not found " newEl = True # --- try to load FFLJ if ( os.path.isfile('FFLJ_x.xsf') ): print " FFLJ_x.xsf found " FFLJ, lvecLJ, nDim, head = GU.loadVecFieldXsf( 'FFLJ' ) lvec2params( lvecLJ ) else: newLJ = True # --- compute Forcefield by atom-wise interactions if ( newEl or newEl ): atoms = basUtils.loadAtoms('geom.bas', elements.ELEMENT_DICT ) iZs,Rs,Qs = parseAtoms( atoms, autogeom = autogeom, PBC = params['PBC'] ) lvec = params2lvec( ) if head is None: head = GU.XSF_HEAD_DEFAULT if newLJ: FFLJ = computeLJ ( Rs, iZs, FFparams=FFparams ) GU.saveVecFieldXsf( 'FFLJ', FF, lvecEl, head = head ) if newEl: FFel = computeCoulomb( Rs, Qs, FFel ) GU.saveVecFieldXsf( 'FFel', FF, lvecEl, head = head ) return FFLJ, FFel
(options, args) = parser.parse_args() num = len(sys.argv) if (num < 2): sys.exit("Number of arguments = "+str(num-1)+". This script should have at least one argument. I am terminating...") finput = sys.argv[num-1] # --- initialization --- sigma = 1.0 # [ Angstroem ] print('--- Data Loading ---') # TODO with time implement reading a hartree potential generated by different software 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('--- 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)
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) finput = sys.argv[num-1] # --- initialization --- sigma = 1.0 # [ Angstroem ] print '--- Data Loading ---' # TODO with time implement reading a hartree potential generated by different software 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 '--- 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)
# This is a sead of simple plotting script which should get AFM frequency delta 'df.xsf' and generate 2D plots for different 'z' import os import sys import numpy as np import matplotlib.pyplot as plt import 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) (options, args) = parser.parse_args() dfs,lvec,nDim,head=GU.loadXSF('df.xsf') #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)
makeclean() import GridUtils as GU import Multipoles as MP import ProbeParticle as PP # ============== Setup WORK_DIR = '/home/prokop/Desktop/Probe_Particle_Simulations/Multipoles/COCu4/' # 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)
sys.path = [ LWD ] print " sys.path = ", sys.path import basUtils import elements import GridUtils as GU import ProbeParticle as PP print " ============= RUN " print " >> WARNING!!! OVEWRITING SETTINGS by params.ini " #PP.loadParams( 'params_carbox.ini' ) 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)
LWD = '/home/prokop/git/ProbeParticleModel/code' 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 os.chdir(CWD) print " >> WORKDIR: ", os.getcwd() print " ============= RUN " Fz, lvec, nDim, head = gu.loadXSF('Fz.xsf') nslice = min(len(Fz), 10) for i in range(nslice): plt.figure() plt.imshow(Fz[i, :, :], origin='image', interpolation='nearest') plt.show()
os.chdir(CWD) makeclean( ) import GridUtils as GU import Multipoles as MP import ProbeParticle as PP # ============== Setup WORK_DIR = '/home/prokop/Desktop/Probe_Particle_Simulations/Multipoles/COCu4/' # 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
LWD = '/home/prokop/git/ProbeParticleModel/code' 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 os.chdir(CWD); print " >> WORKDIR: ", os.getcwd() print " ============= RUN " Fz,lvec,nDim,head=gu.loadXSF('Fz.xsf') nslice = min( len( Fz ), 10 ) for i in range(nslice): plt.figure() plt.imshow( Fz[i,:,:], origin='image', interpolation='nearest' ) plt.show()
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 ) ) FFel[:,:,:,0]=Fx FFel[:,:,:,1]=Fy FFel[:,:,:,2]=Fz
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)) FFel[:, :, :, 0] = Fx FFel[:, :, :, 1] = Fy FFel[:, :, :, 2] = Fz
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()