Skip to content

Commit

Permalink
Add ammonia rule
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaoyan committed Nov 1, 2019
1 parent f7af61e commit 3c43cc1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
9 changes: 8 additions & 1 deletion reaction_completer/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,14 @@ def is_hco(self):

@property
def has_water(self):
return self._component_search_helper(self._COMP_WATER)
has_combined_water = self._component_search_helper(self._COMP_WATER)

has_hydrogen = False
for comp in self.material_composition:
if 'H' in comp['elements']:
has_hydrogen = True

return has_combined_water or has_hydrogen

_COMP_ACETATE = {'C': 2, 'H': 3, 'O': 2}
_COMP_ACETATE_CHARGED = {'C': 2, 'H': 3, 'O': 2, 'e-': 1}
Expand Down
14 changes: 14 additions & 0 deletions reaction_completer/test/test_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ def test_hydroxide(self):
'1 LiFeO2-Li2MnO3 + 22 H2O + 5 [NO3-]'
])

def test_ammonia(self):
reactions = self.balance_equation([
('Li(COOCH3)', 'Li(COOCH3)', 'Li+C:2+O:2+H:3'),
('Mn(COOCH3)2·H2O', 'Mn(COOCH3)2·H2O', 'Mn+C:4+O:4+H:6;H:2+O'),
('NH4H2PO4', 'NH4H2PO4', 'N:1+H:6+P+O:4')
], [
('LiMnPO4', 'LiMnPO4', 'Li+Mn+P+O:4')
])

self.assertReactionsEqual(reactions, [
'1 Li(COOCH3) + 1 Mn(COOCH3)2·H2O + 1 NH4H2PO4 + 3 [OH-] == '
'1 LiMnPO4 + 4 H2O + 1 NH3 + 3 [CH3COO-]'
])


class TestSimple(TestReaction):
def test_carbonate(self):
Expand Down

0 comments on commit 3c43cc1

Please sign in to comment.