|
|
|
@ -17,11 +17,22 @@
|
|
|
|
|
##################################################
|
|
|
|
|
################### It2charge ####################
|
|
|
|
|
##################################################
|
|
|
|
|
It2charge <- function (current, time) {
|
|
|
|
|
## Calculates charge etc. for amperometric data
|
|
|
|
|
## current may be a current or a current density
|
|
|
|
|
## (up to the calling function to keep track of which it is)
|
|
|
|
|
# Calculate the difference of the time vector
|
|
|
|
|
It2charge <- function (time, current) {
|
|
|
|
|
## Description:
|
|
|
|
|
## Calculates cumulative charge, differentials, etc. from
|
|
|
|
|
## amperometric data (current and time).
|
|
|
|
|
## __Intended to be used from within other functions (CHI.R)__
|
|
|
|
|
## Usage:
|
|
|
|
|
## It2charge(time, current)
|
|
|
|
|
## Arguments:
|
|
|
|
|
## time: a vector with time data.
|
|
|
|
|
## current: a vector of the same length as time, with current data.
|
|
|
|
|
## May be either currents or current densities, no matter.
|
|
|
|
|
## Value:
|
|
|
|
|
## Returns a dataframe with columns:
|
|
|
|
|
## timediff, dIdt, charge, sumcharge
|
|
|
|
|
#
|
|
|
|
|
# Calculate the time vector difference
|
|
|
|
|
timediff <- c(time[1], diff(time))
|
|
|
|
|
# timediff times the current gives the charge,
|
|
|
|
|
# since the time vector can be considered as
|
|
|
|
@ -29,11 +40,11 @@ It2charge <- function (current, time) {
|
|
|
|
|
# the current with the time elapsed since the last
|
|
|
|
|
# current measurement (the timediff).
|
|
|
|
|
charge <- current * timediff
|
|
|
|
|
differential <- cumsum(charge) / time
|
|
|
|
|
# Prepare the return dataframe
|
|
|
|
|
ff <- data.frame(time = time, timediff = timediff,
|
|
|
|
|
current = current, charge = charge,
|
|
|
|
|
sumcharge = cumsum(charge), dQdt = differential)
|
|
|
|
|
dIdt <- current / time
|
|
|
|
|
# Return value
|
|
|
|
|
ff <- data.frame(timediff = timediff,
|
|
|
|
|
dIdt = dIdt, charge = charge,
|
|
|
|
|
sumcharge = cumsum(charge))
|
|
|
|
|
return(ff)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|