Skip to content

Commit

Permalink
Added the DMET chemical potential self-consistency variant
Browse files Browse the repository at this point in the history
  • Loading branch information
pulkin committed Jan 15, 2018
1 parent d58165b commit 18f2c3f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
44 changes: 44 additions & 0 deletions dmet.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,50 @@ def __init__(self, driver, projector, reference_solution, log=None):
)


class MuFragmentDMETUSC(GenericDMETUmatSelfConsistency):
def __init__(self, driver, projector, reference_solution, log=None):
"""
Consistency between the chemical potential of the fragment and the fragment density matrix.
Args:
driver: a mean-field object;
projector (numpy.ndarray): a projector for the local fragment;
log: a pyscf object to log to;
"""
n = projector.shape[1]
GenericDMETUmatSelfConsistency.__init__(
self,
driver,
projector[:, :n // 2],
reference_solution,
log=log,
solution_dm_slice=slice(None, n // 2)
)

def get_default_guess(self):
return 0
get_default_guess.__doc__ = GenericDMETUmatSelfConsistency.get_default_guess.__doc__

def parametrize_umat(self, chemical_potential):
"""
Calculates the u-matrix in the projected basis.
Args:
chemical_potential (float): the chemical potential;
Returns:
The u-matrix value.
"""
return GenericDMETUmatSelfConsistency.parametrize_umat(
self,
-numpy.eye(self.umat_projector.shape[1]) * chemical_potential,
)

def gradients(self):
n = self.umat_projector.shape[1]
gradients = GenericDMETUmatSelfConsistency.gradients(self).reshape(n, n)
return -numpy.diag(gradients).sum()
gradients.__doc__ = GenericDMETUmatSelfConsistency.gradients.__doc__


def get_sd_schmidt_basis(basis, domain, threshold=1e-14):
"""
Retrieves the Schmidt basis for Slater determinants.
Expand Down
12 changes: 12 additions & 0 deletions test_dmet.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ def test_dummy_local(self):
style="interacting-bath",
)

def test_dummy_mu(self):
"""
Test a dummy interacting-bath setup where the fragment solver is RHF and only the potential is fitted. The
fragment size is 1.
"""
self.__test_dummy__(
dmet.MuFragmentDMETUSC,
1,
associate='all',
style="interacting-bath",
)

def test_non_self_consistent(self):
"""
Test a dummy interacting-bath non-self-consistent setup where the fragment solver is RHF. The fragment size is
Expand Down

0 comments on commit 18f2c3f

Please sign in to comment.