Hi there,
I’m having some difficulties when I try to define a new SiteType, with some alias pointing to it.
First of all, I defined a custom SiteType I call vS=1/2
; for this type, I defined some states and operators, such as
function ITensors.state(::StateName"Up", ::SiteType"vS=1/2")
return ...
end
Everything works as intended, so far.
Now, I’d like to define an alias, named HvS=1/2
, to this site type.
I added some lines, mimicking the behaviour of some already existing site types:
ITensors.alias(::SiteType"HvS=1/2") = SiteType"vS=1/2"()
ITensors.space(st::SiteType"HvS=1/2") = ITensors.space(ITensors.alias(st))
function ITensors.state(sn::StateName, st::SiteType"HvS=1/2", s::Index; kwargs...)
return ITensors.state(sn, ITensors.alias(st), s; kwargs...)
end
and so on for the operators.
The problem is, when I define an Index of this second site type, my definitions above for vS=1/2
aren’t reached:
i = Index(4, "HvS=1/2")
state(i, "Up")
returns
ERROR: ArgumentError: Overload of "state" or "state!" functions not found for state name "Up" and Index tags "HvS=1/2"
If i try to follow the functions calls in the REPL with @which
I get
@which ITensors.state(StateName("Up"), SiteType("HvS=1/2"), i)
state(sn::StateName, st::SiteType{HvS=1/2}, s::Index; kwargs...) in mypackage at ...
which is okay, this is the function I defined above; but then
@which ITensors.state(StateName("Up"), ITensors.alias(SiteType("HvS=1/2")), i)
state(::StateName, ::SiteType, ::Index; kwargs...) in ITensors at /opt/julia/packages/ITensors/LXBUp/src/physics/sitetype.jl:524
which is the “default” function in ITensors.jl which returns nothing
.
Here I thought that my ITensors.state(::StateName"Up", ::SiteType"vS=1/2")
above would get called.
What am I missing? Do I need do define something else?