Skip to content

Commit

Permalink
Removed old eigh functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
jackbaker1001 committed Sep 8, 2023
1 parent a18d5da commit 487ef3d
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions grad_dft/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from dataclasses import fields
from grad_dft.utils import Array, Scalar, PyTree, vmap_chunked
from functools import partial
from grad_dft.utils.eigenproblem import safe_general_eigh

from jax import numpy as jnp
from jax import scipy as jsp
Expand Down Expand Up @@ -565,27 +564,9 @@ def chunked_jvp(chi_tensor, gr_tensor, ao_tensor):

return (jax.jit(chunked_jvp)(chi.transpose(3, 0, 1, 2), gr, ao)).transpose(1, 2, 3, 0)


def eig(h, x):
e0, c0 = eigh2d(h[0], x)
e1, c1 = eigh2d(h[1], x)
return jnp.stack((e0, e1), axis=0), jnp.stack((c0, c1), axis=0)

def abs_clip(arr, threshold):
return jnp.where(jnp.abs(arr) > threshold, arr, 0)

def general_eigh(A, B):
L = jnp.linalg.cholesky(B)
L_inv = jnp.linalg.inv(L)
C = L_inv @ A @ L_inv.T
C = abs_clip(C, 1e-20)
eigenvalues, eigenvectors_transformed = jnp.linalg.eigh(C)
# eigenvalues, eigenvectors_transformed = jsp.linalg.eigh(C)
eigenvectors_original = L_inv.T @ eigenvectors_transformed
eigenvectors_original = abs_clip(eigenvectors_original, 1e-20)
eigenvalues = abs_clip(eigenvalues, 1e-20)
return eigenvalues, eigenvectors_original


######################################################################

Expand Down

0 comments on commit 487ef3d

Please sign in to comment.