Exemple #1
0
    # Now we need to add the symmetry vector * the strain.
    # For this, we need to identify which struct positions correspond
    # to which position in the posvec output by FROZSL,
    # and apply the corresponding symvec * strain.

    struct = Structure("POSCAR_X3-")
    
    for refposnum in range(len(struct.positions)):
        for posnum in range(len(posvec)):
            if vectorEqual(posvec[posnum], struct.positions[refposnum], 1e-4):
                print "Found the position to move."
                struct.positions[refposnum] = struct.positions[refposnum] + p4mat.Vector(symvec[posnum].tolist()) * strain
    print "New positions: "
    print struct.positions

    struct.write("POSCAR_"+name+"_u_"+repr(strain), newformat=0)

    if runflag:
        # run the calculation
        vaspcmd = 'mr vasp'

        os.system("cp POSCAR_"+name+"_u_"+repr(strain)+" POSCAR")
        os.system("more POSCAR")
        os.system(vaspcmd)
        os.system('cp vasprun.xml vasprun_'+name+'_u_'+repr(strain)+'.xml')
        os.system('cp OUTCAR OUTCAR_'+name+'_u_'+repr(strain))
        os.system('cp CHGCAR CHGCAR_'+name+'_u_'+repr(strain))
        currentrun = XMLSystemPM('vasprun.xml')
        currentenergy = currentrun.FREE_ENERGY
        os.system(" E=`tail -n 2 OSZICAR` ; echo " + ("%1.8g" % strain) + " $E  >> frozen_phonon.out")
        outfile.write(repr(strain)+' '+repr(currentenergy)+'\n')
    # For this, we need to identify which struct positions correspond
    # to which position in the posvec output by FROZSL,
    # and apply the corresponding symvec * strain.

    struct = Structure("POSCAR_X3-")

    for refposnum in range(len(struct.positions)):
        for posnum in range(len(posvec)):
            if vectorEqual(posvec[posnum], struct.positions[refposnum], 1e-4):
                print "Found the position to move."
                struct.positions[refposnum] = struct.positions[
                    refposnum] + p4mat.Vector(symvec[posnum].tolist()) * strain
    print "New positions: "
    print struct.positions

    struct.write("POSCAR_" + name + "_u_" + repr(strain), newformat=0)

    if runflag:
        # run the calculation
        vaspcmd = 'mr vasp'

        os.system("cp POSCAR_" + name + "_u_" + repr(strain) + " POSCAR")
        os.system("more POSCAR")
        os.system(vaspcmd)
        os.system('cp vasprun.xml vasprun_' + name + '_u_' + repr(strain) +
                  '.xml')
        os.system('cp OUTCAR OUTCAR_' + name + '_u_' + repr(strain))
        os.system('cp CHGCAR CHGCAR_' + name + '_u_' + repr(strain))
        currentrun = XMLSystemPM('vasprun.xml')
        currentenergy = currentrun.FREE_ENERGY
        os.system(" E=`tail -n 2 OSZICAR` ; echo " + ("%1.8g" % strain) +
Exemple #3
0
from p4vasp.db import *
from p4vasp.Structure import Structure
from sys import stdout

db = getDatabase()[0]
db.connect()
db.addUser()

path = "XDATCAR"
s = Structure(path)
s.write(stdout)
f = open(path)
for i in range(8):
    f.readline()  #Skip header

db.addRecord(keywords="MD,XDATCAR", name=s.comment)

step = 0
while 1:
    for i in range(len(s)):
        s[i] = map(float, f.readline().split())
    step += 1
    #s.write(stdout)
    db.storeStructure(s, step)
    if f.readline().strip() != "":
        break