File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -814,12 +814,19 @@ def density(
814814 csrDM = csr .tocsr (dim = 0 )
815815
816816 if method == "pre-compute" :
817- # Compute orbital values on the grid
818- psi_values = uc_dm .geometry ._orbital_values (grid .shape )
817+ try :
818+ # Compute orbital values on the grid
819+ psi_values = uc_dm .geometry ._orbital_values (grid .shape )
819820
820- psi_values .reduce_orbital_products (
821- csrDM , uc_dm .lattice , out = grid .grid , ** kwargs
822- )
821+ psi_values .reduce_orbital_products (
822+ csrDM , uc_dm .lattice , out = grid .grid , ** kwargs
823+ )
824+ except MemoryError :
825+ raise MemoryError (
826+ "Ran out of memory while computing the density with the 'pre-compute'"
827+ " method. Try using method='direct', which is slower but requires much"
828+ " less memory."
829+ )
823830 elif method == "direct" :
824831 self ._density_direct (grid , csrDM , atol = atol , eta = eta )
825832
You can’t perform that action at this time.
0 commit comments