Skip to content

Commit

Permalink
Merge pull request #37 from qsimulate/const-mpo-fix
Browse files Browse the repository at this point in the history
Directly handle constant term in the MPO
  • Loading branch information
JProvazza authored Nov 15, 2024
2 parents 9123967 + a0f3a19 commit 5f84159
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mps_fqe/hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pyblock3.hamiltonian import Hamiltonian
from pyblock3.fcidump import FCIDUMP
from pyblock3.algebra.mps import MPS
from pyblock3.symbolic.symbolic import OpString


allowed_types = [
Expand Down Expand Up @@ -108,9 +109,10 @@ def _operator_map(d_c_ops, alpha_terms, beta_terms):
alpha_terms,
beta_terms)
yield coeff * mpo_operators["alpha"] * mpo_operators["beta"]
yield fqe_ham.e_0() * OpString([])

mpo = hamil.build_mpo(generate_terms,
const=fqe_ham.e_0(),
const=0.0,
cutoff=cutoff,
max_bond_dim=max_bond_dim)

Expand Down Expand Up @@ -201,9 +203,10 @@ def generate_terms(n_sites, c, d):
yield v[isite, jsite] \
* (c[isite, ispin] * c[jsite, jspin]
* d[jsite, jspin] * d[isite, ispin])
yield fqe_ham.e_0() * OpString([])

mpo = hamil.build_mpo(generate_terms,
const=fqe_ham.e_0(),
const=0.0,
cutoff=cutoff,
max_bond_dim=max_bond_dim)

Expand Down Expand Up @@ -239,9 +242,10 @@ def generate_terms(n_sites, c, d):
for isite in range(n_sites):
for ispin in [0, 1]:
yield t[isite] * (c[isite, ispin] * d[isite, ispin])
yield fqe_ham.e_0() * OpString([])

mpo = hamil.build_mpo(generate_terms,
const=fqe_ham.e_0(),
const=0.0,
cutoff=cutoff,
max_bond_dim=max_bond_dim)

Expand Down

0 comments on commit 5f84159

Please sign in to comment.