|
6 | 6 |
|
7 | 7 | import numpy as np |
8 | 8 | from monty.serialization import loadfn |
9 | | -from pymatgen.core import Structure |
| 9 | +from pymatgen.core import Lattice, Structure |
10 | 10 | from pymatgen.core.surface import SlabGenerator |
11 | 11 |
|
12 | 12 | sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) |
@@ -99,6 +99,35 @@ def test_make_confs_0(self): |
99 | 99 | # slb = sl.get_slab() |
100 | 100 | st2 = Structure(sl.lattice, sl.species, sl.frac_coords) |
101 | 101 | self.assertEqual(len(st1), len(st2)) |
| 102 | + |
| 103 | + def test_make_confs_with_c_vector_not_aligned_to_z(self): |
| 104 | + bcc_mo = Structure( |
| 105 | + Lattice.cubic(3.16), |
| 106 | + ["Mo", "Mo"], |
| 107 | + [[0, 0, 0], [0.5, 0.5, 0.5]], |
| 108 | + ) |
| 109 | + bcc_mo.to(filename=os.path.join(self.equi_path, "CONTCAR"), fmt="poscar") |
| 110 | + parameter = { |
| 111 | + "type": "decohesive", |
| 112 | + "min_slab_size": 15, |
| 113 | + "max_vacuum_size": 1, |
| 114 | + "vacuum_size_step": 1, |
| 115 | + "miller_index": [1, 0, 0], |
| 116 | + "cal_type": "static", |
| 117 | + } |
| 118 | + |
| 119 | + tasks = Decohesive(parameter).make_confs(self.target_path, self.equi_path) |
| 120 | + zero_vacuum = Structure.from_file(os.path.join(tasks[0], "POSCAR.tmp")) |
| 121 | + one_angstrom_vacuum = Structure.from_file(os.path.join(tasks[1], "POSCAR.tmp")) |
| 122 | + |
| 123 | + self.assertTrue(np.isfinite(zero_vacuum.lattice.matrix).all()) |
| 124 | + self.assertTrue(np.isfinite(one_angstrom_vacuum.lattice.matrix).all()) |
| 125 | + self.assertAlmostEqual( |
| 126 | + np.linalg.norm(one_angstrom_vacuum.lattice.matrix[2]) |
| 127 | + - np.linalg.norm(zero_vacuum.lattice.matrix[2]), |
| 128 | + 1.0, |
| 129 | + places=8, |
| 130 | + ) |
102 | 131 |
|
103 | 132 | def __gen_slab_pmg(self, structure: Structure, |
104 | 133 | plane_miller, slab_size, vacuum_size) -> Structure: |
|
0 commit comments