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.

How to get 2 body density matrix after a dft calculation?

See original GitHub issue

Hi all, after running a dft calculation, it is possible to use the make_rdm1() method to get the reduced 1 body density matrix, but I cannot seem to get the two body density matrix too - so get_rdm2() does not seem to be implemented. Can anyone help me in getting this 2 body density matrix after a dft calculation?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
maxnuscommented, Jul 27, 2022

This transformation you show for the 1-RDM is not correct, you need to consider the AO-overlap matrix which you can get from mf.get_ovlp():

dm1_ao = mf.make_rdm1()
r = np.dot(mf.mo_coeff.T, mf.get_ovlp())
dm1_mo = np.linalg.multi_dot((r, dm1_ao, r.T))

For the 2-DM you can use the numpy.einsum function:

dm2_ao = mf.make_rdm2()
r = np.dot(mf.mo_coeff.T, mf.get_ovlp())
dm2_mo = numpy.einsum("abcd,ia,jb,kc,ld->ijkl", dm2_ao, r, r, r, r)

Note however that in the MO basis the DMs are very simple and diagonal, and can be build directly:

dm1_mo = np.zeros((norb, norb))
for i in range(nocc):
    dm1_mo[i,i] = 2

and

dm2_mo = np.zeros((norb, norb, norb, norb))
for i in range(nocc):
    for j in range(nocc):
        dm2_mo[i,i,j,j] += 4
        dm2_mo[i,j,j,i] -= 2

This is all for restricted spin-symmetry

1reaction
maxnuscommented, Jul 22, 2022

I actually submitted a PR for the HF classes recently here If this gets accepted, the make_rdm2 method should also be available for DFT, via inheritance. In the meantime you can check out the additions in the PR to see how to build it from the 1-DM. Note that in practice you probably don’t need to build the 2-DM in a mean-field method, but simply contract your operator with the product of 1-DMs directly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Orbital functionals in density-matrix - OSTI.gov
relation beyond DFT. Within this theory the one-body reduced density matrix (1-. RDM) is used as the basic variable. Our main interest is...
Read more >
Density Matrix approach in Density Functional Theory
Since Kohn-Sham density functional theory only uses a single Slater determinant, at T=0K the λn are either 0 or 1 (or 0 or...
Read more >
Reduced Density Matrix Functional Theory (P. Romaniello)
This lecture introduces th reduced density matrix functional theory. It is part of the online ISTPC school.
Read more >
A Bird's-Eye View of Density-Functional Theory - arXiv
The final two sections, 5 and 6, contain a (necessarily less detailed) description of approximations typically made in practical DFT calculations, and of...
Read more >
A comprehensive, self‐contained derivation of the one‐body ...
Abstract In this contribution, we review in a rigorous, yet comprehensive fashion the assessment of the one-body reduced density matrices ...
Read more >

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