Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ci_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ channels:
- nodefaults
dependencies:
- libblas=*=*mkl
- adcc>=0.15.16
- adcc>=0.16.0
- numpy
- pytest
- pytest-cov
- coveralls
- zarr>=2,<3
- ruff
- isort
- isort
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ classifiers = [
requires-python = ">=3.7"
# Declare any run-time dependencies that should be installed with the package.
dependencies = [
"adcc >= 0.15.16",
"adcc >= 0.16.0",
"numpy >= 1.14",
]
keywords=[
Expand Down Expand Up @@ -85,4 +85,5 @@ line-length = 100

[tool.ruff]
line-length = 100
ignore = ["E741"]
lint.ignore = ["E741"]
lint.extend-select = ["E501"]
11 changes: 5 additions & 6 deletions respondo/mcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .solve_response import solve_response, transition_polarizability


def mcd_bterm(state, property_method=None, **solver_args):
def mcd_bterm(state, property_method=None, gauge_origin="origin", **solver_args):
if not isinstance(state, Excitation):
raise TypeError()
matrix = construct_adcmatrix(state.parent_state.matrix)
Expand All @@ -17,13 +17,14 @@ def mcd_bterm(state, property_method=None, **solver_args):
mp = matrix.ground_state

dips_el = hf.operators.electric_dipole
dips_mag = hf.operators.magnetic_dipole
dips_mag = hf.operators.magnetic_dipole(gauge_origin)
rhss_el = modified_transition_moments(property_method, mp, dips_el)
rhss_mag = modified_transition_moments(property_method, mp, dips_mag)

# the minus sign is required due to the anti-hermiticity of the magnetic dipole operator
response_mag = [
-1.0 * solve_response(matrix, rhs_mag, omega=0.0, gamma=0.0, **solver_args) for rhs_mag in rhss_mag
-1.0 * solve_response(matrix, rhs_mag, omega=0.0, gamma=0.0, **solver_args)
for rhs_mag in rhss_mag
]

v_f = state.excitation_vector
Expand Down Expand Up @@ -53,7 +54,5 @@ def projection(X, bl=None):
epsilon[2, 1, 0] = epsilon[0, 2, 1] = epsilon[1, 0, 2] = -1

tdip_f = state.transition_dipole_moment
# the minus sign accounts for the negative charge, since it is not included in the operators
# TODO as soon as PR #190 in adcc is merged: remove minus
B = -1.0 * np.einsum("abc,a,bc->", epsilon, tdip_f, term1 + np.transpose(term2))
B = np.einsum("abc,a,bc->", epsilon, tdip_f, term1 + np.transpose(term2))
return B
4 changes: 3 additions & 1 deletion respondo/sos.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ def sos_tpa_matrix_resonant(state, final_state=0):


def sos_mcd_bterm(state, final_state=0):
# Note: there exists only reference data for the gauge origin placed at the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this function can also be called with a normal ExcitedStates object and not only with a MockExcitedStates object, right? I think for the former the gauge selection should still be possible and also the magnetic properties need to be adapted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this function was for testing purposes only.
See lines 110 and 111: An ExcitedStates object does not have these properties, nor does a State2States object. Thus, the function is only meant for the MockExcitedStates object.

110 s2s_tdm = state.transition_dipole_moment_s2s
111 s2s_tdm_mag = state.transition_magnetic_moment_s2s

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this used to work before the State2States class was introduced. But okay, for now, it is okay then, I guess. But maybe we could think about changing this in the future.

# origin of the Cartesian coordinate system!
term1 = np.zeros((3, 3))
term2 = np.zeros_like(term1)

Expand Down Expand Up @@ -126,5 +128,5 @@ def sos_mcd_bterm(state, final_state=0):
epsilon = np.zeros((3, 3, 3))
epsilon[0, 1, 2] = epsilon[1, 2, 0] = epsilon[2, 0, 1] = 1
epsilon[2, 1, 0] = epsilon[0, 2, 1] = epsilon[1, 0, 2] = -1
B = -1.0 * np.einsum("abc,a,bc->", epsilon, tdip_f, term1 + term2)
B = np.einsum("abc,a,bc->", epsilon, tdip_f, term1 + term2)
return B
4 changes: 2 additions & 2 deletions respondo/testdata/0_download_testdata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

# taken from adcc repository, written by @mfherbst

SOURCE="https://wwwagdreuw.iwr.uni-heidelberg.de/respondo_test_data/0.2.0"
SOURCE="https://wwwagdreuw.iwr.uni-heidelberg.de/respondo_test_data/0.3.0"
DATAFILES=(
data_0.2.0.tar.gz
data_0.3.0.tar.gz
)
#
# -----
Expand Down
2 changes: 1 addition & 1 deletion respondo/testdata/SHA256SUMS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ed7bf0506c2c9d299529a56a5b4a6c76b9985b2bd2954b8be13abc33375342ed data_0.2.0.tar.gz
c94462bb9f2adc4d0be9505b307da9ab71b0ef09aff343d4bd17e95098f712da data_0.3.0.tar.gz
13 changes: 11 additions & 2 deletions respondo/testdata/dump_full_diagonalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@


def main():
# Store data for only one gauge origin
gauge_origin="origin"
for case in cases:
n_singlets = cases[case]
molecule, basis, method = case.split("_")
Expand All @@ -20,9 +22,10 @@ def main():
# multiplicity=multiplicity,
# conv_tol_grad=conv_tol_grad,
)
state = adcc.run_adc(method=method, data_or_matrix=scfres, n_singlets=n_singlets)
state = adcc.run_adc(method=method, data_or_matrix=scfres,
n_singlets=n_singlets, n_guesses=n_singlets)
dips = state.reference_state.operators.electric_dipole
mdips = state.reference_state.operators.magnetic_dipole
mdips = state.reference_state.operators.magnetic_dipole(gauge_origin)

# state to state transition moments
s2s_tdms = np.zeros((state.size, state.size, 3))
Expand Down Expand Up @@ -53,6 +56,12 @@ def main():
d = getattr(state, key)
except NotImplementedError:
continue
if callable(d):
try:
d = d(gauge_origin)
except NotImplementedError:
# some properties are not available for every backend
continue
if not isinstance(d, np.ndarray):
continue
if not np.issubdtype(d.dtype, np.number):
Expand Down
Loading