block-hczhai / block2-preview

Efficient parallel quantum chemistry DMRG in MPO formalism
GNU General Public License v3.0
67 stars 23 forks source link

Error transforming SU2 to SZ mps #108

Closed ferupp closed 3 months ago

ferupp commented 3 months ago

I'm trying to transform a SU2 mps into a SZ mps using the mps_change_to_sz function and get an error doing that. Block2 was build from the current main branch.

It seems to me that the error is due to the changes in adjust_mps in the commit ec1a8eb (see the printed ket.center and ket.canonical_form[0]). I haven't tried earlier versions yet, though.

from pyblock2.driver.core import DMRGDriver, SymmetryTypes

driver = DMRGDriver(symm_type=SymmetryTypes.SU2, stack_mem=1073741824*160,
        n_threads=120)
driver.read_fcidump('./FCIDUMP-21', pg='c1')
driver.initialize_system(n_sites=driver.n_sites, n_elec=driver.n_elec,
        spin=driver.spin, orb_sym=driver.orb_sym)

ket = driver.load_mps(tag='KET')

print(ket.center, ket.canonical_form[0])

ket = driver.mps_change_to_sz(ket, "SZ")
0 S
Traceback (most recent call last):
  File "dmrg/get_overlap.py", line 13, in <module>
    ket = driver.mps_change_to_sz(ket, "SZ")
  File "block2-preview/pyblock2/driver/core.py", line 7091, in mps_change_to_sz
    zmps = self.adjust_mps(zmps, dot=mps.dot)[0]
  File "block2-preview/pyblock2/driver/core.py", line 6032, in adjust_mps
    ket.flip_fused_form(ket.center, self.ghamil.opf.cg, self.prule)
TypeError: flip_fused_form(): incompatible function arguments. The following argument types are supported:
    1. (self: block2.sz.MPS, arg0: int, arg1: block2.sz.CG, arg2: block2.sz.ParallelRuleBase) -> None

Invoked with: <block2.sz.MPS object at 0x7f07e9a4c430>, 0, <block2.su2.CG object at 0x7f07e9e56770>, None

Since the script that creates the SU2 mps causing the problem takes a few hours to run, I didn't include it here. Please let me know in case you need it. Thanks

hczhai commented 3 months ago

Thanks for reporting the problem. Should be fixed in https://github.com/block-hczhai/block2-preview/commit/6e4ffc3bb7447e7634b8df41cef1c109d44c7a60. Please let me know if there are any further problems.

ferupp commented 3 months ago

This fixes the issue. Thanks alot for the quick fix!