qojulia / QuantumOptics.jl

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

ParticuleBasis #339

Open ghost opened 1 year ago

ghost commented 1 year ago

Hello, I was wondering if you could add a ParticuleBasis abstract type such that

PositionBasis <: ParticuleBasis
MomentumBasis <: ParticuleBasis
david-pl commented 1 year ago

We could, but I don't really see a use for it. If you just want to dispatch on this in a script, you can also do something like

const ParticleBasis = Union{<:MomentumBasis,<:PositionBasis}

function f(b::ParticleBasis)
# do stuff
end

What do you want to achieve here?

ghost commented 1 year ago

I want to define many functions that work the same for both momentum and position basis. Stuff like

create(b::ParticuleBasis) = (position(b) + im * momentum(b)) / sqrt(2)
destroy(...) = ...
displace(...) = ...
squeeze(...) = ...
...

I also want to define some operators on a composite particule and spin basis.

I know the difference in runtime between the union and abstract type version is marginal, but I find the abstract type version cleaner.