Skip to content

Commit

Permalink
Merge pull request #796 from pfebrer/patch-9
Browse files Browse the repository at this point in the history
Clarify out of memory error on density
  • Loading branch information
zerothi authored Jun 20, 2024
2 parents 3979468 + c2c8aa0 commit b0feb0c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/sisl/physics/densitymatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,12 +814,19 @@ def density(
csrDM = csr.tocsr(dim=0)

if method == "pre-compute":
# Compute orbital values on the grid
psi_values = uc_dm.geometry._orbital_values(grid.shape)
try:
# Compute orbital values on the grid
psi_values = uc_dm.geometry._orbital_values(grid.shape)

psi_values.reduce_orbital_products(
csrDM, uc_dm.lattice, out=grid.grid, **kwargs
)
psi_values.reduce_orbital_products(
csrDM, uc_dm.lattice, out=grid.grid, **kwargs
)
except MemoryError:
raise MemoryError(
"Ran out of memory while computing the density with the 'pre-compute'"
" method. Try using method='direct', which is slower but requires much"
" less memory."
)
elif method == "direct":
self._density_direct(grid, csrDM, atol=atol, eta=eta)

Expand Down

0 comments on commit b0feb0c

Please sign in to comment.