qojulia / QuantumOptics.jl

Library for the numerical simulation of closed as well as open quantum systems.
http://qojulia.org
Other
530 stars 104 forks source link

Defining Wigner for particle bases #420

Open DhruvaSambrani opened 11 hours ago

DhruvaSambrani commented 11 hours ago

Given a state in the position/momentum bases, we can calulcate the wigner function as (black text)

image

as defined in wiki.

We should implement this function for states on the particle bases.

DhruvaSambrani commented 11 hours ago

A starting point can be

function mywigner(psi)
    map(Iterators.product(samplepoints(psi.basis), samplepoints(MomentumBasis(psi.basis)))) do (x, p)
        xmax = psi.basis.xmax
        xmin = psi.basis.xmin
        N = psi.basis.N
        dy = (xmax - xmin)/N
        getloc(x) = round(Int, (x - xmin)/N) + 1
        ys = collect(filter(y->(xmin<x+y<xmax)&&(xmin<x-y<xmax), samplepoints(psi.basis)))
        1/(π*ħ) * sum(ys, init=0) do y
            conj(psi[getloc(x+y)]) * psi[getloc(x-y)] * cis(2*p*y/ħ) * dy
        end
    end
end

However, a better approach may be to actually perform a FT instead of running a sum

Krastanov commented 3 hours ago

Starting with a simple implementation is perfectly reasonable. If you have the time, please submit a PR and the rest of us will try to help with review.