Skip to content

Commit

Permalink
fix electron acceptor COD equivalent
Browse files Browse the repository at this point in the history
  • Loading branch information
joyxyz1994 committed Jan 16, 2024
1 parent ce719c5 commit 43a0d3c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions qsdsan/utils/cod.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,25 @@ def cod_test_stoichiometry(atoms, charge=0, MW=None, missing_handling='elemental


def electron_acceptor_cod(atoms, charge=0):
r'''
.. math::
NO_2^- + 3e^- + 4H^+ -> \frac{1}{2}N_2 + 2H_2O
NO_3^- + 5e^- + 6H^+ -> \frac{1}{2}N_2 + 3H_2O
O_2 + 4e^- + 4H^+ -> 2H_2O
'''
if atoms == {'O':2}:
return -1
elif atoms == {'N':2}:
return 0
elif atoms == {'N':1, 'O':2} and charge == -1:
return -1.5
return -3/4
elif atoms == {'N':1, 'O':3} and charge == -1:
return -2
return -5/4



def get_cod_stoichiometry(component, aqueous=False, **replace):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def test_component():
cmps3 = Components.load_default()
assert cmps3.S_H2.measured_as == 'COD'
assert cmps3.S_H2.i_COD == 1
assert isclose(cmps3.S_NO2.i_COD, - molecular_weight({'O':3})/molecular_weight({'N':1}), rel_tol=1e-3)
assert isclose(cmps3.S_NO3.i_COD, - molecular_weight({'O':4})/molecular_weight({'N':1}), rel_tol=1e-3)
assert isclose(cmps3.S_NO2.i_COD, - 3*molecular_weight({'O':2})/(4*molecular_weight({'N':1})), rel_tol=1e-3)
assert isclose(cmps3.S_NO3.i_COD, - 5*molecular_weight({'O':2})/(4*molecular_weight({'N':1})), rel_tol=1e-3)
set_thermo(cmps3)

# Check if the default groups are up-to-date
Expand Down

0 comments on commit 43a0d3c

Please sign in to comment.