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)
print " saving electrostatic forcefiled " GU.saveXSF('FFel_x.xsf', Fel_x, lvec, head) GU.saveXSF('FFel_y.xsf', Fel_y, lvec, head) GU.saveXSF('FFel_z.xsf', Fel_z, lvec, head) del Fel_x, Fel_y, Fel_z, V print " ========= get lenard jones potential " PPU.params['gridA'] = lvec[1, :].copy() PPU.params['gridB'] = lvec[2, :].copy() PPU.params['gridC'] = lvec[3, :].copy() PPU.params['gridN'] = nDim.copy() print "--- Compute Lennard-Jones Force-filed ---" atoms = basUtils.loadAtoms('input.xyz', elements.ELEMENT_DICT) iZs, Rs, Qs = PPU.parseAtoms(atoms, autogeom=False, PBC=True) FFLJ = PPU.computeLJ(Rs, iZs, FFLJ=None, FFparams=None) # TODO: remove to large values ''' FRLJ = np.sqrt( FFLJ[:,:,:,0]**2 + FFLJ[:,:,:,1]**2 + FFLJ[:,:,:,2]**2 ) mask = ( FRLJ > 1000.0 ) FFLJ[:][mask] = 1000.0 FFLJ[][mask] = 1000.0 FFLJ[][mask] = 1000.0 ''' print "--- Save ---" GU.saveVecFieldXsf('FFLJ', FFLJ, lvec, head)
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 " 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()