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

Doubt regarding callable integer in Hamiltonian functions #202

Closed
Marioherreroglez opened this issue Oct 1, 2024 · 3 comments
Closed

Doubt regarding callable integer in Hamiltonian functions #202

Marioherreroglez opened this issue Oct 1, 2024 · 3 comments

Comments

@Marioherreroglez
Copy link

I am trying to understand why we need to make parameters for the Hamiltonians callable and hence depend on the graph. I want to define three-body terms (actual node, nearest neighbor node, and next nearest neighbor), should I make the parameters depend also on these (below)?

function haldane(g::AbstractGraph; J=1, h₁=0, h₂=0)
    (; J, h₁, h₂) = map(to_callable, (;J, h₁, h₂))
    ℋ = OpSum()
    for e in edges(g)
      for nextnn in next_nearest_neighbors(g, dst(e))
        ℋ -= J(e,nextnn) , "Sz", src(e), "Sx", dst(e),  "Sx", nextnn
      end
      #Other terms go here
    end
  return ℋ
  end

What would be the implications of skipping the callable part as shown below?

function haldane(g::AbstractGraph; J=1, h₁=0, h₂=0)
    ℋ = OpSum()
    for e in edges(g)
      for nextnn in next_nearest_neighbors(g, dst(e))
        ℋ -= J , "Sz", src(e), "Sx", dst(e),  "Sx", nextnn
      end
      #Other terms go here
    end
  return ℋ
  end
@emstoudenmire
Copy link
Contributor

Hi Mario,
This sounds like a support question versus an issue. Could you please post this question on our support forum at https://itensor.discourse.group ? Also when you post, could you please say which file contains the code you are referring to above, to give more context? Thanks.

@mtfishman
Copy link
Member

mtfishman commented Oct 1, 2024

@Marioherreroglez agreed with Miles that if something is more of a question rather than an issue or feature request it should be posted on the support forum rather than on Github.

As a short answer, this allows for users to pass either numbers as parameters, in which case they are treated as uniform couplings and fields, or as a function of the edges and vertices in the case of non-uniform couplings and fields.

In the simplest case, if the couplings and fields are constants (the same on every site/vertex in the case of the fields or bond/edge in the case of the couplings), you can just pass numbers, and the conversion to a callable is just an internal detail that you don't have to worry about.

@mtfishman
Copy link
Member

This question was reposted and answered here: https://itensor.discourse.group/t/itensornetworks-callable-hamiltonian-parameters/2031.

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