library(tidyverse)
library(cowplot)
library(broom) 
library(modelr) 
library(viridis)
library(lubridate)
library(hms)
library(knitr)
library(kableExtra)
library(patchwork)
library(VGAM)
library(nls.multstart)


knitr::opts_chunk$set(tidy.opts=list(width.cutoff=60),tidy=TRUE, echo = TRUE, message=FALSE, warning=FALSE, fig.align="center")

source("../tools/echem_processing_tools.R")
source("../tools/plotting_tools.R")

theme_set(theme_1())

Math - finite diffusion with SWV data

So from the 03/04/19 notebook we have an expression for the concentration at \(x = 0\) over time for a system with finite boundaries at \(x = 0\) and \(x = L\):

\[ C(x=0,t) = \frac{M}{\sqrt{4 \pi D t}} \sum_{n = -\infty}^{\infty} \left[ 2 \exp{ \left( \frac{-(-2nL)^2}{4 D t} \right) } \right] \]

We’re going to adapt this slightly by normalizing by the cross sectional area to get an actual concentration in mol / cm^3 , and let’s go ahead and label M0 and Dm.

\[ C(t) = \frac{M_0}{A \sqrt{4 \pi D_m t}} \sum_{n = -\infty}^{\infty} \left[ 2 \exp{ \left( \frac{-(-2nL)^2}{4 D_m t} \right) } \right] \]

Recall that SWV current can be defined.

\[ I_{swv} = \frac{n F A \sqrt{D_{ap}} C}{\sqrt{\pi t_p}} \psi \] and so \(C\) can be defined in terms of SWV parameters/data:

\[C = \frac{I_{swv} \sqrt{\pi t_p} }{n F A \sqrt{D_{ap}} \psi}\]

And so can \(M_0\):

\[C = \frac{M_0}{V} = \frac{I_0 \sqrt{\pi t_p} }{n F A \sqrt{D_{ap}} \psi}\]

\[ M_0 = \frac{I_0 V \sqrt{\pi t_p} }{n F A \sqrt{D_{ap}} \psi}\]

Now we can substitute \(C\) and \(M_0\) with the equivalent SWV expressions:

\[ \frac{I_{swv} \sqrt{\pi t_p} }{n F A \sqrt{D_{ap}} \psi} = \frac{\frac{I_0 V \sqrt{\pi t_p} }{n F A \sqrt{D_{ap}} \psi}}{A \sqrt{4 \pi D_m t}} \sum_{n = -\infty}^{\infty} \left[ 2 \exp{ \left( \frac{-(-2nL)^2}{4 D_m t} \right) } \right] \]

\[ I_{swv}(t) = \frac{I_0 V}{A \sqrt{4 \pi D_m t}} \sum_{n = -\infty}^{\infty} \left[ 2 \exp{ \left( \frac{-(-2nL)^2}{4 D_m t} \right) } \right] \]

Recall that \(\frac{V}{A} = z\), which is the diffusion layer at the electrode.

\[ z = \sqrt{D_{ap} t_s}\]

So our expression is:

\[ I_{swv}(t) = \frac{I_0 \sqrt{D_{ap} t_s}}{ \sqrt{4 \pi D_m t}} \sum_{n = -\infty}^{\infty} \left[ 2 \exp{ \left( \frac{-(-2nL)^2}{4 D_m t} \right) } \right] \]

So we will need to provide our function to calculate \(I_{swv}(t)\) with \(D_{ap}\), \(t_s\), and \(I_0\). We will be fitting for unknowns \(D_m\) and \(L\).

Fit some data

as;dlfjk