# Companion to Closed & Open Quantum Systems A companion to the tutorial article **"Coding closed and open quantum systems in MATLAB: applications in quantum optics and condensed matter"** by Ariel Norambuena, Diego Tancara, and Raúl Coto — [arXiv:1911.04906](https://arxiv.org/abs/1911.04906). The article presents MATLAB code for simulating many-body quantum systems: magnetization dynamics of the closed and open Ising model, a dynamical quantum phase transition in cavity-QED arrays, Markovian dynamics of interacting two-level systems, and the non-Markovian pure-dephasing spin-boson model. This project collects those programs as runnable [numbl](https://numbl.org) scripts so you can execute and edit them in your browser — no MATLAB, no install. Pick a script in the panel on the left and click **Run**. Edits stay in memory for your session. > This README is a guide to *which* program to open, not a replacement for the > article. Read the article for the physics, the equations, and the derivations; > come here to run the code. The scripts are reproduced **verbatim** from the > article's source (arXiv ancillary files) and run unmodified. The only > repackaging: the article presents Example 1 and Example 2 as a sequence of > code listings, which are concatenated here into single runnable > [`Example1.m`](Example1.m) and [`Example2.m`](Example2.m) files. ## Closed quantum systems (article §2) | Script | Article | What it computes | | --- | --- | --- | | [`Example1.m`](Example1.m) | §2.1 | Magnetization dynamics of the closed two-spin Ising model via the time propagator `expm(-iHt)` | | [`IsingModelTransitionPhase_new.m`](IsingModelTransitionPhase_new.m) | §2.1 | Dynamical quantum phase transition of the Ising model (6 spins): rate function and magnetization | | [`CavityQEDTransitionPhase.m`](CavityQEDTransitionPhase.m) | §2.2 | Dynamical phase transition in a cavity-QED array — Jaynes–Cummings vs. Rabi (order parameter and rate function) | ## Open quantum dynamics (article §3) | Script | Article | What it computes | | --- | --- | --- | | [`Example2.m`](Example2.m) | §3.1 | Markovian master equation for two interacting qubits (open Ising), solved by diagonalizing the Lindbladian | | [`TwoLevelSystemCoupledLight.m`](TwoLevelSystemCoupledLight.m) | §3.2 | A two-level atom coupled to a photon reservoir; numerical solution compared to the exact one | | [`NonMarkovianDynamicsPureDephasing.m`](NonMarkovianDynamicsPureDephasing.m) | §3.4 | Non-Markovian pure-dephasing spin-boson model: time-dependent rates, coherence, and a non-Markovianity measure | ## Helper functions These are called by the scripts above; they are functions, not standalone programs, so there is nothing to "Run" directly. | File | Used by | Builds | | --- | --- | --- | | [`getSci.m`](getSci.m) | `IsingModelTransitionPhase_new.m` | the many-body Pauli operator on site *i* | | [`acav.m`](acav.m) | `CavityQEDTransitionPhase.m` | the cavity annihilation operator on site *i* | | [`sigmap.m`](sigmap.m) | `CavityQEDTransitionPhase.m` | the atomic raising operator on site *i* | | [`QuantumSimulationCavityArray.m`](QuantumSimulationCavityArray.m) | `CavityQEDTransitionPhase.m` | the Jaynes–Cummings/Rabi Hamiltonian, time evolution, and observables | | [`sortingEigenvalues.m`](sortingEigenvalues.m) | `Example2.m`, `TwoLevelSystemCoupledLight.m` | the sorted left/right eigenmatrices of the Lindbladian | ## Notes - **Time evolution** of closed systems uses the matrix exponential `U = expm(-1i*H*dt)`. **Open systems** are solved by diagonalizing the Lindblad superoperator with `eig` and reconstructing the density matrix from its eigenmodes (`sortingEigenvalues`). - `CavityQEDTransitionPhase.m` is the heaviest example — it sweeps 25 detunings for two models with long time evolutions, so it takes a couple of minutes in the browser. The others run in a few seconds. - The article uses `parfor` in the cavity-QED sweep; numbl runs it as an ordinary (serial) loop, which gives the same result. ## How it's deployed On every push to `main`, the workflow in [`.github/workflows/deploy.yml`](.github/workflows/deploy.yml) bundles these files with the numbl browser IDE and publishes the result to GitHub Pages — no server, nothing to build by hand. Edit `numbl-project.json` to change the title or which file opens first. ## Reference Ariel Norambuena, Diego Tancara, Raúl Coto, *Coding closed and open quantum systems in MATLAB: applications in quantum optics and condensed matter*, [arXiv:1911.04906](https://arxiv.org/abs/1911.04906).