<commit_before>#!/usr/bin/python
import sys
import numpy as np
import basUtils
import elements
import GridUtils     as GU
import ProbeParticle      as PP;    PPU = PP.PPU;
import libFFTfin     as LFF
from optparse import OptionParser

parser = OptionParser()
parser.add_option( "-i", "--input", action="store", type="string", help="format of input file", default='vasp.locpot.xsf')
(options, args) = parser.parse_args()

num = len(sys.argv)
if (num < 2):
    sys.exit("Number of arguments = "+str(num-1)+". This script shoudl have at least one argument. I am terminating...")
finput = sys.argv[num-1]


print " >> OVEWRITING SETTINGS by params.ini  "
PPU.loadParams( 'params.ini' )




print " ========= get electrostatic forcefiled from hartree "

# TODO with time implement reading a hartree potential generated by different software
print " loading Hartree potential from disk "
if(options.input == 'vasp.locpot.xsf'):
    V, lvec, nDim, head = GU.loadXSF(finput)
elif(options.input == 'aims.cube'):
    V, lvec, nDim, head = GU.loadCUBE(finput)

print " computing convolution with tip by FFT "
Fel_x,Fel_y,Fel_z = LFF. potential2forces( V, lvec, nDim, sigma = 1.0 )

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 = PP.parseAtoms( atoms, autogeom = False, PBC = True )
FFLJ      = PP.computeLJ( Rs, iZs, FFLJ=None, FFparams=None)

GU.limit_vec_field( FFLJ, Fmax=100.0 ) # remove too large valuesl; keeps the same direction; good for visualization 

print "--- Save  ---"
GU.saveVecFieldXsf( 'FFLJ', FFLJ, lvec, head)
<commit_msg>seprating Lennard-Jones and electrostatic force-fields ploting<commit_after>#!/usr/bin/python
import sys
import numpy as np
import basUtils
import elements
import GridUtils     as GU
import ProbeParticle      as PP;    PPU = PP.PPU;
import libFFTfin     as LFF
from optparse import OptionParser

parser = OptionParser()
parser.add_option( "-i", "--input",       action="store",        type="string", help="format of input file", default='vasp.locpot.xsf')
parser.add_option(       "--lj",          action="store_true",                  help="calculate Lennard-Jones force-field ",  default=False)
parser.add_option(       "--el",          action="store_true",                  help="calculate electrostatic force-field",   default=False)
parser.add_option(       "--all",         action="store_true",                  help="calculate all force-field",             default=True)
(options, args) = parser.parse_args()

num = len(sys.argv)
if (num < 2):
    sys.exit("Number of arguments = "+str(num-1)+". This script shoudl have at least one argument. I am terminating...")
finput = sys.argv[num-1]

if(options.all and not options.el and not options.lj):
    options.el = True
    options.lj = True


print " >> OVEWRITING SETTINGS by params.ini  "
PPU.loadParams( 'params.ini' )



print " ========= get electrostatic forcefiled from hartree "

# TODO with time implement reading a hartree potential generated by different software
print "   + loading Hartree potential from disk "
if(options.input == 'vasp.locpot.xsf'):
    V, lvec, nDim, head = GU.loadXSF(finput)
elif(options.input == 'aims.cube'):
    V, lvec, nDim, head = GU.loadCUBE(finput)
print "     + update super-cell "
PPU.params['gridA'] = lvec[ 1,:  ].copy()
PPU.params['gridB'] = lvec[ 2,:  ].copy()
PPU.params['gridC'] = lvec[ 3,:  ].copy()
PPU.params['gridN'] = nDim.copy()


if(options.el):
    print " --- computing electrostatic forcefiled from hartree ---"
    print "   + computing convolution with tip by FFT "
    Fel_x,Fel_y,Fel_z = LFF. potential2forces( V, lvec, nDim, sigma = 1.0 )
    
    print "   + saving electrostatic forcefiled into *.xsf files"
    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 ""


if(options.lj):
    print "--- computing 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)

    GU.limit_vec_field( FFLJ, Fmax=100.0 ) # remove too large valuesl; keeps the same direction; good for visualization 

    print "   + saving  LJ Force-filed into *.xsf files ---"
    GU.saveVecFieldXsf( 'FFLJ', FFLJ, lvec, head)

{'fraction_non_alphanumeric': 0.14365095698703437, 'fraction_numerical': 0.005350895245935378, 'mean_word_length': 3.5463049579045838, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5255375', 'n_tokens_mistral': 1793, 'n_tokens_neox': 1692, 'n_words': 460}