# About custom sitetypes

**URL:** <https://itensor.discourse.group/t/about-custom-sitetypes/2329>\
**Category:** ITensor Julia Questions\
**Created:** [April 2, 2025, 1:31pm UTC](https://itensor.discourse.group/t/about-custom-sitetypes/2329 "2025-04-02T13:31:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![longisland-icetea](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/longisland-icetea/32/540_2.png) [@longisland-icetea](https://itensor.discourse.group/u/longisland-icetea)\
**Post date:** [April 2, 2025, 1:31pm UTC](https://itensor.discourse.group/t/about-custom-sitetypes/2329/1 "2025-04-02T13:31:22Z")

</div>

I found several pages about custom sitetypes similar to [ITensors.jl: Custom SiteTypes - Specific Domains / Numerics - Julia Programming Language](https://discourse.julialang.org/t/itensors-jl-custom-sitetypes/39717). 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:

```auto
#test.jl
using ITensors, ITensorMPS
include("mytype_test.jl")
sites = siteinds("MyType", 10)

```

```auto
#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?

---

<div class="post-metadata">

**Author:** ![ryanlevy](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/ryanlevy/32/150_2.png) [@ryanlevy](https://itensor.discourse.group/u/ryanlevy)\
**Post date:** [April 2, 2025, 3:58pm UTC](https://itensor.discourse.group/t/about-custom-sitetypes/2329/2 "2025-04-02T15:58:18Z")

</div>

You need to include that these are modifying `ITensors`

```julia
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](https://docs.itensor.org/ITensorMPS/stable/examples/Physics.html)

---

<div class="post-metadata">

**Author:** ![longisland-icetea](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/longisland-icetea/32/540_2.png) [@longisland-icetea](https://itensor.discourse.group/u/longisland-icetea)\
**Post date:** [April 2, 2025, 5:42pm UTC](https://itensor.discourse.group/t/about-custom-sitetypes/2329/3 "2025-04-02T17:42:21Z")

</div>

That works. Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/itensor/original/1X/d3072b13e047cd06df7f3981547c0917d940dfa4.png) [@system](https://itensor.discourse.group/u/system)\
**Post date:** [April 12, 2025, 5:42pm UTC](https://itensor.discourse.group/t/about-custom-sitetypes/2329/4 "2025-04-12T17:42:28Z")

</div>

Closed on April 12, 2025, 5:42pm UTC

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