Skip to content

Commit

Permalink
add tests, docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
ericfell committed Jan 12, 2024
1 parent d16d48a commit 8e52986
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/rfbzero/crossover.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Crossover:
Parameters
----------
membrane_thickness : float
Membrane thickness, input units are (microns) but converted to cm
Membrane thickness (microns)
permeability_ox : float
Permeability of oxidized species through membrane (cm^2/s)
permeability_red : float
Expand All @@ -27,7 +27,7 @@ class Crossover:

def __init__(self, membrane_thickness: float, permeability_ox: float, permeability_red: float) -> None:
"""Initialize Crossover"""
self.membrane_thickness = membrane_thickness / 10000
self.membrane_thickness = membrane_thickness / 10000 # convert microns to cm
self.permeability_ox = permeability_ox
self.permeability_red = permeability_red

Expand Down
2 changes: 1 addition & 1 deletion src/rfbzero/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from abc import ABC, abstractmethod
from enum import Enum
#from typing import Tuple
# from typing import Tuple

from scipy.optimize import fsolve

Expand Down
2 changes: 1 addition & 1 deletion src/rfbzero/redox_flow_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Molar gas constant (J/K/mol)
R = spc.R

# make these parameters at some point?
# TODO make temperature a variable
TEMPERATURE = 298 # Kelvins, for S.T.P.
NERNST_CONST = (R * TEMPERATURE) / F

Expand Down
24 changes: 24 additions & 0 deletions tests/test_redox_flow_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,30 @@ def test_class_init(self, v_cls, v_ncls, ox_cls, red_cls, ox_ncls, red_ncls, ocv
n_ncls=n_n,
)

@pytest.mark.parametrize("v_cls,v_ncls,ox_cls,red_cls,ox_ncls,red_ncls,ocv,res,k_c,k_n,time_i",
[(0.01, 0.05, 0.01, 0.01, 0.01, 0.01, 1, 1, 1e-3, 1e-3, 1.0),
(0.01, 0.05, 0.01, 0.01, 0.01, 0.01, 1, 1, 1e-3, 1e-3, 5.0),
(0.01, 0.05, 0.01, 0.01, 0.01, 0.01, 1, 1, 1e-3, 1e-3, 11.2),
])
def test_timestep_warning(self,v_cls,v_ncls,ox_cls,red_cls,ox_ncls,red_ncls,ocv,res,k_c,k_n,time_i,capsys):
ZeroDModel(cls_volume=v_cls,
ncls_volume=v_ncls,
cls_start_c_ox=ox_cls,
cls_start_c_red=red_cls,
ncls_start_c_ox=ox_ncls,
ncls_start_c_red=red_ncls,
init_ocv=ocv,
resistance=res,
k_0_cls=k_c,
k_0_ncls=k_n,
time_increment=time_i
)

warn_out = "WARNING: 'time_increment' >= 1 second will result in very coarse data.\
\nzero-D model approaches theory as timestep decreases."
captured = capsys.readouterr()
assert captured.out.strip() == warn_out

def test_exchange_current(self):
cell = ZeroDModel(cls_volume=0.005, ncls_volume=0.01, cls_start_c_ox=0.01, cls_start_c_red=0.01,
ncls_start_c_ox=0.01, ncls_start_c_red=0.01, init_ocv=1.0, resistance=1, k_0_cls=1e-3,
Expand Down

0 comments on commit 8e52986

Please sign in to comment.