Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dfocc: canonical uhf df/cd ccsd/(t)/(at) E/G #2739

Merged
merged 8 commits into from
Dec 4, 2022
Merged

Conversation

loriab
Copy link
Member

@loriab loriab commented Oct 5, 2022

Description

Finally, the first of @bozkaya's new methods. These are the canonical (non-orbital-optimized, non-FNO) CC methods with UHF reference by density-fitting and Cholesky decomposition. Gradients available for the most popular methods.

This is PR No. 5 in the mega-dfocc-remp series.

User API & Changelog headlines

  • new methods!
    • uhf df ccd E & G
    • uhf df ccsd E & G
    • uhf df ccsd(t) E & G (present but experimental (require set qc_module occ) until further optimized)
    • uhf df a-ccsd(t) E (present but experimental (require set qc_module occ) until further optimized)
    • uhf cd-ccd E
    • uhf cd-ccsd E
    • uhf cd-ccsd(t) E (present but experimental (require set qc_module occ) until further optimized)
    • uhf cd a-ccsd(t) E (present but experimental (require set qc_module occ) until further optimized)

Dev notes & details

  • pick over canonical methods and run some basic timings tests
  • TODO: kill new pass
  • TODO: there might be UHF CCD in there, too.
  • TODO: merge capabilities maintenance #2731 first. it has a lot of stdsuite changes that I don't want to rebase through. nevertheless, stdsuite on the new methods is working fine locally. the azure errors are that uhf cc methods are running rather than throwing NYI as it expects.
  • TODO: df ccsd(t) gradients need to be marked experimental and semi-hidden until optimization

REVISED 25 Oct

Module comparison timings [s] for CCSD & CCSD(T) energy & gradient
* Benzene, C6H6
* Either aug-cc-pVDZ (192 nbf) or cc-pVDZ (119 nbf); all-electron
* Same singlet system run as RHF & UHF
* CC converged to 1e-7
* 20 GiB, 8 threads

                              GRADIENT                                 ENERGY
                            symm     c1                             symm     c1
                            ----    ----                            ----    ----
<<<  CCSD/aug-cc-pVDZ  >>>

cfour (vcc) rhf   conv       132    1650                              52    1202 
ccenergy    rhf   conv       266    2037                              92    1099
dfocc       rhf   df         n/a     420                             n/a     230
fnocc       rhf   df                                                 n/a     149

cfour       uhf   conv       225    3473                              90    2413 
ccenergy    uhf   conv       463    5196                             222    2576
dfocc       uhf   df         n/a    1545                             n/a     826

cfour       u/r ratio        1.7     2.1                             1.7     2.0                                        
ccenergy    u/r ratio        1.7     2.5                             2.4     2.3
dfocc       u/r ratio        n/a     3.7                             n/a     3.6

Checklist

Status

  • Ready for review
  • Ready for merge

@loriab loriab added testing cc For all issues involving the CC module, ground-state energies to response properties. dfocc For issues in the DFOCC module. labels Oct 6, 2022
@loriab loriab added this to the Psi4 1.7 milestone Oct 6, 2022
Copy link
Contributor

@JonathonMisiewicz JonathonMisiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very initial comments for today:

@@ -374,7 +374,24 @@ Starting in v1.4, MP2.5 and MP3 default to the density-fit algorithm. Set |globa

Publications resulting from the use of the non-OO CC codes should cite the following publications:

* **REMP** [Behnle:2019:REMP]_, [Behnle:2022:OREMP]
* **MP2** [Bozkaya:2011:omp2]_, [Bozkaya:2013:omp2grad]_, and [Bozkaya:2014:dfomp2grad]_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would much rather we separate out the DF and the non-DF implementations. A paper using conventional OMP2 has no business citing the DF-OMP2 paper. That'll just confuse people following citations.

@@ -1043,6 +1055,12 @@ def select_ccsd_at_(name, **kwargs):
if mtd_type == 'CONV':
if module in ['', 'MRCC'] and which("dmrcc", return_bool=True):
func = run_mrcc
elif mtd_type == "DF":
if module in ["OCC"]: # SOON "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in, soon this will be ["OCC", ""]? Why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the "semi-disabling". By not having ["", "OCC"], the naive input set reference uhf; set cc_type df; energy("a-ccsd(t)") won't run and you won't be maddened by worse-than-conventional-CC scaling. However, if you're determined to try the code, it is accessible by adding a set qc_module occ.

psi4/src/psi4/dfocc/ccd_3index_intr.cc Show resolved Hide resolved
psi4/src/psi4/dfocc/ccd_3index_intr.cc Outdated Show resolved Hide resolved
psi4/src/psi4/dfocc/ccd_3index_intr.cc Outdated Show resolved Hide resolved
SharedTensor2d K, T, U, Tau;

// OO block
// F_mi = (1-\delta_{mi}) f_mi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the definition of the F intermediate changing? What other parts of the code have to change, even in the restricted case, in order for the restricted code to give the same results as before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I bet it's preparation for frozen virtual and fno. @bozkaya ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this again, this term is zero for canonical orbitals. Presumably, this term is in the full equations but was neglected previously.

Copy link
Contributor

@JonathonMisiewicz JonathonMisiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chunk for today. Includes a new question for the original code authors.

@@ -47,6 +47,7 @@ markers =
dfccsd-grad
dfccsd-t-grad
dfccsd
dfccsdt-grad
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change exposes an inconsistency in pytest.ini:

Just two lines above, dfccsd-t-grad is defined, but dfccsdt is also defined. Let's be consistent about which we pick. I prefer dfccsd-t. For good measure, let's have dfccsdat be synchronized as to hyphen-or-not, as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The markers are definitely a mess, mostly because they're a mirror of CTest markers that are also haphazard. A difference is that ctest -L matches partial markers but pytest -m requires full match. If we do try to reform markers, there's also https://github.com/psi4/psi4/blob/master/psi4/driver/p4util/exceptions.py#L490-L496 as standard transformation. The test names in stdsuite use this.

W.reset();
Tau.reset();
T2new->write_anti_symm(psio_, PSIF_DFOCC_AMPS);
T2new.reset();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
T2new.reset();

Shared pointers are cleared immediately upon leaving scope: this serves no purpose.

psi4/src/psi4/dfocc/ccd_3index_intr.cc Outdated Show resolved Hide resolved
psi4/src/psi4/dfocc/ccd_3index_intr.cc Outdated Show resolved Hide resolved
psi4/src/psi4/dfocc/ccd_F_intr.cc Outdated Show resolved Hide resolved
// F(m,i) += (1-kronDelta(m,i)) f(m,i)
for(int m=0; m<naoccB; ++m) {
for(int i=0; i<naoccB; ++i) {
int mi = (m * naoccB) + i;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int mi = (m * naoccB) + i;

// F(A,E) = (1-kronDelta(A,E)) f(A,E)
for(int a=0; a<navirA; ++a) {
for(int e=0; e<navirA; ++e) {
int ae = (a * navirA) + e;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int ae = (a * navirA) + e;

SharedTensor2d Tau, T;

// F(M,I) OO Alpha Block
// F(M,I) = (1-kronDelta(M,I)) f(M,I) + \sum_(E) 0.5*t(I,E)*f(M,E) + \sum_(Q) tQ*b(Q,MI) + \sum_(Q,E) Tau"(Q,IE)*b(Q,ME)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this file consistent on delta vs kronDelta, and on whether the overall F is defined before each piece is. This is inconsistent between the restricted and unrestricted parts, at present.

// F(a,e) = (1-kronDelta(a,e)) f(a,e)
for(int a=0; a<navirB; ++a) {
for(int e=0; e<navirB; ++e) {
int ae = (a * navirB) + e;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int ae = (a * navirB) + e;

SharedTensor2d T2, Tau, T2new;

// W_MNIJ Alpha Block
// W_MNIJ = <MN||IJ> + \sum_(EF) T(IJ,EF) * <MN|EF>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once again, the new code includes a comment defining the quantity in full, but the older restricted code includes a comment describing each line. (In other words, where is the restricted code's counterpart to l. 165? I can find its counterpart to 166.)

@bozkaya, how much of this is deliberate? Is this a new code style that you're introducing, but not wanting to change all the code right away?

Copy link
Contributor

@JonathonMisiewicz JonathonMisiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The major sticking point here is that I need to know the source for all these references.

SharedTensor2d K, T, U, Tau;

// OO block
// F_mi = (1-\delta_{mi}) f_mi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this again, this term is zero for canonical orbitals. Presumably, this term is in the full equations but was neglected previously.

psi4/src/psi4/dfocc/ccd_W_intr.cc Outdated Show resolved Hide resolved
psi4/src/psi4/dfocc/ccd_W_intr.cc Outdated Show resolved Hide resolved
psi4/src/psi4/dfocc/ccd_W_intr.cc Outdated Show resolved Hide resolved
psi4/src/psi4/dfocc/ccd_W_intr.cc Outdated Show resolved Hide resolved
psi4/src/psi4/dfocc/uccsdl_W_intr.cc Outdated Show resolved Hide resolved
psi4/src/psi4/dfocc/uccsdl_l2_amps.cc Outdated Show resolved Hide resolved
psi4/src/psi4/dfocc/uccsdl_l2_amps.cc Outdated Show resolved Hide resolved
// DIIS
SharedTensor2d RAA, LAA, RBB, LBB, RAB, LAB, LA, LB;

// RAA
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the extra indent.

@@ -0,0 +1,31 @@
#! DF-CCSD cc-pVDZ gradient for the NH molecule.

ref = psi4.Matrix.from_list([ #TEST
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need sources for all these references.

@loriab loriab merged commit 38cca14 into psi4:master Dec 4, 2022
@loriab loriab deleted the dfocc_dfcc branch December 4, 2022 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cc For all issues involving the CC module, ground-state energies to response properties. dfocc For issues in the DFOCC module. testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants