Skip to content

Commit

Permalink
change SqueezedCoherentState to SqueezedState
Browse files Browse the repository at this point in the history
  • Loading branch information
apkille committed Sep 17, 2024
1 parent d2cd291 commit 57c8e35
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/src/QHO.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Summarized below are supported bosonic states.

- Fock state: `FockState(idx::Int)`,
- Coherent state: `CoherentState(alpha::Number)`,
- Squeezed coherent state: `SqueezedCoherentState(alpha::Number, z::Number)`.
- Squeezed vacuum state: `SqueezedState(z::Number)`.

## Operators

Expand Down
2 changes: 1 addition & 1 deletion ext/QuantumOpticsExt/QuantumOpticsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function finite_basis(s,r)
end
express_nolookup(s::FockState, r::QuantumOpticsRepr) = fockstate(finite_basis(s,r),s.idx)
express_nolookup(s::CoherentState, r::QuantumOpticsRepr) = coherentstate(finite_basis(s,r),s.alpha)
express_nolookup(s::SqueezedCoherentState, r::QuantumOpticsRepr) = (b = finite_basis(s,r); squeeze(b, s.z)*coherentstate(b, s.alpha))
express_nolookup(s::SqueezedState, r::QuantumOpticsRepr) = (b = finite_basis(s,r); squeeze(b, s.z)*fockstate(b, 0))
express_nolookup(o::NumberOp, r::QuantumOpticsRepr) = number(finite_basis(o,r))
express_nolookup(o::CreateOp, r::QuantumOpticsRepr) = create(finite_basis(o,r))
express_nolookup(o::DestroyOp, r::QuantumOpticsRepr) = destroy(finite_basis(o,r))
Expand Down
2 changes: 1 addition & 1 deletion src/QSymbolicsBase/QSymbolicsBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export SymQObj,QObj,
MixedState,IdentityOp,
SApplyKet,SApplyBra,SMulOperator,SSuperOpApply,SCommutator,SAnticommutator,SBraKet,SOuterKetBra,
HGate,XGate,YGate,ZGate,CPHASEGate,CNOTGate,
XBasisState,YBasisState,ZBasisState,FockState,CoherentState,SqueezedCoherentState,
XBasisState,YBasisState,ZBasisState,FockState,CoherentState,SqueezedState,
NumberOp,CreateOp,DestroyOp,PhaseShiftOp,DisplaceOp,SqueezeOp,
XCXGate,XCYGate,XCZGate,YCXGate,YCYGate,YCZGate,ZCXGate,ZCYGate,ZCZGate,
qsimplify,qsimplify_pauli,qsimplify_commutator,qsimplify_anticommutator,qsimplify_fock,
Expand Down
16 changes: 6 additions & 10 deletions src/QSymbolicsBase/predefined_fock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ end
CoherentState(alpha::Number) = CoherentState(alpha, inf_fock_basis)
symbollabel(x::CoherentState) = "$(x.alpha)"

"""Squeezed coherent state in defined Fock basis."""
@withmetadata struct SqueezedCoherentState <: SpecialKet
alpha::Number
"""Squeezed vacuum state in defined Fock basis."""
@withmetadata struct SqueezedState <: SpecialKet
z::Number
basis::FockBasis
end
SqueezedCoherentState(alpha::Number, z::Number) = SqueezedCoherentState(alpha, z, inf_fock_basis)
symbollabel(x::SqueezedCoherentState) = "$(x.alpha),$(x.z)"
SqueezedState(z::Number) = SqueezedState(z, inf_fock_basis)
symbollabel(x::SqueezedState) = "0,$(x.z)"

const inf_fock_basis = FockBasis(Inf,0.)
"""Vacuum basis state of n"""
Expand Down Expand Up @@ -150,14 +149,11 @@ const Destroy = const â = DestroyOp()
"""Squeezing operator in defined Fock basis.
```jldoctest
julia> c = CoherentState(im)
|im⟩
julia> S = SqueezeOp(pi)
S(π)
julia> qsimplify(S*c, rewriter=qsimplify_fock)
|im,π⟩
julia> qsimplify(S*vac, rewriter=qsimplify_fock)
|0,π⟩
```
"""
@withmetadata struct SqueezeOp <: AbstractSingleBosonOp
Expand Down
2 changes: 1 addition & 1 deletion src/QSymbolicsBase/rules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ RULES_FOCK = [
@rule(dagger(~o1::_isa(DisplaceOp)) * ~o2::_isa(DestroyOp) * ~o1 => (~o2) + (~o1).alpha*IdentityOp((~o2).basis)),
@rule(dagger(~o1::_isa(DisplaceOp)) * ~o2::_isa(CreateOp) * ~o1 => (~o2) + conj((~o1).alpha)*IdentityOp((~o2).basis)),
@rule(~o::_isa(DisplaceOp) * ~k::((x->(isa(x,FockState) && x.idx == 0))) => CoherentState((~o).alpha)),
@rule(~o::_isa(SqueezeOp) * ~k::_isa(CoherentState) => SqueezedCoherentState((~k).alpha, (~o).z))
@rule(~o::_isa(SqueezeOp) * ~k::_isequal(vac) => SqueezedState((~o).z, (~o).basis))
]

RULES_SIMPLIFY = [RULES_PAULI; RULES_COMMUTATOR; RULES_ANTICOMMUTATOR; RULES_FOCK]
Expand Down
6 changes: 3 additions & 3 deletions test/test_express_opt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
@test express(Destroy*F1) express(Destroy)*express(F1)
@test express(displace*cstate) express(displace)*express(cstate)

squeezedcstate = SqueezedCoherentState(im, pi)
squeezeop = SqueezeOp(pi)
@test express(squeezedcstate) express(squeezeop)*express(cstate)
squeezed = SqueezedState(pi/4)
squeezeop = SqueezeOp(pi/4)
@test express(squeezed) express(squeezeop)*express(vac)
end
4 changes: 2 additions & 2 deletions test/test_fock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
phase2 = PhaseShiftOp(pi)
displace = DisplaceOp(im)
squeezeop = SqueezeOp(pi)
scstate = SqueezedCoherentState(im,pi)
sstate = SqueezedState(pi)

@testset "ladder and number operators" begin
@test isequal(qsimplify(Destroy*vac, rewriter=qsimplify_fock), SZeroKet())
Expand All @@ -27,6 +27,6 @@
end

@testset "Squeeze operators" begin
@test isequal(qsimplify(squeezeop*cstate, rewriter=qsimplify_fock), scstate)
@test isequal(qsimplify(squeezeop*vac, rewriter=qsimplify_fock), sstate)
end
end

0 comments on commit 57c8e35

Please sign in to comment.