diff --git a/ci_env.yml b/ci_env.yml index 0bd5cfb..055a723 100644 --- a/ci_env.yml +++ b/ci_env.yml @@ -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 \ No newline at end of file + - isort diff --git a/pyproject.toml b/pyproject.toml index 3a8652f..8517b10 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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=[ @@ -85,4 +85,5 @@ line-length = 100 [tool.ruff] line-length = 100 -ignore = ["E741"] \ No newline at end of file +lint.ignore = ["E741"] +lint.extend-select = ["E501"] \ No newline at end of file diff --git a/respondo/mcd.py b/respondo/mcd.py index ada46e1..2a66f4b 100644 --- a/respondo/mcd.py +++ b/respondo/mcd.py @@ -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) @@ -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 @@ -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 diff --git a/respondo/sos.py b/respondo/sos.py index 9dc551e..249da1f 100644 --- a/respondo/sos.py +++ b/respondo/sos.py @@ -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 + # origin of the Cartesian coordinate system! term1 = np.zeros((3, 3)) term2 = np.zeros_like(term1) @@ -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 diff --git a/respondo/testdata/0_download_testdata.sh b/respondo/testdata/0_download_testdata.sh index 0cff9ab..e4f267f 100755 --- a/respondo/testdata/0_download_testdata.sh +++ b/respondo/testdata/0_download_testdata.sh @@ -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 ) # # ----- diff --git a/respondo/testdata/SHA256SUMS b/respondo/testdata/SHA256SUMS index bdca93a..986f866 100644 --- a/respondo/testdata/SHA256SUMS +++ b/respondo/testdata/SHA256SUMS @@ -1 +1 @@ -ed7bf0506c2c9d299529a56a5b4a6c76b9985b2bd2954b8be13abc33375342ed data_0.2.0.tar.gz \ No newline at end of file +c94462bb9f2adc4d0be9505b307da9ab71b0ef09aff343d4bd17e95098f712da data_0.3.0.tar.gz diff --git a/respondo/testdata/dump_full_diagonalization.py b/respondo/testdata/dump_full_diagonalization.py index ad52b4d..52f0a67 100644 --- a/respondo/testdata/dump_full_diagonalization.py +++ b/respondo/testdata/dump_full_diagonalization.py @@ -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("_") @@ -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)) @@ -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):