Skip to content

Conversation

robin-dahl
Copy link

@robin-dahl robin-dahl commented Mar 27, 2025

This PR addresses two minor issues encountered during the self-consistent implementation of ddX.

Initialization in allocate_state
While working on the self-consistent implementation of ddX, we noticed that the initial guesses for the direct and adjoint solutions can be problematic. This was traced back to the allocate_state routine, where variables are allocated but not initialized to zero. This PR adds zero-initialization to the variables.
This change should not affect the behavior of ddX.

Jacobi Solver Convergence in ddLPB
During the implementation of ddLPB, we observed that one of the Jacobi solvers in the lpb_guess_adjoint routine fails to converge after the first SCF iteration. We resolved this by explicitly resetting hsp_guess to zero within the prec_tstarx routine.
This change is not expected to affect ddX, as the hsp_guess is already set to zero in the beginning, which explains why the first iteration works correctly but not the subsequent ones.

@mnottoli
Copy link
Collaborator

mnottoli commented Aug 8, 2025

I changed a bit how the guess for the adjoint screened Poisson equation is done.
Can you try again the case that was causing problems?
If it works, we can close this PR.

@robin-dahl
Copy link
Author

I changed a bit how the guess for the adjoint screened Poisson equation is done. Can you try again the case that was causing problems? If it works, we can close this PR.

Unfortunately, it is not working. However, the error message is a new one. Before the Jacobi solver did not converge but now we get "In fill_guess, the RHS is not initialized"

@mnottoli
Copy link
Collaborator

mnottoli commented Aug 8, 2025

I think the problem is here: https://github.com/robin-dahl/tblite/blob/d4b819c17af6f4748d1fa690718ee5759da1ea67/src/tblite/solvation/ddx.f90#L324C20-L324C23

You are calling fill_guess and fill_guess_adjoint without first calling setup first. The two guesses require the RHS and the adjoint RHS saved in the state.

@robin-dahl
Copy link
Author

Isn't that done by allocate_state?

@mnottoli
Copy link
Collaborator

mnottoli commented Aug 8, 2025

No, allocate_state simply allocates the various vectors. The two guesses are constructed by applying the diagonal of the matrices to the two RHSs. If the RHS has not been loaded by setup, the error is expected.

@robin-dahl
Copy link
Author

Alright, calling the setup however also requires calling multipole_electrostatics and multipole_psi, which I just do now with arbitrary point charges that are equal to zero. Seems to work though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants