Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

squeeze operators #372

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/phasespace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -558,3 +558,34 @@ function _calc_ylm_norm(l, m)
end
return n
end

"""
squeeze(b::FockBasis, x)

Squeeze operator on a `FockBasis` described by
``S = e^{\\frac{1}{2}(x^* a^2 - x (a^\dagger)^2)}``.
For ``x = e^{i θ}`` the squeezing is along `θ/2`.
"""
function squeeze(b::FockBasis,x)
a = destroy(b)
ad = create(b)
s = exp(conj(x)*dense(a)^2/2 - x*dense(ad)^2/2)
return s
end

"""
squeeze(b::SpinBasis, x)

Squeeze operator on a `SpinBasis` described by
``S = e^{\\frac{1}{2 N}(x^* J_-^2 - x J_+^2)}``.
For ``x = e^{i θ}`` the squeezing is along `θ/2`.
Due to the finiteness of the Hilbert space a too large
squeezing ``(|x| > \sqrt{N})`` will create an over-squeezed state.
"""
function squeeze(b::SpinBasis,x)
N = Int(b.spinnumber*2)
Jm = sigmam(b)/2
Jp = sigmap(b)/2
s = exp(conj(x)*dense(Jm)^2/2/N - x*dense(Jp)^2/2/N)
return s
end
34 changes: 33 additions & 1 deletion test/test_phasespace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,36 @@ end
t2 = abs(int*2*(pi/res)^2)
@test isapprox(t2, 0, atol=1e-2)

end # testset
# squeeze operator tests HO
co = 100
b_fock = FockBasis(co)
a = destroy(b_fock)
ad = create(b_fock);
xx = rand()
s = squeeze(b_fock,xx*exp(1im*pi));

@test log(real(variance((ad+a),s*fockstate(b_fock,0))))/2 ≈ xx

s = squeeze(b_fock,xx*exp(1im*pi*rand()));

@test log(real(variance((ad+a),s*fockstate(b_fock,0))))/2 < xx
@test log(real(variance((ad+a),s*fockstate(b_fock,0))))/2 > -xx

# squeeze oerator test SPIN
N = 500
b_spin = SpinBasis(N//2)
ss = squeeze(b_spin,rand()*sqrt(N)*exp(1im*rand()*pi));
st = ss*spindown(b_spin);

# Heisenberg uncertainty test
@test abs(variance(sigmax(b_spin)/2,st)*variance(sigmay(b_spin)/2,st)) ≥ abs2(expect(sigmaz(b_spin)/2,st))/4

# small squeezing test
xx = rand()/10
ss = squeeze(b_spin,xx*sqrt(N));
st = ss*spindown(b_spin);

@test isapprox(2*log(real(variance(sigmax(b_spin)/2,st))/N*4) , -xx*sqrt(N), atol=1e-2)
@test isapprox(2*log(real(variance(sigmay(b_spin)/2,st))/N*4) , xx*sqrt(N), atol=1e-2)

end # testset
Loading