SiteType with attributes

Hi! I am looking to create a site type that hosts multiple different phonon modes (up to 3). When defining operators, I need to know the dimension of each mode subspace so that each mode operator acts only upon its respective subspace. However, I am not familiar enough with the SiteType type to know how to implement this.

For example, I know that the ITensors.op(…) function takes in an index as an operator, and I know that I can extract the overall dimension of the index from here. However, I don’t think I would be able to read off from the index itself how the space is divided up into subspaces.

Thanks again for all the great work you do! Really appreciate it.

Thanks for the question – hopefully the examples here
https://itensor.github.io/ITensors.jl/stable/examples/Physics.html
give enough information if you follow them closely.

From your question, I believe you understand the system better than you might think! That’s right that ITensors.op takes an Index (at least one version of it does) and once you can extract the dimension you are basically in business.

The key thing to realize is that how the space is divided up into subspaces is up to you. So it will actually be set by how you define your operators, and is really divided up any way you want, since it is your custom definition.

To be concrete, we could have just as easily decided that the first setting of a “S=1/2” index meant spin down and then defined all the S=1/2 operators using that convention and it would have worked equally well in terms of giving correct numerical results. But of course we did things in the more “usual” way so as not to be confusing.

Things get slightly more complicated if you want to involve conserved quantum numbers (QNs) though not actually much more complicated.

If you are still feeling stuck after reading through the code examples page, please let me know more specific details about the SiteType you want to define (dimension, QNs if any, and an example operator or two) and we can talk about it in more detail.