Skip to content

Commit b3e4d83

Browse files
committed
respond to rhys and curtis PRs
1 parent 5cc3069 commit b3e4d83

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

torch_sim/autobatching.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,11 @@ def calculate_memory_scaler(
367367
volume = torch.abs(torch.linalg.det(state.cell[0])) / 1000
368368
else:
369369
bbox = state.positions.max(dim=0).values - state.positions.min(dim=0).values
370-
volume = bbox.clamp(min=2.0).prod() / 1000 # min 1 Å for planar molecules
370+
# add 2 A in non-periodic directions to account for 2D systems and slabs
371+
for i, periodic in enumerate(state.pbc):
372+
if not periodic:
373+
bbox[i] += 2.0
374+
volume = bbox.prod() / 1000 # convert A^3 to nm^3
371375
number_density = state.n_atoms / volume.item()
372376
return state.n_atoms * number_density
373377
raise ValueError(

0 commit comments

Comments
 (0)