Runtime Flow
Inputs
The runtime side centers around two input files in the working directory:
param: runtime parameters and workflow switchesdata: generated initial eigenspectrum, operators, and chain coefficients
param is parsed by Params in c++/params.hpp.
data is parsed by InputData in c++/read-input.hpp.
Entry Point
Execution starts in c++/nrg.cc:
- initialize MPI
- report OpenMP and environment information
- validate that
paramanddataexist - set up the temporary workdir
- run master or slave behavior depending on MPI rank
The executable-facing orchestration then moves into NRG_calculation in c++/nrg-general.hpp.
nrg.cc is intentionally thin. Nearly all interesting control flow begins once NRG_calculation is constructed.
Initialization In NRG_calculation
NRG_calculation constructs and wires together the core runtime objects:
ParamsInputDataSymmetry<S>Stats<S>ThermoStore<S>BackiterStore- diagonalization engine selection
Important methods in NRG_calculation:
select_diag_engine(): choose MPI / OpenMP / serial diagonalization backendrun_phase(...): build per-phase helpers and execute the iteration loopprepare_rho(...): initialize and backpropagate shell density matricesprepare_rhoFDM(): initialize and backpropagate FDM density matricesrun_dm_phase(...): launch the second sweep when enabled
InputData performs these steps:
- read the
dataheader - instantiate the symmetry backend
- load the seed eigenspectrum and seed operators
- read operator blocks and coefficient tables
- finalize
Nmaxand related derived parameters
See Input and configuration for the input-side details.
Main NRG Phase
The main run is started through run_phase(RUNTYPE::NRG, ...), which enters nrg_loop(...) in c++/core.hpp.
At a high level, each iteration does the following:
- build the next-shell
SubspaceStructure - convert that into a
TaskList - construct the Hamiltonian blocks for each invariant subspace
- diagonalize each block through the selected
DiagEngine - establish energy references and truncation criteria
- split eigenvectors into ancestor blocks when needed
- update statistics and outputs
- recalculate operators in the new basis
- compute observables and spectral data for the current phase
- archive state into thermodynamic and backward-sweep stores
- truncate the eigenspectra
- recalculate irreducible operators for the next step
The most important coordination logic lives in c++/core.hpp.
See Iteration engine for the function-level breakdown of this phase.
Optional DM-NRG And FDM Phases
After the first sweep, NRG_calculation may run density-matrix-related phases depending on Params:
- prepare
rho - prepare
rhoFDM - run
RUNTYPE::DMNRG
This is still driven through the same broad iteration machinery, but with different runtime mode and output semantics.
Outputs
The runtime produces several forms of output:
- spectral and thermodynamic files in the working directory
- temporary stored eigenspectra and density matrices inside the generated workdir
- optional HDF5 output via
Outputandh5savehelpers - logs and diagnostic dumps when enabled by parameters
The workdir is represented by Workdir in c++/workdir.hpp and is used for transient iteration-state files such as unitary matrices and density matrices.
See State and persistence for the storage model and serialization boundaries.
Mathematica Side
The C++ executable does not construct the initial problem description by itself. The Mathematica-side nrginit pipeline is responsible for:
- model definition
- basis construction
- initial Hamiltonian diagonalization
- seed operator generation
datafile emission
That is why understanding the full project flow requires keeping both nrginit/ and c++/ in mind, even though the iterative heavy lifting happens in C++.
See nrginit workflow for the Mathematica-side entry path.