State Library
Schrodinger.@qb_str
— Macroqb"bitstring"
Generate a qubit state ket from the given bitstring. This string macro can also be invoked via the macro notation @qb_str "bitstring"
.
Returns a sparse vector.
Example
julia> Ψ⁻ = normalize!(qb"01" - qb"10")
4-d Ket{SparseVector{Float64, Int64}, 2} with dimensions 2⊗2
0.71∠0°|0,1⟩ + 0.71∠180°|1,0⟩
See also: ket
, for generating arbitrary states.
Schrodinger.basis
— Methodbasis(N, n)
Generate a basis state (a.k.a. Fock or number state) ket $|n⟩$, in a Hilbert space of size N
. Note that the size of the Hilbert space must be at least n+1
. The function fock
is an alias for basis
.
Returns a sparse vector.
Example
julia> ψ = basis(3,2)
3-d Ket{SparseVector{Float64, Int64}, 1} with dimensions 3
1.00∠0°|2⟩
Schrodinger.coherent
— Functioncoherent(N, α, analytic=false)
Generate a coherent state ket $|α⟩$, in a Hilbert space of size N
. To create a coherent density operator, use the Operator
function: Operator(coherent(N,n))
.
Two methods can be used for generating a coherent state: via application of a displacment operator on a ground state (the default), or analytically, with the formula
\[|α⟩ = e^{-\frac{|α|^2}{2}} ∑_{n=0}^{N-1} \frac{α^n}{\sqrt{n!}} |n⟩.\]
While the operator method will return a normalized ket, the analytic method will not. Both methods converge as N
gets larger. The analytic method is also much faster, especially for large N
.
Returns a dense vector.
Example
julia> coherent(6,0.4+1im)
6-d Ket{Vector{ComplexF64}, 1} with dimensions 6
0.60∠68°|1⟩ + 0.56∠0°|0⟩ + 0.46∠136°|2⟩ + 0.29∠-155°|3⟩ + 0.15∠-87°|4⟩ +…
Schrodinger.ket
— Methodket(state,dims=2)
Generate a state ket from a tuple of basis levels and a tuple of corresponding space dimensions. Note that each space dimension must be larger than the level by at least 1. If only an integer is passed to dims
, all basis levels will have the same dimension.
Returns a sparse vector.
Example
julia> ψ = ket((3,0,1),(5,2,3))
30-d Ket{SparseVector{Float64, Int64}, 3} with dimensions 5⊗2⊗3
1.00∠0°|3,0,1⟩
See also: @qb_str
, for generating qubit states via a bitstring.
Schrodinger.maxentangled
— Functionmaxentangled(n,N=2)
Generate a maximally entangled state between n
N
-d systems:
\[|ϕ⟩=∑_{j=0}^{N-1}\frac{1}{\sqrt{N}}|j⟩^{⊗n}.\]
Tracing out all but one of the entangled systems results in a maximally mixed state.
Example
julia> ψ = maxentangled(3,4)
64-d Ket{SparseVector{Float64, Int64}, 3} with dimensions 4⊗4⊗4
0.50∠0°|0,0,0⟩ + 0.50∠0°|1,1,1⟩ + 0.50∠0°|2,2,2⟩ + 0.50∠0°|3,3,3⟩
julia> ptrace(ψ,(1,3))
4×4 Operator{Matrix{Float64}, 1} with dimensions 4
0.25 0.0 0.0 0.0
0.0 0.25 0.0 0.0
0.0 0.0 0.25 0.0
0.0 0.0 0.0 0.25
Schrodinger.maxmixed
— Methodmaxmixed(N)
Generate a maximally mixed density matrix. The maximally mixed state is a mixture of basis states with uniform probability.
Returns a sparse matrix.
Example
julia> maxmixed(4)
4×4 Operator{SparseMatrixCSC{Float64, Int64}, 1} with dimensions 4
0.25 ⋅ ⋅ ⋅
⋅ 0.25 ⋅ ⋅
⋅ ⋅ 0.25 ⋅
⋅ ⋅ ⋅ 0.25
Schrodinger.thermal
— Methodthermal(N, n)
Generate a thermal state density matrix $ρ_n$ with particle number n
, in a Hilbert space of size N
. A thermal state $ρ_n$ is a probabilistic mixture of basis states such that the expectation value of the number operator $\hat{n}$ is n
. Note that this is true only if $N≫n$. The returned density matrix is always normalized.
Returns a sparse matrix.
Example
julia> N=5; n=0.2;
julia> ρ = thermal(N,n)
5×5 Operator{SparseMatrixCSC{Float64, Int64}, 1} with dimensions 5
0.833441 ⋅ ⋅ ⋅ ⋅
⋅ 0.138907 ⋅ ⋅ ⋅
⋅ ⋅ 0.0231511 ⋅ ⋅
⋅ ⋅ ⋅ 0.00385852 ⋅
⋅ ⋅ ⋅ ⋅ 0.000643087
julia> expect(numberop(N),ρ)
0.19935691318327978