Skip to content

Commit

Permalink
More simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed Jan 20, 2025
1 parent 21b1e78 commit fc05f60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 47 deletions.
28 changes: 2 additions & 26 deletions src/sitetypes/qubit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,11 @@
# defaults for QN names

"""
space(::SiteType"Qubit";
conserve_qns = false,
conserve_parity = conserve_qns,
conserve_number = false,
qnname_parity = "Parity",
qnname_number = "Number")
space(::SiteType"Qubit")
Create the Hilbert space for a site of type "Qubit".
Optionally specify the conserved symmetries and their quantum number labels.
"""
function space(
::SiteType"Qubit";
conserve_qns=false,
conserve_parity=conserve_qns,
conserve_number=false,
qnname_parity="Parity",
qnname_number="Number",
)
if conserve_number && conserve_parity
return [
QN((qnname_number, 0), (qnname_parity, 0, 2)) => 1,
QN((qnname_number, 1), (qnname_parity, 1, 2)) => 1,
]
elseif conserve_number
return [QN(qnname_number, 0) => 1, QN(qnname_number, 1) => 1]
elseif conserve_parity
return [QN(qnname_parity, 0, 2) => 1, QN(qnname_parity, 1, 2) => 1]
end
function space(::SiteType"Qubit")

Check warning on line 14 in src/sitetypes/qubit.jl

View check run for this annotation

Codecov / codecov/patch

src/sitetypes/qubit.jl#L14

Added line #L14 was not covered by tests
return 2
end

Expand Down
29 changes: 8 additions & 21 deletions src/sitetypes/qudit.jl
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
using ChainRulesCore: @non_differentiable

"""
space(::SiteType"Qudit";
dim = 2,
conserve_qns = false,
conserve_number = false,
qnname_number = "Number")
space(::SiteType"Qudit")
Create the Hilbert space for a site of type "Qudit".
Optionally specify the conserved symmetries and their quantum number labels.
"""
function space(
::SiteType"Qudit";
dim=2,
conserve_qns=false,
conserve_number=conserve_qns,
qnname_number="Number",
)
if conserve_number
return [QN(qnname_number, n - 1) => 1 for n in 1:dim]
end
function space(::SiteType"Qudit"; dim=2)

Check warning on line 10 in src/sitetypes/qudit.jl

View check run for this annotation

Codecov / codecov/patch

src/sitetypes/qudit.jl#L10

Added line #L10 was not covered by tests
return dim
end

function val(::ValName{N}, ::SiteType"Qudit") where {N}
return parse(Int, String(N)) + 1
end

## function state(::StateName{N}, ::SiteType"Qudit", s::Index) where {N}
## n = parse(Int, String(N))
## st = zeros(dim(s))
## st[n + 1] = 1.0
## return itensor(st, s)
## end
function state(::StateName{N}, ::SiteType"Qudit") where {N}

Check warning on line 18 in src/sitetypes/qudit.jl

View check run for this annotation

Codecov / codecov/patch

src/sitetypes/qudit.jl#L18

Added line #L18 was not covered by tests
n = parse(Int, String(N))
st = zeros(dim(s))
st[n + 1] = 1.0
return st

Check warning on line 22 in src/sitetypes/qudit.jl

View check run for this annotation

Codecov / codecov/patch

src/sitetypes/qudit.jl#L22

Added line #L22 was not covered by tests
end

# one-body operators
function op(::OpName"Id", ::SiteType"Qudit", ds::Int...)
Expand Down

0 comments on commit fc05f60

Please sign in to comment.