Fit curve

Module for cyclic voltammogram fitting, using a semi-integration simulated CV for one- and two-electron processes.

class src.cvsim.fit_curve.FitMechanism(voltage_to_fit: list[float] | ndarray, current_to_fit: list[float] | ndarray, scan_rate: float, c_bulk: float, step_size: float, disk_radius: float, temperature: float = 298.0, reduction_potential: float | None = None, diffusion_reactant: float | None = None, diffusion_product: float | None = None)[source]

Scheme for fitting cyclic voltammograms.

Parameters:
  • voltage_to_fit (list[float] | np.ndarray) – Array of voltage data of the CV to fit.

  • current_to_fit (list[float] | np.ndarray) – Array of current data of the CV to fit.

  • scan_rate (float) – Potential sweep rate (V/s).

  • c_bulk (float) – Bulk concentration of redox species (mM or mol/m^3).

  • step_size (float) – Voltage increment during CV scan (mV).

  • disk_radius (float) – Radius of disk macro-electrode (mm).

  • temperature (float) – Temperature (K). Default is 298.0 K (24.85C).

  • reduction_potential (float | None) – Reduction potential of the one-electron transfer process (V vs. reference). If known, can be fixed value, otherwise defaults to None.

  • diffusion_reactant (float | None) – Diffusion coefficient of reactant (cm^2/s). If known, can be fixed value, otherwise defaults to None.

  • diffusion_product (float | None) – Diffusion coefficient of product (cm^2/s). If known, can be fixed value, otherwise defaults to None.

class src.cvsim.fit_curve.FitE_rev(voltage_to_fit: list[float] | ndarray, current_to_fit: list[float] | ndarray, scan_rate: float, c_bulk: float, step_size: float, disk_radius: float, temperature: float = 298.0, reduction_potential: float | None = None, diffusion_reactant: float | None = None, diffusion_product: float | None = None)[source]

Scheme for fitting a CV for a reversible (Nernstian) one-electron transfer mechanism.

Parameters:
  • voltage_to_fit (list[float] | np.ndarray) – Array of voltage data of the CV to fit.

  • current_to_fit (list[float] | np.ndarray) – Array of current data of the CV to fit.

  • scan_rate (float) – Potential sweep rate (V/s).

  • c_bulk (float) – Bulk concentration of redox species (mM or mol/m^3).

  • step_size (float) – Voltage increment during CV scan (mV).

  • disk_radius (float) – Radius of disk macro-electrode (mm).

  • temperature (float) – Temperature (K). Default is 298.0 K (24.85C).

  • reduction_potential (float | None) – Reduction potential of the one-electron transfer process (V vs. reference). If known, can be fixed value, otherwise defaults to None.

  • diffusion_reactant (float | None) – Diffusion coefficient of reactant (cm^2/s). If known, can be fixed value, otherwise defaults to None.

  • diffusion_product (float | None) – Diffusion coefficient of product (cm^2/s). If known, can be fixed value, otherwise defaults to None.

fit(reduction_potential: None | float | tuple[float, float] | tuple[float, float, float] = None, diffusion_reactant: None | float | tuple[float, float] | tuple[float, float, float] = None, diffusion_product: None | float | tuple[float, float] | tuple[float, float, float] = None) tuple[ndarray, ndarray, dict[str, float]][source]

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 (lower bound, upper bound) of the initial guess; or tuple[float, float, float] for (initial guess, lower bound, upper bound).

Parameters:
  • reduction_potential (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the reduction potential of the one-electron transfer process (V vs. reference). Defaults to None.

  • diffusion_reactant (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the diffusion coefficient of reactant (cm^2/s). Defaults to None.

  • diffusion_product (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the diffusion coefficient of product (cm^2/s). Defaults to None.

Returns:

  • voltage (np.ndarray) – 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[str, float]) – Dictionary of final fitting parameter values of the CV fit.

class src.cvsim.fit_curve.FitE_q(voltage_to_fit: list[float] | ndarray, current_to_fit: list[float] | ndarray, scan_rate: float, c_bulk: float, step_size: float, disk_radius: float, temperature: float = 298.0, reduction_potential: float | None = None, diffusion_reactant: float | None = None, diffusion_product: float | None = None, alpha: float | None = None, k0: float | None = None)[source]

Scheme for fitting a CV for a quasi-reversible one-electron transfer mechanism.

Parameters:
  • voltage_to_fit (list[float] | np.ndarray) – Array of voltage data of the CV to fit.

  • current_to_fit (list[float] | np.ndarray) – Array of current data of the CV to fit.

  • scan_rate (float) – Potential sweep rate (V/s).

  • c_bulk (float) – Bulk concentration of redox species (mM or mol/m^3).

  • step_size (float) – Voltage increment during CV scan (mV).

  • disk_radius (float) – Radius of disk macro-electrode (mm).

  • temperature (float) – Temperature (K). Default is 298.0 K (24.85C).

  • reduction_potential (float | None) – Reduction potential of the one-electron transfer process (V vs. reference). If known, can be fixed value, otherwise defaults to None.

  • diffusion_reactant (float | None) – Diffusion coefficient of reactant (cm^2/s). If known, can be fixed value, otherwise defaults to None.

  • diffusion_product (float | None) – Diffusion coefficient of product (cm^2/s). If known, can be fixed value, otherwise defaults to None.

  • alpha (float | None) – Charge transfer coefficient (no units). If known, can be fixed value, otherwise defaults to None.

  • k0 (float | None) – Standard electrochemical rate constant (cm/s). If known, can be fixed value, otherwise defaults to None.

fit(reduction_potential: None | float | tuple[float, float] | tuple[float, float, float] = None, diffusion_reactant: None | float | tuple[float, float] | tuple[float, float, float] = None, diffusion_product: None | float | tuple[float, float] | tuple[float, float, float] = None, alpha: None | float | tuple[float, float] | tuple[float, float, float] = None, k0: None | float | tuple[float, float] | tuple[float, float, float] = None) tuple[ndarray, ndarray, dict[str, float]][source]

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 (lower bound, upper bound) of the initial guess; or tuple[float, float, float] for (initial guess, lower bound, upper bound).

Parameters:
  • reduction_potential (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the reduction potential of the one-electron transfer process (V vs. reference). Defaults to None.

  • diffusion_reactant (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the diffusion coefficient of reactant (cm^2/s). Defaults to None.

  • diffusion_product (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the diffusion coefficient of product (cm^2/s). Defaults to None.

  • alpha (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the charge transfer coefficient (no units). Defaults to None.

  • k0 (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the standard electrochemical rate constant (cm/s). Defaults to None.

Returns:

  • voltage (np.ndarray) – 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[str, float]) – Dictionary of final fitting parameter values of the CV fit.

class src.cvsim.fit_curve.FitE_qC(voltage_to_fit: list[float] | ndarray, current_to_fit: list[float] | ndarray, scan_rate: float, c_bulk: float, step_size: float, disk_radius: float, temperature: float = 298.0, reduction_potential: float | None = None, diffusion_reactant: float | None = None, diffusion_product: float | None = None, alpha: float | None = None, k0: float | None = None, k_forward: float | None = None, k_backward: float | None = None)[source]

Scheme for fitting a CV for a quasi-reversible one-electron transfer, followed by a reversible first order homogeneous chemical transformation mechanism.

Parameters:
  • voltage_to_fit (list[float] | np.ndarray) – Array of voltage data of the CV to fit.

  • current_to_fit (list[float] | np.ndarray) – Array of current data of the CV to fit.

  • scan_rate (float) – Potential sweep rate (V/s).

  • c_bulk (float) – Bulk concentration of redox species (mM or mol/m^3).

  • step_size (float) – Voltage increment during CV scan (mV).

  • disk_radius (float) – Radius of disk macro-electrode (mm).

  • temperature (float) – Temperature (K). Default is 298.0 K (24.85C).

  • reduction_potential (float | None) – Reduction potential of the one-electron transfer process (V vs. reference). If known, can be fixed value, otherwise defaults to None.

  • diffusion_reactant (float | None) – Diffusion coefficient of reactant (cm^2/s). If known, can be fixed value, otherwise defaults to None.

  • diffusion_product (float | None) – Diffusion coefficient of product (cm^2/s). If known, can be fixed value, otherwise defaults to None.

  • alpha (float | None) – Charge transfer coefficient (no units). If known, can be fixed value, otherwise defaults to None.

  • k0 (float | None) – Standard electrochemical rate constant (cm/s). If known, can be fixed value, otherwise defaults to None.

  • k_forward (float | None) – First order forward chemical rate constant (1/s). If known, can be fixed value, otherwise defaults to None.

  • k_backward (float | None) – First order backward chemical rate constant (1/s). If known, can be fixed value, otherwise defaults to None.

fit(reduction_potential: None | float | tuple[float, float] | tuple[float, float, float] = None, diffusion_reactant: None | float | tuple[float, float] | tuple[float, float, float] = None, diffusion_product: None | float | tuple[float, float] | tuple[float, float, float] = None, alpha: None | float | tuple[float, float] | tuple[float, float, float] = None, k0: None | float | tuple[float, float] | tuple[float, float, float] = None, k_forward: None | float | tuple[float, float] | tuple[float, float, float] = None, k_backward: None | float | tuple[float, float] | tuple[float, float, float] = None) tuple[ndarray, ndarray, dict[str, float]][source]

Fits the CV for a quasi-reversible one-electron transfer, followed by a reversible first order homogeneous chemical transformation mechanism. If a parameter is given, it must be a: float for initial guess of parameter; tuple[float, float] for (lower bound, upper bound) of the initial guess; or tuple[float, float, float] for (initial guess, lower bound, upper bound).

Parameters:
  • reduction_potential (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the reduction potential of the one-electron transfer process (V vs. reference). Defaults to None.

  • diffusion_reactant (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the diffusion coefficient of reactant (cm^2/s). Defaults to None.

  • diffusion_product (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the diffusion coefficient of product (cm^2/s). Defaults to None.

  • alpha (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the charge transfer coefficient (no units). Defaults to None.

  • k0 (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the standard electrochemical rate constant (cm/s). Defaults to None.

  • k_forward (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the first order forward chemical rate constant (1/s). Defaults to None.

  • k_backward (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the first order backward chemical rate constant (1/s). Defaults to None.

Returns:

  • voltage (np.ndarray) – 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[str, float]) – Dictionary of final fitting parameter values of the CV fit.

class src.cvsim.fit_curve.FitEE(voltage_to_fit: list[float] | ndarray, current_to_fit: list[float] | ndarray, scan_rate: float, c_bulk: float, step_size: float, disk_radius: float, temperature: float = 298.0, reduction_potential: float | None = None, reduction_potential2: float | None = None, diffusion_reactant: float | None = None, diffusion_intermediate: float | None = None, diffusion_product: float | None = None, alpha: float | None = None, alpha2: float | None = None, k0: float | None = None, k0_2: float | None = None)[source]

Scheme for fitting a CV for a two successive one-electron quasi-reversible transfer mechanism.

Parameters:
  • voltage_to_fit (list[float] | np.ndarray) – Array of voltage data of the CV to fit.

  • current_to_fit (list[float] | np.ndarray) – Array of current data of the CV to fit.

  • scan_rate (float) – Potential sweep rate (V/s).

  • c_bulk (float) – Bulk concentration of redox species (mM or mol/m^3).

  • step_size (float) – Voltage increment during CV scan (mV).

  • disk_radius (float) – Radius of disk macro-electrode (mm).

  • temperature (float) – Temperature (K). Default is 298.0 K (24.85C).

  • reduction_potential (float | None) – Reduction potential of the first one-electron transfer process (V vs. reference). If known, can be fixed value, otherwise defaults to None.

  • reduction_potential2 (float | None) – Reduction potential of the second one-electron transfer process (V vs. reference). If known, can be fixed value, otherwise defaults to None.

  • diffusion_reactant (float | None) – Diffusion coefficient of reactant (cm^2/s). If known, can be fixed value, otherwise defaults to None.

  • diffusion_intermediate (float | None) – Diffusion coefficient of intermediate (cm^2/s). If known, can be fixed value, otherwise defaults to None.

  • diffusion_product (float | None) – Diffusion coefficient of product (cm^2/s). If known, can be fixed value, otherwise defaults to None.

  • alpha (float | None) – Charge transfer coefficient of first redox process (no units). If known, can be fixed value, otherwise defaults to None.

  • alpha2 (float | None) – Charge transfer coefficient of second redox process (no units). If known, can be fixed value, otherwise defaults to None.

  • k0 (float | None) – Standard electrochemical rate constant of first redox process (cm/s). If known, can be fixed value, otherwise defaults to None.

  • k0_2 (float | None) – Standard electrochemical rate constant of second redox process (cm/s). If known, can be fixed value, otherwise defaults to None.

fit(reduction_potential: None | float | tuple[float, float] | tuple[float, float, float] = None, reduction_potential2: None | float | tuple[float, float] | tuple[float, float, float] = None, diffusion_reactant: None | float | tuple[float, float] | tuple[float, float, float] = None, diffusion_intermediate: None | float | tuple[float, float] | tuple[float, float, float] = None, diffusion_product: None | float | tuple[float, float] | tuple[float, float, float] = None, alpha: None | float | tuple[float, float] | tuple[float, float, float] = None, alpha2: None | float | tuple[float, float] | tuple[float, float, float] = None, k0: None | float | tuple[float, float] | tuple[float, float, float] = None, k0_2: None | float | tuple[float, float] | tuple[float, float, float] = None) tuple[ndarray, ndarray, dict[str, float]][source]

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 (lower bound, upper bound) of the initial guess; or tuple[float, float, float] for (initial guess, lower bound, upper bound).

Parameters:
  • reduction_potential (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the reduction potential of the first one-electron transfer process (V vs. reference). Defaults to None.

  • reduction_potential2 (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the reduction potential of the second one-electron transfer process (V vs. reference). Defaults to None.

  • diffusion_reactant (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the diffusion coefficient of reactant (cm^2/s). Defaults to None.

  • diffusion_intermediate (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the diffusion coefficient of intermediate (cm^2/s). Defaults to None.

  • diffusion_product (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the diffusion coefficient of product (cm^2/s). Defaults to None.

  • alpha (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the charge transfer coefficient of the first redox process (no units). Defaults to None.

  • alpha2 (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the charge transfer coefficient of the second redox process (no units). Defaults to None.

  • k0 (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the standard electrochemical rate constant of the first redox process (cm/s). Defaults to None.

  • k0_2 (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the standard electrochemical rate constant of the second redox process (cm/s). Defaults to None.

Returns:

  • voltage (np.ndarray) – 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[str, float]) – Dictionary of final fitting parameter values of the CV fit.

class src.cvsim.fit_curve.FitSquareScheme(voltage_to_fit: list[float] | ndarray, current_to_fit: list[float] | ndarray, scan_rate: float, c_bulk: float, step_size: float, disk_radius: float, temperature: float = 298.0, reduction_potential: float | None = None, reduction_potential2: float | None = None, diffusion_reactant: float | None = None, diffusion_product: float | None = None, alpha: float | None = None, alpha2: float | None = None, k0: float | None = None, k0_2: float | None = None, k_forward: float | None = None, k_backward: float | None = None, k_forward2: float | None = None, k_backward2: float | None = None)[source]

Scheme for fitting a CV for two quasi-reversible, one-electron transfers of homogeneously interconverting reactants (Square Scheme) mechanism.

Parameters:
  • voltage_to_fit (list[float] | np.ndarray) – Array of voltage data of the CV to fit.

  • current_to_fit (list[float] | np.ndarray) – Array of current data of the CV to fit.

  • scan_rate (float) – Potential sweep rate (V/s).

  • c_bulk (float) – Bulk concentration of redox species (mM or mol/m^3).

  • step_size (float) – Voltage increment during CV scan (mV).

  • disk_radius (float) – Radius of disk macro-electrode (mm).

  • temperature (float) – Temperature (K). Default is 298.0 K (24.85C).

  • reduction_potential (float | None) – Reduction potential of the first one-electron transfer process (V vs. reference). If known, can be fixed value, otherwise defaults to None.

  • reduction_potential2 (float | None) – Reduction potential of the second one-electron transfer process (V vs. reference). If known, can be fixed value, otherwise defaults to None.

  • diffusion_reactant (float | None) – Diffusion coefficient of reactant (cm^2/s). If known, can be fixed value, otherwise defaults to None.

  • diffusion_product (float | None) – Diffusion coefficient of product (cm^2/s). If known, can be fixed value, otherwise defaults to None.

  • alpha (float | None) – Charge transfer coefficient of first redox process (no units). If known, can be fixed value, otherwise defaults to None.

  • alpha2 (float | None) – Charge transfer coefficient of second redox process (no units). If known, can be fixed value, otherwise defaults to None.

  • k0 (float | None) – Standard electrochemical rate constant of first redox process (cm/s). If known, can be fixed value, otherwise defaults to None.

  • k0_2 (float | None) – Standard electrochemical rate constant of second redox process (cm/s). If known, can be fixed value, otherwise defaults to None.

  • k_forward (float | None) – First order forward chemical rate constant for first redox species (1/s). If known, can be fixed value, otherwise defaults to None.

  • k_backward (float | None) – First order backward chemical rate constant for first redox species (1/s). If known, can be fixed value, otherwise defaults to None.

  • k_forward2 (float | None) – First order forward chemical rate constant for second redox species (1/s). If known, can be fixed value, otherwise defaults to None.

  • k_backward2 (float | None) – First order backward chemical rate constant for second redox species (1/s). If known, can be fixed value, otherwise defaults to None.

fit(reduction_potential: None | float | tuple[float, float] | tuple[float, float, float] = None, reduction_potential2: None | float | tuple[float, float] | tuple[float, float, float] = None, diffusion_reactant: None | float | tuple[float, float] | tuple[float, float, float] = None, diffusion_product: None | float | tuple[float, float] | tuple[float, float, float] = None, alpha: None | float | tuple[float, float] | tuple[float, float, float] = None, alpha2: None | float | tuple[float, float] | tuple[float, float, float] = None, k0: None | float | tuple[float, float] | tuple[float, float, float] = None, k0_2: None | float | tuple[float, float] | tuple[float, float, float] = None, k_forward: None | float | tuple[float, float] | tuple[float, float, float] = None, k_backward: None | float | tuple[float, float] | tuple[float, float, float] = None, k_forward2: None | float | tuple[float, float] | tuple[float, float, float] = None, k_backward2: None | float | tuple[float, float] | tuple[float, float, float] = None) tuple[ndarray, ndarray, dict[str, float]][source]

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 (lower bound, upper bound) of the initial guess; or tuple[float, float, float] for (initial guess, lower bound, upper bound).

Parameters:
  • reduction_potential (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the reduction potential of the first one-electron transfer process (V vs. reference). Defaults to None.

  • reduction_potential2 (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the reduction potential of the second one-electron transfer process (V vs. reference). Defaults to None.

  • diffusion_reactant (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the diffusion coefficient of reactant (cm^2/s). Defaults to None.

  • diffusion_product (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the diffusion coefficient of product (cm^2/s). Defaults to None.

  • alpha (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the charge transfer coefficient of the first redox process (no units). Defaults to None.

  • alpha2 (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the charge transfer coefficient of the second redox process (no units). Defaults to None.

  • k0 (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the standard electrochemical rate constant of the first redox process (cm/s). Defaults to None.

  • k0_2 (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the standard electrochemical rate constant of the second redox process (cm/s). Defaults to None.

  • k_forward (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the first order forward chemical rate constant for the first redox species (1/s). Defaults to None.

  • k_backward (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the first order backward chemical rate constant for the first redox species (1/s). Defaults to None.

  • k_forward2 (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the first order forward chemical rate constant for the second redox species (1/s). Defaults to None.

  • k_backward2 (None | float | tuple[float, float] | tuple[float, float, float]) – Optional guess for the first order backward chemical rate constant for the second redox species (1/s). Defaults to None.

Returns:

  • voltage (np.ndarray) – 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[str, float]) – Dictionary of final fitting parameter values of the CV fit.