示例#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)

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)

示例#4
0
]).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
    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) ?"):
            todoLJ='read'