示例#1
0
    def __init__(self, filename="OUTCAR", poscar="POSCAR"):
        """
        Create a OUTCAR file class.

        Parameters:
        -----------
        filename: File name of OUTCAR, default name is "OUTCAR"(OUTCAR in current path).

        poscar: File name of POSCAR, default value is "POSCAR"(POSCAR in current path).

        Example:

        >>> a = OutCar(filename='OUTCAR', poscar="POSCAR")

        Class attributes descriptions
        =================================================================
          Attribute           Description
          ===============    ============================================
          filename            string, name of OUTCAR file
          max_forces          list of float, 每个离子步迭代的最大原子受力
          last_max_force      float, 最后一步的最大原子受力
          last_max_atom       int, 最后一步受力最大原子序号
          zpe                 float, 零点能
          freq_types          list of str, 频率类型列表
          ===============    ============================================
        """
        VasPy.__init__(self, filename)

        # Get PosCar object.
        self.poscar = PosCar(poscar)

        # Check parameter validity.
        self.__check()
示例#2
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)
示例#3
0
    def test_get_xyz_content(self):
        " Make sure we can get correct xyz file content from poscar. "
        filename = path + "/POSCAR"
        poscar = PosCar(filename)

        ref_content = """          36\nSTEP =        1\nPt   0.244666665792   0.22399999698  0.135815443038\nPt    0.02244444357  0.112888885869  0.271630886077\nPt   0.133555554681  0.001777774758             0.0\nPt   0.133555554681  0.001777774758  0.407446329115\nPt   0.577999999126   0.22399999698  0.135815443038\nPt   0.355777776904  0.112888885869  0.271630886077\nPt   0.466888888015  0.001777774758             0.0\nPt   0.466888888015  0.001777774758  0.407446329115\nPt   0.911333332459   0.22399999698  0.135815443038\nPt   0.689111110237  0.112888885869  0.271630886077\nPt   0.800222221348  0.001777774758             0.0\nPt   0.800222221348  0.001777774758  0.407446329115\nPt   0.244666665792  0.557333330313  0.135815443038\nPt    0.02244444357  0.446222219202  0.271630886077\nPt   0.133555554681  0.335111108091             0.0\nPt   0.133555554681  0.335111108091  0.407446329115\nPt   0.577999999126  0.557333330313  0.135815443038\nPt   0.355777776904  0.446222219202  0.271630886077\nPt   0.466888888015  0.335111108091             0.0\nPt   0.466888888015  0.335111108091  0.407446329115\nPt   0.911333332459  0.557333330313  0.135815443038\nPt   0.689111110237  0.446222219202  0.271630886077\nPt   0.800222221348  0.335111108091             0.0\nPt   0.800222221348  0.335111108091  0.407446329115\nPt   0.244666665792  0.890666663647  0.135815443038\nPt    0.02244444357  0.779555552536  0.271630886077\nPt   0.133555554681  0.668444441424             0.0\nPt   0.133555554681  0.668444441424  0.407446329115\nPt   0.577999999126  0.890666663647  0.135815443038\nPt   0.355777776904  0.779555552536  0.271630886077\nPt   0.466888888015  0.668444441424             0.0\nPt   0.466888888015  0.668444441424  0.407446329115\nPt   0.911333332459  0.890666663647  0.135815443038\nPt   0.689111110237  0.779555552536  0.271630886077\nPt   0.800222221348  0.668444441424             0.0\nPt   0.800222221348  0.668444441424  0.407446329115\n"""

        ret_content = poscar.get_xyz_content()

        self.assertEqual(ref_content, ret_content)
示例#4
0
    def test_add_atom(self):
        "Make sure we can add a new atom to current poscar. "
        poscar = PosCar(self.filename)
        ori_data = poscar.data
        ori_tf = poscar.tf

        poscar.add_atom('O', [0.5, 0.5, 0.5])

        self.assertListEqual(poscar.atom_types, ['Pt', 'O'])
        self.assertListEqual(poscar.atom_numbers, [36, 1])
        self.assertListEqual(ori_data.tolist() + [[0.5, 0.5, 0.5]],
                             poscar.data.tolist())
        self.assertListEqual(ori_tf.tolist() + [['T', 'T', 'T']],
                             poscar.tf.tolist())
示例#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
示例#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