-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from BoothGroup/to_cisdtq
Added to_cisdtq functionality to RFCI wave function types for extract…
- Loading branch information
Showing
22 changed files
with
2,175 additions
and
154 deletions.
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.