-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Currently the docstring for the abstract type Basis
states
The Basis class is meant to specify a basis of the Hilbert space of the
studied system. Besides basis specific information all subclasses must
implement a shape variable which indicates the dimension of the used
Hilbert space. For a spin-1/2 Hilbert space this would be the
vector `[2]`. A system composed of two spins would then have a
shape vector `[2 2]`.
Before getting into what this .shape
field really means, let's get an overview of all the subtypes. First here's all the subtypes defined in QuantumInterface
:
graph TD;
Basis-->GenericBasis;
Basis-->FockBasis;
Basis-->NLevelBasis;
Basis-->CompositeBasis;
Basis-->PauliBasis;
Basis-->SpinBasis;
Basis-->SumBasis;
Then all the subtypes defined in QuantumOpticsBase
graph TD;
Basis-->SubspaceBasis;
Basis-->ChargeBasis;
Basis-->ShiftedChargeBasis;
Basis-->ManyBodyBasis;
Basis-->ParticleBasis;
ParticleBasis-->PositionBasis;
ParticleBasis-->MomentumBasis;
Finally the only other subtype of Basis
I could find in all of the dependent packages of QuantumInterface
was WaveguideQED.WaveguideBasis
.
One general question is whether it makes sense to try to upstream all the subtypes of Basis
into QuantumInterface
and discourage dependents from implementing their own subtypes? I think this would be advantageous for a few reasons. The first is simply because the the basis for a Hilbert space is independent of a given representation of the objects on that Hilbert space with respect to the given basis. Thus for QuantumInterface
to provide a common interface and help dependents interoperate, I think it should strive to contain the definitions of all bases that dependents use. Then the fields of each subtype of Basis
could be well documented as part of the interface. Also we can ensure the fields define only what is necessary in the mathematical notion of that basis, and nothing which secretly encodes aspects that are representation-dependent. This last point brings me to the question of the .shape
field.
Looking at the Basis
docstring and what is practically stored in .shape
, it seems like it's mainly meant for CompositeBasis
. So .shape
stores the dimensions of each of the bases in the .bases
field of CompositeBasis
, which is understood as the basis for the tensor product space. This is consistent with defining Base.length(b::Basis) = prod(b.shape)
. However SumBasis
also uses .shape
to store the dimensions of each of the bases in its .bases
field and thus must implement length(b::SumBasis) = sum(b.shape)
. Meanwhile QuantumSymbolics
uses FockBasis(Inf,0.)
in which case the .shape
field is [Inf]
. Finally another example of different meaning assigned to .shape
is in the PositionBasis
and MomentumBasis
. In .shape
they store the number of points at which the wavefunction is evenly sampled between the minimum and maximum cutoff values.
I don't actually think there's a universal notion of a .shape
property which applies to all the various possible bases for a given Hilbert space. This point is best illustrated by the case of separable (i.e. countably infinite) Hilbert space.
There are an infinite number of irreducible representations of separable Hilbert space which are unitarily equivalent. The most common representations are fock, position/momentum wavefunction, and phase-space (sometimes called coherent state). Currently QuantumSymbolics
uses FockBasis(Inf,0.)
to refer to the bases for both the fock and coherent state representations. Also given that #32 will enforce that subtypes of AbstractOperator
carry a basis, this will break the way Gabs
repurposes those currently free types to parameterize other aspects of Gaussian operators. Since everything in Gabs
is actually just working within in the coherent state basis. I think we should consider making these distinctions explicit by reworking the types intended for bases of separable Hilbert space.
So concretely, my proposal is to move all subtypes of Basis
to QuantumInterface
, remove the requirement for all of them to implement .shape
and instead maybe only require that they implement Base.length
which can be allowed to return Inf
or some other sensible representation of countable infinity. Finally, I would rework the bases on separable Hilbert space to look like
graph TD;
ParticleBasis-->FockBasis;
FockBasis-->FockCutoffBasis;
ParticleBasis-->CoherentStateBasis;
CoherentStateBasis-->CoherentStateCutoffBasis;
ParticleBasis-->PositionBasis;
PositionBasis-->PositionCutoffBasis;
ParticleBasis-->MomentumBasis;
MomentumBasis-->MomentumCutoffBasis;
If all this makes sense, I can work on this on top #32!