pauxy.utils package¶
Submodules¶
pauxy.utils.fft module¶
pauxy.utils.io module¶
-
pauxy.utils.io.get_input_value(inputs, key, default=0, alias=None, verbose=False)[source]¶ Helper routine to parse input options.
-
pauxy.utils.io.write_nomsd(fh5, wfn, uhf, nelec, thresh=1e-08, init=None)[source]¶ Write NOMSD to HDF.
Parameters: - fh5 (h5py group) – Wavefunction group to write to file.
- wfn (
numpy.ndarray) – NOMSD trial wavefunctions. - uhf (bool) – UHF style wavefunction.
- nelec (tuple) – Number of alpha and beta electrons.
- thresh (float) – Threshold for writing wavefunction elements.
-
pauxy.utils.io.write_nomsd_single(fh5, psi, idet)[source]¶ Write single component of NOMSD to hdf.
Parameters: - fh5 (h5py group) – Wavefunction group to write to file.
- psi (
scipy.sparse.csr_matrix) – Sparse representation of trial wavefunction. - idet (int) – Determinant number.
-
pauxy.utils.io.write_phmsd(fh5, occa, occb, nelec, norb, init=None)[source]¶ Write NOMSD to HDF.
Parameters: - fh5 (h5py group) – Wavefunction group to write to file.
- nelec (tuple) – Number of alpha and beta electrons.
-
pauxy.utils.io.write_qmcpack_dense(hcore, chol, nelec, nmo, enuc=0.0, filename='hamiltonian.h5', real_chol=True, verbose=False, ortho=None)[source]¶
pauxy.utils.linalg module¶
-
pauxy.utils.linalg.diagonalise_sorted(H)[source]¶ Diagonalise Hermitian matrix H and return sorted eigenvalues and vectors.
Eigenvalues are sorted as e_1 < e_2 < …. < e_N, where H is an NxN Hermitian matrix.
Parameters: H ( numpy.ndarray) – Hamiltonian matrix to be diagonalised.Returns: - eigs (
numpy.array) – Sorted eigenvalues - eigv (
numpy.array) – Sorted eigenvectors (same sorting as eigenvalues).
- eigs (
-
pauxy.utils.linalg.exponentiate_matrix(M, order=6)[source]¶ Taylor series approximation for matrix exponential
-
pauxy.utils.linalg.modified_cholesky(M, tol=1e-06, verbose=True, cmax=20)[source]¶ Modified cholesky decomposition of matrix.
See, e.g. [Motta17]
Parameters: - M (
numpy.ndarray) – Positive semi-definite, symmetric matrix. - tol (float) – Accuracy desired.
- verbose (bool) – If true print out convergence progress.
Returns: chol_vecs – Matrix of cholesky vectors.
Return type: - M (
-
pauxy.utils.linalg.regularise_matrix_inverse(A, cutoff=1e-10)[source]¶ Perform inverse of singular matrix.
First compute SVD of input matrix then add a tuneable cutoff which washes out elements whose singular values are close to zero.
Parameters: - A (class:numpy.array) – Input matrix.
- cutoff (float) – Cutoff parameter.
Returns: B – Regularised matrix inverse (pseudo-inverse).
Return type: class:numpy.array
-
pauxy.utils.linalg.reortho(A)[source]¶ Reorthogonalise a MxN matrix A.
Performs a QR decomposition of A. Note that for consistency elsewhere we want to preserve detR > 0 which is not guaranteed. We thus factor the signs of the diagonal of R into Q.
Parameters: A ( numpy.ndarray) – MxN matrix.Returns: - Q (
numpy.ndarray) – Orthogonal matrix. A = QR. - detR (float) – Determinant of upper triangular matrix (R) from QR decomposition.
- Q (
-
pauxy.utils.linalg.sherman_morrison(Ainv, u, vt)[source]¶ Sherman-Morrison update of a matrix inverse:
\[(A + u \otimes v)^{-1} = A^{-1} - \frac{A^{-1}u v^{T} A^{-1}} {1+v^{T}A^{-1} u}\]Parameters: - Ainv (numpy.ndarray) – Matrix inverse of A to be updated.
- u (numpy.array) – column vector
- vt (numpy.array) – transpose of row vector
Returns: Ainv – Updated matrix inverse.
Return type:
pauxy.utils.misc module¶
Various useful routines maybe not appropriate elsewhere
-
pauxy.utils.misc.get_from_dict(d, k)[source]¶ Get value from nested dictionary.
- Taken from:
- https://stackoverflow.com/questions/28225552/is-there-a-recursive-version-of-the-dict-get-built-in
Parameters: - d (dict) –
- k (list) – List specifying key to extract.
Returns: value
Return type: Return type or None.
-
pauxy.utils.misc.get_git_revision_hash()[source]¶ Return git revision.
- Adapted from:
- http://stackoverflow.com/questions/14989858/get-the-current-git-hash-in-a-python-script
Returns: sha1 – git hash with -dirty appended if uncommitted changes. Return type: string