Skip to content

Commit 3b7b4b8

Browse files
committed
updated
1 parent e8f7224 commit 3b7b4b8

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

mdapy/cell_opt.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,33 @@ def compute(self):
111111
lmp.commands_string(f"atom_style {self.atomic_style}")
112112
num_type = self.type_list.max()
113113
create_box = f"""
114-
region 1 block 0 1 0 1 0 1
114+
region 1 prism 0 1 0 1 0 1 0 0 0
115115
create_box {num_type} 1
116116
"""
117117
lmp.commands_string(create_box)
118-
lmp.reset_box(*self.to_lammps_box(self.box))
118+
pos = self.pos
119+
box = self.box
120+
if box[0, 1] != 0 or box[0, 2] != 0 or box[1, 2] != 0:
121+
old_box = box.copy()
122+
ax = np.linalg.norm(box[0])
123+
bx = box[1] @ (box[0] / ax)
124+
by = np.sqrt(np.linalg.norm(box[1]) ** 2 - bx**2)
125+
cx = box[2] @ (box[0] / ax)
126+
cy = (box[1] @ box[2] - bx * cx) / by
127+
cz = np.sqrt(np.linalg.norm(box[2]) ** 2 - cx**2 - cy**2)
128+
box = np.array([[ax, bx, cx], [0, by, cy], [0, 0, cz]]).T
129+
rotation = np.linalg.solve(old_box[:-1], box)
130+
pos = self.pos @ rotation
131+
box = np.r_[box, box[-1].reshape(1, -1)]
132+
# lmp.reset_box(*self.to_lammps_box(box))
133+
lo, hi, xy, xz, yz = self.to_lammps_box(box)
134+
lmp.commands_string(
135+
f"change_box all x final {lo[0]} {hi[0]} y final {lo[1]} {hi[1]} z final {lo[2]} {hi[2]} xy final {xy} xz final {xz} yz final {yz}"
136+
)
137+
119138
N = self.pos.shape[0]
120139
N_lmp = lmp.create_atoms(
121-
N, np.arange(1, N + 1), self.type_list, self.pos.flatten()
140+
N, np.arange(1, N + 1), self.type_list, pos.flatten()
122141
)
123142
assert N == N_lmp, "Wrong atom numbers."
124143

mdapy/system.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ def cal_phono_dispersion(
728728
labels,
729729
potential,
730730
elements_list,
731+
symprec=1e-5,
731732
replicate=None,
732733
):
733734
"""This function can be used to calculate the phono dispersion based on Phonopy (https://phonopy.github.io/phonopy/). We support NEP and
@@ -739,6 +740,7 @@ def cal_phono_dispersion(
739740
potential (BasePotential): base potential class defined in mdapy, which must including a compute method to calculate the energy, force, virial.
740741
elements_list (list[str]): element list, such as ['Al']
741742
pair_style (str, optional): pair style, selected in ['nep', 'eam/alloy']. Defaults to "eam/alloy".
743+
symprec (float): this is used to set geometric tolerance to find symmetry of crystal structure. Defaults to 1e-5.
742744
replicate (list, optional): replication to pos, such as [3, 3, 3]. If not given, we will replicate it exceeding 15 A per directions. Defaults to None.
743745
744746
Outputs:
@@ -761,6 +763,7 @@ def cal_phono_dispersion(
761763
self.box,
762764
elements_list,
763765
self.__data["type"].to_numpy(),
766+
symprec,
764767
replicate,
765768
)
766769
self.Phon.compute()

0 commit comments

Comments
 (0)