About custom sitetypes

I found several pages about custom sitetypes similar to ITensors.jl: Custom SiteTypes - Specific Domains / Numerics - Julia Programming Language. But it seems the document pages are deprecated. Are there any new document about this topic?

In fact, I have tried to define my sitetype and simply include to my code and got

ERROR: LoadError: Overload of “space”,“siteind”, or “siteinds” functions not found for Index tag: MyType

Here is the test code:

#test.jl
using ITensors, ITensorMPS
include("mytype_test.jl")
sites = siteinds("MyType", 10)
#mytype_test.jl
function space(::SiteType"MyType")
    return 2
end

val(::ValName"1", ::SiteType"MyType") = 1
val(::ValName"2", ::SiteType"MyType") = 2

state(::StateName"1", ::SiteType"MyType") = [1.0, 0.0]
state(::StateName"2", ::SiteType"MyType") = [0.0, 1.0]

What’s the right way to do this?

You need to include that these are modifying ITensors

function ITensors.space(::SiteType"MyType")
    return 2
end

ITensors.val(::ValName"1", ::SiteType"MyType") = 1
ITensors.val(::ValName"2", ::SiteType"MyType") = 2

ITensors.state(::StateName"1", ::SiteType"MyType") = [1.0, 0.0]
ITensors.state(::StateName"2", ::SiteType"MyType") = [0.0, 1.0]

Here is the new relevant doc at the moment: Physics (SiteType) System Examples · ITensorMPS.jl

1 Like

That works. Thanks.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.