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
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 ] for iq, Q in enumerate(Qs): FF = FFLJ + FFel * Q PP.setFF_Pointer(FF) for ik, K in enumerate(Ks):
(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 ] for iq,Q in enumerate( Qs ): FF = FFLJ + FFel * Q
else: todoEL = 'compute' else: print "I haven't found files containing electrostatic forcefields. Therefore I will recompute them from scratch" todoEL = 'compute' #print iZs if todoLJ == 'compute': FFLJ = PP.computeLJ(Rs, iZs, FFLJ=None, FFparams=None) GU.saveVecFieldXsf(ProjName + "_LJ_F", FFLJ, lvec=[[0.0, 0.0, 0.0], PP.params['gridA'], PP.params['gridB'], PP.params['gridC']]) elif todoLJ == 'read': FFLJ, lvec, nDim, head = GU.loadVecFieldXsf(ProjName + "_LJ_F") PP.lvec2params(lvec) xTips, yTips, zTips, lvecScan = PP.prepareScanGrids() print xTips, yTips, zTips if todoEL == 'read': FFEL, lvec, nDim, head = GU.loadVecFieldXsf(ProjName + "_EL_F") Q = PP.params['charge'] K = 0.3 PP.setTip(kSpring=np.array((K, K, 0.0)) / -PP.eVA_Nm) FF = FFLJ #+ FFEL * Q PP.setFF_Pointer(FF)
todoEL = "compute" else: print "I haven't found files containing electrostatic forcefields. Therefore I will recompute them from scratch" todoEL = "compute" # print iZs if todoLJ == "compute": FFLJ = PP.computeLJ(Rs, iZs, FFLJ=None, FFparams=None) GU.saveVecFieldXsf( ProjName + "_LJ_F", FFLJ, lvec=[[0.0, 0.0, 0.0], PP.params["gridA"], PP.params["gridB"], PP.params["gridC"]] ) elif todoLJ == "read": FFLJ, lvec, nDim, head = GU.loadVecFieldXsf(ProjName + "_LJ_F") PP.lvec2params(lvec) xTips, yTips, zTips, lvecScan = PP.prepareScanGrids() print xTips, yTips, zTips if todoEL == "read": FFEL, lvec, nDim, head = GU.loadVecFieldXsf(ProjName + "_EL_F") Q = PP.params["charge"] K = 0.3 PP.setTip(kSpring=np.array((K, K, 0.0)) / -PP.eVA_Nm)