question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error getting 1rdm after KCCSD calculation

See original GitHub issue

Hello,

Can you please help me resolve the following issue: I am trying to obtain a 1rdm after performing a KCCSD calculation for a single k point that is not the gamma point, as shown below (PySCF v1.7.6) :

import numpy
from   pyscf.pbc import gto,scf,cc,mp
cell = gto.M(a       = numpy.eye(3)*3.5668,
             atom    = '''Mg 0 0 0''',
             basis   = 'gth-dzv',
             pseudo  = 'gth-pade',
             verbose = 4)

kpts = numpy.ones((1,3))*0.1
mf   = scf.KRHF(cell,kpts).density_fit()
mf.kernel()
c = mp.KMP2(mf)
c.kernel()
c.make_rdm1()

c = cc.KCCSD(mf)
c.kernel()
c.make_rdm1()

The above code was able to produce the KMP2 based 1 body RDM, but fails when called for KCCSD with the following error:

Traceback (most recent call last):
  File "pyscf_1rdm_error.py", line 20, in <module>
    c.make_rdm1()
  File ".../lib/python3.8/site-packages/pyscf/cc/ccsd.py", line 1139, in make_rdm1
    if l1 is None: l1, l2 = self.solve_lambda(t1, t2)
  File ".../lib/python3.8/site-packages/pyscf/cc/ccsd.py", line 1079, in solve_lambda
    ccsd_lambda.kernel(self, eris, t1, t2, l1, l2,
  File ".../lib/python3.8/site-packages/pyscf/cc/ccsd_lambda.py", line 51, in kernel
    imds = fintermediates(mycc, t1, t2, eris)
  File ".../lib/python3.8/site-packages/pyscf/cc/ccsd_lambda.py", line 81, in make_intermediates
    nocc, nvir = t1.shape
ValueError: too many values to unpack (expected 2)

Is there a way to resolve this error and obtain a 1RDM for a KCCSD calculation at a single k point which is not the gamma point, please?

Thank you very much for the help!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
yangcalcommented, Aug 26, 2021

Hello,

We currently don’t have lambda solvers for pbc.cc and make_rdm1 is only implemented for kuccsd as Xiao mentioned. Please note that we just found a bug in kuccsd_rdm (l1, l2 should be approximated by (t1.conj(), t2.conj()) rather than (t1, t2), this will be fixed after PR: https://github.com/pyscf/pyscf/pull/1043).

1reaction
xwang862commented, Aug 25, 2021

I just found out that @yangcal has implemented 1-RDM for KUCCSD, which should work for your case (if you are not restricted to RCCSD). Here is a sample input:

import numpy
from   pyscf.pbc import gto,scf,cc,mp
cell = gto.M(a       = numpy.eye(3)*3.5668,
             atom    = '''Mg 0 0 0''',
             basis   = 'gth-dzv',
             pseudo  = 'gth-pade',
             verbose = 7)

kpts = numpy.ones((1,3))*0.1
mf   = scf.KRHF(cell,kpts).density_fit()
mf.kernel()
c = mp.KMP2(mf)
c.kernel()
c.make_rdm1()

c = cc.KUCCSD(mf)
ecc, t1, t2 = c.kernel()

from pyscf.pbc.cc.kuccsd_rdm import make_rdm1
dm1a,dm1b = make_rdm1(c, t1, t2, l1=None, l2=None)

Note that I didn’t provide lambdas (l1, l2). They will be approximated later by (t1, t2) amplitudes, which I think is a fair treatment in many cases. @yangcal can probably share more insights.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found