Package 'EleChemr'

Title: Electrochemical Reactions Simulation
Description: Digital simulation of electrochemical processes. Each function allows for implicit and explicit solution of the differential equation using methods like Euler, Backwards implicit, Runge Kutta 4, Crank Nicholson and Backward differentiation formula as well as different number of points for derivative approximation. Several electrochemical processes can be simulated such as: Chronoamperometry, Potential Step, Linear Sweep, Cyclic Voltammetry, Cyclic Voltammetry with electrochemical reaction followed by chemical reaction (EC mechanism) and CV with two following electrochemical reaction (EE mechanism). In update 1.1.0 has been added a general purpose CV function that allow to simulate up to 4 EE mechanism combined with chemical reaction for each species.Update 1.2.0 improved the accuracy of the measurements and allow personalized data resolution for simulation. Bibliography regarding this methods can be found in the following texts. Dieter Britz, Jorg Strutwolf (2016) <ISBN:978-3-319-30292-8>. Allen J. Bard, Larry R. Faulkner (2000) <ISBN:978-0-471-04372-0>.
Authors: Federico Maria Vivaldi [aut, cre]
Maintainer: Federico Maria Vivaldi <[email protected]>
License: GPL-3
Version: 1.2.0
Built: 2024-11-11 03:28:32 UTC
Source: https://github.com/federicoviv/elechemr

Help Index


Chrono amperometry digital simulation

Description

Return a graph I vs t of the electrochemical process

Usage

ChronAmp(
  Co = 0.001,
  exptime = 1,
  Dx = 1e-05,
  Dm = 0.45,
  Temp = 298.15,
  n = 1,
  Area = 1,
  DerApprox = 2,
  l = 100,
  errCheck = FALSE,
  Method = "Euler"
)

Arguments

Co

bulk concentration expressed in Molar

exptime

experimental time to be simulated expressed in seconds

Dx

diffusion coefficient expressed in cm^2/s

Dm

simulation parameter, maximum 0.5 for explicit methods

Temp

temperature in kelvin

n

number of electrons involved in the process

Area

area of the electrode expressed in cm^2

DerApprox

number of point for the approximation of the first derivative

l

number of time steps of the simulation

errCheck

if true the function returns a list with parameters for CottrCheck function

Method

method to be used for the simulation = "Euler" "BI" "RK4" "CN" "BDF"

Value

if errCheck == F a graph I vs t, if errCheck == T a list

Examples

ChronAmp(Co = 0.001, exptime = 1, DerApprox = 2, Dm = 0.45, errCheck = FALSE, Method = "Euler")

Cottrel current check for the Chronoamperometric simulation

Description

Return a graph G/Gcot vs t of the electrochemical process

Usage

CottrCheck(Elefun)

Arguments

Elefun

the function to be checked = ChronAmp, PotStep

Value

A graph G/Gcot vs t for the simulation data selected

Examples

CottrCheck(ChronAmp(errCheck = TRUE, Method = "BI"))

Cyclic voltammetry digitial simulation

Description

Return a graph I vs E of the electrochemical process

Usage

CV(
  Co = 0.001,
  Dx = 1e-05,
  Eo = 0,
  Dm = 0.45,
  Vi = 0.3,
  Vf = -0.3,
  Vs = 0.001,
  ko = 0.01,
  alpha = 0.5,
  Temp = 298.15,
  n = 1,
  Area = 1,
  l = 100,
  DerApprox = 2,
  errCheck = FALSE,
  Method = "Euler"
)

Arguments

Co

bulk concentration expressed in Molar

Dx

diffusion coefficient expressed in cm^2/s

Eo

reduction potential of the species expressed in Volts

Dm

simulation parameter, maximum 0.5 for explicit methods

Vi

initial potential of the sweep expressed in Volts

Vf

final potential of the sweepexpressed in Volts

Vs

potential scan rate of the simulation expressed in V/s

ko

heterogeneous electron transfer rate constant expressed in m/s

alpha

charge transfer coefficient

Temp

temperature in kelvin

n

number of electrons involved in the process

Area

area of the electrode expressed in cm^2

l

number of time steps of the simulation

DerApprox

number of point for the approximation of the first derivative

errCheck

if true the function returns a list with parameters for CottrCheck function

Method

method to be used for the simulation = "Euler" "BI" "RK4" "CN" "BDF"

Value

if errCheck == F a graph I vs E, if errCheck == T a list

Examples

CV(Co = 0.001, DerApprox = 2, Dm = 0.45, errCheck = FALSE, Method = "Euler")

EC behaviour cyclic voltammetry simulator

Description

Return a graph I vs E of the electrochemical process

Usage

CVEC(
  Co = 0.001,
  Dx = 1e-05,
  Eo = 0,
  Dm = 0.45,
  Vi = 0.3,
  Vf = -0.3,
  Vs = 0.001,
  ko = 0.01,
  kc = 0.001,
  l = 100,
  alpha = 0.5,
  Temp = 298.15,
  n = 1,
  Area = 1,
  DerApprox = 2,
  errCheck = FALSE,
  Method = "Euler"
)

Arguments

Co

bulk concentration expressed in Molar

Dx

diffusion coefficient expressed in cm^2/s

Eo

reduction potential of the species expressed in Volt

Dm

simulation parameter, maximum 0.5 for explicit methods

Vi

initial potential of the sweep expressed in Volt

Vf

final potential of the sweep expressed in Volt

Vs

potential scan rate of the simulation expressed in V/s

ko

heterogeneous electron transfer rate constant expressed in m/s

kc

rate constant of the reaction Red -> C expressed in s^-1

l

number of time steps of the simulation

alpha

charge transfer coefficient

Temp

temperature in kelvin

n

number of electrons involved in the process

Area

area of the electrode expressed in cm^2

DerApprox

number of point for the approximation of the first derivative

errCheck

if true the function returns a list with parameters for CottrCheck function

Method

method to be used for the simulation = "Euler" "BI" "RK4" "CN "BDF"

Value

if errCheck == F a graph I vs E, if errCheck == T a list

Examples

CVEC(Co = 0.001, DerApprox = 2, Dm = 0.45, kc = 0.00001, errCheck = FALSE, Method = "Euler")

EE behaviour cyclic voltammetry simulator

Description

Return a graph I vs E of the electrochemical process

Usage

CVEE(
  Co = 0.001,
  Dx1 = 1e-05,
  Eo1 = 0,
  Vi = 0.3,
  Vf = -0.3,
  Vs = 0.001,
  ko1 = 0.01,
  alpha1 = 0.5,
  Dred = 1e-05,
  Dred2 = 1e-05,
  Eo2 = 0,
  ko2 = 0.01,
  alpha2 = 0.5,
  Dm = 0.45,
  l = 100,
  Temp = 298.15,
  n = 1,
  Area = 1,
  DerApprox = 2,
  errCheck = FALSE,
  Method = "Euler"
)

Arguments

Co

bulk concentration expressed in Molar

Dx1

diffusion coefficient of the oxidized species expressed in cm^2/s

Eo1

reduction potential of the first electrochemical reaction expressed in Volt

Vi

initial potential of the sweep expressed in Volt

Vf

final potential of the sweep expressed in Volt

Vs

potential scan rate of the simulation expressed in V/s

ko1

heterogeneous electron transfer rate constant of the first electrochemical reaction expressed in m/s

alpha1

charge transfer coefficient of the first electrochemical reaction

Dred

diffusion coefficient of the first reduced species expressed in cm^2/s

Dred2

diffusion coefficient of the second reduced species expressed in cm^2/s

Eo2

reduction potential of the second electrochemical reaction expressed in Volt

ko2

heterogeneous electron transfer rate constant of the second electrochemical reaction expressed in m/s

alpha2

charge transfer coefficient of the second electrochemical reaction

Dm

simulation parameter, maximum 0.5 for explicit methods

l

number of time steps of the simulation

Temp

temperature in kelvin

n

number of electrons involved in the process

Area

area of the electrode expressed in cm^2

DerApprox

number of point for the approximation of the first derivative

errCheck

if true the function returns a list with parameters for CottrCheck function

Method

method to be used for the simulation = "Euler" "BI" "RK4" "CN "BDF"

Value

if errCheck == F a graph I vs E, if errCheck == T a list

Examples

CVEE(Co = 0.001, DerApprox = 2, Dm = 0.45, errCheck = FALSE, Method = "Euler")
CVEE(Co = 0.001, Eo2 = -0.15, Dm = 0.45)

Derivative calculation of concentration profile

Description

Return a the derivative of the concentration profile simulated

Usage

Derv(
  npoints = 2,
  h,
  Ox,
  mode = "Forward",
  Derivative = "First",
  CoefMat = FALSE
)

Arguments

npoints

number of points to be used for the derivative

h

space for the finite difference

Ox

data upon the derivative is calculated

mode

"Forward" or "Backward" the derivative will be calculated for the npoints

Derivative

"First" or "Second" derivative to calculate

CoefMat

if T return the derivative coefficient matrix for selected derivative

Value

a vector with the derivative requested or the coefficient of such derivative

Examples

Derv(npoints = 2, h = 0.13, Ox = matrix(c(1,2), nrow = 1), mode = "Forward", Derivative = "First")

General Purpose CV simulation

Description

Return a graph I vs E of the electrochemical process, up to 4 EE mechanisms and CE mechanisms can be simulated

Usage

Gen_CV(
  Co = 0.001,
  Cred = 0,
  kco = 0,
  Dx1 = 1e-05,
  Eo1 = 0,
  kc1 = 0,
  Vi = 0.3,
  Vf = -0.3,
  Vs = 0.001,
  ko1 = 0.01,
  alpha1 = 0.5,
  Dred = 1e-05,
  Dred2 = 1e-05,
  Eo2 = 0,
  kc2 = 0,
  ko2 = 0,
  alpha2 = 0.5,
  Dm = 0.45,
  Dred3 = 1e-05,
  Eo3 = 0,
  kc3 = 0,
  ko3 = 0,
  alpha3 = 0.5,
  Dred4 = 1e-05,
  Eo4 = 0,
  kc4 = 0,
  ko4 = 0,
  alpha4 = 0.5,
  Temp = 298.15,
  n = 1,
  Area = 1,
  l = 100,
  DerApprox = 2,
  errCheck = FALSE,
  Method = "Euler"
)

Arguments

Co

bulk concentration oxidated speciesexpressed in Molar

Cred

bulk concentration of reduced species expressed in Molar

kco

Chemical rate constant for Ox Species expressed in s^-1

Dx1

diffusion coefficient of the oxidized species expressed in cm^2/s

Eo1

reduction potential of the first electrochemical reaction expressed in Volt

kc1

Chemical rate constant for Red Species expressed in s^-1

Vi

initial potential of the sweep expressed in Volt

Vf

final potential of the sweep expressed in Volt

Vs

potential scan rate of the simulation expressed in V/s

ko1

heterogeneous electron transfer rate constant of the first electrochemical reaction expressed in m/s

alpha1

charge transfer coefficient of the first electrochemical reaction

Dred

diffusion coefficient of the first reduced species expressed in cm^2/S

Dred2

diffusion coefficient of the second reduced species expressed in cm^2/s

Eo2

reduction potential of the second electrochemical reaction expressed in Volt

kc2

Chemical rate constant for second Red Species expressed in s^-1

ko2

heterogeneous electron transfer rate constant of the second electrochemical reaction expressed in m/s

alpha2

charge transfer coefficient of the second electrochemical reaction

Dm

simulation parameter, maximum 0.5 for explicit methods

Dred3

diffusion coefficient of the third reduced species expressed in cm^2/s

Eo3

reduction potential of the third electrochemical reaction expressed in Volt

kc3

Chemical rate constant for third Red Species expressed in s^-1

ko3

heterogeneous electron transfer rate constant of the third electrochemical reaction expressed in m/s

alpha3

charge transfer coefficient of the third electrochemical reaction

Dred4

diffusion coefficient of the fourth reduced species cm^2/s

Eo4

reduction potential of the fourth electrochemical reaction expressed in Volt

kc4

Chemical rate constant for fourth Red Species expressed in s^-1

ko4

heterogeneous electron transfer rate constant of the fourth electrochemical reaction expressed in m/s

alpha4

charge transfer coefficient of the fourth electrochemical reaction

Temp

temperature in kelvin

n

number of electrons involved in the process

Area

area of the electrode expressed in cm^2

l

number of time steps of the simulation

DerApprox

number of point for the approximation of the first derivative

errCheck

if true the function returns a list with parameters for CottrCheck function

Method

method to be used for the simulation = "Euler" "BI" "RK4" "CN "BDF"

Value

if errCheck == F a graph I vs E, if errCheck == T a list

Examples

Gen_CV(Co = 0.001, DerApprox = 2, Dm = 0.45, errCheck = FALSE, Method = "Euler")
Gen_CV(Co = 0.001, Eo2 = -0.15, Dm = 0.45, kc1 = 0.0001)

Inverse matrix

Description

Returns the inverse matrix of the selected one

Usage

invMat(A)

Arguments

A

matrix to be inverted

Value

inverse matrix of the selected

Examples

invMat(A = matrix(c(1,2,6,14), nrow = 2))

Linear Sweep digitial simulation

Description

Return a graph I vs E of the electrochemical process

Usage

LinSwp(
  Co = 0.001,
  Dx = 1e-05,
  Eo = 0,
  Dm = 0.45,
  Vi = 0.3,
  Vf = -0.3,
  Vs = 0.001,
  ko = 0.01,
  alpha = 0.5,
  Temp = 298.15,
  n = 1,
  Area = 1,
  l = 100,
  DerApprox = 2,
  errCheck = FALSE,
  Method = "Euler"
)

Arguments

Co

bulk concentration expressed in Molar

Dx

diffusion coefficient expressed in cm^2/s

Eo

reduction potential of the species expressed in Volt

Dm

simulation parameter, maximum 0.5 for explicit methods

Vi

initial potential of the sweep expressed in Volt

Vf

final potential of the sweep expressed in Volt

Vs

potential scan rate of the simulation expressed in V/s

ko

heterogeneous electron transfer rate constant expressed in m/s

alpha

charge transfer coefficient

Temp

temperature in kelvin

n

number of electrons involved in the process

Area

area of the electrode expressed in cm^2

l

number of time steps of the simulation

DerApprox

number of point for the approximation of the first derivative

errCheck

if true the function returns a list with parameters for CottrCheck function

Method

method to be used for the simulation = "Euler" "BI" "RK4" "CN" "BDF"

Value

if errCheck == F a graph I vs E, if errCheck == T a list

Examples

LinSwp(Co = 0.001, Dm =0.45, DerApprox = 2, errCheck = FALSE, Method = "Euler")

Starting Matrix of oxidazed species

Description

Return a matrix ixj filled with 1 value

Usage

OneMat(i, j = i)

Arguments

i

number of rows

j

number of columns

Value

a matrix of dimention ixj filled with 1 value

Examples

OneMat(2,2)

Parameters call

Description

Returns a list with the parameters necessary for the simulation

Usage

ParCall(
  Fun,
  n.,
  Temp.,
  Dx1.,
  eta.,
  exptime.,
  Eo1.,
  ko1.,
  ko2.,
  kc.,
  Dm.,
  Vf.,
  Vi.,
  Vs.,
  alpha1.,
  Eo2.,
  Dred1.,
  Dred2.,
  alpha2.,
  Dred3.,
  Dred4.,
  ko3.,
  ko4.,
  kco.,
  kc1.,
  kc2.,
  kc3.,
  kc4.,
  alpha3.,
  alpha4.,
  Eo3.,
  Eo4.,
  l.
)

Arguments

Fun

Name of the function this function is called to. Must be a string.

n.

Number of electrons

Temp.

Temperature for the simulation

Dx1.

Diffusion coefficient of species One

eta.

OverPotential for potential step

exptime.

experimental time for the simulation

Eo1.

reduction potential of the first electrochemical reaction

ko1.

heterogeneous electron transfer rate constant of the first electrochemical reaction

ko2.

heterogeneous electron transfer rate constant of the second electrochemical reaction

kc.

Chemical rate constant for first Ox Species, used in simulation with just one species

Dm.

Simulation parameter, maximum 0.5 for explicit methods

Vf.

Final potential of the sweep

Vi.

Initial potential of the sweep

Vs.

Scan rate of the simulation

alpha1.

charge transfer coefficient of the first electrochemical reaction

Eo2.

reduction potential of the second electrochemical reaction

Dred1.

diffusion coefficient of the first reduced species

Dred2.

diffusion coefficient of the second reduced species

alpha2.

charge transfer coefficient of the second electrochemical reaction

Dred3.

diffusion coefficient of the third reduced species

Dred4.

diffusion coefficient of the fourth reduced species

ko3.

heterogeneous electron transfer rate constant of the third electrochemical reaction

ko4.

heterogeneous electron transfer rate constant of the fourth electrochemical reaction

kco.

Chemical rate constant for first Ox Species

kc1.

Chemical rate constant for first Red Species

kc2.

Chemical rate constant for second Red Species

kc3.

Chemical rate constant for third Red Species

kc4.

Chemical rate constant for fourth Red Species

alpha3.

charge transfer coefficient of the third electrochemical reaction

alpha4.

charge transfer coefficient of the fourth electrochemical reaction

Eo3.

reduction potential of the third electrochemical reaction

Eo4.

reduction potential of the fourth electrochemical reaction

l.

numer of time steps

Value

inverse matrix of the selected

Examples

ParCall("ChronAmp", n. = 1, Temp. = 298, Dx1. = 0.0001, exptime. = 1, Dm. = 0.45, l. = 100)

Chrono amperometry with a finite step digital simulation

Description

Return a graph I vs t of the electrochemical process

Usage

PotStep(
  Co = 0.001,
  exptime = 1,
  Dx = 1e-05,
  Dm = 0.45,
  eta = 0,
  Temp = 298.15,
  n = 1,
  Area = 1,
  l = 100,
  DerApprox = 2,
  errCheck = FALSE,
  Method = "Euler"
)

Arguments

Co

bulk concentration expressed in Molar

exptime

experimental time to be simulated expressed in seconds

Dx

diffusion coefficient expressed in cm^2/s

Dm

simulation parameter, maximum 0.5 for explicit methods

eta

overpotential of the step expressed in Volt

Temp

temperature in kelvin

n

number of electrons involved in the process

Area

area of the electrode expressed in cm^2

l

number of time steps of the simulation

DerApprox

number of point for the approximation of the first derivative

errCheck

if true the function returns a list with parameters for CottrCheck function

Method

method to be used for the simulation = "Euler" "BI" "RK4" "CN" "BDF"

Value

if errCheck == F a graph I vs t, if errCheck == T a list

Examples

PotStep(Co = 0.001, exptime = 1, Dm =0.45, DerApprox = 2, errCheck = FALSE, Method = "Euler")

Starting Matrix of reduces species and fluxes

Description

Return a matrix ixj filled with 0 value

Usage

ZeroMat(i, j = i)

Arguments

i

number of rows

j

number of columns

Value

a matrix of dimention ixj filled with 1 value

Examples

ZeroMat(2,2)