Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite range gives InexactError: trunc(Int64, Inf) #27

Open
HumpyBlumpy opened this issue Sep 17, 2024 · 3 comments
Open

Infinite range gives InexactError: trunc(Int64, Inf) #27

HumpyBlumpy opened this issue Sep 17, 2024 · 3 comments

Comments

@HumpyBlumpy
Copy link

Hi,

Trying out one of the examples to create a Hamiltonian on an infinite chain:

using MPSKit, MPSKitModels, TensorKit
H = @mpoham sum(σᶻᶻ{i, i+1} + h * σˣ{i} for i in -Inf:Inf)

yields ERROR: InexactError: trunc(Int64, Inf). Tried replacing Inf with ∞ but it is not recognized.
Am I missing a certain package or something?
I have Julia 1.10

@lkdvos
Copy link
Member

lkdvos commented Sep 18, 2024

Hi,

My apologies for this inconvenience. The macro is supposed to handle these kinds of syntactic sugar features (in this case just replacing the range with InfiniteChain(L) where L is the unit cell) but at some point it became quite inconvenient to keep track of what are intuitive things that should be supported, and what is not. My own opinion on the matter is that it has taken too much development time for very little benefit, so I have been neglecting the macro a bit (again my apologies for that).

In this case, you can just simply replace the iterator with some type of lattice, which should then work.
I will make sure to update the examples to reflect this.

As a side note, do you feel like this kind of syntax adds a lot of value? If so, I will definitely try and fix it and support this again.
(Next week, as I am currently on holiday)

@HumpyBlumpy
Copy link
Author

HumpyBlumpy commented Sep 18, 2024

Thanks for the quick response. I think I managed to construct the Hamiltonian by copying parts of the source code for some of the predefined models. The syntax there is however somewhat cumbersome.
I am not sure what you mean by

simply replace the iterator with some type of lattice

An example would help:)
I tried
H = @mpoham sum(σᶻᶻ{i, i+1} + h * σˣ{i} for i in InfiniteChain(1)) but that didnt work.

@leburgel
Copy link
Member

I think you need to add an explicit iteration over the vertices for it to know what to do. This should work I think:

H = @mpoham sum(σᶻᶻ(){i, i+1} + h * σˣ(){i} for i in vertices(InfiniteChain(1)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants