Skip to content

Commit 5c29935

Browse files
committed
Add warning and improve docstrings for build_*_lattice functions
1 parent 7246297 commit 5c29935

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/tinyff/atomsmithy.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# --
1919
"""Tools to build initial atomic positions."""
2020

21+
import warnings
22+
2123
import numpy as np
2224
from numpy.typing import ArrayLike, NDArray
2325
from scipy.optimize import minimize
@@ -45,14 +47,20 @@ def build_general_cubic_lattice(prim_frpos: ArrayLike, prim_length: float, nrep:
4547
prim_length
4648
The length of a primitive cubic cell edge.
4749
nrep
48-
The number of times to repeat the primitive cell
49-
(in three directions).
50+
The number of times to repeat the primitive cell along each dimension.
51+
The primitive cell will thus be repeated `nrep**3` times.
5052
5153
Returns
5254
-------
5355
atpos
5456
Atomic positions, array with shape (natom, 3).
5557
"""
58+
if nrep > 30:
59+
warnings.warn(
60+
f"With nrep = {nrep}, the primitive cell is repeated nrep**3 = {nrep**3} times, "
61+
"which potentially causes memory issues.",
62+
stacklevel=3,
63+
)
5664
prim_frpos = np.asarray(prim_frpos)
5765
if prim_frpos.ndim != 2:
5866
raise TypeError("prim_frpos must be a 2D array")

0 commit comments

Comments
 (0)