Skip to content

Commit

Permalink
Merge pull request #105 from UCL-CCS/dependency-update
Browse files Browse the repository at this point in the history
Dependency update, pyscf to 2.3, poetry in dev deps, trigger ci on dispatch
  • Loading branch information
MIWdlB committed Oct 3, 2023
2 parents f426005 + 83dd769 commit 4bbf50c
Show file tree
Hide file tree
Showing 10 changed files with 1,388 additions and 471 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
types:
- opened
- edited
workflow_dispatch:
inputs:
branch:
description: 'Branch to test'
required: true
jobs:
build:
runs-on: ubuntu-latest
Expand Down
7 changes: 5 additions & 2 deletions nbed/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ def _subsystem_dft(self) -> None:
logger.debug("Calculating active and environment subsystem terms.")

def _rks_components(
rks_system: Localizer, subsystem_dm: np.ndarray,
rks_system: Localizer,
subsystem_dm: np.ndarray,
) -> Tuple[float, float, np.ndarray, np.ndarray, np.ndarray]:
"""Calculate the components of subsystem energy from a RKS DFT calculation.
Expand Down Expand Up @@ -767,7 +768,9 @@ def embed_dft_in_dft(self, xc_func: str, embedding_method: Callable):
y_emb = result["scf_dft"].make_rdm1()
# calculate correction
result["correction"] = np.einsum(
"ij,ij", result["v_emb_dft"], (y_emb - self.localized_system.dm_active),
"ij,ij",
result["v_emb_dft"],
(y_emb - self.localized_system.dm_active),
)
veff = result["scf_dft"].get_veff(dm=y_emb)
rks_e_elec = veff.exc + veff.ecoul + np.einsum("ij,ij", hcore_std, y_emb)
Expand Down
4 changes: 3 additions & 1 deletion nbed/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ def nbed(
hamiltonians = ()
for scf, e_classical in zip(driver.embedded_scf, driver.e_classical):
qham = HamiltonianBuilder(
scf_method=scf, constant_e_shift=e_classical, transform=transform,
scf_method=scf,
constant_e_shift=e_classical,
transform=transform,
).build(n_qubits=qubits)
converter = HamiltonianConverter(qham)
qham = getattr(converter, output.lower())
Expand Down
5 changes: 4 additions & 1 deletion nbed/ham_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
class HamiltonianConverter:
"""Class to create and output qubit hamiltonians."""

def __init__(self, input_hamiltonian: Union[QubitOperator, str, Path],) -> None:
def __init__(
self,
input_hamiltonian: Union[QubitOperator, str, Path],
) -> None:
"""Initialise class and return output.
Args:
Expand Down
2 changes: 1 addition & 1 deletion nbed/localizers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _localize_virtual_orbs(self) -> None:
# active AOs coeffs for a given MO j
numerator_all = np.einsum("ij->j", (c_virtual_loc[ao_active_inds, :]) ** 2)
# all AOs coeffs for a given MO j
denominator_all = np.einsum("ij->j", c_virtual_loc ** 2)
denominator_all = np.einsum("ij->j", c_virtual_loc**2)

active_percentage_MO = numerator_all / denominator_all

Expand Down
2 changes: 1 addition & 1 deletion nbed/localizers/pyscf.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _localize(
numerator_all = np.einsum("ij->j", (c_loc_occ[ao_active_inds, :]) ** 2)

# all AOs coeffs for a given MO j
denominator_all = np.einsum("ij->j", c_loc_occ ** 2)
denominator_all = np.einsum("ij->j", c_loc_occ**2)

mo_active_share = numerator_all / denominator_all

Expand Down
26 changes: 20 additions & 6 deletions nbed/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def parse():
logger.debug("Adding CLI arguments.")
parser = argparse.ArgumentParser(description="Output embedded Qubit Hamiltonian.")
parser.add_argument(
"--config", type=str, help="Path to a config file. Overwrites other arguments.",
"--config",
type=str,
help="Path to a config file. Overwrites other arguments.",
)
parser.add_argument(
"--geometry",
Expand All @@ -90,7 +92,10 @@ def parse():
help="Number of atoms to include in active region.",
)
parser.add_argument(
"--basis", "-b", type=str, help="Basis set to use.",
"--basis",
"-b",
type=str,
help="Basis set to use.",
)
parser.add_argument(
"--xc_functional",
Expand Down Expand Up @@ -136,10 +141,15 @@ def parse():
help="Convergence tolerance for calculations.",
)
parser.add_argument(
"--charge", type=int, help="Charge of molecular system.",
"--charge",
type=int,
help="Charge of molecular system.",
)
parser.add_argument(
"--savefile", "-s", type=str, help="Path to save file.",
"--savefile",
"-s",
type=str,
help="Path to save file.",
)
parser.add_argument(
"--run_ccsd_emb",
Expand All @@ -152,10 +162,14 @@ def parse():
help="Include if you want to run a fci calculation of the active embedded system.",
)
parser.add_argument(
"--ram", type=str, help="amount of ram in MB that PySCF can use",
"--ram",
type=str,
help="amount of ram in MB that PySCF can use",
)
parser.add_argument(
"--mu_shift", type=int, help="mu energy shift value",
"--mu_shift",
type=int,
help="mu energy shift value",
)
parser.add_argument(
"--virtual_localization",
Expand Down
Loading

0 comments on commit 4bbf50c

Please sign in to comment.