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 either a unique temporary workdir or an exact checkpoint directory
- 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
Checkpoint discovery runs after these steps because its iteration range depends
on the finalized Nmax value. The discovered prefix is fully validated before
phase output streams are opened.
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 - load a completed checkpoint or construct the Hamiltonian blocks
- diagonalize each uncached block through the selected
DiagEngine - establish energy references and truncation criteria, including the Floquet criterion when selected
- split eigenvectors into ancestor blocks when needed
- update iteration metadata and basic diagnostics
- for
strategy=all, recalculate operators and measure before truncation - truncate the eigenspectra
- archive truncated state into thermodynamic and backward-sweep stores
- recalculate irreducible operators for the next step
- for
strategy=kept, recalculate operators and measure after truncation
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
- stored eigenspectra and density matrices inside the temporary or checkpoint 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.
Persistent result files are written in the calculation directory, not the workdir. See the output format reference for filenames, columns, units, and lifecycle behavior. See State and persistence for the in-memory 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.