gem.solvers.simple_ed.SimpleED

class gem.solvers.simple_ed.SimpleED(norb, use_Ntot=False, use_Sz=False, dtype=<class 'numpy.complex128'>, N_sector=None, Sz_sector=None, solver_params=None, comm=None, **kwargs)[source]

Simple exact diagonalization solver for a general embedding Hamiltonian.

Symmetry sectors are controlled by use_Ntot / use_Sz (which symmetries to exploit) and N_sector / Sz_sector (which sector(s) to include):

  • N_sector = <int> — solve only that particle-number sector.

  • N_sector = None — solve all particle-number sectors.

  • Sz_sector = <int> — solve only that Sz sector.

  • Sz_sector = None — solve all Sz sectors.

The Hamiltonian is built and diagonalised independently in each sector. Expectation values (density matrix, energies) are obtained as thermal/degeneracy-weighted averages across all included sectors.

MPI. The sectors are distributed over the ranks of comm (by default MPI.COMM_WORLD when mpi4py is installed, otherwise a serial stand-in). Each rank builds the basis and all operators only for the sectors it owns, diagonalises them, and the global ground-state energy, partition function and thermal expectation values are obtained by reduction over the ranks. self.my_sectors holds the global indices owned by this rank; every per-sector list (basis_list, evals_list, bw_per_sector, …) is indexed by the local position inside it. Reduced quantities (gs_ene, Zpart, Tstates, deg, dm, the energies, gs_wf) are identical on every rank.

build_Hemb, solve_Hemb, calc_density_matrix, compute_E1loc, compute_E2loc and calc_double_occ are collective: every rank of comm must call them, in the same order. Calling one of them inside an if rank == 0: block deadlocks. h5write_gs is the exception, it writes from rank 0 and is a no-op elsewhere.

Matrix-free. With solver_params['matrix_free'] = True nothing is stored per sector but the basis: the Hamiltonian is handed to ARPACK as a LinearOperator and the c^dag_i c_j operators are applied on the fly, so the memory goes from O(dim*norb^2) to O(dim) and the sector size stops being limited by memory. It costs a few times more per matvec, it needs num_eig at T>0 once a sector reaches dense_cutoff (the full-spectrum fallback cannot work without the matrix), and it does not support the spin penalties. Results are otherwise identical to the stored path, sign for sign.

Methods

build_Hemb(D, eloc, Lambdac, V2E[, mu, ...])

Build the embedding Hamiltonian in every sector owned by this rank.

calc_density_matrix()

Compute the one-body density matrix as a thermal/degeneracy average across all active sectors, reduced over the MPI ranks.

calc_double_occ(i)

Thermal double occupancy on orbital (i, i+1), averaged over all sectors.

compute_E1loc(nimp)

One-body local energy (impurity block) averaged across sectors.

compute_E2loc()

Two-body local energy averaged across sectors.

missing_methods()

Names of the mandatory methods that are still the gemSolver stubs, i.e. that this solver has not implemented.

solve_Hemb([num_eig, which, tol, ...])

Diagonalise each sector and build the global (thermal) partition function.

build_S2_op

build_denmat_op

build_h1e

build_one_body

build_two_body

h5read_state

h5write_gs

Methods

__init__(norb[, use_Ntot, use_Sz, dtype, ...])

Initialize the solver with the given number of orbitals and symmetry settings.

build_Hemb(D, eloc, Lambdac, V2E[, mu, ...])

Build the embedding Hamiltonian in every sector owned by this rank.

build_S2_op()

build_denmat_op()

build_h1e(eloc, D, Lambdac, mu[, verbose])

build_one_body(H1E)

build_two_body(Umatrix[, debug])

calc_density_matrix()

Compute the one-body density matrix as a thermal/degeneracy average across all active sectors, reduced over the MPI ranks.

calc_double_occ(i)

Thermal double occupancy on orbital (i, i+1), averaged over all sectors.

compute_E1loc(nimp)

One-body local energy (impurity block) averaged across sectors.

compute_E2loc()

Two-body local energy averaged across sectors.

h5read_state(filename, group_path, name)

h5write_gs(filename, group_path, name)

missing_methods()

Names of the mandatory methods that are still the gemSolver stubs, i.e. that this solver has not implemented.

solve_Hemb([num_eig, which, tol, ...])

Diagonalise each sector and build the global (thermal) partition function.

Attributes

mandatory_methods