pauxy.utils package

Submodules

pauxy.utils.fft module

pauxy.utils.fft.fft_wavefunction(psi, nx, ny, ns, sin)[source]
pauxy.utils.fft.ifft_wavefunction(psi, nx, ny, ns, sin)[source]

pauxy.utils.io module

pauxy.utils.io.dump_qmcpack_trial_wfn(wfn, nelec, filename='wfn.dat')[source]
pauxy.utils.io.fcidump_header(nel, norb, spin)[source]
pauxy.utils.io.format_fixed_width_floats(floats)[source]
pauxy.utils.io.format_fixed_width_strings(strings)[source]
pauxy.utils.io.from_qmcpack_complex(data, shape)[source]
pauxy.utils.io.from_qmcpack_dense(filename)[source]
pauxy.utils.io.from_qmcpack_sparse(filename)[source]
pauxy.utils.io.get_input_value(inputs, key, default=0, alias=None, verbose=False)[source]

Helper routine to parse input options.

pauxy.utils.io.orbs_from_dset(dset)[source]

Will read actually A^{H} but return A.

pauxy.utils.io.qmcpack_wfn_namelist(nci, uhf, fullmo=True)[source]
pauxy.utils.io.read_fortran_complex_numbers(filename)[source]
pauxy.utils.io.read_phfmol(filename, nmo, na, nb)[source]
pauxy.utils.io.read_qmcpack_nomsd_hdf5(wgroup, nelec=None)[source]
pauxy.utils.io.read_qmcpack_phmsd_hdf5(wgroup, nelec=None)[source]
pauxy.utils.io.read_qmcpack_wfn(filename, skip=9)[source]
pauxy.utils.io.read_qmcpack_wfn_hdf(filename, nelec=None)[source]
pauxy.utils.io.to_json(afqmc)[source]
pauxy.utils.io.to_qmcpack_complex(array)[source]
pauxy.utils.io.to_qmcpack_index(matrix, offset=0)[source]
pauxy.utils.io.to_sparse(vals, offset=0, cutoff=1e-08)[source]
pauxy.utils.io.write_input(filename, hamil, wfn, bp=False, options={})[source]
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_phfmol_wavefunction(coeffs, dets, filename='wfn.dat', padding=0)[source]
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.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]
pauxy.utils.io.write_qmcpack_wfn(filename, wfn, walker_type, nelec, norb, init=None, mode='w')[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).
pauxy.utils.linalg.exponentiate_matrix(M, order=6)[source]

Taylor series approximation for matrix exponential

pauxy.utils.linalg.get_orthoAO(S, LINDEP_CUTOFF=1e-14)[source]
pauxy.utils.linalg.get_ortho_ao_mod(S, LINDEP_CUTOFF=1e-14, verbose=False)[source]
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:

numpy.ndarray

pauxy.utils.linalg.molecular_orbitals_rhf(fock, AORot)[source]
pauxy.utils.linalg.molecular_orbitals_uhf(fock, AORot)[source]
pauxy.utils.linalg.overlap(A, B)[source]
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.
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:

numpy.ndarray

pauxy.utils.misc module

Various useful routines maybe not appropriate elsewhere

class pauxy.utils.misc.dotdict[source]

Bases: dict

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
pauxy.utils.misc.get_numeric_names(d)[source]
pauxy.utils.misc.is_class(obj)[source]
pauxy.utils.misc.is_h5file(obj)[source]
pauxy.utils.misc.merge_dicts(a, b, path=None)[source]
pauxy.utils.misc.print_section_header(string)[source]
pauxy.utils.misc.print_sys_info(sha1, branch, uuid, nranks)[source]
pauxy.utils.misc.serialise(obj, verbose=0)[source]
pauxy.utils.misc.unit_test()[source]
pauxy.utils.misc.update_stack(stack_size, num_slices, name='stack', verbose=False)[source]

Module contents