Basis construction
In SymBasis.jl, you construct a basis by first defining a DoF object and then calling the basis function from the SymBasis.Bases submodule. If you want to resolve symmetries, you additionally provide one symmetry group or a combined symmetry group; otherwise, you can omit them to build the full, unreduced basis. The basis function takes the DoF object, the system size, and optionally symmetry group(s), and returns a basis object containing the basis states and their normalization constants.
First, let's import the necessary submodules:
using SymBasis.DoFObjects
using SymBasis.SymGroups
using SymBasis.BasesNext, we define a DoF object for a system, for example, containing spin-1/2 particles:
N = 4 # number of sites
dofo = dof_object(Spin(1 // 2)) # define, for example, a spin-1/2DoFObject: Spin (B=2)
ldof: (-1//2, 1//2)
index types: T=UInt64, Ti=Int64Without any symmetries
To construct the full, unreduced basis without any symmetries, you can simply call the basis function with the DoF object and the system size as follows:
b_wo_sym = basis(dofo, N)Basis{SymBasis.DigitBase.BaseInt{UInt64, Int64, 2},Float64} with 16 states
states: Vector{SymBasis.DigitBase.BaseInt{UInt64, Int64, 2}}
norms : Vector{Float64}
first 10 states/norms:
(0)₂ (norm=1.0)
(1)₂ (norm=1.0)
(10)₂ (norm=1.0)
(11)₂ (norm=1.0)
(100)₂ (norm=1.0)
(101)₂ (norm=1.0)
(110)₂ (norm=1.0)
(111)₂ (norm=1.0)
(1000)₂ (norm=1.0)
(1001)₂ (norm=1.0)
⋮
This will generate the full basis for a system of 4 spin-1/2 particles, which consists of $2^4 = 16$ basis states.
With symmetries
To construct a basis that resolves one or more symmetries, you can first define the corresponding symmetry group(s) and then pass them to the basis function. For example, if you want to construct a basis that resolves the total magnetization symmetry, you can define the symmetry group for total magnetization and then call the basis function as follows:
Sz = 0 # total magnetization quantum number
# Define the symmetry group for total magnetization
sg_Sz = sym(TotalMagnetization(Sz, N), dofo)
# Construct the basis that resolves the total magnetization symmetry
b_with_Sz_sym = basis(dofo, N, sg_Sz)Basis{SymBasis.DigitBase.BaseInt{UInt64, Int64, 2},Float64} with 6 states
states: Vector{SymBasis.DigitBase.BaseInt{UInt64, Int64, 2}}
norms : Vector{Float64}
first 6 states/norms:
(11)₂ (norm=1.0)
(101)₂ (norm=1.0)
(110)₂ (norm=1.0)
(1001)₂ (norm=1.0)
(1010)₂ (norm=1.0)
(1100)₂ (norm=1.0)
This will generate a basis that consists of the basis states with total magnetization quantum number $S^z = 0$ for a system of 4 spin-1/2 objects. You can similarly define other symmetry groups and combine them to construct bases that resolve multiple symmetries simultaneously.
For instance, if you want to construct a basis that resolves both the total magnetization symmetry and the translational symmetry, you can define the symmetry group for translational symmetry and then combine it with the total magnetization symmetry group as follows:
perm = mod1.((1:N) .+ 1, N) # permutation for translational symmetry
k = 0 # momentum quantum number
# Define the symmetry group for translational symmetry
sg_translational = sym(Translational(k, perm), dofo)
# Combine the total magnetization symmetry and the translational symmetry
csg = sg_Sz ∘ sg_translational
# Construct the basis that resolves both symmetries
b_with_both_syms = basis(dofo, N, csg)Basis{SymBasis.DigitBase.BaseInt{UInt64, Int64, 2},Float64} with 2 states
states: Vector{SymBasis.DigitBase.BaseInt{UInt64, Int64, 2}}
norms : Vector{Float64}
first 2 states/norms:
(1010)₂ (norm=8.0)
(1100)₂ (norm=4.0)
This will generate a basis that consists of the basis states with total magnetization quantum number $S^z = 0$ and momentum quantum number $k = 0$ for a system of 4 spin-1/2 objects.
If you are unsure about whether these symmetries commute with each other in the constructed basis, you can simply pass the combined symmetry group to the is_commutative function from the SymBasis.SymGroups submodule to check if the symmetries commute:
is_commutative(b_with_both_syms, csg)trueThis will return true if the symmetries with commute and false otherwise. If the symmetries do not commute, you cannot combine them to construct a basis that resolves both symmetries simultaneously.