def importGeometries(fname): if (fname.lower().endswith(".xyz") or fname.lower().endswith(".bas")): atoms, nDim, lvec = bU.loadAtoms(fname) elif fname.lower().endswith(".xsf"): atoms, nDim, lvec = bU.loadXSFGeom(fname) elif fname.lower().endswith(".cube"): atoms, nDim, lvec = bU.loadAtomsCUBE(fname) elif fname.lower().endswith(".in"): atoms, nDim, lvec = bU.loadGeometryIN(fname) else: sys.exit("ERROR!!! Unknown format of geometry system. Supported " "formats are: .xyz, .bas., .xsf, .cube, .in \n\n") if (nDim != []): PPU.params['gridN'] = nDim if (lvec != []): PPU.params['gridA'] = lvec[1] PPU.params['gridB'] = lvec[2] PPU.params['gridC'] = lvec[3] else: lvec = np.zeros((4, 3)) lvec[1, :] = PPU.params['gridA'].copy() lvec[2, :] = PPU.params['gridB'].copy() lvec[3, :] = PPU.params['gridC'].copy() return atoms, lvec
del Fz cell = np.array([ PP.params['gridA'], PP.params['gridB'], PP.params['gridC'], ]).copy() gridN = PP.params['gridN'] print("cell", cell) PP.setFF(FFLJ, cell) print(" # ============ define atoms ") atoms = basUtils.loadAtoms('watter4NaCl-2.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']) print(" NO PBC => params[ 'gridB' ] ", PP.params['gridB']) print(" NO PBC => params[ 'gridC' ] ", PP.params['gridC']) print(" NO PBC => params[ 'scanMin' ] ", PP.params['scanMin']) print(" NO PBC => params[ 'scanMax' ] ", PP.params['scanMax']) Rs = np.transpose(Rs, (1, 0)).copy() Qs = np.array(atoms[4])
cell =np.array([ PP.params['gridA'], PP.params['gridB'], PP.params['gridC'], ]).copy() gridN = PP.params['gridN'] print "cell", cell PP.setFF( FFLJ, cell ) print " # ============ define atoms " atoms = basUtils.loadAtoms('watter4NaCl-2.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' ] print " NO PBC => params[ 'gridB' ] ", PP.params[ 'gridB' ] print " NO PBC => params[ 'gridC' ] ", PP.params[ 'gridC' ] print " NO PBC => params[ 'scanMin' ] ", PP.params[ 'scanMin' ] print " NO PBC => params[ 'scanMax' ] ", PP.params[ 'scanMax' ] Rs = np.transpose( Rs, (1,0) ).copy() Qs = np.array( atoms[4] )
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)
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') 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)
# 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: exists = True for lj_file in ["x", "y", "z"]: lj_file = ProjName + "_LJ_F_" + lj_file + ".xsf" if not os.path.exists(lj_file): exists = False if exists: if query_yes_no( "I have found files containing LJ forcefield. Should I use them (yes) or do you want me to recompute them from scratch (n) ?"
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: exists = True for lj_file in ["x", "y", "z"]: lj_file = ProjName + "_LJ_F_" + lj_file + ".xsf" if not os.path.exists(lj_file): exists = False if exists: if query_yes_no( "I have found files containing LJ forcefield. Should I use them (yes) or do you want me to recompute them from scratch (n) ?" ):
del Fz cell = np.array([ PP.params['gridA'], PP.params['gridB'], PP.params['gridC'], ]).copy() gridN = PP.params['gridN'] print "cell", cell PP.setFF(FFLJ, cell) print " # ============ define atoms " atoms = basUtils.loadAtoms('watter4NaCl-2.xyz', elements.ELEMENT_DICT) 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'] print " NO PBC => params[ 'gridB' ] ", PP.params['gridB'] print " NO PBC => params[ 'gridC' ] ", PP.params['gridC'] print " NO PBC => params[ 'scanMin' ] ", PP.params['scanMin'] print " NO PBC => params[ 'scanMax' ] ", PP.params['scanMax'] Rs = np.transpose(Rs, (1, 0)).copy() Qs = np.array(atoms[4])
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) 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 " ============= 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', elements.ELEMENT_DICT ) iZs,Rs,Qs = parseAtoms( atoms, autogeom = False, PBC = True ) FFLJ = PP.computeLJ( iZs, Rs, FFLJ=None, cell=None, autogeom = False, PBC = True ) 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 ***** "
cell =np.array([ PP.params['gridA'], PP.params['gridB'], PP.params['gridC'], ]).copy() gridN = PP.params['gridN'] print "cell", cell PP.setFF( FFLJ, cell ) print " # ============ define atoms " atoms = basUtils.loadAtoms('watter4NaCl-2.xyz', elements.ELEMENT_DICT ) 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' ] print " NO PBC => params[ 'gridB' ] ", PP.params[ 'gridB' ] print " NO PBC => params[ 'gridC' ] ", PP.params[ 'gridC' ] print " NO PBC => params[ 'scanMin' ] ", PP.params[ 'scanMin' ] print " NO PBC => params[ 'scanMax' ] ", PP.params[ 'scanMax' ] Rs = np.transpose( Rs, (1,0) ).copy() Qs = np.array( atoms[4] )
FFel[:,:,:,2]=Fz cell =np.array([ PP.params['gridA'], PP.params['gridB'], PP.params['gridC'], ]).copy() gridN = PP.params['gridN'] print " # ============ define atoms " atoms = basUtils.loadAtoms(sys.argv[1], elements.ELEMENT_DICT ) 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' ] print " NO PBC => params[ 'gridB' ] ", PP.params[ 'gridB' ] print " NO PBC => params[ 'gridC' ] ", PP.params[ 'gridC' ] print " NO PBC => params[ 'scanMin' ] ", PP.params[ 'scanMin' ] print " NO PBC => params[ 'scanMax' ] ", PP.params[ 'scanMax' ] """ Rs = np.transpose( Rs, (1,0) ).copy() Qs = np.array( atoms[4] )
FFel = np.zeros(np.shape(FF)) FFel[:, :, :, 0] = Fx FFel[:, :, :, 1] = Fy FFel[:, :, :, 2] = Fz cell = np.array([ PP.params['gridA'], PP.params['gridB'], PP.params['gridC'], ]).copy() gridN = PP.params['gridN'] print " # ============ define atoms " atoms = basUtils.loadAtoms(sys.argv[1], elements.ELEMENT_DICT) 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' ] print " NO PBC => params[ 'gridB' ] ", PP.params[ 'gridB' ] print " NO PBC => params[ 'gridC' ] ", PP.params[ 'gridC' ] print " NO PBC => params[ 'scanMin' ] ", PP.params[ 'scanMin' ] print " NO PBC => params[ 'scanMax' ] ", PP.params[ 'scanMax' ] """ Rs = np.transpose(Rs, (1, 0)).copy() Qs = np.array(atoms[4])
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', elements.ELEMENT_DICT) iZs, Rs, Qs = parseAtoms(atoms, autogeom=False, PBC=True) FFLJ = PP.computeLJ(iZs, Rs, FFLJ=None, cell=None, autogeom=False, PBC=True) 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)
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']: print " NO PBC => autoGeom " PP.autoGeom(Rs, shiftXY=True, fitCell=True, border=3.0) print " NO PBC => params[ 'gridA' ] ", PP.params['gridA'] print " NO PBC => params[ 'gridB' ] ", PP.params['gridB'] print " NO PBC => params[ 'gridC' ] ", PP.params['gridC'] print " NO PBC => params[ 'scanMin' ] ", PP.params['scanMin'] print " NO PBC => params[ 'scanMax' ] ", PP.params['scanMax'] #Rs[0] += PP.params['moleculeShift' ][0] # shift molecule so that we sample reasonable part of potential #Rs[1] += PP.params['moleculeShift' ][1] #Rs[2] += PP.params['moleculeShift' ][2]
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) FFparams = None 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) # Lennard Jonnes contribution to the force field if PP.params['useLJ']: #checking if files exist: exists = True
#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' ] print " NO PBC => params[ 'gridB' ] ", PP.params[ 'gridB' ] print " NO PBC => params[ 'gridC' ] ", PP.params[ 'gridC' ] print " NO PBC => params[ 'scanMin' ] ", PP.params[ 'scanMin' ] print " NO PBC => params[ 'scanMax' ] ", PP.params[ 'scanMax' ] #Rs[0] += PP.params['moleculeShift' ][0] # shift molecule so that we sample reasonable part of potential #Rs[1] += PP.params['moleculeShift' ][1]
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 ) FFparams=None 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 ) # Lennard Jonnes contribution to the force field if PP.params['useLJ']: #checking if files exist: