Skip to content

Conversation

obrien951
Copy link
Contributor

Description

Calculates exchange terms in a single tensor rather than contracting and adding. Reduces the cost of contractions against SCF coefficients in range separated DFT.

Changes the working equation for calculating the coulomb matrix in range separated DFT calculations. This lowers the number of tensors that Psi4 needs to store, reducing memory costs and extending the number of cases operable by DFHelper.

Todos

Notable points (developer or user-interest) that this PR has or will accomplish.

  • Extend formulations to DiskDFJK

Questions

  • Question1

Checklist

Status

  • Ready for review
  • Ready for merge

@susilehtola
Copy link
Member

btw some functionals use several range separation constants, could this be already supported in this PR or should it wait?

@obrien951
Copy link
Contributor Author

@susilehtola Multiple coefficients, exponential constants, and weights is not supported in this PR. You should wait.

@loriab loriab added this to the Psi4 1.4 milestone Jun 23, 2020
m1Ppq_ = std::unique_ptr<double[]>(new double[big_skips_[nbf_]]);

if (!wcombine_) Ppq_ = std::unique_ptr<double[]>(new double[big_skips_[nbf_]]);
Copy link
Contributor

@robertodr robertodr Jun 25, 2020

Choose a reason for hiding this comment

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

Small nitpick: could you switch these constructors (here and the following) to use make_unique instead?

Ppq_ = std::make_unique<double[]>(big_skips_[nbf_]);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will be making the changes. Someone might want to take a look at the rest of dfhelper.cc to make this change to another group of unique_ptr 's. I don't know what all the rest of the code does, so I don't think I should submit those changes in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up making changes only to functions touched by this PR. I'll leave the other functions to people who know what to do with them.

@loriab
Copy link
Member

loriab commented Jun 28, 2020

rebase will fix CI

Copy link
Member

@dgasmith dgasmith left a comment

Choose a reason for hiding this comment

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

Just to check, the memory estimator correctly accounts for this new mode of operation?

Also can you recommend specific tests for this?

@@ -208,7 +207,7 @@ void UHF::form_G() {
double alpha = functional_->x_alpha();
double beta = functional_->x_beta();

if (alpha != 0.0) {
if ( alpha != 0.0 && !(functional_->is_x_lrc() && jk_->name() == "MemDFJK" && jk_->get_wcombine()) ){
Copy link
Member

Choose a reason for hiding this comment

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

It might be best if jk_->wcombine() or similar is for every JK object which normally returns false. This could be useful for Direct as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The memory checker does make the correct estimation based on this new operation.

As far as testing it goes, the only way would be to set the memory in the test script and to make sure that psi gives back the right value, but that could be problematic if someone messes with the fudge factor and gibi vs. giga bytes.

The complicated logic in that if statement is necessary because there are conditions that can be taken for granted without wcombine that can't without it.

It would be useful for direct, but I wanted to wait on the libint2 branch to get sorted before I did anything with that.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not suggesting that you implement it into Direct at the moment, but more of the point that jk_->name() == "MemDFJK" && jk_->get_wcombine() is a leaky abstraction and creates a headache throughout the code. This get_wcombine should be native to the JK base object and return false for all classes where this isn't implemented.

Otherwise if you add this to direct we will need to add additional logic to every instance where you wrote this.

Copy link
Contributor Author

@obrien951 obrien951 Jul 2, 2020

Choose a reason for hiding this comment

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

jk_->get_wcombine() will already return false for all classes that aren't MemDFJK as you've suggested. I included the condition jk_->name() == "MemDFJK" because I didn't think I would need the !jk_->get_wcombine() case when I started working on the code. This isn't an attempt at short-circuiting as it appears to be.

I'm going to try getting rid of the jk_->name() == "MemDFJK" condition. If I understand the code correctly, it should work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made the change and tested it. It seems to be working just fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fyi, commit message would more precisely say "condition" than "conditional"

@dgasmith
Copy link
Member

dgasmith commented Jul 2, 2020

Looks good, thanks for the changes.

@dgasmith dgasmith merged commit 26bae16 into psi4:master Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants