We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5cc3069 commit b3e4d83Copy full SHA for b3e4d83
torch_sim/autobatching.py
@@ -367,7 +367,11 @@ def calculate_memory_scaler(
367
volume = torch.abs(torch.linalg.det(state.cell[0])) / 1000
368
else:
369
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
+ # 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
375
number_density = state.n_atoms / volume.item()
376
return state.n_atoms * number_density
377
raise ValueError(
0 commit comments