Skip to content

Commit c2918e4

Browse files
committed
option for reduced form box vectors
1 parent 3972897 commit c2918e4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

moleculekit/unitcell.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
##############################################################################
3131

3232

33-
def lengths_and_angles_to_box_vectors(a_length, b_length, c_length, alpha, beta, gamma):
33+
def lengths_and_angles_to_box_vectors(
34+
a_length, b_length, c_length, alpha, beta, gamma, reduced=False
35+
):
3436
"""Convert from the lengths/angles of the unit cell to the box
3537
vectors (Bravais vectors). The angles should be in degrees.
3638
@@ -106,6 +108,12 @@ def lengths_and_angles_to_box_vectors(a_length, b_length, c_length, alpha, beta,
106108
b[np.logical_and(b > -tol, b < tol)] = 0.0
107109
c[np.logical_and(c > -tol, c < tol)] = 0.0
108110

111+
if reduced:
112+
# Make sure they're in the reduced form required by OpenMM.
113+
c = c - b * np.round(c[1] / b[1])
114+
c = c - a * np.round(c[0] / a[0])
115+
b = b - a * np.round(b[0] / a[0])
116+
109117
return a.T, b.T, c.T
110118

111119

0 commit comments

Comments
 (0)