Fix multipole order forwarding and ddCOSMO radius derivatives - #185
Merged
Conversation
mnottoli
force-pushed
the
fix-version-for-mpddX
branch
from
September 1, 2026 14:27
e303b7d to
098d27d
Compare
mnottoli
force-pushed
the
fix-version-for-mpddX
branch
from
September 2, 2026 08:43
c6ca29c to
c869193
Compare
mnottoli
enabled auto-merge (squash)
September 2, 2026 08:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes two independent problems affecting multipolar electrostatics and combined Cartesian/radius derivatives.
Multipolar electrostatics
multipole_electrostaticspreviously passed a hard-codedmmax = 0to the underlying_0,_1, and_2routines. Consequently, only monopoles were evaluated even when the caller supplied higher-order multipoles.The wrapper now forwards the requested
mmaxin all three paths.COSMO radius derivatives
contract_grad_Upreviously updated either the Cartesian force or the radius derivative, depending on whetherdrwas present. Therefore, requesting radius derivatives caused the Cartesian force to omit the entireUcontribution. The routine now always accumulates the Cartesian contribution and additionally accumulatesdrwhen requested.The combined COSMO derivative now also:
zeta_grad_dr.Finally, the gradient tests now use a separate scratch-force array when evaluating radius derivatives. This prevents the corrected combined-output behavior from modifying Cartesian-gradient results that are checked later.
The existing tests did not expose this discrepancy because they validated the Cartesian and radius contributions separately through helper routines that already applied the correct -1/2 scaling and radial zeta term, rather than testing the affected combined
cosmo_solvation_force_dr_termsroutine.