Skip to content

Commit

Permalink
include charges on positive and negative ion
Browse files Browse the repository at this point in the history
  • Loading branch information
richardjgowers committed Apr 4, 2022
1 parent 3754cc8 commit 815f16c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gufe/solventcomponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ def __init__(self, *, # force kwarg usage
norm = positive_ion.strip('-+').capitalize()
if norm not in _CATIONS:
raise ValueError(f"Invalid positive ion, got {positive_ion}")
positive_ion = norm
positive_ion = norm + '+'
self._positive_ion = positive_ion
if negative_ion is not None:
norm = negative_ion.strip('-+').capitalize()
if norm not in _ANIONS:
raise ValueError(f"Invalid negative ion, got {negative_ion}")
negative_ion = norm
negative_ion = norm + '-'
self._negative_ion = negative_ion

self._neutralize = neutralize
Expand Down
7 changes: 4 additions & 3 deletions gufe/tests/test_solvents.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def test_hash(pos, neg):

assert s1 == s2
assert hash(s1) == hash(s2)

assert s2.positive_ion == 'Na+'
assert s2.negative_ion == 'Cl-'

def test_neq():
s1 = SolventComponent(positive_ion='Na', negative_ion='Cl')
Expand All @@ -36,8 +37,8 @@ def test_to_dict():
s = SolventComponent(positive_ion='Na', negative_ion='Cl')

assert s.to_dict() == {'smiles': 'O',
'positive_ion': 'Na',
'negative_ion': 'Cl',
'positive_ion': 'Na+',
'negative_ion': 'Cl-',
'neutralize': True,
'ion_concentration': None}

Expand Down

0 comments on commit 815f16c

Please sign in to comment.