### Transition usage example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Example showing how to create a transition operator and verify the composition rule. ```julia julia> h = NLevelSpace(:atom, 3); julia> σ = Transition(h, :σ, 1, 2); julia> σ * σ' σ₁₁ julia> σ' * σ σ₂₂ ``` -------------------------------- ### get_order usage examples Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Examples of get_order on a bare operator, a product, and a number, showing the returned orders. ```julia julia> h = FockSpace(:a) ⊗ FockSpace(:b); julia> @qnumbers a::Destroy(h, 1) b::Destroy(h, 2); julia> get_order(a) 1 julia> get_order(a * b) 2 julia> get_order(1) 0 ``` -------------------------------- ### Spin usage example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Example showing how to create spin operators and verify the commutation relation. ```julia julia> h = SpinSpace(:S); julia> Sx = Spin(h, :S, 1); Sy = Spin(h, :S, 2); julia> Sy * Sx -im * Sz + Sx * Sy ``` -------------------------------- ### Pauli usage example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Example showing how to create Pauli operators and verify their multiplication rules. ```julia julia> h = PauliSpace(:s); julia> σx = Pauli(h, :σ, 1); σy = Pauli(h, :σ, 2); julia> σx * σy im * σz julia> σx * σx 1 ``` -------------------------------- ### average usage example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Example of using average with a FockSpace and @qnumbers. Shows that the result is recognized by is_average and can be added to a number. ```julia julia> h = FockSpace(:f); julia> @qnumbers a::Destroy(h); julia> avg = average(a' * a); julia> is_average(avg) true julia> avg + 1 1 + ⟨a' * a⟩ ``` -------------------------------- ### SpinSpace example: create a spin space Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Shows how to create a SpinSpace. The output displays the resulting space. ```julia julia> SpinSpace(:S) ℋ(S) ``` -------------------------------- ### expand_completeness example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Shows how to rewrite a ground-state projector σ11 using the completeness relation. The output is 1 - σ₂₂. ```julia julia> h = NLevelSpace(:atom, 2); julia> σ11 = Transition(h, :σ, 1, 1); julia> expand_completeness(σ11) 1 - σ₂₂ ``` -------------------------------- ### Julia versioninfo output Source: https://qojulia.github.io/QuantumCumulants.jl/stable/examples/filter-cavity_indexed Example output from `versioninfo()` showing Julia version, platform, and environment details. ```text Julia Version 1.13.0 Commit d1c37793dd2 (2026-09-09 19:00 UTC) Build Info: Official https://julialang.org release Platform Info: OS: Linux (x86_64-linux-gnu) CPU: 4 × AMD EPYC 7763 64-Core Processor WORD_SIZE: 64 LLVM: libLLVM-20.1.8 (ORCJIT, znver3) GC: Built with stock GC Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores) Environment: JULIA_PKG_SERVER_REGISTRY_PREFERENCE = eager JULIA_DEBUG = Documenter ``` -------------------------------- ### Position usage example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Example showing how to create position and momentum operators and verify the canonical commutation relation. ```julia julia> h = PhaseSpace(:osc); julia> @qnumbers x::Position(h) p::Momentum(h); julia> p * x -im + x * p ``` -------------------------------- ### PhaseSpace example: create an oscillator space Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Shows how to create a PhaseSpace for an oscillator. The output displays the resulting space. ```julia julia> PhaseSpace(:osc) ℋ(osc) ``` -------------------------------- ### fundamental_operators example with FockSpace and NLevelSpace Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Shows how to create a product Hilbert space and count the fundamental operators. The example creates a FockSpace and a 2-level NLevelSpace, then returns the length of the fundamental operator set, which is 3. ```julia julia> h = FockSpace(:cavity) ⊗ NLevelSpace(:atom, 2); julia> length(fundamental_operators(h)) 3 ``` -------------------------------- ### numeric_average example with QuantumOpticsBase Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Demonstrates computing the expectation value of a'*a for a Fock state. The example creates a FockSpace, defines a Destroy operator, and checks that the result is approximately 2. ```julia julia> using QuantumOpticsBase julia> h = FockSpace(:f); julia> @qnumbers a::Destroy(h); julia> b = FockBasis(5); ψ = fockstate(b, 2); julia> real(numeric_average(a' * a, ψ)) ≈ 2 true ``` -------------------------------- ### to_numeric example with QuantumOpticsBase Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Demonstrates converting a symbolic operator expression to a numeric operator using QuantumOpticsBase. The example creates a FockSpace, defines a Destroy operator, and checks that the expectation value of a'*a is approximately 2. ```julia julia> using QuantumOpticsBase julia> h = FockSpace(:f); julia> @qnumbers a::Destroy(h); julia> b = FockBasis(5); ψ = fockstate(b, 2); julia> real(expect(to_numeric(a' * a, b), ψ)) ≈ 2 true ``` -------------------------------- ### Destroy usage example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Example showing how to create a bosonic annihilation operator and verify the commutation relation [a, a†] = 1. ```julia julia> h = FockSpace(:cavity); julia> @qnumbers a::Destroy(h); julia> a * a' 1 + a' * a ``` -------------------------------- ### FockSpace example: create a cavity mode Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Shows how to create a FockSpace for a cavity mode. The output displays the resulting space. ```julia julia> FockSpace(:cavity) ℋ(cavity) ``` -------------------------------- ### get_operators usage example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Example showing how to count unique operators in a QAdd. Creates a Fock space and a Destroy operator, then counts operators in a'*a. ```julia julia> h = FockSpace(:f); julia> @qnumbers a::Destroy(h); julia> length(get_operators(a' * a)) 2 ``` -------------------------------- ### expand example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Expands the symbolic prefactor of each term. The example expands (x + y)^2 * a to (x^2 + 2x*y + y^2) * a. ```julia julia> h = FockSpace(:f); julia> @qnumbers a::Destroy(h); julia> @variables x y; julia> expand((x + y)^2 * a) (x^2 + 2x*y + y^2) * a ``` -------------------------------- ### Example: Constructing a correlation function and its spectrum Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api This example demonstrates constructing a correlation function for a cavity mode and computing its spectrum. It defines a Fock space, a destroy operator, mean-field equations, a correlation function, and then calls Spectrum(c). The output shows the resulting spectrum expression ℱ(⟨a' * a_0⟩)(ω). ```julia julia> h = FockSpace(:cavity); julia> @qnumbers a::Destroy(h); julia> eqs = meanfield([a' * a], a' * a, [a]; rates = [1.0], order = 2); julia> c = CorrelationFunction(a', a, eqs); julia> Spectrum(c) ℱ(⟨a' * a_0⟩)(ω) ``` -------------------------------- ### PauliSpace example: create a spin space Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Shows how to create a PauliSpace for a spin. The output displays the resulting space. ```julia julia> PauliSpace(:spin) ℋ(spin) ``` -------------------------------- ### symmetric_to_normal example: convert from symmetric to normal ordering Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Shows symmetric_to_normal converting expressions from symmetric to normal ordering. The example demonstrates that it is the exact inverse of normal_to_symmetric for both a' * a and x * p. ```julia julia> hf = FockSpace(:f); julia> @qnumbers a::Destroy(hf); julia> symmetric_to_normal(normal_to_symmetric(a' * a)) a' * a julia> hp = PhaseSpace(:osc); julia> @qnumbers x::Position(hp) p::Momentum(hp); julia> symmetric_to_normal(normal_to_symmetric(x * p)) x * p ``` -------------------------------- ### Import packages for Mollow triplet example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/examples/mollow Imports QuantumCumulants for the main functionality, ModelingToolkitBase and OrdinaryDiffEqLowOrderRK for equation handling and solving, and Plots for visualization. ```julia using QuantumCumulants using ModelingToolkitBase, OrdinaryDiffEqLowOrderRK using Plots ``` -------------------------------- ### Display Julia and package versions Source: https://qojulia.github.io/QuantumCumulants.jl/stable/examples/heterodyne_detection Runs versioninfo() and Pkg.status() to show the Julia version and the versions of the packages used in the example. The output includes the Julia version, platform details, and the full manifest status. ```julia using InteractiveUtils versioninfo() using Pkg Pkg.status( ["QuantumCumulants", "ModelingToolkitBase", "OrdinaryDiffEqLowOrderRK", "StochasticDiffEqLowOrder", "Plots"], mode = PKGMODE_MANIFEST, ) ``` -------------------------------- ### Show package versions Source: https://qojulia.github.io/QuantumCumulants.jl/stable/examples/ramsey_spectroscopy Displays Julia version information and the status of the packages used in the examples, including QuantumCumulants and the ODE solvers. ```julia using InteractiveUtils versioninfo() using Pkg Pkg.status(["QuantumCumulants", "OrdinaryDiffEqTsit5", "OrdinaryDiffEqLowOrderRK"], mode = PKGMODE_MANIFEST) ``` -------------------------------- ### normal_to_symmetric example: convert from normal to symmetric ordering Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Shows normal_to_symmetric converting expressions from normal to symmetric ordering. The example demonstrates that it is the exact inverse of symmetric_to_normal for both a' * a and x * p, producing -1//2 + a' * a and 1//2im + x * p respectively. ```julia julia> hf = FockSpace(:f); julia> @qnumbers a::Destroy(hf); julia> normal_to_symmetric(a' * a) -1//2 + a' * a julia> hp = PhaseSpace(:osc); julia> @qnumbers x::Position(hp) p::Momentum(hp); julia> normal_to_symmetric(x * p) 1//2im + x * p ``` -------------------------------- ### Install QuantumCumulants.jl with Julia package manager Source: https://qojulia.github.io/QuantumCumulants.jl/stable Use the Julia package manager to add the registered QuantumCumulants package. This is the standard installation method for Julia packages. ```julia pkg> add QuantumCumulants ``` -------------------------------- ### cumulant usage examples Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Examples of computing joint cumulants of a product of operators for different orders, showing the raw unsimplified results. ```julia julia> h = FockSpace(:a) ⊗ FockSpace(:b); julia> @qnumbers a::Destroy(h, 1) b::Destroy(h, 2); julia> cumulant(a * b) ⟨a * b⟩ - ⟨b⟩*⟨a⟩ julia> cumulant(a * b, 1) ⟨a * b⟩ julia> cumulant(a * b, 3) 0 ``` -------------------------------- ### @qnumbers example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Declares a quantum operator using the @qnumbers macro. The example creates a Destroy operator on a Fock space and returns a tuple. ```julia julia> h = FockSpace(:fock); julia> @qnumbers a::Destroy(h) (a,) ``` -------------------------------- ### get_variables example: extract variables from QAdd expression Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Shows how to use get_variables on a QAdd expression. The example creates a Fock space, a destroy operator, and symbolic variables, then counts the variables in the expression ω * a' * a + g * a, returning 2. ```julia julia> h = FockSpace(:f); julia> @qnumbers a::Destroy(h); julia> @variables ω g; julia> length(get_variables(ω * a' * a + g * a)) 2 ``` -------------------------------- ### get_prefactor usage example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Example showing how to extract the prefactor from a single-term QAdd. Creates a Fock space and a Destroy operator, then computes the prefactor of 2*a'*a. ```julia julia> h = FockSpace(:f); julia> @qnumbers a::Destroy(h); julia> get_prefactor(2 * a' * a) 2 ``` -------------------------------- ### System environment and package manifest status Source: https://qojulia.github.io/QuantumCumulants.jl/stable/examples/pulsed_mollow_spectrum This output provides the detailed system platform information and the full list of installed packages and their versions. ```text Julia Version 1.13.0 Commit d1c37793dd2 (2026-09-09 19:00 UTC) Build Info: Official https://julialang.org release Platform Info: OS: Linux (x86_64-linux-gnu) CPU: 4 × AMD EPYC 7763 64-Core Processor WORD_SIZE: 64 LLVM: libLLVM-20.1.8 (ORCJIT, znver3) GC: Built with stock GC Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores) Environment: JULIA_PKG_SERVER_REGISTRY_PREFERENCE = eager JULIA_DEBUG = Documenter Status `~/work/QuantumCumulants.jl/QuantumCumulants.jl/docs/Manifest.toml` [47edcb42] ADTypes v1.24.0 [1520ce14] AbstractTrees v0.4.5 ⌅ [7d9fca2a] Arpack v0.5.3 [4fba245c] ArrayInterface v7.30.2 [aae01518] BandedMatrices v1.12.0 [caf10ac8] BipartiteGraphs v0.1.14 [8e7c35d0] BlockArrays v1.10.0 ⌅ [861a8166] Combinatorics v1.0.2 [38540f10] CommonSolve v0.2.14 [34da2185] Compat v4.18.1 [187b0558] ConstructionBase v1.6.0 [d38c429a] Contour v0.6.3 [864edb3b] DataStructures v0.19.6 [2b5f629d] DiffEqBase v7.21.1 [459566f4] DiffEqCallbacks v4.19.4 [77a26b50] DiffEqNoiseProcess v5.36.3 [b552c78f] DiffRules v1.16.0 [a0c0ee7d] DifferentiationInterface v0.7.21 [ffbed154] DocStringExtensions v0.9.5 [5b8099bc] DomainSets v0.8.1 [4e289a0a] EnumX v1.0.7 [f151be2c] EnzymeCore v0.8.21 [e2ba6199] ExprTools v0.1.11 [c87230d0] FFMPEG v0.4.5 [7a1cc6ca] FFTW v1.10.0 [7034ab61] FastBroadcast v1.4.0 [1a297f60] FillArrays v1.17.0 ⌅ [53c48c17] FixedPointNumbers v0.8.6 [f6369f11] ForwardDiff v1.4.6 [069b7b12] FunctionWrappers v1.1.3 [77dc65aa] FunctionWrappersWrappers v1.13.0 [28b8d3ca] GR v0.73.27 [86223c79] Graphs v1.15.0 [3263718b] ImplicitDiscreteSolve v2.3.0 [8197267c] IntervalSets v0.7.14 [42fd0dbc] IterativeSolvers v0.9.4 [1019f520] JLFzf v0.1.11 [682c06a0] JSON v1.8.0 [ccbc3e58] JumpProcesses v9.32.3 [0b1a1467] KrylovKit v0.10.4 [b964fa9f] LaTeXStrings v1.4.1 [23fbe1c1] Latexify v0.16.12 [7a12625a] LinearMaps v3.11.4 [1914dd2f] MacroTools v0.5.16 [442fdcdd] Measures v0.3.3 [7771a370] ModelingToolkitBase v1.71.2 ⌅ [2e0e35c7] Moshi v0.3.9 [46d2c3a1] MuladdMacro v0.2.7 [77ba4419] NaNMath v1.1.4 [be0214bd] NonlinearSolveBase v2.49.5 [6fe1bfb0] OffsetArrays v1.17.0 [bac558e1] OrderedCollections v2.0.1 [bbf590c4] OrdinaryDiffEqCore v4.17.2 [1344f307] OrdinaryDiffEqLowOrderRK v2.2.5 [b1df2697] OrdinaryDiffEqTsit5 v2.1.4 [ccf2f8ad] PlotThemes v3.3.0 [995b91a9] PlotUtils v1.4.4 [91a5bcdd] Plots v1.41.7 [f517fe37] Polyester v0.7.19 [d236fae5] PreallocationTools v1.7.1 [aea7be01] PrecompileTools v1.3.4 [21216c6a] Preferences v1.6.0 [35bcea6d] QuantumCumulants v0.7.2 `~/work/QuantumCumulants.jl/QuantumCumulants.jl` [6e0679c1] QuantumOptics v1.2.10 [4f57444f] QuantumOpticsBase v0.5.16 [795d4caa] ReadOnlyDicts v1.0.1 [3cdcf5f2] RecipesBase v1.3.4 [01d81517] RecipesPipeline v0.6.12 [731186ca] RecursiveArrayTools v4.5.1 [189a3867] Reexport v1.2.2 [05181044] RelocatableFolders v1.0.1 [ae029012] Requires v1.3.1 [7e49a35a] RuntimeGeneratedFunctions v0.5.26 [9dfe8606] SCCNonlinearSolve v1.15.3 [0bca4576] SciMLBase v3.54.0 [431bcebd] SciMLPublic v1.3.0 [53ae85a6] SciMLStructures v1.10.5 [6c6a2e73] Scratch v1.3.0 [f7aa4685] SecondQuantizedAlgebra v0.12.0 [efcf1570] Setfield v1.1.2 [992d4aef] Showoff v1.1.1 [727e6d20] SimpleNonlinearSolve v2.14.5 [276daf66] SpecialFunctions v2.9.0 [90137ffa] StaticArrays v1.9.20 [1e83bf80] StaticArraysCore v1.4.4 [10745b16] Statistics v1.11.5 [2913bbd2] StatsBase v0.34.13 [789caeaf] StochasticDiffEq v7.2.0 [2efcf032] SymbolicIndexingInterface v0.3.55 [d1185830] SymbolicUtils v4.46.6 [0c5d862f] Symbolics v7.39.2 [ed4db957] TaskLocalValues v0.1.3 [8ea1fca8] TermInterface v2.0.0 [781d530d] TruncatedStacktraces v1.4.0 [3a884ed6] UnPack v1.0.2 [1cfade01] UnicodeFun v0.4.1 [41fe7b60] Unzip v0.2.0 [2a0f44e3] Base64 v1.11.0 [ade2ca70] Dates v1.11.0 [f43a241f] Downloads v1.7.0 [b77e0a4c] InteractiveUtils v1.11.0 [8f399da3] Libdl v1.11.0 [37e2e46d] LinearAlgebra v1.13.0 [44cfe95a] Pkg v1.13.0 [de0858da] Printf v1.11.0 [3fa0cd96] REPL v1.11.0 [9a3f8284] Random v1.11.0 [9e88b42a] Serialization v1.11.0 [2f01184e] SparseArrays v1.13.0 [fa267f1f] TOML v1.0.3 [cf7118a7] UUIDs v1.11.0 Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m` ``` -------------------------------- ### Pkg.status manifest output Source: https://qojulia.github.io/QuantumCumulants.jl/stable/examples/filter-cavity_indexed Example output from `Pkg.status` showing the versions of packages in the manifest, including QuantumCumulants v0.7.2. ```text Status `~/work/QuantumCumulants.jl/QuantumCumulants.jl/docs/Manifest.toml` [47edcb42] ADTypes v1.24.0 [1520ce14] AbstractTrees v0.4.5 [4fba245c] ArrayInterface v7.30.2 [aae01518] BandedMatrices v1.12.0 [caf10ac8] BipartiteGraphs v0.1.14 [8e7c35d0] BlockArrays v1.10.0 ⌅ [861a8166] Combinatorics v1.0.2 [38540f10] CommonSolve v0.2.14 [34da2185] Compat v4.18.1 [187b0558] ConstructionBase v1.6.0 [d38c429a] Contour v0.6.3 [864edb3b] DataStructures v0.19.6 [2b5f629d] DiffEqBase v7.21.1 [459566f4] DiffEqCallbacks v4.19.4 [b552c78f] DiffRules v1.16.0 [a0c0ee7d] DifferentiationInterface v0.7.21 [ffbed154] DocStringExtensions v0.9.5 [5b8099bc] DomainSets v0.8.1 [4e289a0a] EnumX v1.0.7 [f151be2c] EnzymeCore v0.8.21 [e2ba6199] ExprTools v0.1.11 [c87230d0] FFMPEG v0.4.5 [7034ab61] FastBroadcast v1.4.0 [1a297f60] FillArrays v1.17.0 ⌅ [53c48c17] FixedPointNumbers v0.8.6 [f6369f11] ForwardDiff v1.4.6 [069b7b12] FunctionWrappers v1.1.3 [77dc65aa] FunctionWrappersWrappers v1.13.0 [28b8d3ca] GR v0.73.27 [86223c79] Graphs v1.15.0 [3263718b] ImplicitDiscreteSolve v2.3.0 [8197267c] IntervalSets v0.7.14 [1019f520] JLFzf v0.1.11 [682c06a0] JSON v1.8.0 [ccbc3e58] JumpProcesses v9.32.3 [b964fa9f] LaTeXStrings v1.4.1 [23fbe1c1] Latexify v0.16.12 [1914dd2f] MacroTools v0.5.16 [442fdcdd] Measures v0.3.3 [7771a370] ModelingToolkitBase v1.71.2 ⌅ [2e0e35c7] Moshi v0.3.9 [46d2c3a1] MuladdMacro v0.2.7 [77ba4419] NaNMath v1.1.4 [be0214bd] NonlinearSolveBase v2.49.5 [6fe1bfb0] OffsetArrays v1.17.0 [bac558e1] OrderedCollections v2.0.1 [bbf590c4] OrdinaryDiffEqCore v4.17.2 [b1df2697] OrdinaryDiffEqTsit5 v2.1.4 [ccf2f8ad] PlotThemes v3.3.0 [995b91a9] PlotUtils v1.4.4 [91a5bcdd] Plots v1.41.7 [f517fe37] Polyester v0.7.19 [d236fae5] PreallocationTools v1.7.1 [aea7be01] PrecompileTools v1.3.4 [21216c6a] Preferences v1.6.0 [35bcea6d] QuantumCumulants v0.7.2 `~/work/QuantumCumulants.jl/QuantumCumulants.jl` [795d4caa] ReadOnlyDicts v1.0.1 [3cdcf5f2] RecipesBase v1.3.4 [01d81517] RecipesPipeline v0.6.12 [731186ca] RecursiveArrayTools v4.5.1 [189a3867] Reexport v1.2.2 [05181044] RelocatableFolders v1.0.1 [ae029012] Requires v1.3.1 [7e49a35a] RuntimeGeneratedFunctions v0.5.26 [9dfe8606] SCCNonlinearSolve v1.15.3 [0bca4576] SciMLBase v3.54.0 [431bcebd] SciMLPublic v1.3.0 [53ae85a6] SciMLStructures v1.10.5 [6c6a2e73] Scratch v1.3.0 [f7aa4685] SecondQuantizedAlgebra v0.12.0 [efcf1570] Setfield v1.1.2 [992d4aef] Showoff v1.1.1 [727e6d20] SimpleNonlinearSolve v2.14.5 [276daf66] SpecialFunctions v2.9.0 [90137ffa] StaticArrays v1.9.20 [1e83bf80] StaticArraysCore v1.4.4 [10745b16] Statistics v1.11.5 [2913bbd2] StatsBase v0.34.13 [2efcf032] SymbolicIndexingInterface v0.3.55 [d1185830] SymbolicUtils v4.46.6 [0c5d862f] Symbolics v7.39.2 [ed4db957] TaskLocalValues v0.1.3 [8ea1fca8] TermInterface v2.0.0 [781d530d] TruncatedStacktraces v1.4.0 [3a884ed6] UnPack v1.0.2 [1cfade01] UnicodeFun v0.4.1 [41fe7b60] Unzip v0.2.0 [2a0f44e3] Base64 v1.11.0 [ade2ca70] Dates v1.11.0 [f43a241f] Downloads v1.7.0 [b77e0a4c] InteractiveUtils v1.11.0 [8f399da3] Libdl v1.11.0 [37e2e46d] LinearAlgebra v1.13.0 [44cfe95a] Pkg v1.13.0 [de0858da] Printf v1.11.0 [3fa0cd96] REPL v1.11.0 [9a3f8284] Random v1.11.0 [9e88b42a] Serialization v1.11.0 [2f01184e] SparseArrays v1.13.0 [fa267f1f] TOML v1.0.3 [cf7118a7] UUIDs v1.11.0 Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m` ``` -------------------------------- ### Get Julia and package versions with versioninfo and Pkg.status Source: https://qojulia.github.io/QuantumCumulants.jl/stable/examples/superradiant_laser_indexed Run these Julia commands to display the Julia version and the status of the QuantumCumulants and OrdinaryDiffEqTsit5 packages from the manifest. The output shows the exact versions used for the documentation results. ```julia using InteractiveUtils versioninfo() using Pkg Pkg.status(["QuantumCumulants", "OrdinaryDiffEqTsit5"], mode = PKGMODE_MANIFEST) ``` -------------------------------- ### ⊗ example: combine multiple spaces Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Shows how to use the ⊗ operator to combine multiple Hilbert spaces into a ProductSpace. The output displays the resulting composite space. ```julia julia> FockSpace(:a) ⊗ FockSpace(:b) ⊗ NLevelSpace(:atom, 2) ℋ(a) ⊗ ℋ(b) ⊗ ℋ(atom) ``` -------------------------------- ### tensor example: combine two spaces Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Shows how to use the tensor function to combine two Hilbert spaces. The output displays the resulting composite space. ```julia julia> tensor(FockSpace(:a), FockSpace(:b)) ℋ(a) ⊗ ℋ(b) ``` -------------------------------- ### anticommutator example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Computes the anticommutator of a and a' for a Fock space, returning 1 + 2 * a' * a. ```julia julia> h = FockSpace(:f); julia> @qnumbers a::Destroy(h); julia> anticommutator(a, a') 1 + 2 * a' * a ``` -------------------------------- ### Index usage example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Creates a product Hilbert space and two indices: one using a subspace type and one using an integer position. Shows that the two indices are not equal. ```julia julia> h = FockSpace(:site) ⊗ FockSpace(:cavity); julia> i = Index(h, :i, 10, FockSpace(:site)); julia> j = Index(h, :j, 10, 1); # same subspace via integer position julia> i == j false ``` -------------------------------- ### ProductSpace example: tensor product of FockSpace and NLevelSpace Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Shows how to create a ProductSpace by combining a FockSpace and an NLevelSpace with the ⊗ operator. The output displays the resulting composite space. ```julia julia> FockSpace(:cavity) ⊗ NLevelSpace(:atom, 2) ℋ(cavity) ⊗ ℋ(atom) ``` -------------------------------- ### unique_up_to_adjoint! example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Example showing the in-place version modifies the vector to length 1. ```julia julia> h = FockSpace(:f); julia> @qnumbers a::Destroy(h); julia> v = [a, a']; julia> SecondQuantizedAlgebra.unique_up_to_adjoint!(v); julia> length(v) 1 ``` -------------------------------- ### unique_up_to_adjoint example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Example showing unique_up_to_adjoint returns 1 for a list containing a, a', and a. ```julia julia> h = FockSpace(:f); julia> @qnumbers a::Destroy(h); julia> length(unique_up_to_adjoint([a, a', a])) 1 ``` -------------------------------- ### NLevelSpace examples: integer and symbolic levels Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Shows two ways to create an NLevelSpace: with an integer number of levels and with symbolic level names. The output displays the resulting spaces. ```julia julia> NLevelSpace(:atom, 3) ℋ(atom) julia> NLevelSpace(:atom, (:g, :e)) ℋ(atom) ``` -------------------------------- ### Set up and solve ODE system Source: https://qojulia.github.io/QuantumCumulants.jl/stable/examples/weighted_phase_invariance Builds a system from the filtered equations, sets initial conditions with four photons in mode a, defines parameters, and solves the ODE problem using Tsit5. ```julia @named sys = System(eqs_c) sys = complete(sys) u0 = zeros(ComplexF64, length(eqs_c)) u0[1] = 4.0 # ⟨a'a⟩(0) = 4, all other averages zero ps = [Δₐ => 0.0, Δb => 0.0, Δf => 0.0, g => 1.0, κₐ => 0.1, κb => 0.2, κf => 0.2] prob = ODEProblem(sys, merge(initial_values(eqs_c, u0), Dict(ps)), (0.0, 30.0)) sol = solve(prob, Tsit5()) ``` -------------------------------- ### Load required packages Source: https://qojulia.github.io/QuantumCumulants.jl/stable/examples/cavity_antiresonance_indexed Loads QuantumCumulants, OrdinaryDiffEqTsit5, ModelingToolkitBase, and Plots for the simulation. ```julia using QuantumCumulants using OrdinaryDiffEqTsit5, ModelingToolkitBase using Plots ``` -------------------------------- ### First-order mean-field model of a laser with a single atom Source: https://qojulia.github.io/QuantumCumulants.jl/stable This example implements a Jaynes-Cummings Hamiltonian for an optical cavity coupled to a two-level atom, specifies decay processes, derives mean-field equations for the operators [a, σ(:g,:e), σ(:e,:e)] to first order, solves them numerically using ModelingToolkitBase and OrdinaryDiffEq, and plots the photon number dynamics. ```julia using QuantumCumulants h_cav = FockSpace(:cavity) h_atom = NLevelSpace(:atom, (:g,:e)) h = tensor(h_cav, h_atom) @variables Δ::Real g::Real κ::Real γ::Real ν::Real @qnumbers a::Destroy(h) σ(i, j) = Transition(h, :σ, i, j) H = Δ*a'*a + g*(a'*σ(:g,:e) + a*σ(:e,:g)) J = [a,σ(:g,:e),σ(:e,:g)] rates = [κ,γ,ν] eqs = meanfield([a,σ(:g,:e),σ(:e,:e)], H, J; rates=rates, order=1) using ModelingToolkitBase, OrdinaryDiffEqLowOrderRK sys = mtkcompile(System(eqs; name=:laser)) p0 = [Δ=>0, g=>1.5, κ=>1, γ=>0.25, ν=>4] u0 = ComplexF64[1e-2, 0, 0] prob = ODEProblem(sys, merge(initial_values(eqs, u0), Dict(p0)), (0.0,50.0)) sol = solve(prob,RK4()) using Plots ts = range(0.0, 50.0; length=200) n = abs2.(get_solution(sol, a, eqs).(ts)) plot(ts, n, xlabel="t", label="n") ``` -------------------------------- ### simplify example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Simplifies an operator expression by normal-ordering and simplifying coefficients. The example simplifies to 0. ```julia julia> h = FockSpace(:f); julia> @qnumbers a::Destroy(h); julia> @variables x y; julia> expr = (x^2 + 2x*y + y^2) * a' * a - (x + y)^2 * a' * a; julia> simplify(expr) 0 ``` -------------------------------- ### Load required packages Source: https://qojulia.github.io/QuantumCumulants.jl/stable/examples/many-atom-laser Loads QuantumCumulants, ModelingToolkitBase, OrdinaryDiffEqTsit5, and Plots for the simulation. ```julia using QuantumCumulants using ModelingToolkitBase, OrdinaryDiffEqTsit5 using Plots ``` -------------------------------- ### get_sum_indices usage example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Example showing how to use get_sum_indices on an indexed-sum expression, returning the index i. ```julia julia> h = FockSpace(:site); julia> @qnumbers a::Destroy(h); julia> i = Index(h, :i, 3, h); julia> x = average(Σ(IndexedOperator(a', i) * IndexedOperator(a, i), i)); julia> SecondQuantizedAlgebra.get_sum_indices(x) == [i] true ``` -------------------------------- ### Get Julia and package versions Source: https://qojulia.github.io/QuantumCumulants.jl/stable/examples/single-atom-laser-spectrum Run these Julia commands to display the Julia version and the status of the QuantumCumulants and OrdinaryDiffEqLowOrderRK packages from the manifest. The output shows Julia 1.13.0 and the exact package versions used for the documentation. ```julia using InteractiveUtils versioninfo() using Pkg Pkg.status(["QuantumCumulants", "OrdinaryDiffEqLowOrderRK"], mode = PKGMODE_MANIFEST) ``` -------------------------------- ### cumulant_expansion usage example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Example of cumulant_expansion on a product of operators from two subspaces, expanding to order 1. ```julia julia> h = FockSpace(:a) ⊗ FockSpace(:b); julia> @qnumbers a::Destroy(h, 1) b::Destroy(h, 2); julia> cumulant_expansion(average(a * b), 1) ⟨b⟩*⟨a⟩ ``` -------------------------------- ### Create ODE problem and solve Source: https://qojulia.github.io/QuantumCumulants.jl/stable/examples/waveguide Builds the system, compiles it with MTK, maps parameters, and solves the ODE problem with Tsit5. ```julia sys = System(eqs; name = :sys) sys = mtkcompile(sys) dict = parameter_map(sys, merge(Dict(unknowns(sys) .=> u0), Dict(ps .=> p0))) prob = ODEProblem(sys, dict, (0.0, 8.0e-3)) sol = solve(prob, Tsit5(), abstol = 1.0e-6, reltol = 1.0e-6) ``` -------------------------------- ### undo_average example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Strips symbolic averages from an expression. The example verifies that undo_average(average(a' * a)) equals a' * a. ```julia julia> h = FockSpace(:f); julia> @qnumbers a::Destroy(h); julia> undo_average(average(a' * a)) == a' * a true ``` -------------------------------- ### Define system parameters and initial state Source: https://qojulia.github.io/QuantumCumulants.jl/stable/examples/waveguide Sets up the system parameters Γ_ and Ω_, computes position-dependent coupling matrices Γ_ls and Ω_ls, and defines the parameter list ps and initial parameter values p0. ```julia Γ_ = 1.0 # Γ1D # System Parameters Ω_ = Γ_ / 2 # Ω1D x_p = [i / M_p for i in 0:(M_p - 1)] * 2π # positions x_np = [i / M_np for i in 0:(M_np - 1)] * 2π x_ls = [x_p; x_np] Γij(i, j) = cos(abs(x_ls[i] - x_ls[j])) Γ_ls = [Γij(i, j) for i in 1:M for j in 1:M] * Γ_ Ωij(i, j) = sin(abs(x_ls[i] - x_ls[j])) Ω_ls = [Ωij(i, j) for i in 1:M for j in 1:M] * Ω_ ps = [[Γp(i, j) for i in 1:M for j in 1:M]; [Ωp(i, j) for i in 1:M for j in 1:M];] p0 = [Γ_ls; Ω_ls;] ``` -------------------------------- ### Import packages for heterodyne detection simulation Source: https://qojulia.github.io/QuantumCumulants.jl/stable/examples/heterodyne_detection Loads QuantumCumulants, ModelingToolkitBase, OrdinaryDiffEqLowOrderRK, StochasticDiffEqLowOrder, DiffEqNoiseProcess, and Plots for the simulation. ```julia using QuantumCumulants using ModelingToolkitBase using OrdinaryDiffEqLowOrderRK using StochasticDiffEqLowOrder: SDEProblem, EM, EnsembleProblem, ReturnCode using DiffEqNoiseProcess: RealWienerProcess using Plots ``` -------------------------------- ### find_operators example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Example usage of find_operators on a Fock space, showing it returns 1 operator for order 1. ```julia julia> h = FockSpace(:f); julia> length(find_operators(h, 1)) 1 ``` -------------------------------- ### get_indices usage example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Example showing how to use get_indices on an IndexedOperator, returning a vector containing the index i. ```julia julia> h = FockSpace(:site); julia> @qnumbers a::Destroy(h); julia> i = Index(h, :i, 5, h); julia> get_indices(IndexedOperator(a, i)) 1-element Vector{Index}: i ``` -------------------------------- ### substitute example Source: https://qojulia.github.io/QuantumCumulants.jl/stable/api Substitutes a symbolic parameter in an operator expression. The example replaces x with 2 in x * a' * a, yielding 2 * a' * a. ```julia julia> h = FockSpace(:f); julia> @qnumbers a::Destroy(h); julia> @variables x; julia> substitute(x * a' * a, Dict(x => 2)) 2 * a' * a ```