Skip to content

fix: skip ionization when no ions would be added - #44

Closed
BetterAndBetterII wants to merge 1 commit into
emdgroup:mainfrom
BetterAndBetterII:fix/skip-empty-ionization
Closed

fix: skip ionization when no ions would be added#44
BetterAndBetterII wants to merge 1 commit into
emdgroup:mainfrom
BetterAndBetterII:fix/skip-empty-ionization

Conversation

@BetterAndBetterII

Copy link
Copy Markdown

Summary

ionize_solvated_system called ionize() even when concentration=0.0 and neutralize=False, so both ion counts were zero. MDAnalysis then tried to merge empty cation/anion AtomGroups and raised ValueError: cannot merge empty AtomGroup.

Return the solvated universe unchanged (and an empty species list) when no ions would be added — same outcome as ion_config is None.

Test plan

  • pytest mdfactory/tests/test_solvation.py::test_ionize_solvated_system_skips_when_no_ions --no-cov
  • pytest mdfactory/tests/test_solvation.py --no-cov (4 passed)

Fixes #42

When concentration is 0 and neutralize is false, ionize() was still
called with empty ion counts and MDAnalysis raised ValueError on
merging empty AtomGroups. Return the solvated universe unchanged.

Fixes emdgroup#42
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@maxscheurer maxscheurer closed this Sep 4, 2026
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.

ionize_solvated_system crashes when concentration=0.0 and neutralize=False

3 participants