示例#1
0
                "\n**WARNING: A file called CHGDIFF already exists in this directory."
            )
            if float(sys.version.split()[0][:3]) < 3.0:
                yesno = raw_input(
                    "Type y to continue and overwrite it, any other key to stop\n"
                )
            else:
                yesno = input(
                    "Type y to continue and overwrite it, any other key to stop\n"
                )
            if yesno != "y":
                sys.exit(0)
    # Writing data ...
    print("Writing density difference data to file ...", end='')
    sys.stdout.flush()
    chg_total.write(filename="SPINCAR_total.vasp", format="chgcar")
    chg_x.write(filename="SPINCAR_x.vasp", format="chgcar")
    chg_y.write(filename="SPINCAR_y.vasp", format="chgcar")
    chg_z.write(filename="SPINCAR_z.vasp", format="chgcar")
    # adding atomic species
    fin = [atoms.get_chemical_symbols()[0]]
    for i in range(len(atoms.get_chemical_symbols())):
        if i == len(atoms.get_chemical_symbols()) - 1: break
        if atoms.get_chemical_symbols()[i] != atoms.get_chemical_symbols()[i +
                                                                           1]:
            fin.append(atoms.get_chemical_symbols()[i + 1])

    for chgfiles in [
            'SPINCAR_total.vasp', 'SPINCAR_x.vasp', 'SPINCAR_y.vasp',
            'SPINCAR_z.vasp'
    ]:
示例#2
0
        sys.stdout.flush()

    # Take difference
    # -----------------
    chgdiff = chgdiff - chg2
    print "done."

vasp_charge_diff = VaspChargeDensity(filename=None)
vasp_charge_diff.atoms = [atoms1]
vasp_charge_diff.chg = [chgdiff]

# Print out charge density
# --------------------------
# Check whether CHGDIFF exists
if os.path.isfile("./CHGDIFF"):
    print "\n**WARNING: A file called CHGDIFF already exists in this directory."
    yesno = raw_input("Type y to continue and overwrite it, any other key to stop\n")
    if yesno != "y":
        sys.exit(0)


print "Writing density difference data to file CHGDIFF ...",
sys.stdout.flush()
vasp_charge_diff.write(filename="CHGDIFF", format="chgcar")
print "done."

endtime = time.clock()
runtime = endtime - starttime
print "\nEnd of calculation."
print "Program was running for %.2f seconds." % runtime
示例#3
0
if chg1.is_spin_polarized():
    print 'Spin polarized'

    for i, cd in enumerate(chg1.chgdiff):
        cd2 = chg2.chgdiff[i]
        if op == '+':
            nd = cd + cd2
        elif op == '-':
            nd = cd - cd2
        elif op == '*':
            nd = cd * cd2
        elif op == '/':
            nd = cd / cd2
        elif op == 'avg':
            nd = (cd + cd2) / 2
        newchg.chgdiff.append(nd)

# Screw doing anything fancy with the augmentation charges
# Just take them from the same file as the embedded atoms object.
newchg.aug = chga.aug
newchg.augdiff = chga.augdiff

if options.outfile:
    fname = options.outfile
else:
    from os.path import basename
    fname = basename(chgf1) + oplong + basename(chgf2)

newchg.write(fname)
示例#4
0
zero = raw_input(
    "Set negative values of the added charge density to zero (Yes/No): ")

vasp_charge_add = VaspChargeDensity(filename=None)
vasp_charge_add.atoms = [
    atoms1,
]
vasp_charge_add.chg = [
    chgadd,
]

# Print out charge density
#--------------------------
# Check whether CHGADD exists
if os.path.isfile("./CHGADD"):
    print "\n**WARNING: A file called CHGADD already exists in this directory."
    yesno = raw_input(
        "Type y to continue and overwrite it, any other key to stop\n")
    if yesno != "y":
        sys.exit(0)

print "Writing added density data to file CHGADD ...",
sys.stdout.flush()
vasp_charge_add.write(filename="CHGADD", format="chgcar")
print "done."

endtime = time.clock()
runtime = endtime - starttime
print "\nEnd of calculation."
print "Program was running for %.2f seconds." % runtime
示例#5
0
#----------------------------------------
parchg_up = (parchg_sum+parchg_diff)/2.

# Calculate down spin density (sum-diff)/2
#----------------------------------------
parchg_down = (parchg_sum-parchg_diff)/2.

# Write out parchg files
#------------------------
parchgfile = PARCHGfile + ".UP"
print "Writing up spin data to file %s..." % parchgfile,
sys.stdout.flush()
output_charge_data = VaspChargeDensity(filename=None)
output_charge_data.atoms=[geomdata,]
output_charge_data.chg=[parchg_up,]
output_charge_data.write(filename=parchgfile,format="chgcar")
print "done."

parchgfile = PARCHGfile + ".DOWN"
print "Writing down spin data to file %s..." % parchgfile,
sys.stdout.flush()
output_charge_data = VaspChargeDensity(filename=None)
output_charge_data.atoms=[geomdata,]
output_charge_data.chg=[parchg_down,]
output_charge_data.write(filename=parchgfile,format="chgcar")
print "done."

parchgfile = PARCHGfile + ".DIFF"
print "Writing up-down spin data to file %s..." % parchgfile,
sys.stdout.flush()
output_charge_data = VaspChargeDensity(filename=None)
def chgarith(chgf1, chgf2, op, filename, wcell):

    # chgf1 = args[0]
    # chgf2 = args[2]
    # op = args[1]

    chg1 = VaspChargeDensity(chgf1)
    chg2 = VaspChargeDensity(chgf2)

    # if options.wcell:
    #     wcell = int(options.wcell)
    if wcell == 0:
        chga = chg1
    elif wcell == 1:
        chga = chg2
    #     else:
    #         print ('Error, invalid argument to -w option')
    #         sys.exit(1)
    # else:
    # chga = chg1

    if len(chg1.chg) != len(chg2.chg):
        print(
            'Number of images in charge density files not equal. Using just   the final images in both files.'
        )
        print('len(chg.chg)', len(chg1.chg), len(chg2.chg))
        chg1.chg = [chg1.chg[-1]]
        chg1.atoms = [chg1.atoms[-1]]
        if chg1.is_spin_polarized():
            chg1.chgdiff = [chg1.chgdiff[-1]]
            chg2.chgdiff = [chg2.chgdiff[-1]]
        chg2.chg = [chg2.chg[-1]]
        chg2.atoms = [chg2.atoms[-1]]

    newchg = VaspChargeDensity(None)

    print('Start charge manipul')

    for i, atchg in enumerate(chg1.chg):
        c1 = atchg
        c2 = chg2.chg[i]
        newchg.atoms.append(chga.atoms[i].copy())
        if op == '+':
            nc = c1 + c2
            oplong = '_add_'
        elif op == '-':
            nc = c1 - c2
            oplong = '_sub_'
        elif op == '*':
            nc = c1 * c2
            oplong = '_mult_'
        elif op == '/':
            nc = c1 / c2
            oplong = '_div_'
        elif op == 'avg':
            nc = (c1 + c2) / 2
            oplong = '_avg_'
        newchg.chg.append(nc)

    if chg1.is_spin_polarized():
        print('Spin polarized')

        for i, cd in enumerate(chg1.chgdiff):
            cd2 = chg2.chgdiff[i]
            if op == '+':
                nd = cd + cd2
            elif op == '-':
                nd = cd - cd2
            elif op == '*':
                nd = cd * cd2
            elif op == '/':
                nd = cd / cd2
            elif op == 'avg':
                nd = (cd + cd2) / 2
            newchg.chgdiff.append(nd)

    # Screw doing anything fancy with the augmentation charges
    # Just take them from the same file as the embedded atoms object.
    newchg.aug = chga.aug
    newchg.augdiff = chga.augdiff

    # if options.outfile:
    #     fname = options.outfile
    # else:
    #     from os.path import basename
    #     fname = basename(chgf1) + oplong + basename(chgf2)

    newchg.write(filename)

    return filename
示例#7
0
    chgdiff = chgdiff - chg2
    print "done."

vasp_charge_diff = VaspChargeDensity(filename=None)
vasp_charge_diff.atoms = [
    atoms1,
]
vasp_charge_diff.chg = [
    chgdiff,
]

# Print out charge density
#--------------------------
# Check whether CHGDIFF exists
if os.path.isfile("./CHGDIFF"):
    print "\n**WARNING: A file called CHGDIFF already exists in this directory."
    yesno = raw_input(
        "Type y to continue and overwrite it, any other key to stop\n")
    if yesno != "y":
        sys.exit(0)

print "Writing density difference data to file CHGDIFF ...",
sys.stdout.flush()
vasp_charge_diff.write(filename="CHGDIFF", format="chgcar")
print "done."

endtime = time.clock()
runtime = endtime - starttime
print "\nEnd of calculation."
print "Program was running for %.2f seconds." % runtime
示例#8
0
    # Add charge density
    #-----------------
    chgadd += chg2
    print "done." 

zero = raw_input("Set negative values of the added charge density to zero (Yes/No): ")

vasp_charge_add = VaspChargeDensity(filename=None)
vasp_charge_add.atoms=[atoms1,]
vasp_charge_add.chg=[chgadd,] 

# Print out charge density
#--------------------------
# Check whether CHGADD exists
if os.path.isfile("./CHGADD"):
   print "\n**WARNING: A file called CHGADD already exists in this directory."
   yesno=raw_input("Type y to continue and overwrite it, any other key to stop\n")
   if yesno!="y":
      sys.exit(0)


print "Writing added density data to file CHGADD ...", 
sys.stdout.flush()
vasp_charge_add.write(filename="CHGADD",format="chgcar")
print "done."

endtime = time.clock() 
runtime = endtime-starttime
print "\nEnd of calculation." 
print "Program was running for %.2f seconds." % runtime
示例#9
0
        field *= x

    if (options.plus != None):
        plus = options.plus
        field += plus
        print plus, min(field), max(field)
#        for i,x in enumerate(field):
#            for j,y in enumerate(x):
#                for k,z in enumerate(y):
#                    field[i][j][k] += plus
#        print field.shape
#        field = field +

####### WRITEING THE FILE #############
    if (oformat == "xsf"):
        #        write_xsf(sys.stdout,field[1],field[0])
        write_xsf(sys.stdout, atoms, field)
    elif (oformat == "cube"):
        #        print "Warrning: Third line should contain number of atoms together with position of the origin of the volumetric data."
        #        print "Warrning: Make sure it contain corrrect data."
        write_cube(sys.stdout, atoms, field)
    elif (oformat == "locpot"):
        locpot_out = VaspChargeDensity(filename=None)
        locpot_out.atoms = [
            atoms,
        ]
        locpot_out.chg = [
            field,
        ]
        locpot_out.write(filename=sys.argv[num - 1] + ".out", format="chgcar")