diff --git a/Project.toml b/Project.toml index 2d631639..2bd7726f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "QuantumOpticsBase" uuid = "4f57444f-1401-5e15-980d-4471b28d5678" -version = "0.4.7" +version = "0.4.8" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/docs/src/api.md b/docs/src/api.md index e66a317c..5b23bf87 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -248,6 +248,10 @@ create(::Type{C}, ::FockBasis) where C displace ``` +```@docs +squeeze +``` + ```@docs fockstate ``` diff --git a/src/QuantumOpticsBase.jl b/src/QuantumOpticsBase.jl index bc55fe35..83c0395a 100644 --- a/src/QuantumOpticsBase.jl +++ b/src/QuantumOpticsBase.jl @@ -38,6 +38,7 @@ export Basis, GenericBasis, CompositeBasis, basis, FockBasis, number, destroy, create, fockstate, coherentstate, coherentstate!, displace, displace_analytical, displace_analytical!, + squeeze, randstate, randoperator, thermalstate, coherentthermalstate, phase_average, passive_state, #spin SpinBasis, sigmax, sigmay, sigmaz, sigmap, sigmam, spinup, spindown, diff --git a/src/fock.jl b/src/fock.jl index fa40c2b0..96ef671e 100644 --- a/src/fock.jl +++ b/src/fock.jl @@ -49,7 +49,7 @@ create(b::FockBasis) = create(ComplexF64, b) """ displace([T=ComplexF64,] b::FockBasis, alpha) -Displacement operator ``D(α)`` for the specified Fock space with optional data +Displacement operator ``D(α)=\\exp{\\left(α\\hat{a}^\\dagger-α^*\\hat{a}\\right)}`` for the specified Fock space with optional data type `T`, computed as the matrix exponential of finite-dimensional (truncated) creation and annihilation operators. """ @@ -60,6 +60,20 @@ end displace(b::FockBasis, alpha::T) where {T <: Number} = displace(ComplexF64, b, alpha) +""" + squeeze([T=ComplexF64,] b::FockBasis, z) + +Squeezing operator ``S(z)=\\exp{\\left(\\frac{z^*\\hat{a}^2-z\\hat{a}^{\\dagger2}}{2}\\right)}`` for the specified Fock space with optional data +type `T`, computed as the matrix exponential of finite-dimensional (truncated) +creation and annihilation operators. +""" +function squeeze(::Type{T}, b::FockBasis, z::Number) where T + z = T(z)/2 + asq = destroy(T, b)^2 + exp(dense(conj(z) * asq - z * dagger(asq))) +end + +squeeze(b::FockBasis, z::T) where {T <: Number} = squeeze(ComplexF64, b, z) # associated Laguerre polynomial, borrowed from IonSim.jl function _alaguerre(x::Real, n::Int, k::Int) diff --git a/test/test_fock.jl b/test/test_fock.jl index 77f3a906..b1dde2de 100644 --- a/test/test_fock.jl +++ b/test/test_fock.jl @@ -46,12 +46,18 @@ basis = FockBasis(2) b = FockBasis(30) alpha = complex(0.5, 0.3) d = displace(b, alpha) -a = destroy(b) @test 1e-12 > D(d*dagger(d), identityoperator(b)) @test 1e-12 > D(dagger(d)*d, identityoperator(b)) @test 1e-12 > D(dagger(d), displace(b, -alpha)) @test 1e-15 > norm(coherentstate(b, alpha) - displace(b, alpha)*fockstate(b, 0)) +# Test squeezing operator +b = FockBasis(30) +z = complex(0.5, 0.3) +s = squeeze(b, z) +@test 1e-12 > D(s*dagger(s), identityoperator(b)) +@test 1e-12 > D(dagger(s)*s, identityoperator(b)) +@test 1e-12 > D(dagger(s), squeeze(b, -z)) α = complex(rand(0.0:0.1:2.0), rand(0.0:0.1:2.0)) for ofs in 0:3