pkozlows / fci

0 stars 0 forks source link

how to generate the fci matrix? #10

Closed pkozlows closed 1 year ago

pkozlows commented 1 year ago

I am confused about how to pack the MEls from the unique determinant pairs I generated into a full configuration interaction matrix. I believe I asked a similar question before I started writing code for the project, but I still haven't resolved it. That is, I've calculated {0,1,2,3,4,6}, {0,1,3,5,6,7}, and {0,1,2,3,4,7}, {2,3,4,5,6,7} to have different MEls, even if they are both of the form <single|H|double>, where * means single excitation from GS det, etc. However, there is only one full configuration interaction matrix, but I have calculated different MEls for what should be the same entry, if that makes sense.

pkozlows commented 1 year ago

If you have a second, you could take a quick peak at main.py, where I have combined all the functions I created thus far, ranging from the determinant generation that I started with to now implementation of the Condon rules.

Walter-Feng commented 1 year ago

No I don’t think they should be same entry. It’s not like <single | H | double>.

Is it like you are thinking the FCI matrix is in the basis of {ground state, single, double, triple…}?

pkozlows commented 1 year ago

Yes, the difference from the ground state basis is the only one I have read about for full configuration interaction, especially in the modern quantum chemistry book by szabo. I see that it would be more convenient to think about it not in terms of excitations from the ground state determinant. How would I think about it differently though? Like is there any literature I could read to educate myself on this point?

pkozlows commented 1 year ago

I imagine that this is something I should read through?

https://www.sciencedirect.com/science/article/pii/0010465589900337

Walter-Feng commented 1 year ago

I personally prefer Molecular electronic-structure theory by Helgaker. Let me know if you have no access to the book. The article you mentioned might be slightly too difficult for you.

pkozlows commented 1 year ago

Screenshot_20230204-103119.png

I took a look at the article I mentioned, and it doesn't look like the best introduction for me. I don't have access to the book you mentioned through the California institute of technology library. However, if you think buying a paper copy of this book would also be useful for future purposes, I would be happy to do so.

pkozlows commented 1 year ago

Paying for online access could be an option to, if I am only interested in the chapter on configuration interaction theory or for a few select chapters.

pkozlows commented 1 year ago

Let me also ask around to check if any one I know has a copy that they aren't using, and they would be willing to mail it to me.

pkozlows commented 1 year ago

the price options for online access look like this. Screenshot_20230204-103821.png

Walter-Feng commented 1 year ago

No worries. Sent email regarding this.

pkozlows commented 1 year ago

This textbook seems to have exactly what I need. For now, do I just want to try to understand the sections 11.6 and 11.7 or would it be good to divert myself to read the whole chapter on configuration interaction theory straight away?

Walter-Feng commented 1 year ago

maybe 11.1 can also help you shape a good understanding of CI. A glance at Hartree-Fock may also be helpful.

pkozlows commented 1 year ago

After glancing at the book, I'm getting the feeling that I need to develop a more complete understanding of CI and HF. Particularly, I don't yet fully understand the theory behind CSFs, and although I know that they are not that relevant to generating the full configuration interaction matrix in the Slater-determined basis that I am working on, it is probably worth it to study relevant basis sets, like CSFs, a little bit more before I can figure out how to generate the full configuration interaction matrix in the Slater-determined basis. HF and 11.1 are helpful, but maybe I need to take a bit of a detour in order to understand the theory better so I can implement it? I'm getting the feeling that reading chapters 8 and 9 will not be helpful for this project. Do you have any recommendations about what it would be helpful for me to read, or do you need to know a little more about my knowledge base? My current knowledge base of HF and full configuration interaction has helped me get to the point where I am in the project so far, but I'm getting the feeling that I need to do a little bit more studying of the theory before I can make further progress in implementing full configuration interaction.

Walter-Feng commented 1 year ago

According to my experience, it’s not barely the mathematical understanding that hinders your progress - but more to me the ability to convert the mathematical understanding to blocks of code. In a certain way, writing program debugs your math.

If you are confident about your HF, you can try with writing HF given the h1e / h2e. It will be part of FCI matrix anyway, so not too far away from the journey.

You can also consider reading some code to see how we match the equations with code. You can check my Hartree Fock code, written in C++, or Junjie’s code in python. I am confident about my code style, but I cannot guarantee the grammars in C++ will not become obstacle to your reading.

pkozlows commented 1 year ago

Yeah, I agree with you on the first point; I don't think just sitting and reading without writing any code will be too constructive.

I believe I have some understanding of HF: HF approximate the wave function as a single determinant, the GS determinant. So writing a code for HF wouldn't be constructing a Matrix at all, I would just be computing the expectation value <psi_GS|1e+2e|psi_GS>. I believe I can readily compute this quantity, as I implemented the Condon rules for when there is no difference between two determinants, as in the HF case. And I missing something here?

pkozlows commented 1 year ago

If I'm understanding the HF correctly, computing a value like <psi_GS|1e+2e|psi_GS> wouldn't be too much of a problem for me, but I am more confused about how to implement full configuration interaction in a determinant basis, so I don't see how a HF computation would help me with that?

Walter-Feng commented 1 year ago

Ah well it's the first step for constructing the matrix, as the HF energy will go into the very first diagonal element of FCI matrix. We can compare the HF energy and see if it matches. If can manage to make HF energy correct, then basically you solve the first part of Condon rule, which is the diagonal elements of FCI matrix.

pkozlows commented 1 year ago

That sounds like a good start. Do you have a HF value I can compare to, or should I look online for value for hydrogen 6?

I am pretty stuck in terms of thinking about the full configuration interaction matrix in the basis of |hf>, |single>, |double>, etc., Where the single and double notation corresponds to excitations from The HF G state, where the former in reality corresponds to a lot of different determinants. So, I think I would be able to readily compute <hf|H||hf>, but being stuck in thinking of the bases of the full configuration interaction Matrix in terms of excitations from the HF GS will also, I believe ,inhibit me from computing the diagonals. I hope what I'm saying makes some sense, but if not, maybe just starting out by comparing my HF value to yours will be a good starting point.

Walter-Feng commented 1 year ago

You can confirm with me once you get the value - I can generate it from my old code.

From this you can make matrix element of “ground state” with some “single” determinants, then some “double” determinants. You can also compare diagonal elements of some “single” determinants, etc… then gradually you might get rid of the singles and doubles, getting the whole idea of determinant basis.

pkozlows commented 1 year ago

My HF energy is -6.277825297355697.

I feel like I might be canting the idea of a determinant basis. But then my energy for <6,7,8,9,10,11|1e+2e|6,7,8,9,10,11> Is also -6.277825297355697, so the same as for the grand state HF diiagonal of <0,1,2,3,4,5|1e+2e|0,1,2,3,4,5>. so, it seems The value of -6.277825297355697 is reasonable for the HF energy, but I probably have some debugging to do if I'm getting the same the value for <6,7,8,9,10,11|1e+2e|6,7,8,9,10,11>?

I think I would be canting a better idea for the determined basis if a quantity like <6,7,8,9,10,11|1e+2e|6,7,8,9,10,11>, which should be lower than the HF energy, was lower?

are you kind of able to follow my thought process or should I tract something up on latex to explain?

Walter-Feng commented 1 year ago

<6,7,8,9,10,11|1e+2e|6,7,8,9,10,11> should not be having the same energy as <0,1,2,3,4,5|1e+2e|0,1,2,3,4,5> - otherwise you are having the same energy when electrons are stuffed into orbitals with higher energy, or say, anti-bonding orbitals.

The energy I get, <0,1,2,3,4,5|1e+2e|0,1,2,3,4,5>, is -7.73937395. As I have unit test that my FCI matrix will produce the correct FCI energy, I am relatively confident about my number.

pkozlows commented 1 year ago

So let's assume that eventually I will get correct energies for an arbitrary pair of determinants. I need to figure out a way to order correctly. Order The various Matrix elements that I found using the condon rules Probably into a numpy ndarray.Do you have any hints? Because I'm not sure how I would get started with this.

pkozlows commented 1 year ago

I forgot to mention, I think I am getting the idea of a determinant basis now, but I'm just not completely sure how I would implement this.

Walter-Feng commented 1 year ago

If you understand what is determinant basis, or before that, what a basis means in Quantum mechanics, then it will be trivial to understand what a Hamiltonian basis is in this representation.

It requires a bit more knowledge to understand that ndarray, or high-order tensors, are still part of linear algebra. Nevertheless, this extra knowledge makes me believe that Full CI can be fit into different ndarray representations.

In other words, the shape of ndarray should be a result of your understanding about basis and Hamiltonian, instead of the initiator to your understanding. Hence I would like to keep it a secret for now.

pkozlows commented 1 year ago

So if I'm understanding correctly, they shape of the Full country duration, interaction Matrix. Would be ndarray that is (# of determinants, # of determinants) With they bases That would be the number of determinants that are unique?

pkozlows commented 1 year ago

Nevertheless, this extra knowledge makes me believe that Full CI can be fit into different ndarray representations.

This line confused me. What could I do to learn more about it? So, doesn't confuse me.

Walter-Feng commented 1 year ago

Exactly. That’s why I have always been emphasizing how to generate a determinant basis.

Walter-Feng commented 1 year ago

Nevertheless, this extra knowledge makes me believe that Full CI can be fit into different ndarray representations.

This line confused me. What could I do to learn more about it? So, doesn't confuse me.

I will be giving a hint here- there is an operation called flatten in any linear algebra library, including numpy.

Walter-Feng commented 1 year ago

But it’s out of scope - taking a few days understanding this will not help you shape the Full CI program.

We can iterate over this after this project. I was playing with this a few months ago.