Skip to content

Commit 42a0b1f

Browse files
committed
Add warning when cluster does not fit in Cage
1 parent c0d22c0 commit 42a0b1f

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

AtomPacker/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
the resulting structures.
1010
"""
1111

12-
__version__ = "0.5.1"
12+
__version__ = "0.5.2"
1313
__name__ = "AtomPacker"
1414
license = "GNU GPL-3.0 License"
1515

AtomPacker/structure/Cage.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,11 @@ def pack(
329329
ValueError
330330
If the cage is not loaded, cavity is not detected, or
331331
clashing_tolerance < 0.
332+
333+
Warns
334+
-----
335+
UserWarning
336+
If no atoms were packed inside the cavity.
332337
"""
333338
if self.universe is None:
334339
raise ValueError("No cage loaded. Please run load() first.")
@@ -397,8 +402,14 @@ def pack(
397402
verbose=verbose,
398403
)
399404

400-
# Create `AtomPacker.structure.Cluster` object
401-
self.cluster = Cluster(cluster=_cluster, cavity=self.cavity, log=log)
405+
if len(_cluster) > 0:
406+
# Create `AtomPacker.structure.Cluster` object
407+
self.cluster = Cluster(cluster=_cluster, cavity=self.cavity, log=log)
408+
else:
409+
warnings.warn(
410+
"No atoms were packed: the nanocluster does not fit \
411+
inside the cavity with the current parameters."
412+
)
402413

403414
def preview(
404415
self,

0 commit comments

Comments
 (0)