Skip to content

Commit

Permalink
add missing methods for symmetrized_basis with only zbasis arg
Browse files Browse the repository at this point in the history
  • Loading branch information
abraemer committed Sep 17, 2021
1 parent 8199186 commit 3cb8b93
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SpinSymmetry"
uuid = "ebcc8a00-959b-4e58-a088-282ffd8a4f25"
authors = ["Adrian Braemer <[email protected]> and contributors"]
version = "0.3.0"
version = "0.3.1"

[compat]
julia = "1.6"
Expand Down
8 changes: 6 additions & 2 deletions src/basis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ struct SymmetrizedBasis
end

"""
symmetrized_basis(N[, k], symmetry, sector, more...)
symmetrized_basis(zbasis, symmetry, sector, more...)
symmetrized_basis(N[, k], [symmetry, sector, more...])
symmetrized_basis(zbasis, [symmetry, sector, more...])
Construct a basis in the specified symmetry sectors. Any number of symmetries may be specified.
Expand All @@ -118,6 +118,10 @@ function symmetrized_basis(N::Int, symmetry::AbstractSymmetry, sector::Int, more
symmetrized_basis(zbasis(N), symmetry, sector, more...)
end

symmetrized_basis(N::Int) = SymmetrizedBasis(zbasis(N), [], [])
symmetrized_basis(N::Int, k::Int) = SymmetrizedBasis(zbasis(N, k), [], [])
symmetrized_basis(zbasis::ZBasis) = SymmetrizedBasis(zbasis, [], [])

function symmetrized_basis(N::Int, k::Int, symmetry::AbstractSymmetry, sector::Int, more...)
symmetrized_basis(zbasis(N, k), symmetry, sector, more...)
end
Expand Down
15 changes: 7 additions & 8 deletions test/basis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@

@testset "symmetrized_basis" begin
# different argument forms
@test symmetrized_basis(6) == symmetrized_basis(zbasis(6))
@test symmetrized_basis(6, 2) == symmetrized_basis(zbasis(6, 2))
@test symmetrized_basis(6) isa SymmetrizedBasis
@test symmetrized_basis(zbasis(6), Flip(6), 0) == symmetrized_basis(6, Flip(6), 0)
@test symmetrized_basis(zbasis(6, 2), Flip(6), 0) == symmetrized_basis(6, 2, Flip(6), 0)

Expand Down Expand Up @@ -86,14 +89,10 @@
front = 1:mid
back = 2^N:-1:mid+1

function compare_bases(b1, b2)
return all(SpinSymmetry._indices(b1.basis) .== SpinSymmetry._indices(b2.basis)) &&
all(b1.symmetries .== b2. symmetries) &&
all(b1.sectors .== b2.sectors)
end

@test compare_bases(base, symmetrized_basis(zbasis(N), Flip(N), 0))
@test compare_bases(symmetrized_basis(zbasis(N,1), Flip(N), 1), symmetrized_basis(N, 1, Flip(N), 1))
@test symmetrize_state(state, symmetrized_basis(N, 0)) [state[1]]
@test symmetrize_state(state, zbasis(N, N)) [state[end]]
@test symmetrize_operator(operator, symmetrized_basis(N, 0)) [operator[1,1]]
@test symmetrize_operator(operator, zbasis(N, N)) [operator[end, end]]

symm_state = symmetrize_state(state, base)
@test symm_state symmetrize_state(state, N, Flip(N), 0)
Expand Down

2 comments on commit 3cb8b93

@abraemer
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

  • Add missing methods for symmetrized_basis with only zbasis information. This also enables things like symmetrize_state(state, 5, 1) to project on a magnetization block.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/45071

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.1 -m "<description of version>" 3cb8b93175f405260f05c2ef027496542eee975a
git push origin v0.3.1

Please sign in to comment.