forked from deepmodeling/dpgen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
2,766 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Mo2 | ||
1.0000000000000000 | ||
3.1623672675177916 -0.0000000000000000 -0.0000000000000000 | ||
-0.0000000000000000 3.1623672675177916 -0.0000000000000000 | ||
0.0000000000000000 0.0000000000000000 3.1623672675177916 | ||
Mo | ||
2 | ||
Direct | ||
0.0000000000000000 0.0000000000000000 0.0000000000000000 | ||
0.5000000000000000 0.5000000000000000 0.5000000000000000 | ||
|
||
0.00000000E+00 0.00000000E+00 0.00000000E+00 | ||
0.00000000E+00 0.00000000E+00 0.00000000E+00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Mo2 | ||
1.0 | ||
3.1617699325125632e+00 0.0000000000000000e+00 0.0000000000000000e+00 | ||
-2.9607253805968378e-17 3.1617699325125632e+00 0.0000000000000000e+00 | ||
-6.1517551630255350e-18 -4.3742379676789617e-17 3.1617699325125632e+00 | ||
Mo | ||
2 | ||
Cartesian | ||
0.0000000000 0.0000000000 0.0000000000 | ||
1.5808849663 1.5808849663 1.5808849663 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import os, sys, json, glob, shutil | ||
import dpdata | ||
import numpy as np | ||
import unittest | ||
import dpdata | ||
|
||
from monty.serialization import loadfn, dumpfn | ||
from pymatgen.core.structure import Structure | ||
from pymatgen.core.surface import SlabGenerator | ||
from pymatgen.io.vasp import Incar | ||
from pymatgen.io.ase import AseAtomsAdaptor | ||
from ase.lattice.cubic import BodyCenteredCubic as bcc | ||
from ase.lattice.cubic import FaceCenteredCubic as fcc | ||
from ase.lattice.hexagonal import HexagonalClosedPacked as hcp | ||
|
||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | ||
__package__ = 'auto_test' | ||
|
||
from .context import make_kspacing_kpoints | ||
from .context import setUpModule | ||
|
||
from dpgen.auto_test.Gamma import Gamma | ||
|
||
class TestGamma(unittest.TestCase): | ||
|
||
def setUp(self): | ||
_jdata = { | ||
"structures": ["confs/hp-Mo"], | ||
"interaction": { | ||
"type": "vasp", | ||
"incar": "vasp_input/INCAR_Mo", | ||
"potcar_prefix": "vasp_input", | ||
"potcars": {"Mo": "POTCAR_Mo"} | ||
}, | ||
"properties": [ | ||
{ | ||
"type": "gamma", | ||
"lattice_type": "bcc", | ||
"miller_index": [1, 1, 0], | ||
"displace_direction": [1, 1, 1], | ||
"min_supercell_size": [1, 1, 10], | ||
"min_vacuum_size": 10, | ||
"add_fix": ["true", "true", "false"], | ||
"n_steps": 20 | ||
} | ||
] | ||
} | ||
|
||
self.equi_path = 'confs/hp-Mo/relaxation/relax_task' | ||
self.source_path = 'equi/vasp' | ||
self.target_path = 'confs/hp-Mo/gamma_00' | ||
if not os.path.exists(self.equi_path): | ||
os.makedirs(self.equi_path) | ||
if not os.path.exists(self.target_path): | ||
os.makedirs(self.target_path) | ||
|
||
self.confs = _jdata["structures"] | ||
self.inter_param = _jdata["interaction"] | ||
self.prop_param = _jdata['properties'] | ||
|
||
self.gamma = Gamma(_jdata['properties'][0]) | ||
|
||
def tearDown(self): | ||
if os.path.exists(self.equi_path): | ||
shutil.rmtree(self.equi_path) | ||
if os.path.exists(self.target_path): | ||
shutil.rmtree(self.target_path) | ||
|
||
def test_task_type(self): | ||
self.assertEqual('gamma', self.gamma.task_type()) | ||
|
||
def test_task_param(self): | ||
self.assertEqual(self.prop_param[0], self.gamma.task_param()) | ||
|
||
def test_make_confs_bcc(self): | ||
if not os.path.exists(os.path.join(self.equi_path, 'CONTCAR')): | ||
with self.assertRaises(RuntimeError): | ||
self.gamma.make_confs(self.target_path, self.equi_path) | ||
shutil.copy(os.path.join(self.source_path, 'CONTCAR_Mo_bcc'), os.path.join(self.equi_path, 'CONTCAR')) | ||
task_list = self.gamma.make_confs(self.target_path, self.equi_path) | ||
dfm_dirs = glob.glob(os.path.join(self.target_path, 'task.*')) | ||
self.assertEqual(len(dfm_dirs), self.gamma.n_steps+1) | ||
|
||
incar0 = Incar.from_file(os.path.join('vasp_input', 'INCAR.rlx')) | ||
incar0['ISIF'] = 4 | ||
|
||
self.assertEqual(os.path.realpath(os.path.join(self.equi_path, 'CONTCAR')), | ||
os.path.realpath(os.path.join(self.target_path, 'POSCAR'))) | ||
ref_st = Structure.from_file(os.path.join(self.target_path, 'POSCAR')) | ||
dfm_dirs.sort() | ||
for ii in dfm_dirs: | ||
st_file = os.path.join(ii, 'POSCAR') | ||
self.assertTrue(os.path.isfile(st_file)) | ||
st0 = Structure.from_file(st_file) | ||
st1_file = os.path.join(ii, 'POSCAR.tmp') | ||
self.assertTrue(os.path.isfile(st1_file)) | ||
st1 = Structure.from_file(st1_file) | ||
with open(st1_file, mode='r') as f: | ||
z_coord_str = f.readlines()[-1].split()[-2] | ||
z_coord = float(z_coord_str) | ||
self.assertTrue(z_coord <= 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#Parameters | ||
SYSTEM = Mo_hcp | ||
PREC = Accurate | ||
ISTART = 0 | ||
ICHARG = 2 | ||
#Electronic Relaxation | ||
ENCUT = 800 # test | ||
NELM = 100 | ||
NELMIN = 6 | ||
NELMDL = -5 | ||
EDIFF = 1e-06 # test | ||
LREAL = False | ||
ALGO = Normal # or normal | ||
#Ionic relaxation | ||
IBRION = 2 | ||
#POTIM = 0.3 | ||
ISIF = 3 | ||
EDIFFG = -0.01 # test | ||
#ISYM = 0 | ||
NSW = 100 | ||
ISMEAR = 1 | ||
SIGMA = 0.1 # test | ||
# Write flags | ||
LWAVE = False | ||
LCHARG = False | ||
#parallel related | ||
#KPAR = 16 | ||
NPAR = 4 | ||
#KPAR = 1 | ||
KSPACING = 0.1 # test | ||
KGAMMA = False | ||
|
||
PSTRESS = 0.0 |
Oops, something went wrong.