Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
basilib committed Jul 7, 2023
2 parents 27f43a2 + bacf8d4 commit c6daee3
Show file tree
Hide file tree
Showing 85 changed files with 471 additions and 6,264 deletions.
23 changes: 0 additions & 23 deletions .coveragerc

This file was deleted.

4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

33 changes: 32 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- cron: '0 2 * * *'

jobs:
build:
full:
name: python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

Expand All @@ -19,6 +19,7 @@ jobs:
- {python-version: "3.8", os: ubuntu-latest, documentation: True}
- {python-version: "3.9", os: ubuntu-latest, documentation: False}
- {python-version: "3.10", os: ubuntu-latest, documentation: False}
- {python-version: "3.11", os: ubuntu-latest, documentation: False}

steps:
- uses: actions/checkout@v2
Expand All @@ -33,8 +34,12 @@ jobs:
run: |
python -m pip install wheel --user
python -m pip install setuptools --upgrade --user
<<<<<<< HEAD
python -m pip install https://github.com/BoothGroup/dyson/archive/master.zip
python -m pip install .[dmet] --user
=======
python -m pip install .[dmet,ebcc] --user
>>>>>>> master
- name: Run unit tests
run: |
python -m pip install pytest pytest-cov --user
Expand All @@ -61,3 +66,29 @@ jobs:
force_orphan: true
if: ${{ matrix.documentation && github.ref == 'refs/heads/master' && github.event_name != 'schedule' }}

bare:
name: python 3.8 on ubuntu-latest with no optional dependencies
runs-on: ubuntu-latest

strategy:
fail-fast: false

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
- name: Install Vayesta
run: |
python -m pip install wheel --user
python -m pip install setuptools --upgrade --user
python -m pip install . --user
- name: Run unit tests
run: |
python -m pip install pytest pytest-cov --user
python .github/workflows/run_tests.py
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
import sys
import os
import sys

src = os.path.abspath(os.path.join(__file__, "..", "..", "..", "vayesta"))

Expand Down
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
include MANIFEST.in
include README.md setup.py CHANGELOG LICENSE
include README.md pyproject.toml setup.py CHANGELOG LICENSE

global-exclude *.py[cod]
prune vayesta/libs/build

recursive-include vayesta *.dat
recursive-include vayesta/misc/gmtkn55 *
include vayesta/libs/*.so
include vayesta/logo.txt

# MacOS dynamic libraries
include vayesta/libs/*.dylib
Expand Down
2 changes: 1 addition & 1 deletion examples/dmet/02-rotational-symmetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# One-shot DMET
dmet = vayesta.dmet.DMET(mf, solver='FCI', maxiter=1)
with dmet.sao_fragmentation() as f:
with f.rotational_symmetry(3, axis='z'):
with f.rotational_symmetry(3, axis=[0,0,1]):
f.add_atomic_fragment([0,1])
dmet.kernel()

Expand Down
3 changes: 3 additions & 0 deletions examples/dmet/04-h-ring-diis.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import numpy as np

import pyscf
import pyscf.scf

import vayesta
import vayesta.dmet
from vayesta.misc.molecules import ring
Expand Down
1 change: 1 addition & 0 deletions examples/dmet/63-hubbard-1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
f.add_atomic_fragment(list(range(site, site+nimp)))
dmet.kernel()

print(dmet.fragments)
# Calculate a single fragment and use translational symmetry:
dmet_sym = vayesta.dmet.DMET(mf, solver='FCI')
# Specify the number of translational copies in direction of the three lattice vectors by passing a list with three
Expand Down
4 changes: 2 additions & 2 deletions examples/edmet/01-1d-hubbard-comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def gen_comparison(hubbard_u, nimp=2):
mf = gen_hub(nsite, hubbard_u)

dmet = vayesta.dmet.DMET(mf, solver='FCI', charge_consistent=True, maxiter=1,
bath_type=None)
bath_options=dict(bathtype='dmet'))
with dmet.site_fragmentation() as f:
frag = f.add_atomic_fragment(list(range(nimp)))
# Add fragments which are translationally symmetric to f - the results of the fragment f
Expand All @@ -33,7 +33,7 @@ def gen_comparison(hubbard_u, nimp=2):
symfrags = frag.make_tsymmetric_fragments(tvecs=[nsite // nimp, 1, 1])
res_dmet += [sum(dmet.fragments[0].get_dmet_energy_contrib())/nimp]

edmet = vayesta.edmet.EDMET(mf, solver="EBFCI", charge_consistent = True,maxiter=1, bath_type=None)
edmet = vayesta.edmet.EDMET(mf, solver="FCI", charge_consistent = True,maxiter=1, bath_options=dict(bathtype='dmet'))
with edmet.site_fragmentation() as f:
frag = f.add_atomic_fragment(list(range(nimp)))
# Add fragments which are translationally symmetric to f - the results of the fragment f
Expand Down
6 changes: 3 additions & 3 deletions examples/edmet/10-bosonic-Hamiltonians.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@

# Can generate bosons using either RPA couplings or direct projection of the Hamiltonian into the bosonic space.

rdfedmet_drpa_bos = vayesta.edmet.EDMET(mf, solver="EBCCSD", dmet_threshold=1e-12, bosonic_interaction="direct", oneshot=True, make_dd_moments=False)
rdfedmet_drpa_bos = vayesta.edmet.EDMET(mf, solver="CCSD-S-1-1", bath_options=dict(dmet_threshold=1e-12), bosonic_interaction="direct", oneshot=True, make_dd_moments=False)
with rdfedmet_drpa_bos.iao_fragmentation() as f:
f.add_all_atomic_fragments()
rdfedmet_drpa_bos.kernel()

rdfedmet_qba_directbos = vayesta.edmet.EDMET(mf, solver="EBCCSD", dmet_threshold=1e-12, bosonic_interaction="qba", oneshot=True, make_dd_moments=False)
rdfedmet_qba_directbos = vayesta.edmet.EDMET(mf, solver="CCSD-S-1-1", bath_options=dict(dmet_threshold=1e-12), bosonic_interaction="qba", oneshot=True, make_dd_moments=False)
with rdfedmet_qba_directbos.iao_fragmentation() as f:
f.add_all_atomic_fragments()
rdfedmet_qba_directbos.kernel()

rdfedmet_qba = vayesta.edmet.EDMET(mf, solver="EBCCSD", dmet_threshold=1e-12, bosonic_interaction="qba_bos_ex",
rdfedmet_qba = vayesta.edmet.EDMET(mf, solver="CCSD-S-1-1", bath_options=dict(dmet_threshold=1e-12), bosonic_interaction="qba_bos_ex",
oneshot=True, make_dd_moments=False)
with rdfedmet_qba.iao_fragmentation() as f:
f.add_all_atomic_fragments()
Expand Down
6 changes: 3 additions & 3 deletions examples/edmet/30-start-from-dft.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# The KS opbject needs to be converted to a HF object:
lda = lda.to_rhf()

emb_lda = vayesta.edmet.EDMET(lda, dmet_threshold=1e-12, solver="EBCCSD", oneshot=True, make_dd_moments=False)
emb_lda = vayesta.edmet.EDMET(lda, solver="CCSD-S-1-1", bath_options=dict(dmet_threshold=1e-12), oneshot=True, make_dd_moments=False)
with emb_lda.iao_fragmentation() as f:
f.add_all_atomic_fragments()
emb_lda.kernel()
Expand All @@ -38,7 +38,7 @@
# The KS opbject needs to be converted to a HF object:
b3lyp = b3lyp.to_rhf()

emb_b3lyp = vayesta.edmet.EDMET(b3lyp, dmet_threshold=1e-12, solver="EBCCSD", oneshot=True, make_dd_moments=False)
emb_b3lyp = vayesta.edmet.EDMET(b3lyp, solver="CCSD-S-1-1", bath_options=dict(dmet_threshold=1e-12), oneshot=True, make_dd_moments=False)
with emb_b3lyp.iao_fragmentation() as f:
f.add_all_atomic_fragments()
emb_b3lyp.kernel()
Expand All @@ -47,7 +47,7 @@
hf = pyscf.scf.RHF(mol).density_fit()
hf.kernel()

emb_hf = vayesta.edmet.EDMET(hf, dmet_threshold=1e-12, solver="EBCCSD", oneshot=True, make_dd_moments=False)
emb_hf = vayesta.edmet.EDMET(hf, solver="CCSD-S-1-1", bath_options=dict(dmet_threshold=1e-12), oneshot=True, make_dd_moments=False)
with emb_hf.iao_fragmentation() as f:
f.add_all_atomic_fragments()
emb_hf.kernel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,28 @@


natom = 6
filename = "energies_scEDMET_h{:d}_compare.txt".format(natom)
filename = "energies_scEDMET_h{:d}_compare_df.txt".format(natom)

with open(filename, "a") as f:
f.write(("%6s" + " %16s " * 8) % (
"d", "HF", "CCSD", "FCI", "DMET (Oneshot)", "DMET", "EDMET (Oneshot)", "EDMET (old)", "EDMET (new)"))

import numpy as np
import pyscf.cc
import pyscf.fci
import pyscf.tools
import pyscf.tools.ring
import vayesta.dmet
import vayesta.edmet


natom = 6
filename = "energies_h{:d}_compare_df.txt".format(natom)

with open(filename, "a") as f:
f.write(("%6s" + " %16s " * 6 + "\n") % (
"d", "HF", "CCSD", "FCI", "DMET (Oneshot)", "DMET", "EDMET (Oneshot)"))

for d in np.arange(0.5, 3.0001, 0.25):

ring = pyscf.tools.ring.make(natom, d)
Expand All @@ -27,7 +43,10 @@
mol.build()

# Hartree-Fock
mf = pyscf.scf.RHF(mol)
# Replace with
# mf = pyscf.scf.RHF(mol)
# to run without density fitting.
mf = pyscf.scf.RHF(mol).density_fit()
mf.kernel()

# Reference full system CCSD:
Expand All @@ -51,43 +70,26 @@
f.add_atomic_fragment([i, i + 1])
dmet_diis.kernel()
# Single-shot EDMET
edmet_oneshot = vayesta.edmet.EDMET(mf, solver='EBFCI', max_elec_err=1e-4, maxiter=1, max_boson_occ=2)
edmet_oneshot = vayesta.edmet.EDMET(mf, solver='FCI', max_elec_err=1e-4, maxiter=1,
solver_options=dict(max_boson_occ=2), oneshot=True)
with edmet_oneshot.iao_fragmentation() as f:
for i in range(0, natom, 2):
f.add_atomic_fragment([i, i + 1])
edmet_oneshot.kernel()
# Full DMET
edmet_orig = vayesta.edmet.EDMET(mf, solver='EBFCI', charge_consistent=True, max_elec_err=1e-4, maxiter=40,
max_boson_occ=2, old_sc_condition=True)
with edmet_orig.iao_fragmentation() as f:
for i in range(0, natom, 2):
f.add_atomic_fragment([i, i + 1])
edmet_orig.kernel()

edmet_new = vayesta.edmet.EDMET(mf, solver='EBFCI', charge_consistent=True, max_elec_err=1e-4, maxiter=40,
max_boson_occ=2)
with edmet_new.iao_fragmentation() as f:
for i in range(0, natom, 2):
f.add_atomic_fragment([i, i + 1])
edmet_new.kernel()

e_sc_edmet1 = edmet_orig.e_tot if edmet_orig.converged else np.NaN
e_sc_edmet2 = edmet_new.e_tot if edmet_new.converged else np.NaN
e_cc = mycc.e_tot if mycc.converged else np.NaN
e_dmet = dmet_diis.e_tot if dmet_diis.converged else np.NaN
print("E%-14s %+16.8f Ha" % ('(HF)=', mf.e_tot))
print("E%-14s %+16.8f Ha" % ('(CCSD)=', e_cc))
print("E%-14s %+16.8f Ha" % ('(FCI)=', myfci.e_tot))
print("E%-14s %+16.8f Ha" % ('(DMET-FCI)=', dmet_oneshot.e_tot))
print("E%-14s %+16.8f Ha" % ('(EDMET-FCI-Oneshot)=', edmet_oneshot.e_tot))
print("E%-14s %+16.8f Ha" % ('(EDMET1-FCI)=', e_sc_edmet1))
print("E%-14s %+16.8f Ha" % ('(EDMET2-FCI)=', e_sc_edmet2))


with open(filename, "a") as f:
f.write("%.2f % 16.8f % 16.8f % 16.8f %16.8f %16.8f %16.8f %16.8f %16.8f\n" % (d, mf.e_tot, e_cc,
f.write("%.2f % 16.8f % 16.8f % 16.8f %16.8f %16.8f %16.8f\n" % (d, mf.e_tot, e_cc,
myfci.e_tot,
dmet_oneshot.e_tot,
e_dmet,
edmet_oneshot.e_tot,
e_sc_edmet1,
e_sc_edmet2))
edmet_oneshot.e_tot
))
94 changes: 0 additions & 94 deletions examples/edmet/71-h-ring-benchmark-df.py

This file was deleted.

Loading

0 comments on commit c6daee3

Please sign in to comment.