-
Notifications
You must be signed in to change notification settings - Fork 8
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
Added to_cisdtq functionality to RFCI wave function types for extract… #69
Merged
Changes from all commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
81a7715
Added to_cisdtq functionality to RFCI wave function types for extract…
5080b65
Added cisdtq -> ccsdtq functionality for restricted wave functions
9e306b9
pass in tuple for t4 and c4 arguments rather than individual spin sig…
847f0f5
Fix string format
5105d8a
Update example to non-deprecated practices
410a320
Add OBC 1D chain of atoms constructor
14de2a2
WIP
cdff3cb
Merge remote-tracking branch 'origin/v1.0.2a' into to_cisdtq
bf6d8d8
Complete code for ec-cc with all hamiltonian terms from child cluster.
da04535
Local external correction implemented and running. Now to debug...!
6d187ce
fix for 2e systems
b8262a8
ec-cc now exact for 4-electron systems and full FCI space. Seems to b…
4d7381f
Energy denominators now dealt with effectively outside the callback
ab487aa
Address Max comments on code style. Fix bug in external-ccsdv
b8fd264
Added alternate equations to check consistency of EC implementation. …
15d4fbf
Passed in ERIs sometimes fails, as they are stored as HDF5 file, rath…
31f5b79
Add tests for external correction, including Hubbard model and LiH (w…
befe789
Add example of EC-CCSD via local FCI clusters, both for a full system…
4b45e16
Add example of various external corrections on the Hubbard model. Wil…
d46d0db
Clean up ext-corr hubbard example
87d34bd
Allow external correction to be used along with scmf
75103a7
Update Hubbard EC-CC example to print out whether converged.
a5dec5b
Fix for use of delta-tailoring correction with symmetry-derived fragm…
b174b0e
Merge. Also include test for symmetry in external corrections
d949b68
Update EC-CC example to use symmetry correctly. Put note in external-…
2549eef
Tidying in response to PR comments.
c341e98
Merge remote-tracking branch 'origin/v1.0.2a' into to_cisdtq
c8e5b2a
Merge remote-tracking branch 'origin/v1.0.2a' into to_cisdtq
6aaff99
Update examples and tests for (single kernel) EC
b70ae52
Merge branch 'v1.0.2a' into to_cisdtq
90e7319
WIP to prep for UHF implementation
c2a04c0
Code to create packed C1 -> C4 UHF arrays. Need to unpack.
11089bd
Add unpacking for unrestricted C amplitudes via ebcc
obackhouse e847618
Implemented C to T conversion for UHF
obackhouse 5ba4933
Adds routine to build external correction in UHF
obackhouse 6e1b83a
Enable external correction for UHF
obackhouse 1835603
Fixes for UHF external correction
obackhouse 8ee1b3b
Some fixes for UHF external corrections
obackhouse d31532c
Forgot T4 contractions
obackhouse 65289e1
Comment
779e95d
Resolve merge
822c69f
Merge branch 'master' into to_cisdtq
a6b3fbd
Fix bug in array sizes
obackhouse 4b26d22
Merge branch 'to_cisdtq' of github.com:BoothGroup/Vayesta into to_cisdtq
6c6138d
Allow slicing for FCI vector with empty lists
9e7f0f9
Refactorises conversion UHF C->T conversion routines
obackhouse 8262222
Fixes factors in ECCC contractions
obackhouse 701dbe3
Bugfix for C_abaa amplitudes to get EC-CC (RHF) working.
4645f13
added tests for unrestricted ec-cc
c24dea2
Resolve minor comments
obackhouse cc198d3
Updated ec-cc unit tests with UHF, regression
a3d53b9
added a testsytem variation lih_631g
8def64f
Fix to example 25-externally-correct.
b5fb8a5
Changes filename of conversion routines
obackhouse f6db4e4
Merge branch 'to_cisdtq' of https://github.com/BoothGroup/Vayesta int…
obackhouse 24898b2
Cleans up conversion routines
obackhouse 5c52285
Refactoring and cleaning
obackhouse cb37eeb
More cleanup and addressing reviews
obackhouse 9d003dd
Fix bug in integral unpacking
obackhouse 9e4dc54
Move t3v terms into separate function
obackhouse ff11ba5
Starting UHF t3v (buggy)
obackhouse cabb987
Fixes bugs in UHF external-ccsdv
obackhouse c98b0c5
Cleans up tests
obackhouse c1bca35
Fixed bug with single-site embedding in AFM systems.
cjcscott b0e860d
Added test for dissociated H2 with symmetry broken, reference, as wel…
cjcscott 4806b24
fixed UHF external-ccsdv regression tests
d9c63e5
Merge pull request #80 from BoothGroup/fix_AFM_single_site
ghb24 6c04dee
Removed many redundant tests, external-fciv tests
859b6bf
Trigger CI build
obackhouse f02001c
Address Max's comments
obackhouse 544cc66
Merge branch 'v1.0.2a' into to_cisdtq
cjcscott 7fe0cdf
Moved to not using density fitting for dissociated UHF test. Also ens…
cjcscott 07f2773
Remove separate options 'external-ccsdv' and 'external-fciv'.
54e0fa3
Update externally corrected Hubbard model exammple too.
9f60bcb
TODO added to improve integral transformation for delta-tailoring
18aa87a
Fixes for tests.
0c962df
Merge pull request #88 from BoothGroup/fix_h2_dissoc_test
ghb24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ on: | |
push: | ||
branches: [master, dev] | ||
pull_request: | ||
branches: [master, dev] | ||
schedule: | ||
- cron: '0 2 * * *' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import numpy as np | ||
import pyscf | ||
import pyscf.gto | ||
import pyscf.scf | ||
import pyscf.cc | ||
import pyscf.fci | ||
import vayesta | ||
import vayesta.ewf | ||
from vayesta.misc import molecules | ||
|
||
mol = pyscf.gto.Mole() | ||
mol.atom = """ | ||
Se 0.0000 0.0000 0.2807 | ||
O 0.0000 1.3464 -0.5965 | ||
O 0.0000 -1.3464 -0.5965 | ||
""" | ||
mol.basis = 'cc-pVDZ' | ||
mol.output = 'pyscf.out' | ||
mol.build() | ||
|
||
# Hartree-Fock | ||
mf = pyscf.scf.RHF(mol) | ||
mf.kernel() | ||
|
||
# Reference full system CCSD: | ||
cc = pyscf.cc.CCSD(mf) | ||
cc.kernel() | ||
|
||
# 1) Consider setup where you have a complete CCSD, externally corrected by local atomic fragment+DMET FCI clusters | ||
emb = vayesta.ewf.EWF(mf) | ||
with emb.iao_fragmentation() as f: | ||
# Add all atomic FCI fragments with DMET bath | ||
# Store the FCI wave functions as CCSDTQ types, so they can be used for correction later. | ||
# These want to be flagged as 'auxiliary', as they are solved first, and then used as constraints for the | ||
# non-auxiliary fragments. | ||
fci_frags = f.add_all_atomic_fragments(solver='FCI', bath_options=dict(bathtype='dmet'), store_wf_type='CCSDTQ', auxiliary=True) | ||
# Add single 'complete' CCSD fragment covering all IAOs | ||
ccsd_frag = f.add_full_system(solver='CCSD', bath_options=dict(bathtype='full')) | ||
# Setup the external correction from the CCSD fragment. | ||
# Main option is 'projectors', which should be an integer between 0 and 2 (inclusive). | ||
# The larger the number, the more fragment projectors are applied to the correcting T2 contributions, and less | ||
# 'bath' correlation from the FCI clusters is used as a constraint in the external correction of the CCSD clusters. | ||
# For multiple constraining fragments, proj=0 will double-count the correction due to overlapping bath spaces, and | ||
# in this case, only proj=1 will be exact in the limit of enlarging (FCI) bath spaces. | ||
# Note that there is also the option 'low_level_coul' (default True). For the important T3 * V contribution to the | ||
# T2 amplitudes, this determines whether the V is expressed in the FCI or CCSD cluster space. The CCSD cluster is | ||
# larger, and hence this is likely to be better (and is default), as the correction is longer-ranged (though slightly more expensive). | ||
ccsd_frag.add_external_corrections(fci_frags, correction_type='external', projectors=1) | ||
emb.kernel() | ||
print('Total energy from full system CCSD tailored (CCSD Coulomb interaction) by atomic FCI fragments (projectors=1): {}'.format(emb.e_tot)) | ||
|
||
# 2) Now, we also fragment the CCSD spaces, and use BNOs. These CCSD fragments are individually externally corrected from the FCI clusters. | ||
# Similar set up, but we now have multiple CCSD clusters. | ||
emb = vayesta.ewf.EWF(mf) | ||
with emb.iao_fragmentation() as f: | ||
fci_frags = f.add_all_atomic_fragments(solver='FCI', bath_options=dict(bathtype='dmet'), store_wf_type='CCSDTQ', auxiliary=True) | ||
ccsd_frags = f.add_all_atomic_fragments(solver='CCSD', bath_options=dict(bathtype='mp2', threshold=1.e-5)) | ||
# Now add external corrections to all CCSD clusters, and use 'external' correction, with 2 projectors and only contracting with the FCI integrals | ||
for cc_frag in ccsd_frags: | ||
cc_frag.add_external_corrections(fci_frags, correction_type='external', projectors=2, low_level_coul=False) | ||
emb.kernel() | ||
print('Total energy from embedded CCSD tailored (FCI Coulomb interaction) by atomic FCI fragments (projectors=2): {}'.format(emb.e_tot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import pyscf | ||
import pyscf.cc | ||
import pyscf.fci | ||
import vayesta | ||
import vayesta.ewf | ||
import vayesta.lattmod | ||
|
||
nsite = 10 | ||
nelectron = nsite | ||
hubbard_u = 4.0 | ||
mol = vayesta.lattmod.Hubbard1D(nsite, nelectron=nelectron, hubbard_u=hubbard_u) | ||
mf = vayesta.lattmod.LatticeMF(mol) | ||
mf.kernel() | ||
assert(mf.converged) | ||
|
||
# Reference full system CCSD and FCI | ||
cc = pyscf.cc.CCSD(mf) | ||
cc.kernel() | ||
fci = pyscf.fci.FCI(mf) | ||
fci.threads = 1 | ||
fci.conv_tol = 1e-12 | ||
fci.davidson_only = True | ||
fci.kernel() | ||
|
||
# Perform embedded FCI with two sites | ||
emb_simp = vayesta.ewf.EWF(mf, solver='FCI', bath_options=dict(bathtype='dmet')) | ||
with emb_simp.site_fragmentation() as f: | ||
f.add_atomic_fragment([0, 1], sym_factor=nsite/2, nelectron_target=2*nelectron/nsite) | ||
emb_simp.kernel() | ||
|
||
# Perform full system CCSD, externally corrected by two-site+DMET bath FCI level clusters | ||
emb = vayesta.ewf.EWF(mf) | ||
fci_frags = [] | ||
with emb.site_fragmentation() as f: | ||
# Set up a two-site FCI fragmentation of full system as auxiliary clusters | ||
# Ensure the right number of electrons on each fragment space of the FCI calculation. | ||
fci_frags.append(f.add_atomic_fragment([0, 1], solver='FCI', bath_options=dict(bathtype='dmet'), store_wf_type='CCSDTQ', nelectron_target=2*nelectron/nsite, auxiliary=True)) | ||
# Add single 'complete' CCSD fragment covering all sites | ||
ccsd_frag = f.add_full_system(solver='CCSD', bath_options=dict(bathtype='full'), solver_options=dict(solve_lambda=False, init_guess='CISD')) | ||
# Add symmetry-derived FCI fragments to avoid multiple calculations | ||
fci_frags.extend(fci_frags[0].add_tsymmetric_fragments(tvecs=[5, 1, 1]) | ||
|
||
e_extcorr = [] | ||
extcorr_conv = [] | ||
#Main options: 'projectors', which should be an integer between 0 and 2 (inclusive). | ||
#The larger the number, the more fragment projectors are applied to the correcting T2 contributions, and less | ||
#'bath' correlation from the FCI clusters is used as a constraint in the external correction of the CCSD clusters. | ||
#NOTE that with multiple FCI fragments providing constraints and overlapping bath spaces, proj=0 will | ||
#overcount the correction, so do not use with multiple FCI clusters. It will not e.g. tend to the right answer as | ||
#the FCI bath space becomes complete (for which you must have proj=1). Only use with a single FCI fragment. | ||
ccsd_frag.add_external_corrections(fci_frags, correction_type='external', projectors=1) | ||
emb.kernel() | ||
e_extcorr.append(emb.e_tot); extcorr_conv.append(emb.converged) | ||
|
||
# For subsequent calculations where we have just changed the mode/projectors in the external tailoring, we want to avoid having | ||
# to resolve the FCI fragments. Set them to inactive, so just the CCSD fragments will be resolved. | ||
for fci_frag in fci_frags: | ||
fci_frag.active = False | ||
|
||
ccsd_frag.clear_external_corrections() # Clear any previous corrections applied | ||
ccsd_frag.add_external_corrections(fci_frags, correction_type='external', projectors=2) | ||
emb.kernel() | ||
e_extcorr.append(emb.e_tot); extcorr_conv.append(emb.converged) | ||
|
||
ccsd_frag.clear_external_corrections() # Clear any previous corrections applied | ||
ccsd_frag.add_external_corrections(fci_frags, correction_type='external', projectors=1, low_level_coul=False) | ||
emb.kernel() | ||
e_extcorr.append(emb.e_tot); extcorr_conv.append(emb.converged) | ||
|
||
ccsd_frag.clear_external_corrections() # Clear any previous corrections applied | ||
ccsd_frag.add_external_corrections(fci_frags, correction_type='external', projectors=2, low_level_coul=False) | ||
emb.kernel() | ||
e_extcorr.append(emb.e_tot); extcorr_conv.append(emb.converged) | ||
|
||
# Compare to a simpler tailoring | ||
e_tailor = [] | ||
tailor_conv = [] | ||
ccsd_frag.clear_external_corrections() | ||
ccsd_frag.add_external_corrections(fci_frags, correction_type='tailor', projectors=1) | ||
emb.kernel() | ||
e_tailor.append(emb.e_tot); tailor_conv.append(emb.converged) | ||
ccsd_frag.clear_external_corrections() | ||
ccsd_frag.add_external_corrections(fci_frags, correction_type='tailor', projectors=2) | ||
emb.kernel() | ||
e_tailor.append(emb.e_tot); tailor_conv.append(emb.converged) | ||
|
||
# Compare to a delta-tailoring, where the correction is the difference between full-system | ||
# CCSD and CCSD in the FCI cluster. | ||
e_dtailor = [] | ||
dtailor_conv = [] | ||
ccsd_frag.clear_external_corrections() | ||
ccsd_frag.add_external_corrections(fci_frags, correction_type='delta-tailor', projectors=1) | ||
emb.kernel() | ||
e_dtailor.append(emb.e_tot); dtailor_conv.append(emb.converged) | ||
ccsd_frag.clear_external_corrections() | ||
ccsd_frag.add_external_corrections(fci_frags, correction_type='delta-tailor', projectors=2) | ||
emb.kernel() | ||
e_dtailor.append(emb.e_tot); dtailor_conv.append(emb.converged) | ||
|
||
print("E(MF)= %+16.8f Ha, conv = %s" % (mf.e_tot/nsite, mf.converged)) | ||
print("E(CCSD)= %+16.8f Ha, conv = %s" % (cc.e_tot/nsite, cc.converged)) | ||
print("E(FCI)= %+16.8f Ha, conv = %s" % (fci.e_tot/nsite, fci.converged)) | ||
print("E(Emb. FCI, 2-site)= %+16.8f Ha, conv = %s" % (emb_simp.e_tot/nsite, emb_simp.converged)) | ||
print("E(EC-CCSD, 2-site FCI, 1 proj, ccsd V)= %+16.8f Ha, conv = %s" % ((e_extcorr[0]/nsite), extcorr_conv[0])) | ||
print("E(EC-CCSD, 2-site FCI, 2 proj, ccsd V)= %+16.8f Ha, conv = %s" % ((e_extcorr[1]/nsite), extcorr_conv[1])) | ||
print("E(EC-CCSD, 2-site FCI, 1 proj, fci V)= %+16.8f Ha, conv = %s" % ((e_extcorr[2]/nsite), extcorr_conv[2])) | ||
print("E(EC-CCSD, 2-site FCI, 2 proj, fci V)= %+16.8f Ha, conv = %s" % ((e_extcorr[3]/nsite), extcorr_conv[3])) | ||
print("E(T-CCSD, 2-site FCI, 1 proj)= %+16.8f Ha, conv = %s" % ((e_tailor[0]/nsite), tailor_conv[0])) | ||
print("E(T-CCSD, 2-site FCI, 2 proj)= %+16.8f Ha, conv = %s" % ((e_tailor[1]/nsite), tailor_conv[1])) | ||
print("E(DT-CCSD, 2-site FCI, 1 proj)= %+16.8f Ha, conv = %s" % ((e_dtailor[0]/nsite), dtailor_conv[0])) | ||
print("E(DT-CCSD, 2-site FCI, 2 proj)= %+16.8f Ha, conv = %s" % ((e_dtailor[1]/nsite), dtailor_conv[1])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
RCCSDTQ_WaveFunction
would not be the right place for contracting out T4sThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I guess we would make a new wave function class, which has T1, T2, T3, and some additional intermediates. It wouldn't be part of the ccsdtq class (though I'm not sure what we would call it)...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be a specialized
ExternalCorrection
classThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, exactly, but inheriting from
WaveFunction