Template Class nrgcore#
Defined in File nrgcore.hpp
Class Documentation#
-
template<typename im_type, typename bath_type>
class nrgcore# Solves the NRG (Numerical Renormalization Group) problem for a quantum impurity model coupled to a bath.
This class implements the iterative NRG algorithm by diagonalizing the Hamiltonian in a basis of quantum numbers. It combines an impurity model and a bath model, progressively adding bath sites and truncating high-energy states to simulate the low-energy physics of the system.
- Template Parameters:
im_type – The type of the impurity model, which must provide quantum numbers, eigenvalues, basis, and operators.
bath_type – The type of the bath model, which must provide quantum numbers, eigenvalues, basis, and operators.
Public Functions
-
inline nrgcore(im_type &im_hamilt, bath_type &bt_hamilt)#
Constructs the
nrgcoreobject.Initializes the NRG solver with references to the impurity and bath models. Retrieves initial quantum numbers, eigenvalues, and basis from the models. Sets default parameters and performs consistency checks.
- Parameters:
im_hamilt – Reference to the impurity Hamiltonian model.
bt_hamilt – Reference to the bath Hamiltonian model.
-
inline void add_bath_site(const std::vector<double> &thopping, double rescale)#
Add a new Wilson bath site and perform the NRG iteration update.
Creates the next basis, builds Hamiltonians for each quantum-number block, diagonalizes each block, and truncates high-energy states if needed. Also updates system operators and tracks iteration state.
- Parameters:
thopping – Hopping coefficients for each bath channel.
rescale – NRG energy rescaling factor for new site.
-
inline void update_internal_state()#
Updates the internal state after adding a bath site.
Increments the iteration counter, discards high-energy states, and moves the current basis to the previous one for the next iteration.
-
inline void test()#
Performs basic consistency tests between impurity and bath models.
Ensures that the number of quantum numbers and the size of the f-dag operator arrays match between the impurity and bath models to prevent runtime errors.
-
inline void create_next_hamiltonians(const std::vector<double> &t_hopping, double rescale)#
Creates the Hamiltonians for the next NRG iteration by coupling system and bath.
For each coupled quantum number sector, constructs a matrix representing the Hamiltonian with diagonal elements from rescaled system eigenvalues and bath eigenvalues, and off-diagonal elements from hopping terms involving f-dag operators.
- Parameters:
t_hopping – Vector of hopping parameters (must match the number of f-dag operators).
rescale – Energy rescaling factor.
-
inline void create_next_basis()#
Creates the next basis by coupling the previous system’s quantum numbers with the bath’s.
Generates new quantum number sectors by summing the quantum numbers of the previous system and the bath, and groups coupled indices for efficient Hamiltonian construction.
-
inline void discard_higher_energies()#
Discards high-energy states to keep only the lowest-energy ones.
Collects all eigenvalues, sorts them, and keeps up to
max_kept_statesplus degenerate states withinerrorbarInEnergy. Updates kept indices, shifts energies relative to the ground state if truncation occurs, and logs statistics.
-
inline void set_parameters(size_t n = 1024)#
Sets the maximum number of states to keep in each iteration.
Also initializes other parameters like energy error bar and iteration counters.
- Parameters:
n – Maximum number of states to keep (default: 1024).
-
inline std::vector<std::vector<int>> get_basis_nQ()#
Retrieves the current basis quantum numbers.
- Throws:
std::runtime_error – if the current basis is empty.
- Returns:
Vector of vectors representing quantum numbers for each sector.
-
inline std::vector<std::vector<double>> get_eigenvaluesQ()#
Retrieves the eigenvalues of the current Hamiltonian.
- Throws:
std::runtime_error – if eigenvalues are empty.
- Returns:
Vector of vectors of eigenvalues for each quantum sector.
-
inline auto get_f_dag_operator()#
Retrieves the f-dag operators in the current basis.
These operators are used to construct the Hamiltonian for the next iteration.
- Returns:
Vector of qOperator objects.
-
inline bool checkHigherEnergyDiscarded()#
Checks if higher-energy states were discarded in the current iteration.
- Returns:
True if the number of kept states is at or below the maximum, indicating no truncation.
Public Members
-
std::vector<double> all_eigenvalue#
All eigenvalues from all quantum number sectors, sorted in ascending order.
-
std::vector<double> relativeGroundStateEnergy#
The ground state energy of each NRG iteration.
-
std::vector<std::vector<size_t>> eigenvaluesQ_kept_indices#
Indices of the kept states in each quantum number sector.
-
std::vector<qmatrix<double>> current_hamiltonQ#
The Hamiltonian for each quantum number sector in the current iteration. This is the unitary matrix that diagonalizes the Hamiltonian.
-
std::vector<std::vector<int>> current_sysmQ#
The quantum numbers of the current system.
-
std::vector<std::vector<int>> pre_sysmQ#
The quantum numbers of the previous system.
-
std::vector<std::vector<double>> eigenvaluesQ#
The eigenvalues of the Hamiltonian for each quantum number sector.
-
std::vector<std::vector<size_t>> coupled_nQ_index#
Indices that couple different quantum number sectors.
-
int nrg_iterations_cnt = {}#
The current NRG iteration count.
-
int nrg_iterations_min = {}#
The NRG iteration from which the truncation of states started.
-
std::vector<std::vector<double>> bath_eigenvaluesQ#
The eigenvalues of the bath Hamiltonian for each quantum number sector.
-
std::vector<std::vector<int>> nq_bath#
The quantum numbers of the bath.