Skip to content

Doubt regarding callable integer in Hamiltonian functions #202

@Marioherreroglez

Description

@Marioherreroglez

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions