Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

hongzhouye
Copy link
Contributor

@hongzhouye hongzhouye commented Jan 11, 2024

In a previous PR (#1893), the frozen variable in FNOCCSD was not used in the full-system MP2 calculation. As a result,

  1. natural orbitals are selected based on non-frozen MP2 rdm1, leading to suboptimal active-space NOs
  2. MP2 composite correction includes the core correlation energy, making the final FNOCCSD energy include a MP2-level core correlation and thus not approximate frozen-core CCSD.

Both problems are fixed in this PR. The make_fno function in MP2/UMP2 now supports general frozen pattern. The unit tests are updated for frozen-core tests. New tests for a UHF reference are added.

A new input argument pvir_act is added to select active NOs by the percentage of total number of virtuals (which is used in literature, see e.g., J. Chem. Phys. 128, 164101, 2008). New tests are added for all strategies of choosing active NOs.

@sunqm The reason why previous tests not passing is likely because the reference values were generated using all-e potential while the tests themselves used a pseudopotential (likely a copy-paste error when I wrote the test file). Once I turned off the pseudopotential, all tests that do not use frozen (thus not affecting by this PR) can pass.

@hongzhouye hongzhouye marked this pull request as draft January 13, 2024 19:00
nvir_act=nvir_act)
if len(frozen) == 0: frozen = None
pt_no = mp.MP2(mf, frozen=frozen, mo_coeff=no_coeff).set(verbose=0).run()
pt_no = mp.MP2(mf, frozen=frozen, mo_coeff=no_coeff).set(verbose=2).run()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should verbosity level be taken from mol/cell instance?

Copy link
Contributor

@verena-neufeld verena-neufeld left a comment

Choose a reason for hiding this comment

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

Thanks Hong-Zhou! I have only added some high level comments. I have not tested this or more carefully read through.

pct_occ : float
Percentage of total occupation number. Default is None. If present, overrides `thresh`.
pvir_act : float
Percentage of total number of virtuals (ceiling is taken to get an integer number).
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this "Percentage of number of virtual NOs to keep" or something else? (I'm comparing this to the comment below "nvir_act").

Copy link
Contributor

Choose a reason for hiding this comment

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

The "Percentage of total occupation number" is called pct_occ. pvir_act doesn't use that naming convention (no "pct") but follows nvir_act (which makes sense but might be a little bit inconsistent) <- minor comment.

Percentage of total number of virtuals (ceiling is taken to get an integer number).
Default is None. If present, overrides `thresh` and `pct_occ`.
nvir_act : int
Number of virtual NOs to keep. Default is None. If present, overrides `thresh` and `pct_occ`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does nvir_act override pvir_act, too? It starts getting a little bit tricky to distinguish the keywords here and what takes priority. Some sort of overview sentence comparing them might be helpful.

from pyscf import mp
pt = mp.MP2(mf).set(verbose=0).run()
frozen, no_coeff = pt.make_fno(thresh=thresh, pct_occ=pct_occ, nvir_act=nvir_act)
frozen = numpy.hstack([numpy.arange(frozenocc),frozen])
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be a comment in the docstring how frozen passed by the user is being used?


def make_fno(mp, thresh=1e-6, pct_occ=None, nvir_act=None, t2=None):
def make_fno(mp, thresh=1e-6, pct_occ=None, pvir_act=None, nvir_act=None, t2=None):
r'''
Copy link
Contributor

Choose a reason for hiding this comment

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

See previous review comments

idx = numpy.argsort(n)[::-1]
n,v = n[idx], v[:,idx]
pct_occ_sum = numpy.cumsum(n/numpy.sum(n))
numpy.set_printoptions(threshold=nmo)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be added as an option to log since this is about how the logging should be done and might apply to other parts of pyscf? Or is this a special case?

@hongzhouye
Copy link
Contributor Author

@verena-neufeld Thanks for the comments! There are things in the MP2 module that I need to fix first (mostly handle user input mean-field through mo_coeff and mo_occ, but this affects the iterative solver and other places as well). I will let you know once it's ready for review.

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.

2 participants