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 = 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 ) plotImages( dirname+AmpStr+"/df", dfs, slices = range( 0, len(dfs) ) )
]).copy() gridN = PP.params['gridN'] FF = np.zeros( (gridN[2],gridN[1],gridN[0],3) ) #quit() # ============================================== # The costly part of simulation starts here # ============================================== print " # =========== Sample LenardJones " PP.setFF( FF, cell ) PP.setFF_Pointer( FF ) PP.getLenardJonesFF( Rs, C6, C12 ) plt.figure(figsize=( 5*nslice,5 )); plt.title( ' FF LJ ' ) ''' for i in range(nslice): plt.subplot( 1, nslice, i+1 ) plt.imshow( FF[i,:,:,2], origin='image', interpolation='nearest' ) ''' withElectrostatics = ( abs( PP.params['charge'] )>0.001 ) if withElectrostatics: print " # =========== Sample Coulomb " FFel = np.zeros( np.shape( FF ) ) CoulombConst = -14.3996448915; # [ e^2 eV/A ] Qs *= CoulombConst
]).copy() gridN = PP.params['gridN'] FF = np.zeros((gridN[2], gridN[1], gridN[0], 3)) #quit() # ============================================== # The costly part of simulation starts here # ============================================== print " # =========== Sample LenardJones " PP.setFF(FF, cell) PP.setFF_Pointer(FF) PP.getLenardJonesFF(Rs, C6, C12) plt.figure(figsize=(5 * nslice, 5)) plt.title(' FF LJ ') ''' for i in range(nslice): plt.subplot( 1, nslice, i+1 ) plt.imshow( FF[i,:,:,2], origin='image', interpolation='nearest' ) ''' withElectrostatics = (abs(PP.params['charge']) > 0.001) if withElectrostatics: print " # =========== Sample Coulomb " FFel = np.zeros(np.shape(FF)) CoulombConst = -14.3996448915
print(" # =========== Sample LenardJones ") #xsfLJ = True xsfLJ = False recomputeLJ = True if (xsfLJ and os.path.isfile('FFLJ_x.xsf')): recomputeLJ = False if ((not xsfLJ) and os.path.isfile('FFLJ_y.npy')): recomputeLJ = False if recomputeLJ: FFparams = PP.loadSpecies('atomtypes.ini') C6, C12 = PP.getAtomsLJ(PP.params['probeType'], iZs, FFparams) PP.setFF(FFLJ, cell) PP.setFF_Pointer(FFLJ) PP.getLenardJonesFF(Rs, C6, C12) if xsfLJ: PP.saveXSF('FFLJ_x.xsf', head, lvec, FFLJ[:, :, :, 0]) PP.saveXSF('FFLJ_y.xsf', head, lvec, FFLJ[:, :, :, 1]) PP.saveXSF('FFLJ_z.xsf', head, lvec, FFLJ[:, :, :, 2]) else: np.save('FFLJ_x.npy', FFLJ[:, :, :, 0]) np.save('FFLJ_y.npy', FFLJ[:, :, :, 1]) np.save('FFLJ_z.npy', FFLJ[:, :, :, 2]) else: if xsfLJ: FFLJ[:, :, :, 0], lvec, nDim, head = PP.loadXSF('FFLJ_x.xsf') FFLJ[:, :, :, 1], lvec, nDim, head = PP.loadXSF('FFLJ_y.xsf') FFLJ[:, :, :, 2], lvec, nDim, head = PP.loadXSF('FFLJ_z.xsf') else:
print " # =========== Sample LenardJones " #xsfLJ = True xsfLJ = False recomputeLJ = True if ( xsfLJ and os.path.isfile('FFLJ_x.xsf')): recomputeLJ = False if ((not xsfLJ) and os.path.isfile('FFLJ_y.npy')): recomputeLJ = False if recomputeLJ: FFparams = PP.loadSpecies ( 'atomtypes.ini' ) C6,C12 = PP.getAtomsLJ( PP.params['probeType'], iZs, FFparams ) PP.setFF( FFLJ, cell ) PP.setFF_Pointer( FFLJ ) PP.getLenardJonesFF( Rs, C6, C12 ) if xsfLJ: PP.saveXSF('FFLJ_x.xsf', head, lvec, FFLJ[:,:,:,0] ) PP.saveXSF('FFLJ_y.xsf', head, lvec, FFLJ[:,:,:,1] ) PP.saveXSF('FFLJ_z.xsf', head, lvec, FFLJ[:,:,:,2] ) else: np.save('FFLJ_x.npy', FFLJ[:,:,:,0] ) np.save('FFLJ_y.npy', FFLJ[:,:,:,1] ) np.save('FFLJ_z.npy', FFLJ[:,:,:,2] ) else: if xsfLJ: FFLJ[:,:,:,0],lvec,nDim,head=PP.loadXSF('FFLJ_x.xsf') FFLJ[:,:,:,1],lvec,nDim,head=PP.loadXSF('FFLJ_y.xsf') FFLJ[:,:,:,2],lvec,nDim,head=PP.loadXSF('FFLJ_z.xsf') else: