ipie.utils package
Submodules
ipie.utils.fft module
ipie.utils.io module
- ipie.utils.io.get_input_value(inputs, key, default, alias=None, verbose=False)[source]
Helper routine to parse input options.
- ipie.utils.io.read_particle_hole_wavefunction(filename: str) Tuple[ndarray, ndarray, ndarray][source]
- ipie.utils.io.write_hamiltonian(hcore: ndarray, LXmn: ndarray, e0: float, filename: str = 'hamiltonian.h5') None[source]
- ipie.utils.io.write_json_input_file(input_filename: str, hamil_filename: str, wfn_filename: str, nelec: tuple, num_walkers: int = 640, timestep: float = 0.005, num_blocks: float = 10, estimates_filename: str = 'estimates.0.h5', options: dict = {})[source]
- ipie.utils.io.write_noci_wavefunction(wfn: tuple, filename: str, phi0: Union[None, list] = None) None[source]
- ipie.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.
- ipie.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.
- ipie.utils.io.write_particle_hole_wavefunction(wfn: tuple, filename: str, phi0: Union[None, list] = None) None[source]
- ipie.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.
- ipie.utils.io.write_qmcpack_dense(hcore, chol, nelec, nmo, enuc=0.0, filename='hamiltonian.h5', real_chol=True, verbose=False, ortho=None)[source]
- ipie.utils.io.write_qmcpack_sparse(hcore, chol, nelec, nmo, enuc=0.0, filename='hamiltonian.h5', real_chol=False, verbose=False, cutoff=1e-16, ortho=None)[source]
- ipie.utils.io.write_qmcpack_wfn(filename, wfn, walker_type, nelec, norb, init=None, mode='w')[source]
ipie.utils.linalg module
- ipie.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 eigenvalueseigv (
numpy.array) – Sorted eigenvectors (same sorting as eigenvalues).
- ipie.utils.linalg.exponentiate_matrix(M, order=6)[source]
Taylor series approximation for matrix exponential
- ipie.utils.linalg.minor_mask(A, i, j)[source]
computing matrix minor, i-th row and j-th column removed
- ipie.utils.linalg.minor_mask4(A, i, j, k, l)[source]
computing matrix minor, i-th and k-th rows and j-th and l-th column removed
- ipie.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:
- ipie.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
- ipie.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.
- ipie.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:
ipie.utils.misc module
Various useful routines maybe not appropriate elsewhere
- ipie.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.
- ipie.utils.misc.get_git_info()[source]
Return git info.
- Adapted from:
http://stackoverflow.com/questions/14989858/get-the-current-git-hash-in-a-python-script
- Returns:
sha1 (string) – git hash with -dirty appended if uncommitted changes.
branch (string) – Current branch
local_mod (list of strings) – List of locally modified files tracked and untracked.