Ejemplo n.º 1
0
    def test_make_confs_0(self):

        if not os.path.exists(os.path.join(self.equi_path, 'CONTCAR')):
            with self.assertRaises(RuntimeError):
                self.eos.make_confs(self.target_path, self.equi_path)
        shutil.copy(os.path.join(self.source_path, 'CONTCAR'),
                    os.path.join(self.equi_path, 'CONTCAR'))
        task_list = self.eos.make_confs(self.target_path, self.equi_path)
        dfm_dirs = glob.glob(os.path.join(self.target_path, 'task.*'))

        incar0 = Incar.from_file(os.path.join('vasp_input', 'INCAR.rlx'))
        incar0['ISIF'] = 4

        for ii in dfm_dirs:
            self.assertTrue(os.path.isfile(os.path.join(ii, 'POSCAR')))
            eos_json_file = os.path.join(ii, 'eos.json')
            self.assertTrue(os.path.isfile(eos_json_file))
            eos_json = loadfn(eos_json_file)
            self.assertEqual(
                os.path.realpath(os.path.join(ii, 'POSCAR.orig')),
                os.path.realpath(os.path.join(self.equi_path, 'CONTCAR')))
            sys = dpdata.System(os.path.join(ii, 'POSCAR'))
            natoms = sys.get_natoms()
            self.assertAlmostEqual(eos_json['volume'],
                                   np.linalg.det(sys['cells'][0]) / natoms)
Ejemplo n.º 2
0
    def test_post_fp_vasp_0(self):

        with open(param_file, 'r') as fp:
            jdata = json.load(fp)
        jdata['use_ele_temp'] = 2
        post_fp_vasp(0, jdata, rfailed=0.3)

        sys = dpdata.LabeledSystem('iter.000000/02.fp/data.000/',
                                   fmt='deepmd/raw')
        self.assertEqual(sys.get_nframes(), 2)

        if sys.data['coords'][0][1][0] < sys.data['coords'][1][1][0]:
            idx = [1, 0]
        else:
            idx = [0, 1]
        ref_coord = self.ref_coord[idx]
        ref_cell = self.ref_cell[idx]
        ref_e = self.ref_e[idx]
        ref_f = self.ref_f[idx]
        ref_v = self.ref_v[idx]
        ref_at = self.ref_at

        for ff in range(2):
            self.assertAlmostEqual(ref_e[ff], sys.data['energies'][ff])
        for ii in range(2):
            self.assertEqual(ref_at[ff], sys.data['atom_types'][ff])
        for ff in range(2):
            for ii in range(2):
                for dd in range(3):
                    self.assertAlmostEqual(ref_coord[ff][ii][dd],
                                           sys.data['coords'][ff][ii][dd])
                    self.assertAlmostEqual(ref_f[ff][ii][dd],
                                           sys.data['forces'][ff][ii][dd])
        for ff in range(2):
            for ii in range(3):
                for jj in range(3):
                    self.assertAlmostEqual(ref_v[ff][ii][jj],
                                           sys.data['virials'][ff][ii][jj],
                                           places=5)
                    self.assertAlmostEqual(ref_cell[ff][ii][jj],
                                           sys.data['cells'][ff][ii][jj])

        self.assertTrue(
            os.path.isfile('iter.000000/02.fp/data.000/set.000/aparam.npy'))
        aparam = np.load('iter.000000/02.fp/data.000/set.000/aparam.npy')
        natoms = sys.get_natoms()
        self.assertEqual(natoms, 2)
        self.assertEqual(list(list(aparam)[0]), [0, 0])
        self.assertEqual(list(list(aparam)[1]), [1, 1])
Ejemplo n.º 3
0
 def test_make_vasp_rlx_cell_shape (self):
     jdata = {
         'relax_incar' : 'vasp_input/INCAR.rlx',
         'potcar_map': {'Si': 'vasp_input/POTCAR' },
         'vol_start': 15,
         'vol_end':  25,
         'vol_step':  1.0,
         'eos_relax_cell_shape':  True,
     }
     make_vasp(jdata, 'confs/si/mp-149')
     
     target_path = '01.eos/si/mp-149/vasp-relax_incar'
     equi_path = '00.equi/si/mp-149/vasp-relax_incar'
     dfm_dirs = glob.glob(os.path.join(target_path, 'vol*'))
    
     # check root INCAR
     incar0 = Incar.from_file(os.path.join('vasp_input', 'INCAR.rlx'))
     incar1 = Incar.from_file(os.path.join(target_path, 'INCAR'))
     self.assertFalse(incar0 == incar1)
     incar0['ISIF'] = 4
     self.assertTrue(incar0 == incar1)
     # check root POTCAR
     with open(os.path.join('vasp_input', 'POTCAR')) as fp:
         pot0 = fp.read()
     with open(os.path.join(target_path, 'POTCAR')) as fp:
         pot1 = fp.read()
     self.assertEqual(pot0, pot1)
     # check subdir
     for ii in dfm_dirs:
         self.assertTrue(os.path.isfile(os.path.join(ii, 'KPOINTS')))
         self.assertEqual(os.path.realpath(os.path.join(ii, 'POSCAR.orig')),
                          os.path.realpath(os.path.join(equi_path, 'CONTCAR')))
         self.assertEqual(os.path.realpath(os.path.join(ii, 'INCAR')),
                          os.path.realpath(os.path.join(target_path, 'INCAR')))
         self.assertEqual(os.path.realpath(os.path.join(ii, 'POTCAR')),
                          os.path.realpath(os.path.join(target_path, 'POTCAR')))
         sys = dpdata.System(os.path.join(ii, 'POSCAR'))
         vol = float(ii.split('/')[-1].split('-')[1])
         natoms = sys.get_natoms()
         self.assertAlmostEqual(vol, np.linalg.det(sys['cells'][0]) / natoms)