Hello,

I am new to Psi4, and I really like the Python API! I would like to develop an interface with Psi4 for a software package I am developing which is aimed at describing metastable states using the complex absorbing potential method. We use a subspace projection scheme in which the CAP is projected onto a set of eigenvectors obtained from an excited electronic structure method such as CI,EOM-CC etc. My package computes the CAP matrix in atomic orbital basis, and then uses 1RDMs and TDMs (passed to my program from Psi4 as numpy matrices) to compute CAP matrix elements (a 1-electron operator) in the state basis. So far, I’ve gotten it to work with CI in Psi4, but only for C1 symmetry:

```
import psi4
import numpy as np
mol = psi4.geometry("""H 0.0000000000 0.0000000000 0.3705000000
H 0.0000000000 0.0000000000 -0.3705000000
Symmetry C1""")
E, wfn = psi4.energy('scf/aug-cc-pvqz', return_wfn=True)
mints = psi4.core.MintsHelper(wfn.basisset())
S_mat = np.asarray(mints.ao_overlap())
# verify overlap matrix in my program to check AO ordering, this always works
# s.check_overlap_mat(S_mat,"psi4")
nstates= 10
psi4.set_options({"opdm":True,"num_roots":nstates,"tdm":True,"basis":"aug-cc-pvqz"})
ci_energy, ci_wfn = psi4.energy('FCI', return_wfn=True)
mo_coeff = ci_wfn.Ca()
for i in range(0,nstates):
for j in range(i,nstates):
opdm_mo = ci_wfn.get_opdm(i, j, "SUM", True)
opdm_ao = psi4.core.triplet(mo_coeff, opdm_mo, mo_coeff, False, False, True)
opdm_ao = opdm_ao.to_array(dense=True)
# pass tdm/rdm for each state/transition to my program, only works properly for C1
# pc.add_tdm(opdm_ao,i,j,"psi4")
```

My program currently understands the GTO ordering that Psi4 uses (verified by checking overlap matrix), so when there’s just a single irrep, things work fine. But I haven’t been able to figure out how to perform this MO–>AO transformation (in the original AO ordering) when there are multiple irreps. I know the dense=True argument to the to_array function at returns a single matrix rather than a matrix for each irrep, but it seems to be sorted by irrep, and I’m not sure how to transform this into the original AO ordering, which is required for my program. So to summarize, I have two main questions:

- Is there a convenient way to perform MO–>AO transformation for 1RDMs and 1TDMs which recovers the original atomic orbital ordering (i.e. which matches the orbital ordering used in the overlap matrix) when there are multiple irreps?
- Are there functions similar to get_opdm for CI which provide direct access to 1RDMs and 1TDMs between excited states for other methods such as EOM-CC?

Any help would be greatly appreciated!

Here are the topic threads I have consulted:

- Calculating transition dipole moment between different CI excited states
- Calculating transition and state density matrices and dipole moment matrices
- Extracting alpha and beta densities
- What is the syntax for the Da function?
- Is there a way to calculate transition dipole moments between excited states?
- MO basis - dipole moments and amplitudes at positions

I’ve also consulted the doc string in the Molden function here: psi4/driver.py at a548d758c52fd76d5f10e9592e36d84b127bb432 · psi4/psi4 · GitHub