Skip to content

Commit 138e019

Browse files
akirakyleKrastanov
andauthored
Add squeezing operator (#114)
* Add squeezing operator * add explicit formula in docstring for displace and squeeze * bump version number --------- Co-authored-by: Stefan Krastanov <[email protected]>
1 parent ab9995f commit 138e019

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "QuantumOpticsBase"
22
uuid = "4f57444f-1401-5e15-980d-4471b28d5678"
3-
version = "0.4.7"
3+
version = "0.4.8"
44

55
[deps]
66
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

docs/src/api.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ create(::Type{C}, ::FockBasis) where C
248248
displace
249249
```
250250

251+
```@docs
252+
squeeze
253+
```
254+
251255
```@docs
252256
fockstate
253257
```

src/QuantumOpticsBase.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export Basis, GenericBasis, CompositeBasis, basis,
3838
FockBasis, number, destroy, create,
3939
fockstate, coherentstate, coherentstate!,
4040
displace, displace_analytical, displace_analytical!,
41+
squeeze,
4142
randstate, randoperator, thermalstate, coherentthermalstate, phase_average, passive_state,
4243
#spin
4344
SpinBasis, sigmax, sigmay, sigmaz, sigmap, sigmam, spinup, spindown,

src/fock.jl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ create(b::FockBasis) = create(ComplexF64, b)
4949
"""
5050
displace([T=ComplexF64,] b::FockBasis, alpha)
5151
52-
Displacement operator ``D(α)`` for the specified Fock space with optional data
52+
Displacement operator ``D(α)=\\exp{\\left(α\\hat{a}^\\dagger-α^*\\hat{a}\\right)}`` for the specified Fock space with optional data
5353
type `T`, computed as the matrix exponential of finite-dimensional (truncated)
5454
creation and annihilation operators.
5555
"""
@@ -60,6 +60,20 @@ end
6060

6161
displace(b::FockBasis, alpha::T) where {T <: Number} = displace(ComplexF64, b, alpha)
6262

63+
"""
64+
squeeze([T=ComplexF64,] b::FockBasis, z)
65+
66+
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
67+
type `T`, computed as the matrix exponential of finite-dimensional (truncated)
68+
creation and annihilation operators.
69+
"""
70+
function squeeze(::Type{T}, b::FockBasis, z::Number) where T
71+
z = T(z)/2
72+
asq = destroy(T, b)^2
73+
exp(dense(conj(z) * asq - z * dagger(asq)))
74+
end
75+
76+
squeeze(b::FockBasis, z::T) where {T <: Number} = squeeze(ComplexF64, b, z)
6377

6478
# associated Laguerre polynomial, borrowed from IonSim.jl
6579
function _alaguerre(x::Real, n::Int, k::Int)

test/test_fock.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,18 @@ basis = FockBasis(2)
4646
b = FockBasis(30)
4747
alpha = complex(0.5, 0.3)
4848
d = displace(b, alpha)
49-
a = destroy(b)
5049
@test 1e-12 > D(d*dagger(d), identityoperator(b))
5150
@test 1e-12 > D(dagger(d)*d, identityoperator(b))
5251
@test 1e-12 > D(dagger(d), displace(b, -alpha))
5352
@test 1e-15 > norm(coherentstate(b, alpha) - displace(b, alpha)*fockstate(b, 0))
5453

54+
# Test squeezing operator
55+
b = FockBasis(30)
56+
z = complex(0.5, 0.3)
57+
s = squeeze(b, z)
58+
@test 1e-12 > D(s*dagger(s), identityoperator(b))
59+
@test 1e-12 > D(dagger(s)*s, identityoperator(b))
60+
@test 1e-12 > D(dagger(s), squeeze(b, -z))
5561

5662
α = complex(rand(0.0:0.1:2.0), rand(0.0:0.1:2.0))
5763
for ofs in 0:3

0 commit comments

Comments
 (0)