|
1 | | -* [An introductory talk](https://youtu.be/yunR73LNJ1M) given at GPU Day 2019 |
2 | | -* [Video tutorial part 1](https://youtu.be/Ozj4sDNdlmM) — How to download, configure and build C++QED, and run the testsuite on a fresh Ubuntu20.04 installation. The commands used in the tutorial can be found in [`helperscripts/cloudScript.sh`](helperscripts/cloudScript.sh). They are as follows: |
| 1 | +# C++QED v3 |
| 2 | + |
| 3 | +**A C++20 framework for high-performance simulation of open quantum dynamics** |
| 4 | + |
| 5 | +C++QED is a framework for simulating open quantum systems — master equations and quantum-jump Monte Carlo (QJMC) trajectories — targeting production-scale runs on HPC/HTC clusters. It is the successor to C++QED v2, rewritten in a modern C++20 functional style while preserving the core performance principle: **compile-time resolution of the full tensor-product structure of the Hilbert space**. |
| 6 | + |
| 7 | +📖 **[Developer Guide](https://vukics.github.io/cppqed/)** — narrative documentation, design rationale, and API reference. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## Who is this for? |
| 12 | + |
| 13 | +C++QED occupies a different niche from QuTiP or QuantumOptics.jl: |
| 14 | + |
| 15 | +| | QuTiP / QuantumOptics.jl | C++QED v3 | |
| 16 | +|---|---|---| |
| 17 | +| **Interface** | Interactive notebook / REPL | Compiled executable | |
| 18 | +| **Workflow** | Prototype → explore → iterate | Define system → compile → deploy | |
| 19 | +| **Execution** | Single workstation | Command-line, batch jobs, HPC/HTC clusters | |
| 20 | +| **Parameter sweep** | Python/Julia loop | Cluster job array | |
| 21 | +| **State** | In-memory, session-based | Checkpointed, resumable, serialized | |
| 22 | +| **Output** | Inline plots | Structured, streamable data files | |
| 23 | + |
| 24 | +If you are exploring a new system interactively, use QuTiP. If you are running thousands of trajectories in a parameter study on a cluster, C++QED is the right tool. |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +## Key features |
| 29 | + |
| 30 | +- **Compile-time tensor product structure.** The `RANK` (number of subsystems) and the axes retained in any partial operation are non-type template parameters, resolved entirely at compile time. You pay the compilation cost once; every trajectory runs at full speed. |
| 31 | +- **C++20 concepts and Boost.Hana sequences** replace the v2 template metaprogramming maze. Composite system Hamiltonians are heterogeneous Hana tuples; composition is recursive and zero-overhead. |
| 32 | +- **Multi-diagonal sparse operators.** Virtually all physically relevant operators in quantum optics (ladder, number, Kerr, displacement, squeezing) are multi-diagonal in the Fock basis. `MultiDiagonal` is closed under composition, direct product, and Hermitian conjugation, with exact offset arithmetic. |
| 33 | +- **Unified trajectory driver.** A single `run()` function handles checkpointing, automatic continuation, autostopping at steady state, adaptive output density, and structured JSON logging — everything needed for unattended HPC jobs. |
| 34 | +- **QJMC ensemble parallelism.** The natural HTC model: submit N independent single-trajectory jobs; average in post-processing. `pcg64` provides provably independent parallel streams. |
| 35 | +- **Master equation.** Lindblad master equation on full density operators, using the same `H/i` convention and non-Hermitian picture as QJMC — state-vector operations are broadcast directly over density operator indices. |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## Library structure |
| 40 | + |
| 41 | +The `MultiDiagonal` sparse operator library has been split into its own repository: **[cppqed-multidiagonal](https://github.com/vukics/cppqed-multidiagonal)**. It is a standalone, physics-agnostic C++ library for multi-diagonal sparse operators over tensor-product Hilbert spaces, and is a dependency of this repository. |
| 42 | + |
3 | 43 | ``` |
4 | | -# Starting from fresh Ubuntu 20.04 LTS installation |
5 | | -# Install prerequisites: |
6 | | -sudo apt install libgsl-dev libboost-all-dev libeigen3-dev clang cmake cmake-curses-gui git python3-scipy # ipython3 |
7 | | -# Clone repo + submodules: |
8 | | -git clone --recurse-submodules --remote-submodules https://github.com/vukics/cppqed.git; cd cppqed |
9 | | -# Checkout Ubuntu branch: |
10 | | -git checkout Ubuntu20.04LTS |
11 | | -mkdir build; cd build |
12 | | -# Configure build: |
13 | | -cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=/usr/bin/clang++ |
14 | | -# Build everything needed for tests: |
15 | | -make -j4 boostTester fewer_scripts compileTests cpypyqed |
16 | | -# Tests can be run with |
17 | | -# ctest -j4 # from the main build folder |
| 44 | +cppqed-multidiagonal/ Standalone sparse operator library (separate repo) |
| 45 | + MultiDiagonal.h/.cc Closed under composition, direct product, Hermitian conjugation |
| 46 | +
|
| 47 | +CPPQEDutils/ Generic scaffolding |
| 48 | + MultiArray.h Strided N-dimensional array |
| 49 | + SliceIterator.h Compile-time axis slicing and partial trace |
| 50 | + ODE.h Adaptive ODE engine (Boost.Odeint / RKCK54) |
| 51 | + Trajectory.h run() driver: streaming, checkpointing, autostop |
| 52 | + StochasticTrajectory.h Ensemble and stochastic trajectory concepts |
| 53 | + Pars.h Command-line / JSON parameter machinery |
| 54 | +
|
| 55 | +CPPQEDcore/ |
| 56 | + quantumdata/ LazyDensityOperator — lazy pure/mixed state |
| 57 | + quantumoperator/ MultiDiagonal integration and quantum operator algebra |
| 58 | + quantumtrajectory/ Master equation and QJMC integrators |
| 59 | + structure/ Hamiltonian, Liouvillian, ExpectationValues |
| 60 | + → quantumdynamics |
| 61 | +
|
| 62 | +CPPQEDelements/ |
| 63 | + Mode.{h,cc} Harmonic oscillator (Kerr, drive, decay) |
| 64 | + Qbit.{h,cc} Two-level system |
| 65 | + JaynesCummings.h Cavity–atom coupling |
| 66 | + Composite.h Broadcaster: lifts subsystems to full tensor-product rank |
18 | 67 | ``` |
19 | 68 |
|
20 | | -C++QED is a C++/Python framework for simulating open quantum dynamics. It allows users to build arbitrarily complex interacting quantum systems from elementary free subsystems and interactions, and simulate their time evolution with a number of available time-evolution drivers. |
| 69 | +--- |
| 70 | + |
| 71 | +## Examples |
| 72 | + |
| 73 | +### Jaynes-Cummings QJMC |
| 74 | + |
| 75 | +The canonical composite system: a two-level atom coupled to a driven, lossy cavity mode. This is the verified working example as of 2026-04. |
| 76 | + |
| 77 | +```cpp |
| 78 | +#include "Composite.h" |
| 79 | +#include "JaynesCummings.h" |
| 80 | +#include "Mode.h" |
| 81 | +#include "Qbit.h" |
| 82 | +#include "QuantumJumpMonteCarlo.h" |
| 83 | +#include "Pars.h" |
| 84 | +#include "pcg_random.hpp" |
| 85 | + |
| 86 | +using namespace cppqedutils; using namespace quantumdata; |
| 87 | +using namespace quantumtrajectory; using namespace structure; |
| 88 | + |
| 89 | +int main(int argc, const char* argv[]) |
| 90 | +{ |
| 91 | + auto op = optionParser(); |
| 92 | + trajectory::Pars<qjmc::Pars<qjmc::Algorithm::integrating, pcg64>> pt{op}; |
| 93 | + qbit::Pars pq{op, "q"}; |
| 94 | + mode::Pars pm{op, "m"}; |
| 95 | + double g; |
| 96 | + add(op, parameters::_("g", "Jaynes-Cummings coupling", 1., g)); |
| 97 | + parse(op, argc, argv); |
| 98 | + |
| 99 | + StateVector<2> psi{ qbit::init(pq) * mode::init(pm) }; |
| 100 | + |
| 101 | + Broadcaster<2,0> bQ{psi.extents}; |
| 102 | + Broadcaster<2,1> bM{psi.extents}; |
| 103 | + auto [cutoffQ, haQ, liQ, evQ, descrQ] = qbit::make(pq); |
| 104 | + auto [cutoffM, haM, liM, evM, descrM] = mode::make(pm); |
| 105 | + |
| 106 | + auto ha = hana::make_tuple(bQ(haQ), bM(haM), |
| 107 | + jaynescummings::hamiltonian<0,1>(pm.cutoff, g)); |
| 108 | + auto li = bQ(liQ); |
| 109 | + for (auto& l : bM(liM)) li.push_back(std::move(l)); |
| 110 | + |
| 111 | + quantumtrajectory::run<qjmc::Algorithm::integrating, ODE_EngineBoost>( |
| 112 | + ha, li, hana::make_tuple(bQ(evQ), bM(evM)), |
| 113 | + json::object{{"system","Jaynes-Cummings"},{"qubit",descrQ},{"mode",descrM},{"g",g}}, |
| 114 | + std::move(psi), pt, trajectory::observerNoOp); |
| 115 | +} |
| 116 | +``` |
| 117 | +
|
| 118 | +Run it from bash as: |
| 119 | +
|
| 120 | +```bash |
| 121 | +./jc_qjmc --T 500 --Dt 1 --o results/probe.out --kappaq 0.1 --kappam 0.1 --cutoffm 30 --g 5.0 --etam 10. |
| 122 | +``` |
| 123 | + |
| 124 | + |
| 125 | +### Photon blockade breakdown (single driven Kerr mode) |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | +The photon-blockade breakdown is a dissipative quantum phase transition of the strongly driven, strongly coupled Jaynes-Cummings model: as the drive amplitude increases, the cavity-atom system switches from a quantum (blockaded, low-photon-number) to a classical (unblocked, high-photon-number) regime. Finite-size scaling of this transition and its experimental observation have been studied with C++QED v2 simulations; the driven-dissipative Jaynes-Cummings model in v3 targets the same physics. |
| 130 | + |
| 131 | +**Related publications:** |
| 132 | +- Vukics et al., *Finite-size scaling of the photon-blockade breakdown dissipative quantum phase transition*, **Quantum** 3, 150 (2019). [DOI: 10.22331/q-2019-06-03-150](https://doi.org/10.22331/q-2019-06-03-150) |
| 133 | +- Fink et al., *Observation of the Photon-Blockade Breakdown Phase Transition*, **Phys. Rev. X** 7, 011012 (2017). [DOI: 10.1103/PhysRevX.7.011012](https://doi.org/10.1103/PhysRevX.7.011012) |
| 134 | +- Sett et al., *Emergent Macroscopic Bistability Induced by a Single Superconducting Qubit*, **PRX Quantum** 5, 010327 (2024). [DOI: 10.1103/PRXQuantum.5.010327](https://doi.org/10.1103/PRXQuantum.5.010327) |
| 135 | + |
| 136 | +--- |
| 137 | + |
| 138 | +## Building |
| 139 | + |
| 140 | +**Requirements:** C++20 compiler (GCC ≥ 12 or Clang ≥ 16), CMake ≥ 3.20, Boost (Odeint, Hana, Iostreams, JSON), Blitz++, [cppqed-multidiagonal](https://github.com/vukics/cppqed-multidiagonal). |
| 141 | + |
| 142 | +```bash |
| 143 | +git clone https://github.com/vukics/cppqed-multidiagonal.git |
| 144 | +git clone https://github.com/vukics/cppqed.git |
| 145 | +cd cppqed |
| 146 | +cmake -B build -DCMAKE_BUILD_TYPE=Release |
| 147 | +cmake --build build -j$(nproc) |
| 148 | +``` |
| 149 | + |
| 150 | +On Windows, [WSL2](https://learn.microsoft.com/en-us/windows/wsl/) with Ubuntu 24.04 is the recommended environment. |
| 151 | + |
| 152 | +--- |
| 153 | + |
| 154 | +## Papers |
| 155 | + |
| 156 | +### C++QED v2 (predecessor) |
| 157 | + |
| 158 | +The physics and algorithmic foundations of the framework are described in the v2 papers. v3 preserves the core methods while modernizing the implementation: |
| 159 | + |
| 160 | +- A. Vukics, H. Ritsch, *C++QED: an object-oriented framework for wave-function simulations of cavity QED systems*, **Eur. Phys. J. D** 44, 585 (2007). [DOI: 10.1140/epjd/e2007-00210-x](https://doi.org/10.1140/epjd/e2007-00210-x) |
| 161 | +- A. Vukics, *C++QEDv2: The multi-array concept and compile-time algorithms in the definition of composite quantum systems*, **Comput. Phys. Commun.** 183, 1381 (2012). [DOI: 10.1016/j.cpc.2012.01.004](https://doi.org/10.1016/j.cpc.2012.01.004) |
| 162 | +- A. Vukics, T. Grießer, P. Domokos, *C++QEDv2 Milestone 10: A C++/Python application-programming framework for simulating open quantum dynamics*, **Comput. Phys. Commun.** 183, 1381 (2014). [DOI: 10.1016/j.cpc.2014.02.011](https://doi.org/10.1016/j.cpc.2014.02.011) |
| 163 | +- M. Kornyik, A. Vukics, *The Monte Carlo wave-function method: A robust adaptive algorithm and a study in convergence*, **Comput. Phys. Commun.** 238, 88–101 (2019). [DOI: 10.1016/j.cpc.2018.12.015](https://doi.org/10.1016/j.cpc.2018.12.015) |
| 164 | + |
| 165 | +- [An introductory talk](https://youtu.be/yunR73LNJ1M) given at GPU Day 2019 |
| 166 | + |
| 167 | +### C++QED v3 (in preparation) |
| 168 | + |
| 169 | +Two papers are in preparation for *SciPost Physics Codebases*: |
| 170 | + |
| 171 | +- **Paper 1 — [cppqed-multidiagonal](https://github.com/vukics/cppqed-multidiagonal)**: a standalone C++ library for multi-diagonal sparse operators over tensor-product Hilbert spaces; algebraically closed under composition, direct product, and Hermitian conjugation. |
| 172 | +- **Paper 2 — C++QED v3**: the full framework; C++20 concepts + Boost.Hana replacing v2 TMP, with continuous interaction-picture reset, parallel-safe PRNG, and HPC/HTC production workflow. |
| 173 | + |
| 174 | +--- |
| 175 | + |
| 176 | +## Status |
| 177 | + |
| 178 | +C++QED v3 is under active development. The Jaynes-Cummings QJMC example compiles and runs correctly as of 2026-04. Known open items (exact propagators, `AutostopHandlerGeneric` with Hana tuple TDPs, signed-offset `MultiDiagonal` refactor) are tracked in the development primer. |
| 179 | + |
| 180 | +--- |
| 181 | + |
| 182 | +## License |
21 | 183 |
|
22 | | -Earlier, C++QED was located at sourceforge: http://cppqed.sf.net. The (at the moment somewhat outdated) documentation can still be found there. |
23 | | -* [User guide](http://cppqed.sourceforge.net/cppqed/html/userguide.html) |
| 184 | +Distributed under the [Boost Software License, Version 1.0](LICENSE.txt). |
24 | 185 |
|
25 | | - |
| 186 | +## Authors |
26 | 187 |
|
27 | | -The plot is from a recent publication related to the photon-blockade breakdown effect. Here are two nice recent related papers where C++QED was used for the simulations: |
28 | | -* [Vukics et al. *Finite-size scaling of the photon-blockade breakdown dissipative quantum phase transition.* Quantum **3**, 150 (2019)](https://doi.org/10.22331/q-2019-06-03-150) |
29 | | -* [Fink et al. *Observation of the Photon-Blockade Breakdown Phase Transition.* Phys. Rev. X **7**, 011012 (2017)](https://doi.org/10.1103/PhysRevX.7.011012) |
| 188 | +András Vukics — Wigner Research Centre for Physics, Budapest |
0 commit comments