Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Currently available mechanisms:
git clone git@github.com:ericfell/CVsim.git
```

See [Getting started with `cvsim.py`](https://cvsim.readthedocs.io/en/latest/getting-started.html) for instructions on simulating CVs.

## Dependencies

Expand Down Expand Up @@ -77,7 +78,7 @@ potential, current = E_rev(
digital simulation, *Electrochimica Acta*, **56**, 2011, 10612-10625.](https://www.sciencedirect.com/science/article/abs/pii/S0013468611007651)


*The schemes for CE<sub>r</sub> , catalytic C'E<sub>q</sub> , and E<sub>r</sub>CE<sub>r</sub> are currently in development
*The schemes for CE<sub>r</sub> , catalytic C'E<sub>q</sub> , and E<sub>r</sub>CE<sub>r</sub> need development, PRs welcome!


## License
Expand Down
6 changes: 6 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
'nbsphinx',
]

autodoc_default_options = {
'members': True,
'undoc-members': True,
'inherited-members': True,
}

templates_path = ['_templates']
exclude_patterns = []

Expand Down
165 changes: 161 additions & 4 deletions docs/source/examples/cvsim_examples.ipynb

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions src/cvsim/fit_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def _fit_var_checker(fit_vars: dict, fit_default_vars: dict) -> dict:
def _scheme(self, get_var: Callable[[str], float]) -> CyclicVoltammetryScheme:
raise NotImplementedError

def _fit(self, fit_vars: dict[str, _ParamGuess]) -> tuple[np.ndarray, np.ndarray, dict]:
def _fit(self, fit_vars: dict[str, _ParamGuess]) -> tuple[np.ndarray, np.ndarray, dict[str, float]]:
fit_vars = self._non_none_dict(fit_vars)
fixed_vars = self._non_none_dict(self.fixed_vars)

Expand Down Expand Up @@ -246,7 +246,7 @@ def fit_function(
current_fit = fit_function(self.voltage, *popt)
sigma = np.sqrt(np.diag(pcov)) # one standard deviation of the parameters

final_fit = {}
final_fit: dict[str, float] = {}
for val, error, param in zip(popt, sigma, fitting_params):
final_fit[param] = val
print(f"Final fit: '{param}': {val:.2E} +/- {error:.0E}")
Expand Down Expand Up @@ -280,7 +280,7 @@ def fit(
reduction_potential: _ParamGuess = None,
diffusion_reactant: _ParamGuess = None,
diffusion_product: _ParamGuess = None,
) -> tuple[np.ndarray, np.ndarray, dict]:
) -> tuple[np.ndarray, np.ndarray, dict[str, float]]:
"""
Fits the CV for a reversible (Nernstian) one-electron transfer mechanism.
If a parameter is given, it must be a: float for initial guess of parameter; tuple[float, float] for
Expand All @@ -305,7 +305,7 @@ def fit(
Array of potential (V) values of the CV fit.
current_fit : np.ndarray
Array of current (A) values of the CV fit.
final_fit : dict
final_fit : dict[str, float]
Dictionary of final fitting parameter values of the CV fit.

"""
Expand Down Expand Up @@ -424,7 +424,7 @@ def fit(
diffusion_product: _ParamGuess = None,
alpha: _ParamGuess = None,
k0: _ParamGuess = None,
) -> tuple[np.ndarray, np.ndarray, dict]:
) -> tuple[np.ndarray, np.ndarray, dict[str, float]]:
"""
Fits the CV for a quasi-reversible one-electron transfer mechanism.
If a parameter is given, it must be a: float for initial guess of parameter; tuple[float, float] for
Expand Down Expand Up @@ -455,7 +455,7 @@ def fit(
Array of potential (V) values of the CV fit.
current_fit : np.ndarray
Array of current (A) values of the CV fit.
final_fit : dict
final_fit : dict[str, float]
Dictionary of final fitting parameter values of the CV fit.

"""
Expand Down Expand Up @@ -596,7 +596,7 @@ def fit(
k0: _ParamGuess = None,
k_forward: _ParamGuess = None,
k_backward: _ParamGuess = None,
) -> tuple[np.ndarray, np.ndarray, dict]:
) -> tuple[np.ndarray, np.ndarray, dict[str, float]]:
"""
Fits the CV for a quasi-reversible one-electron transfer, followed by a reversible first
order homogeneous chemical transformation mechanism.
Expand Down Expand Up @@ -634,7 +634,7 @@ def fit(
Array of potential (V) values of the CV fit.
current_fit : np.ndarray
Array of current (A) values of the CV fit.
final_fit : dict
final_fit : dict[str, float]
Dictionary of final fitting parameter values of the CV fit.

"""
Expand Down Expand Up @@ -799,7 +799,7 @@ def fit(
alpha2: _ParamGuess = None,
k0: _ParamGuess = None,
k0_2: _ParamGuess = None,
) -> tuple[np.ndarray, np.ndarray, dict]:
) -> tuple[np.ndarray, np.ndarray, dict[str, float]]:
"""
Fits the CV for a two successive one-electron quasi-reversible transfer mechanism.
If a parameter is given, it must be a: float for initial guess of parameter; tuple[float, float] for
Expand Down Expand Up @@ -842,7 +842,7 @@ def fit(
Array of potential (V) values of the CV fit.
current_fit : np.ndarray
Array of current (A) values of the CV fit.
final_fit : dict
final_fit : dict[str, float]
Dictionary of final fitting parameter values of the CV fit.

"""
Expand Down Expand Up @@ -1042,7 +1042,7 @@ def fit(
k_backward: _ParamGuess = None,
k_forward2: _ParamGuess = None,
k_backward2: _ParamGuess = None,
) -> tuple[np.ndarray, np.ndarray, dict]:
) -> tuple[np.ndarray, np.ndarray, dict[str, float]]:
"""
Fits the CV for a Square Scheme mechanism.
If a parameter is given, it must be a: float for initial guess of parameter; tuple[float, float] for
Expand Down Expand Up @@ -1094,7 +1094,7 @@ def fit(
Array of potential (V) values of the CV fit.
current_fit : np.ndarray
Array of current (A) values of the CV fit.
final_fit : dict
final_fit : dict[str, float]
Dictionary of final fitting parameter values of the CV fit.

"""
Expand Down