Exemplo n.º 1
0
    def load(self):
        "Rewrite load method"
        PosCar.load(self)
        with open(self.filename, 'r') as f:
            for i in range(self.totline):
                f.readline()
            #get dimension of 3d array
            grid = f.readline().strip(whitespace)
            empty = not grid  # empty row
            while empty:
                grid = f.readline().strip(whitespace)
                empty = not grid
            x, y, z = line2list(grid, dtype=int)
            #read electron localization function data
            elf_data = []
            for line in f:
                datalist = line2list(line)
                elf_data.extend(datalist)
        #########################################
        #                                       #
        #           !!! Notice !!!              #
        # NGX is the length of the **0th** axis #
        # NGY is the length of the **1st** axis #
        # NGZ is the length of the **2nd** axis #
        #                                       #
        #########################################
        #reshape to 3d array
        elf_data = np.array(elf_data).reshape((x, y, z), order='F')
        #set attrs
        self.grid = x, y, z
        self.elf_data = elf_data

        return
Exemplo n.º 2
0
    def load(self):
        "Rewrite load method"
        PosCar.load(self)
        with open(self.filename, 'r') as f:
            for i in range(self.totline):
                f.readline()
            #get dimension of 3d array
            grid = f.readline().strip(whitespace)
            empty = not grid  # empty row
            while empty:
                grid = f.readline().strip(whitespace)
                empty = not grid
            x, y, z = line2list(grid, dtype=int)
            #read electron localization function data
            elf_data = []
            for line in f:
                datalist = line2list(line)
                elf_data.extend(datalist)
        #########################################
        #                                       #
        #           !!! Notice !!!              #
        # NGX is the length of the **0th** axis #
        # NGY is the length of the **1st** axis #
        # NGZ is the length of the **2nd** axis #
        #                                       #
        #########################################
        #reshape to 3d array
        elf_data = np.array(elf_data).reshape((x, y, z), order='F')
        #set attrs
        self.grid = x, y, z
        self.elf_data = elf_data

        return
Exemplo n.º 3
0
    def test_get_poscar_content(self):
        " Make sure we can get the correct poscar content. "
        poscar = PosCar(self.filename)

        ref_content = """Created by VASPy\n 1.000000000\n    7.29321435   -4.21073927    0.00000000\n    0.00000000    8.42147853    0.00000000\n   -0.00000000    0.00000000   16.87610843\n   Pt\n   36\nSelective Dynamics\nDirect\n    0.244666665792    0.223999996980    0.135815443038 F    F    F    \n    0.022444443570    0.112888885869    0.271630886077 T    T    T    \n    0.133555554681    0.001777774758    0.000000000000 F    F    F    \n    0.133555554681    0.001777774758    0.407446329115 T    T    T    \n    0.577999999126    0.223999996980    0.135815443038 F    F    F    \n    0.355777776904    0.112888885869    0.271630886077 T    T    T    \n    0.466888888015    0.001777774758    0.000000000000 F    F    F    \n    0.466888888015    0.001777774758    0.407446329115 T    T    T    \n    0.911333332459    0.223999996980    0.135815443038 F    F    F    \n    0.689111110237    0.112888885869    0.271630886077 T    T    T    \n    0.800222221348    0.001777774758    0.000000000000 F    F    F    \n    0.800222221348    0.001777774758    0.407446329115 T    T    T    \n    0.244666665792    0.557333330313    0.135815443038 F    F    F    \n    0.022444443570    0.446222219202    0.271630886077 T    T    T    \n    0.133555554681    0.335111108091    0.000000000000 F    F    F    \n    0.133555554681    0.335111108091    0.407446329115 T    T    T    \n    0.577999999126    0.557333330313    0.135815443038 F    F    F    \n    0.355777776904    0.446222219202    0.271630886077 T    T    T    \n    0.466888888015    0.335111108091    0.000000000000 F    F    F    \n    0.466888888015    0.335111108091    0.407446329115 T    T    T    \n    0.911333332459    0.557333330313    0.135815443038 F    F    F    \n    0.689111110237    0.446222219202    0.271630886077 T    T    T    \n    0.800222221348    0.335111108091    0.000000000000 F    F    F    \n    0.800222221348    0.335111108091    0.407446329115 T    T    T    \n    0.244666665792    0.890666663647    0.135815443038 F    F    F    \n    0.022444443570    0.779555552536    0.271630886077 T    T    T    \n    0.133555554681    0.668444441424    0.000000000000 F    F    F    \n    0.133555554681    0.668444441424    0.407446329115 T    T    T    \n    0.577999999126    0.890666663647    0.135815443038 F    F    F    \n    0.355777776904    0.779555552536    0.271630886077 T    T    T    \n    0.466888888015    0.668444441424    0.000000000000 F    F    F    \n    0.466888888015    0.668444441424    0.407446329115 T    T    T    \n    0.911333332459    0.890666663647    0.135815443038 F    F    F    \n    0.689111110237    0.779555552536    0.271630886077 T    T    T    \n    0.800222221348    0.668444441424    0.000000000000 F    F    F    \n    0.800222221348    0.668444441424    0.407446329115 T    T    T    \n"""

        ret_content = poscar.get_poscar_content()

        self.assertEqual(ref_content, ret_content)
Exemplo n.º 4
0
import numpy as np

from vaspy.atomco import XyzFile, PosCar
from vaspy.functions import str2list


class ContinueError(Exception):
    pass

if len(sys.argv) != 2:
    print 'Usage: %s *.xyz' % sys.argv[0]
    exit(1)
filename = sys.argv[1]

a = XyzFile(filename=filename)
b = PosCar(filename='POSCAR')
#create new dir
if not os.path.exists('./continue'):
    os.mkdir('./continue')
if os.path.isfile('./fort.188'):
    fail = os.system("cp INCAR POTCAR KPOINTS fort.188 vasp.script ./continue")
else:
    fail = os.system("cp INCAR POTCAR KPOINTS vasp.script ./continue")

if not fail:
    #new fort.188
    #change distance of 2 atoms
    with open('./continue/fort.188', 'r') as f:
        content_list = f.readlines()
    m, n, distance = str2list(content_list[5])  # atom number and distance
    x = a.data[int(m)-1, :]  # atom coordinates
Exemplo n.º 5
0
from vaspy.matstudio import XsdFile
from vaspy.functions import str2list

_logger = logging.getLogger("vaspy.script")

# Set arguments parser.
parser = argparse.ArgumentParser()
parser.add_argument("--xsd",
                    help="create MaterStudio .xsd file",
                    action="store_true")
args = parser.parse_args()

outcar = OutCar()
poses, forces = outcar.forces(-1)

poscar = PosCar()
tfs = poscar.tf

incar = InCar()
#print(incar.paras)
EDIFFG = incar.get_pvalue('EDIFFG')
#EDIFFG = 0.05

bad_ids = []
max_idx = [-1, -1, -1]
max_force = [0., 0., 0.]
for i, (pos, force, tf) in enumerate(zip(poses, forces, tfs)):
    for j, (c, f) in enumerate(zip(tf, force)):
        if c == 'T':
            if np.fabs(f) >= max_force[j]:
                max_idx[j] = i
Exemplo n.º 6
0
from vaspy.atomco import XyzFile, PosCar
from vaspy.functions import str2list


class ContinueError(Exception):
    pass


if len(sys.argv) != 2:
    print 'Usage: %s *.xyz' % sys.argv[0]
    exit(1)
filename = sys.argv[1]

a = XyzFile(filename=filename)
b = PosCar(filename='POSCAR')
#create new dir
if not os.path.exists('./continue'):
    os.mkdir('./continue')
if os.path.isfile('./fort.188'):
    fail = os.system("cp INCAR POTCAR KPOINTS fort.188 vasp.script ./continue")
else:
    fail = os.system("cp INCAR POTCAR KPOINTS vasp.script ./continue")

if not fail:
    #new fort.188
    #change distance of 2 atoms
    with open('./continue/fort.188', 'r') as f:
        content_list = f.readlines()
    m, n, distance = str2list(content_list[5])  # atom number and distance
    x = a.data[int(m) - 1, :]  # atom coordinates