gayverjr / opencap

An open source program for the description of metastable electronic states in molecules.
https://gayverjropencap.readthedocs.io/en/latest/index.html
MIT License
19 stars 7 forks source link

getting error in eomea_ccsd.py example(path: opencap/examples/pyopencap/pyscf /eomea_ccsd.py) #52

Open gorachand-das opened 5 months ago

gorachand-das commented 5 months ago

Please help me to resolve the issue, While attempting to execute the ''eomea_ccsd.py'' code , specifically the line where the spatial2spin_ea function is called, I encountered the following error:

ValueError: shape mismatch: value array of shape (112,) could not be broadcast to indexing result of shape (0,224). (for the given basis set n2.nw, I checked with other basis sets also.)

image

gorachand-das commented 5 months ago

We need to perform r1_spin and r2_spin separately.

gayverjr commented 5 months ago

Hi there, Thanks for the report! I can take a closer look tomorrow, but it seems you may have figured it out?

We need to perform r1_spin and r2_spin separately.

Do you mind sharing what you were able to get to work, so I can update the example?

gorachand-das commented 5 months ago

Yes, It seems like appending issue, so the updated code will be as follows,

r1 = [] r2 = [] l1 = [] l2 = [] h0 = np.zeros((nstates,nstates))

collect EOM amplitudes in spin orbital basis

for i in range(0,nstates): r1_curr,r2_curr = myeom.vector_to_amplitudes(r_eom[:,i],myeom.nmo,myeom.nocc) l1_curr,l2_curr = myeom.vector_to_amplitudes(l_eom[:,i],myeom.nmo,myeom.nocc) dummyR1 = np.zeros(np.shape(r1_curr)) dummyR2 = np.zeros(np.shape(r2_curr)) r1_spin = spatial2spin_ea((r1_curr,dummyR1)) r2_spin=spatial2spin_ea((dummyR2,r2_curr,dummyR2,dummyR2)) l1_spin = spatial2spin_ea((l1_curr,dummyR1)) l2_spin = spatial2spin_ea((dummyR2,l2_curr,dummyR2,dummyR2)) r1.append(r1_spin) r2.append(r2_spin) l1.append(l1_spin) l2.append(l2_spin) h0[i][i] = e_r[i] + mycc.e_hf + mycc.e_corr

gayverjr commented 5 months ago

Great thanks! One more question, what version of PySCF are you using?

I'll get some more updated wheels on PyPi soon too :)

gorachand-das commented 5 months ago

Yea, I am currently using the 2.5.0 version.

I have another query. Can we extract information (or visualize) about the modified orbitals due to the presence of CAP?

gayverjr commented 5 months ago

Can we extract information (or visualize) about the modified orbitals due to the presence of CAP?

Good question. Unfortunately, it's not the most straightforward thing, especially with a package like PySCF which doesn't provide a ton of niceties out of the box. One thing to keep in mind here is that the type of calculations one does with OpenCAP are projected CAP, so the CAP is only applied post-hoc. In other words, the orbitals are real, the eigenstates of the EOM-CC Hamiltonian are also real, and we get our representation of the resonance by allowing the N+1 electron eigenstates to mix under the influence of CAP. In my experience, this approximation works quite well when you have enough eigenstates, but translating the CAP-modified eigenstates back to the one-electron orbitals is not straightforward.

Where I have seen this done is with CAP implementations that implement the CAP as an additional one-electron term starting from HF. This is quite a bit more expensive computationally than the projected formalism, but does more readily allow this type of analysis. Here are some papers I recommend on the subject: https://iopenshell.usc.edu/pubs/pdf/jcp-144-054113.pdf https://pubs.acs.org/doi/abs/10.1021/acs.jpca.9b01134

gorachand-das commented 5 months ago

Thank you for your prompt response, I will definitely go through these articles. By the way I am more interested to study temporary negative ion (TNI) states formed due to low energy electron impact with molecules. Now formation of these TNI states are resonance (shape/feshbach) process, and if any of the TNI state survives for long enough time (compaired to auto detachment of electron, roughly more than 50 fs), It can undergo dissociation (dissociative electron attachment). That's why I am interested to calculate the lifetime.

gayverjr commented 5 months ago

Exciting work, I hope you find OpenCAP useful! One tip I have for feshbach resonances is that you likely will want to reach for multi-reference methods due to their multi-electron character. The OpenMolcas interface (and through OpenMolcas, Columbus) would likely be helpful for that. Here's a reference you may find useful as well: https://pubs.acs.org/doi/abs/10.1021/acs.jctc.1c01310

gorachand-das commented 5 months ago

Yes, thank you; this is a very useful suggestion for me.