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

Spin adapted dsrg #182

Merged
merged 90 commits into from
Mar 29, 2020
Merged

Spin adapted dsrg #182

merged 90 commits into from
Mar 29, 2020

Conversation

lcyyork
Copy link
Contributor

@lcyyork lcyyork commented Feb 25, 2020

Description

Spin-adapted DSRG implementation.

User Notes

  • Fix a bug of state averaging in ActiveSpaceSolver.
  • Add supports of spin-averaged RDMs in RDMs and ActiveSpaceSolver classes.
  • Implement the spin-adapted single commutators up to singles and doubles.
  • Add complete supports of PT2, PT3, LDSRG(2) energies.
  • Support non-semicanonical orbitals and completely zeroing CCVV block.

The spin-adapted DSRG code is arranged in the following way:

SADSRG --|
         -- SA_MRDSRG (nonperturbative DSRG implementation)
         |
         -- SA_DSRGPT --|
                        -- SA_MRPT2 (DSRG-MRPT2 implementation)
                        |
                        -- SA_MRPT3 (DSRG-MRPT3 implementation)

Checklist

  • Add several tests under groups mrdsrg-spin-adapted, mrdsrg-spin-adapted-pt2, and mrdsrg-spin-adapted-pt3.
  • Removed comments in code and input files
  • Checked for redundant headers
  • Checked for consistency in the formatting of the output file
  • Documented new features in the manual
  • Ready to go!

TODOs

  • Implement internal amplitudes for general PT
  • Test speed for PT2 threading
  • The test cases' numbers may be updated when Psi4's CASSCF problem is fixed.

@codecov
Copy link

codecov bot commented Feb 25, 2020

Codecov Report

Merging #182 into master will increase coverage by 1.98%.
The diff coverage is 94.41%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #182      +/-   ##
==========================================
+ Coverage    64.1%   66.09%   +1.98%     
==========================================
  Files         171      189      +18     
  Lines       40573    43638    +3065     
==========================================
+ Hits        26010    28841    +2831     
- Misses      14563    14797     +234
Impacted Files Coverage Δ
src/base_classes/state_info.h 50% <ø> (ø) ⬆️
src/sci/fci_mo.h 10% <ø> (ø) ⬆️
src/mrdsrg-spin-integrated/master_mrdsrg.h 29.41% <ø> (ø) ⬆️
src/orbital-helpers/semi_canonicalize.h 100% <ø> (ø) ⬆️
src/base_classes/dynamic_correlation_solver.h 100% <ø> (ø) ⬆️
src/mrdsrg-helper/dsrg_time.h 100% <ø> (ø) ⬆️
src/base_classes/active_space_solver.h 100% <ø> (ø) ⬆️
src/mrdsrg-spin-integrated/mrdsrg_nonpt.cc 20.86% <0%> (ø) ⬆️
src/mrdsrg-spin-adapted/sa_mrdsrg_amps.cc 100% <100%> (ø)
src/base_classes/state_info.cc 92.15% <100%> (+7.84%) ⬆️
... and 52 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c7a6907...c0507e1. Read the comment docs.

@lcyyork
Copy link
Contributor Author

lcyyork commented Feb 25, 2020

@henankf223 @fevangelista This PR is not ready because the actual spin-adapted DSRG is not yet implemented. However, I made changes to ActiveSpaceSolver and RDMs to average spin multiplets. Now, the spin-integrated DSRG code should be able to handle any spin cases by setting SPIN_AVG_DENSITY to True.

@fevangelista
Copy link
Member

@lcyyork: thanks! I will download a copy and start to go over it!

Copy link
Member

@fevangelista fevangelista left a comment

Choose a reason for hiding this comment

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

This looks very good. I think that we should have it tested for a bit before adopting it just to make sure all works well together. Any concerns on your part or things that remain to be done?

::

correlation_solver sa-mrdsrg # spin-adapted DSRG computation
spin_avg_density true # must use spin-averaged densities
Copy link
Member

Choose a reason for hiding this comment

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

Could we get rid of the variable spin_avg_density? At least we should have logic to enforce that when sa-mrdsrg is set then spin_avg_density = True.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, let me work on it.

@@ -270,7 +274,11 @@ def compute_dsrg_unrelaxed_energy(correlation_solver_type, rdms, scf_info, optio
ints, mo_space_info, Ua, Ub):
Heff_actv_implemented = False

if correlation_solver_type == "MRDSRG_SO":
if correlation_solver_type == "SA-MRDSRG":
Copy link
Member

Choose a reason for hiding this comment

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

Here is a good spot for testing that spin_avg_density is set to true.

src/base_classes/active_space_solver.cc Outdated Show resolved Hide resolved
}
print_energies(state_energies_map_);
return state_energies_map_;
}

void ActiveSpaceSolver::print_energies(std::map<StateInfo, std::vector<double>>& energies) {
print_h2("Energy Summary");
psi::outfile->Printf("\n Multi. Irrep. No. Energy");
std::string dash(41, '-');
psi::outfile->Printf("\n Multi.(ms) Irrep. No. Energy");
Copy link
Member

Choose a reason for hiding this comment

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

Is this M_S? If yes we can just replace

Suggested change
psi::outfile->Printf("\n Multi.(ms) Irrep. No. Energy");
psi::outfile->Printf("\n M_S Irrep. No. Energy");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, there are two values here. One is for multiplicity (i.e., Multi.) and the other is for MS that is in the parentheses.

std::string dash(ltotal, '-');
psi::outfile->Printf("\n Irrep. Multi. Nstates");
psi::outfile->Printf("\n Irrep. Multi.(ms) N");
Copy link
Member

Choose a reason for hiding this comment

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

M_S?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as the last one.

have_L3bbb_ = true;
}
return L3bbb_;
}

ambit::Tensor RDMs::SFg2() {
Copy link
Member

Choose a reason for hiding this comment

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

Can you give the precise definition of what this returns in the header file?

/// @return the beta-beta-beta 3-RDM
ambit::Tensor g3bbb() const { return g3bbb_; }
ambit::Tensor g3bbb();

// Spin-free RDMs

/// @return the spin-free 2-RDM
Copy link
Member

Choose a reason for hiding this comment

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

Here add definition of what does this return.

};

/**
Copy link
Member

Choose a reason for hiding this comment

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

This is great!


namespace forte {

class DSRG_MEM {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be used for other codes? If it can then let's not be specific (DSRG). It might be nice to start it outside of the DSRG codes. However, this might not play well with python.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This class is just for memory inspection before any actual DSRG computation. So this class might be useful for other dynamical correlation solver.

#include "base_classes/mo_space_info.h"

namespace forte {

Copy link
Member

Choose a reason for hiding this comment

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

What does this class do?

Copy link
Contributor Author

@lcyyork lcyyork Mar 19, 2020

Choose a reason for hiding this comment

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

This class is created to check/print the memory usage before any real DSRG computation. Different DSRG levels have different memory requirement and it is useful to terminate the job if it lacks of memory.

Basically the user sets the max memory available and a map of the space character to its size (e.g., 'c': 20, 'a': 4, 'v': 80, 'h': 24, 'p': 84, 'g': 104).

Take LDSRG(2) as an example. It stores F, V, T1, T2, Hbar1, Hbar2, and other intermediates. To compute the memory usage of T1 and T2, the user can add_entry and pass the name and the labels: add_entry("T1 and T2 amplitudes", {"hp", "hhpp"});. This will be computed as 8 * (24 * 84 + 24 * 24 * 84 * 84), which will be subtracted from the max available memory.

To indicate two sets of global intermediates used in LDSRG(2) both of sizes g^2 + g^4, the uset can say add_entry("Global intermediates", {"gg", "gggg"}, 2);.

Besides global memory usage, there are also local usage. In this case, the max local memory usage will be the bottleneck. To add a local memory usage, use add_entry("Local storage for S1 and S2 amplitudes", {"hp", "hhpp"}, 1, false);

The print function will print all passed-in entries in a table and terminate the job if the global memory plus the max local memory is greater than the max available set by the user.

the user should specify the following keyword:
::

spin_avg_density true # use spin-summed reduced density matrices
Copy link
Member

Choose a reason for hiding this comment

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

Is this obsolete now? If it is, it might still be a good idea to mention it somewhere, either here or in a section on active space solvers.

Copy link
Member

Choose a reason for hiding this comment

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

BTW, how do you feel about moving our manual to jupyter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it is not obsolete. It shows the user should specify this keyword to run jobs with even multiplicities using the spin integrated code. I will emphasize this using bold font.

I am OK to move them to Jupyter but not sure what the benefit is. I assume they will still be markdown in Jupyter.

@fevangelista
Copy link
Member

@lcyyork: can you run the full test suite and make sure everything works?

@lcyyork
Copy link
Contributor Author

lcyyork commented Mar 28, 2020

@fevangelista All tests pass on my computer.

@lcyyork lcyyork mentioned this pull request Mar 29, 2020
3 tasks
@lcyyork lcyyork merged commit 03bd753 into master Mar 29, 2020
@lcyyork lcyyork deleted the spin-adapted-dsrg branch March 29, 2020 03:53
@lcyyork lcyyork mentioned this pull request Nov 17, 2020
11 tasks
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.

None yet

2 participants