|
Quandary
|
Output management for quantum control simulations and optimization. More...
#include <output.hpp>
Public Member Functions | |
| Output () | |
| Output (const Config &config, MPI_Comm comm_petsc, MPI_Comm comm_init, bool quietmode=false) | |
| Constructor with configuration and MPI setup. | |
| ~Output () | |
| void | writeOptimFile (int optim_iter, double objective, double gnorm, double stepsize, double Favg, double cost, double tikh_regul, double penalty_leakage, double penalty_dpdm, double penalty_energy, double penalty_variation, double penalty_weightedcost) |
| Writes optimization progress to history file. | |
| void | writeControls (Vec params, MasterEq *mastereq, int ntime, double dt) |
| Writes current control pulses per oscillator and control parameters. | |
| void | writeGradient (Vec grad) |
| Writes gradient vector for debugging adjoint calculations. | |
| void | openTrajectoryDataFiles (std::string prefix, int initid) |
| Opens data files for time evolution output for one oscillator. | |
| void | writeTrajectoryDataFiles (int timestep, double time, const Vec state, MasterEq *mastereq) |
| Writes time evolution data to files. | |
| void | closeTrajectoryDataFiles () |
| Closes open time evolution data files. | |
Public Attributes | |
| std::string | output_dir |
| Directory path for output data files. | |
| int | output_optimization_stride |
| Write output files every N optimization iterations. | |
Protected Attributes | |
| int | mpirank_world |
| Rank of processor in MPI_COMM_WORLD. | |
| int | mpirank_petsc |
| Rank of processor for PETSc parallelization. | |
| int | mpisize_petsc |
| Size of communicator for PETSc parallelization. | |
| int | mpirank_init |
| Rank of processor for initial condition parallelization. | |
| bool | quietmode |
| Flag for reduced screen output. | |
| FILE * | optimfile |
| Output file for logging optimization progress. | |
| int | output_timestep_stride |
| Time domain output frequency (write every N time steps) | |
| std::vector< OutputType > | output_observables |
| List of output types applied to all oscillators. | |
| size_t | noscillators |
| Number of oscillators in the system. | |
| bool | writeFullState |
| Flag to determine if evolution of full state vector should be written to file. | |
| bool | writeExpectedEnergy |
| Flag to determine if evolution of expected energy per oscillator should be written to files. | |
| bool | writeExpectedEnergy_comp |
| Flag to determine if evolution of expected energy of the full composite system should be written to file. | |
| bool | writePopulation |
| Flag to determine if the evolution of the energy level occupations per oscillator should be written to files. | |
| bool | writePopulation_comp |
| Flag to determine if the evolution of the energy level occupations of the full composite system should be written to file. | |
| FILE * | ufile |
| File for writing real part of fullstate evolution. | |
| FILE * | vfile |
| File for writing imaginary part of fullstate evolution. | |
| std::vector< FILE * > | expectedfile |
| Files for expected energy evolution per oscillator. | |
| std::vector< FILE * > | populationfile |
| Files for population evolution per oscillator. | |
| FILE * | expectedfile_comp |
| File for expected energy evolution of the full composite system. | |
| FILE * | populationfile_comp |
| File for population evolution of the full composite system. | |
Output management for quantum control simulations and optimization.
This class handles all file output operations for Quandary, including optimization progress logging, control pulse output, state evolution data, and population dynamics. It manages MPI-aware output to avoid duplicate writes in parallel runs.
| Output::Output | ( | ) |
| Output::Output | ( | const Config & | config, |
| MPI_Comm | comm_petsc, | ||
| MPI_Comm | comm_init, | ||
| bool | quietmode = false |
||
| ) |
Constructor with configuration and MPI setup.
| config | Configuration parameters from input file |
| comm_petsc | MPI communicator for PETSc parallelization |
| comm_init | MPI communicator for initial condition parallelization |
| quietmode | Flag for reduced output (default: false) |
| Output::~Output | ( | ) |
| void Output::closeTrajectoryDataFiles | ( | ) |
Closes open time evolution data files.
Properly closes and flushes all output files after time-stepping completion.
| void Output::openTrajectoryDataFiles | ( | std::string | prefix, |
| int | initid | ||
| ) |
Opens data files for time evolution output for one oscillator.
Prepares files for writing full state, expected energy, and population evolution data. Called before timestepping starts.
| prefix | Filename prefix for output files |
| initid | Initial condition identifier |
| void Output::writeControls | ( | Vec | params, |
| MasterEq * | mastereq, | ||
| int | ntime, | ||
| double | dt | ||
| ) |
Writes current control pulses per oscillator and control parameters.
Called every output_optimization_stride optimization iterations. Control pulses are written to <output_dir>/control<ioscillator>.dat Control parameters are written to <output_dir>/params.dat
| params | Current parameter vector |
| mastereq | Pointer to master equation solver |
| ntime | Total number of time steps |
| dt | Time step size |
| void Output::writeGradient | ( | Vec | grad | ) |
Writes gradient vector for debugging adjoint calculations.
Gradient is written to <output_dir>/grad.dat
| grad | Gradient vector to output |
| void Output::writeOptimFile | ( | int | optim_iter, |
| double | objective, | ||
| double | gnorm, | ||
| double | stepsize, | ||
| double | Favg, | ||
| double | cost, | ||
| double | tikh_regul, | ||
| double | penalty_leakage, | ||
| double | penalty_dpdm, | ||
| double | penalty_energy, | ||
| double | penalty_variation, | ||
| double | penalty_weightedcost | ||
| ) |
Writes optimization progress to history file.
Called at every optimization iteration to log convergence data. Optimization history will be written to <output_dir>/optim_history.dat.
| optim_iter | Current optimization iteration |
| objective | Total objective function value |
| gnorm | Gradient norm |
| stepsize | Optimization step size |
| Favg | Average fidelity |
| cost | Final-time cost term |
| tikh_regul | Tikhonov regularization term |
| penalty_leakage | Penalty term for leakage |
| penalty_weightedcost | Weighted cost penalty |
| penalty_dpdm | Second-order derivative penalty |
| penalty_energy | Energy penalty term |
| penalty_variation | Control variation penalty |
| void Output::writeTrajectoryDataFiles | ( | int | timestep, |
| double | time, | ||
| const Vec | state, | ||
| MasterEq * | mastereq | ||
| ) |
Writes time evolution data to files.
Outputs state vector, expected energies, and populations at current time step. Called at each time step
| timestep | Current time step number |
| time | Current time value |
| state | Current state vector |
| mastereq | Pointer to master equation solver |
|
protected |
Files for expected energy evolution per oscillator.
|
protected |
File for expected energy evolution of the full composite system.
|
protected |
Rank of processor for initial condition parallelization.
|
protected |
Rank of processor for PETSc parallelization.
|
protected |
Rank of processor in MPI_COMM_WORLD.
|
protected |
Size of communicator for PETSc parallelization.
|
protected |
Number of oscillators in the system.
| std::string Output::output_dir |
Directory path for output data files.
|
protected |
List of output types applied to all oscillators.
| int Output::output_optimization_stride |
Write output files every N optimization iterations.
|
protected |
Time domain output frequency (write every N time steps)
|
protected |
Files for population evolution per oscillator.
|
protected |
File for population evolution of the full composite system.
|
protected |
Flag for reduced screen output.
|
protected |
File for writing real part of fullstate evolution.
|
protected |
File for writing imaginary part of fullstate evolution.
|
protected |
Flag to determine if evolution of expected energy per oscillator should be written to files.
|
protected |
Flag to determine if evolution of expected energy of the full composite system should be written to file.
|
protected |
Flag to determine if evolution of full state vector should be written to file.
|
protected |
Flag to determine if the evolution of the energy level occupations per oscillator should be written to files.
|
protected |
Flag to determine if the evolution of the energy level occupations of the full composite system should be written to file.