Ejemplo n.º 1
0
    V*=27.211396132
else:
    sys.exit("ERROR!!! Unknown format of the input file\n\n"+HELP_MSG)
rho = None
sigma = options.sigma if ( options.sigma > 0.0) else PPU.params['sigma']
multipole = None

if (options.tip.endswith(".xsf") or options.tip.endswith(".cube") ) :
    rho, lvec_tip, nDim_tip, tiphead = GU.loadXSF(options.tip) if (options.tip.endswith(".xsf")) else GU.loadCUBE(options.tip)
    if (nDim_tip != nDim):
        sys.exit("Error: Input file for tip charge density has been specified, but the dimensions are incompatible with the Hartree potential file!")    
else:
    multipole = {options.tip:1.0} if ( options.tip in {'s','px','py','pz','dx2','dy2','dz2','dxy','dxz','dyz'} ) else {PPU.params['tip']:1.0}

print " computing convolution with tip by FFT "
Fel_x,Fel_y,Fel_z = fFFT.potential2forces(V, lvec, nDim, rho=rho, sigma = sigma, multipole = multipole); del rho, multipole;
FFel = GU.packVecGrid(Fel_x,Fel_y,Fel_z); del Fel_x,Fel_y,Fel_z;

print " saving electrostatic forcefield "
GU.save_vec_field("FFel",FFel,lvec,data_format=data_format); del FFel;

tip_base = options.tip_base if ( options.tip_base is not 'None') else PPU.params["tip_base"][0]

if ((tip_base  != 'None') and (tip_base != None)):
    print " CALCULATING z-force-field for tip_base mono-/multipole "
    print " chosen tip_base multipole: ", tip_base
    print " computing convolution with tip_base by FFT "
    rho = None
    Fel_x,Fel_y,Fel_z = fFFT.potential2forces(V, lvec, nDim, rho=rho, sigma = sigma, multipole = {tip_base:1.0} ); del rho;
    #FFel = GU.packVecGrid(Fel_x,Fel_y,Fel_z)
    print " saving z-electrostatic forcefield of the tip_base"
Ejemplo n.º 2
0
    print "Electrostatic Field from xyzq file"
    multipole = {
        options.tip: 1.0
    } if (options.tip in {
        's', 'px', 'py', 'pz', 'dx2', 'dy2', 'dz2', 'dxy', 'dxz', 'dyz'
    }) else {
        PPU.params['tip']: 1.0
    }
    sigma = options.sigma if (options.sigma > 0.0) else PPU.params['sigma']
    print "DEBUG: multipole, sigma", multipole, sigma
    Vpot = options.energy if (multipole == {'s': 1.0}) else True
    print "DEBUG: Vpot", Vpot
    FFel, Vel = PPH.computeCoulomb(Rs, Qs, FFel=None, Vpot=Vpot)
    if (multipole != {'s': 1.0}):
        print " computing convolution with tip by FFT "
        Fel_x, Fel_y, Fel_z = fFFT.potential2forces(Vel,
                                                    lvec,
                                                    PPU.params['gridN'][::-1],
                                                    rho=None,
                                                    sigma=sigma,
                                                    multipole=multipole)
        del multipole
        FFel = GU.packVecGrid(Fel_x, Fel_y, Fel_z)
        del Fel_x, Fel_y, Fel_z
    print "--- Save ---"
    GU.save_vec_field('FFel', FFel, lvec, data_format=data_format)
    if options.energy:
        Vmax = 10.0
        Vel[Vel > Vmax] = Vmax
        GU.save_scal_field('Vel', Vel, lvec, data_format=data_format)
# TODO with time implement reading a hartree potential generated by different software
print " loading Hartree potential from disk "

if(options.input.lower().endswith(".xsf") ):
    print "Use loadXSF"
    V, lvec, nDim, head = GU.loadXSF(options.input)
elif(options.input.lower().endswith(".cube") ):
    print "Use loadCUBE"
    V, lvec, nDim, head = GU.loadCUBE(options.input)
    V*=27.211396132
else:
    sys.exit("ERROR!!! Unknown format of the input file\n\n"+HELP_MSG)
rho = None
multipole = None
if options.tip in {'s','px','py','pz','dx2','dy2','dz2','dxy','dxz','dyz'}:
    rho = None
    multipole={options.tip:1.0}
elif options.tip.endswith(".xsf"):
    rho, lvec_tip, nDim_tip, tiphead = GU.loadXSF(options.tip)
    if any(nDim_tip != nDim):
        sys.exit("Error: Input file for tip charge density has been specified, but the dimensions are incompatible with the Hartree potential file!")    

print " computing convolution with tip by FFT "
Fel_x,Fel_y,Fel_z = fFFT.potential2forces(V, lvec, nDim, rho=rho, sigma = options.sigma, multipole = multipole)
FFel = GU.packVecGrid(Fel_x,Fel_y,Fel_z)

print " saving electrostatic forcefiled "
GU.save_vec_field("FFel",FFel,lvec,format=format)

del Fel_x,Fel_y,Fel_z,V, FFel;