Calculating transition and state density matrices and dipole moment matrices

Hello to all Psi4 users and authors,

I am rather new to Psi4, and I like the interface! I am trying to use it to calculate electronic density matrices (transition and for individual states) and electronic dipole moment matrices (transition and for individual states) for a CASSCF calculation. I intend to use these for comparison with a custom code that I am modifying, which calculates the same quantities.

The input I am using is as follows:

molecule hehp1 {
H   0.0  0.0 -0.386
He  0.0  0.0  0.386

1 1

symmetry c1
}

set {
    scf_type        out_of_core
    basis           STO-3G
    reference       rhf
    print           5
    frozen_docc     [0]
    active          [2]
    frozen_uocc     [0]
    mcscf_type      ao
    num_roots       R
    opdm            true
    tdm             true
    dipmom          true
}

cas_e, wfn = energy("casscf", return_wfn=True)
#fci_e, wfn = energy("fci", return_wfn=True)

opdm_a = wfn.get_opdm(N, M, "A", True)

dm = opdm_a.to_array()
#print('density matrix(S', N, ', S', M, '):\n', dm)

My values for R, N, M are 3, (b/w 0 and 2), and (b/w 0 and 2), respectively.

I have a few questions about this calculation:

  1. The above works for N=0 and any value of M up to (R-1). A GitHub issue thread tells me it should work for other values of N up to (R-1) as well, but it doesn’t. Why does it not work for the above input, and is there a solution to get it to work? For more information, running the above input gives me the following error (even with the fci method):
    Traceback (most recent call last):
    File "/path/to/psi4conda/bin/psi4", line 287, in <module>
    exec(content)
    File "<string>", line 39, in <module>
    Fatal Error: CIWavefunction::get_opdm: Requested OPDM was not formed!
    Error occurred in file: /path/to/scratch/psilocaluser/conda-builds/psi4-multiout_1557940846948/work/psi4/src/psi4/detci/ciwave.cc on line: 359

  2. How do I access the dipole moment matrices (transition as well as individual state ones, between and of all the R states), so I can print them out/save in numpy data files?

  3. Is there a way to print these matrices in the AO basis?

  4. How do I access the CI vectors of all the R roots (also to print out/save as numpy data files)?

Thank you for your patience with this post, and any help is greatly appreciated!

Karnamohit

P.S.: Here is a list of some of the topic threads and manual pages I consulted before I decided to create this topic (for help in any future searches):

*I forgot to mention that the version of psi4 I’m using is 1.3.2

  1. I don’t think there is another way. (This PR is tangentially relevant https://github.com/psi4/psi4/issues/1812, though understanding why requires some background knowledge about how detci makes OPDMs.) The good news is that I think I see the issue in the code, and this looks like an easy bug to fix. I’m running this past some of the developers more experienced in the ways of the detci module. (https://github.com/psi4/psi4/issues/1890) If my diagnosis of the problem is correct, this will be very easy to fix.

I’m a little confused on 2 and 3. It sounds like you want this matrix in the basis of CI states, and in the basis of AOs. Those aren’t compatible bases. There is no way to write a CI state as a linear combination of AOs, unless it’s a one-electron state. A CI state is a linear combination of Slater Determinants or Configuration State Functions, if you’re being fancy. Both the matrices you’re asking about exist, but they’re not related by change of basis.

  1. I don’t think you can. The best you can do is manually use the CI coefficients detci gives at the end of the output file. This is a grievance my group has, as well. Friendly poke at @loriab that others are interested in this feature as well, so don’t let CDS forget. My understanding is that there’s only one person who knows this part of the code well enough to add this feature, and that while this is on his to-do list, he’s a busy man, so it’ll be some time.
1 Like

I only want 3. for the density matrices, so that was an unclear on my part. I do need the dipole moment matrices in the CI basis. If not available, I could use the OPDMs to get the dipole moment matrices in the CI basis, I would think, if I have them (CI OPDMs) in the AO basis and the HF dipole moment matrices in the AO basis. Is there a way I could get access those? I briefly checked out the -m flag, for a messy execution that saves a bunch of matrices from the hf method calculation but it did not seem to have what I wanted.

I am yet to check what prop function gives me for the fci or the casscf method (going by the cc55.in test input), but if this works then I think it might be sufficient for me.

Thank you for your help and the clarification!

While I haven’t tried this myself, you should be able to get the dipole elements one-by-one with syntax of the form get_variable("CI ROOT n -> ROOT m DIPOLE X").

As for the dipole matrices, I believe you’re looking for this. Construct a MintsHelper object, then call the ao_dipole method to get a lit of the AO basis dipole elements.

1 Like