Skip to content

Commit

Permalink
add trailing commas
Browse files Browse the repository at this point in the history
  • Loading branch information
ericfell committed Jan 30, 2024
1 parent 9b4bdfe commit 8b9c5ac
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/rfbzero/crossover.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def crossover(
c_red_ncls: float,
volume_cls: float,
volume_ncls: float,
time_step: float
time_step: float,
) -> tuple[float, float, float, float, float, float]:
"""
Calculation of crossover species, considering permeabilities of oxidized/reduced species.
Expand Down
53 changes: 28 additions & 25 deletions src/rfbzero/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(
time_step: float,
charge_first: bool = True,
products_cls: list[str] = None,
products_ncls: list[str] = None
products_ncls: list[str] = None,
) -> None:
self.duration = duration
self.time_step = time_step
Expand Down Expand Up @@ -258,7 +258,7 @@ def __init__(
update_concentrations: Callable[[float], tuple[dict[str, float], dict[str, float]]],
current: float,
current_lim_cls: float = None,
current_lim_ncls: float = None
current_lim_ncls: float = None,
) -> None:
self.charge = charge
self.cell_model = cell_model
Expand Down Expand Up @@ -330,7 +330,7 @@ def __init__(
update_concentrations: Callable[[float], tuple[dict[str, float], dict[str, float]]],
current: float,
voltage_limit: float,
voltage_limit_capacity_check: bool = True
voltage_limit_capacity_check: bool = True,
) -> None:
super().__init__(charge, cell_model, results, update_concentrations, current)
self.voltage_limit = voltage_limit
Expand Down Expand Up @@ -399,7 +399,7 @@ def cycle_step(self) -> CyclingStatus:
ocv,
n_act,
n_mt,
total_overpotential
total_overpotential,
)

return self._check_time(cycling_status)
Expand Down Expand Up @@ -441,7 +441,7 @@ def __init__(
voltage_limit: float,
current_estimate: float,
current_lim_cls: float = None,
current_lim_ncls: float = None
current_lim_ncls: float = None,
) -> None:
super().__init__(charge, cell_model, results, update_concentrations, current_estimate,
current_lim_cls, current_lim_ncls)
Expand Down Expand Up @@ -479,7 +479,7 @@ def cycle_step(self) -> CyclingStatus:
self.charge,
self.current,
self.voltage_limit,
ocv
ocv,
)

if abs(self.current) <= abs(self.current_cutoff):
Expand All @@ -503,7 +503,7 @@ def solver(current) -> float:
loss_solve, *_ = self.cell_model._total_overpotential(
current.item(),
self.current_lim_cls,
self.current_lim_ncls
self.current_lim_ncls,
)
return self.voltage_limit - ocv - self.__current_direction() * loss_solve

Expand Down Expand Up @@ -567,7 +567,7 @@ def _validate_cycle_values(
value: Optional[float],
value_charge: Optional[float],
value_discharge: Optional[float],
name: str
name: str,
) -> tuple[float, float]:
"""Checks validity of user inputs for current limits and/or cutoffs."""
if value is not None and (value_charge is not None or value_discharge is not None):
Expand Down Expand Up @@ -595,7 +595,7 @@ def _validate_protocol(
degradation: Optional[DegradationMechanism],
cls_degradation: Optional[DegradationMechanism],
ncls_degradation: Optional[DegradationMechanism],
crossover: Optional[Crossover]
crossover: Optional[Crossover],
) -> tuple[CyclingResults, Callable[[float], tuple[dict[str, float], dict[str, float]]]]:
"""Checks validity of user inputs for voltage limits and optional degradation and crossover mechanisms."""
if not self.voltage_limit_discharge < cell_model.ocv_50_soc < self.voltage_limit_charge:
Expand Down Expand Up @@ -677,7 +677,7 @@ def __init__(
) -> None:
super().__init__(voltage_limit_charge, voltage_limit_discharge, charge_first)
self.current_charge, self.current_discharge = self._validate_cycle_values(
current, current_charge, current_discharge, 'current'
current, current_charge, current_discharge, 'current',
)

def run(
Expand All @@ -687,7 +687,7 @@ def run(
degradation: DegradationMechanism = None,
cls_degradation: DegradationMechanism = None,
ncls_degradation: DegradationMechanism = None,
crossover: Crossover = None
crossover: Crossover = None,
) -> CyclingResults:
"""
Applies the constant current (CC) protocol and (optional) degradation/crossover mechanisms to a cell model.
Expand Down Expand Up @@ -715,7 +715,7 @@ def run(
"""

results, update_concentrations = self._validate_protocol(
duration, cell_model, degradation, cls_degradation, ncls_degradation, crossover
duration, cell_model, degradation, cls_degradation, ncls_degradation, crossover,
)

def get_cycle_mode(charge: bool) -> _ConstantCurrentCycleMode:
Expand All @@ -726,7 +726,7 @@ def get_cycle_mode(charge: bool) -> _ConstantCurrentCycleMode:
results,
update_concentrations,
self.current_charge if charge else self.current_discharge,
self.voltage_limit_charge if charge else self.voltage_limit_discharge
self.voltage_limit_charge if charge else self.voltage_limit_discharge,
)

cycle_mode = get_cycle_mode(self.charge_first)
Expand Down Expand Up @@ -788,7 +788,7 @@ def __init__(
) -> None:
super().__init__(voltage_limit_charge, voltage_limit_discharge, charge_first)
self.current_cutoff_charge, self.current_cutoff_discharge = self._validate_cycle_values(
current_cutoff, current_cutoff_charge, current_cutoff_discharge, 'current_cutoff'
current_cutoff, current_cutoff_charge, current_cutoff_discharge, 'current_cutoff',
)

def run(
Expand All @@ -798,7 +798,7 @@ def run(
degradation: DegradationMechanism = None,
cls_degradation: DegradationMechanism = None,
ncls_degradation: DegradationMechanism = None,
crossover: Crossover = None
crossover: Crossover = None,
) -> CyclingResults:
"""
Applies the constant voltage (CV) cycling protocol and (optional) degradation/crossover mechanisms to a cell
Expand Down Expand Up @@ -827,7 +827,7 @@ def run(
"""

results, update_concentrations = self._validate_protocol(
duration, cell_model, degradation, cls_degradation, ncls_degradation, crossover
duration, cell_model, degradation, cls_degradation, ncls_degradation, crossover,
)

def get_cycle_mode(charge: bool) -> _ConstantVoltageCycleMode:
Expand All @@ -838,7 +838,7 @@ def get_cycle_mode(charge: bool) -> _ConstantVoltageCycleMode:
update_concentrations,
self.current_cutoff_charge if charge else self.current_cutoff_discharge,
self.voltage_limit_charge if charge else self.voltage_limit_discharge,
0.0
0.0,
)

cycle_mode = get_cycle_mode(self.charge_first)
Expand Down Expand Up @@ -904,10 +904,10 @@ def __init__(
) -> None:
super().__init__(voltage_limit_charge, voltage_limit_discharge, charge_first)
self.current_cutoff_charge, self.current_cutoff_discharge = self._validate_cycle_values(
current_cutoff, current_cutoff_charge, current_cutoff_discharge, 'current_cutoff'
current_cutoff, current_cutoff_charge, current_cutoff_discharge, 'current_cutoff',
)
self.current_charge, self.current_discharge = self._validate_cycle_values(
current, current_charge, current_discharge, 'current'
current, current_charge, current_discharge, 'current',
)

def run(
Expand All @@ -917,7 +917,7 @@ def run(
degradation: DegradationMechanism = None,
cls_degradation: DegradationMechanism = None,
ncls_degradation: DegradationMechanism = None,
crossover: Crossover = None
crossover: Crossover = None,
) -> CyclingResults:
"""
Applies the constant current constant voltage (CCCV) cycling protocol and (optional) degradation/crossover
Expand Down Expand Up @@ -945,7 +945,7 @@ def run(
"""
results, update_concentrations = self._validate_protocol(
duration, cell_model, degradation, cls_degradation, ncls_degradation, crossover
duration, cell_model, degradation, cls_degradation, ncls_degradation, crossover,
)

def get_cc_cycle_mode(charge: bool) -> _ConstantCurrentCycleMode:
Expand All @@ -956,7 +956,7 @@ def get_cc_cycle_mode(charge: bool) -> _ConstantCurrentCycleMode:
update_concentrations,
self.current_charge if charge else self.current_discharge,
self.voltage_limit_charge if charge else self.voltage_limit_discharge,
voltage_limit_capacity_check=False
voltage_limit_capacity_check=False,
)

def get_cv_cycle_mode(
Expand All @@ -974,7 +974,7 @@ def get_cv_cycle_mode(
self.voltage_limit_charge if charge else self.voltage_limit_discharge,
current_estimate,
current_lim_cls,
current_lim_ncls
current_lim_ncls,
)

cycle_mode: _CycleMode = get_cc_cycle_mode(self.charge_first)
Expand All @@ -994,8 +994,11 @@ def get_cv_cycle_mode(
if is_cc_mode:
if cycling_status == CyclingStatus.VOLTAGE_LIMIT_REACHED:
is_cc_mode = False
cycle_mode = get_cv_cycle_mode(cycle_mode.charge, cycle_mode.current,
cycle_mode.current_lim_cls, cycle_mode.current_lim_ncls)
cycle_mode = get_cv_cycle_mode(cycle_mode.charge,
cycle_mode.current,
cycle_mode.current_lim_cls,
cycle_mode.current_lim_ncls,
)
cycling_status = CyclingStatus.NORMAL
elif cycling_status == CyclingStatus.NEGATIVE_CONCENTRATIONS:
# Record info for the half cycle
Expand Down
4 changes: 2 additions & 2 deletions src/rfbzero/redox_flow_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(
roughness_factor: float = 26.0,
num_electrons_cls: int = 1,
num_electrons_ncls: int = 1,
temperature: float = 298.0
temperature: float = 298.0,
) -> None:
self.volume_cls = volume_cls
self.volume_ncls = volume_ncls
Expand Down Expand Up @@ -381,7 +381,7 @@ def _coulomb_counter(
current: float,
cls_degradation: DegradationMechanism = None,
ncls_degradation: DegradationMechanism = None,
cross_over: Crossover = None
cross_over: Crossover = None,
) -> tuple[dict[str, float], dict[str, float]]:
"""
Updates all species' concentrations at each time step. Contributions from faradaic current, (optional)
Expand Down

0 comments on commit 8b9c5ac

Please sign in to comment.