% Authors: <NAME>
% License: Creative Commons Attribution 4.0 International
% License link: creativecommons.org/licenses/by/4.0/legalcode
% Contact: <EMAIL>
%
\documentclass[12pt]{article}

\usepackage{amsmath}
\usepackage{verbatim}
\usepackage{mathtools}
\setlength{\parindent}{0pt}
\setlength{\parskip}{2ex plus 0.5ex minus 0.2ex}

\begin{document}

\begin{comment}

  \begin{equation}
    R\left(x\right) = \frac{\Sigma_a}{2}\left(\int_0^x S\left(x_k\right) e^{-\Sigma_a\left(x-x_k\right)} dx_k + \int_x^L S\left(x_k\right) e^{-\Sigma_a\left(x_k-x\right)} dx_k\right)
    \label{eq:photo}
  \end{equation}

  \begin{equation}
    R\left(x\right) = \frac{\Sigma_a}{2}\left(\int_0^L S\left(x_k\right) e^{-\Sigma_a\lvert x-x_k\rvert} dx_k\right)
    \label{eq:simplifiedPhoto}
  \end{equation}

  \begin{equation}
    S\left(x\right) = \alpha\ n_e\left(x\right) \lvert W_e\left(x\right)\rvert\ exp\left(\frac{-E_c}{\lvert E\left(x\right)\rvert}\right)
    \label{eq:source}
  \end{equation}

  \begin{equation}
    \frac{\partial}{\partial u_j}\left(\frac{\left(\vec{a}\cdot\nabla u\right)^2}{\nabla u\cdot\nabla u}\left(\vec{c}\cdot\nabla u\right)\right) = \frac{\partial}{\partial u}\left(\frac{\left(\vec{a}\cdot\nabla u\right)^2}{\nabla u\cdot\nabla u}\left(\vec{c}\cdot\nabla u\right)\right)\phi_j
    \label{eq:Jacobians}
  \end{equation}

  \begin{equation}
    \frac{\partial}{\partial u}\nabla u = \nabla
    \label{eq:simple}
  \end{equation}

  \begin{equation}
    \frac{\partial}{\partial t}n_e+\nabla\cdot\Gamma_e=R_e
  \end{equation}

  \begin{equation}
    \frac{\partial}{\partial t}n_i+\nabla\cdot\Gamma_i=R_i
  \end{equation}

  \begin{equation}
    \frac{\partial}{\partial t}n_{\epsilon}+\nabla\cdot\Gamma_{\epsilon}+\vec{E}\cdot\Gamma_e=R_{\epsilon}
  \end{equation}

  \begin{equation}
    -\nabla\cdot\nabla V = \frac{e}{\epsilon_0}(n_i-n_e)
  \end{equation}

  \begin{align}
    \Gamma_e &= -n_e(\mu_e\cdot\vec{E}-D_e\cdot\nabla n_e) \\
    \Gamma_{\epsilon} &= -n_{\epsilon}(\mu_{\epsilon}\cdot\vec{E}-D_{\epsilon}\cdot\nabla n_{\epsilon}) \\
    n_{\epsilon} &= \frac{3}{2}n_eT_e \\
    \vec{E} &= -\nabla V \\
  \end{align}

  Example of a reaction in R$_{e,i,\epsilon}$:

  \begin{align}
    R_1 &= k_1n_en_{i} \\
    k_1 &= c_1T_e^{0.5}exp(-E_a/T_e)
  \end{align}

DGFunctionDiffusionDirichletBC

\begin{equation}
  { \nabla u \cdot n_e} [v] + \epsilon { \nabla v \cdot n_e } [u] + (\frac{\sigma}{|e|} \cdot [u][v])
\end{equation}

DGDiffusion

\begin{equation*}
\begin{multlined}
{\nabla u * n_e} [v] + \epsilon { \nabla v * n_e } [u] + (\sigma / |e| * [u][v]) \\
[a] = [ a_1 - a_2 ] \\
{a} = 0.5 * (a_1 + a_2)
\end{multlined}
\end{equation*}

\begin{gather*}
\int \vec{\Gamma}\cdot\vec{n}\,ds\\
\int \vec{\Gamma}\cdot\vec{n}\,2\pi r\,ds
\end{gather*}
\end{comment}

Hi all, I'm looking for suggestions. I'm running a 2D simulation with two variables: electrical potential (V) and some positively charged ions (u). At my cathode boundary, I have the following condition for the potential:

\begin{equation}
0 = V_{src} - V + R \int_{x_1}^{x_2}\left(u\nabla V\cdot\vec{n} - \nabla u\cdot\vec{n}\right)dx
\end{equation}

where $V_{src}$ is a constant potential generated by a battery in an external circuit and  R is a resistance in the external circuit. Does anyone have a suggestion for the best way to impose this condition that will maximize the efficiency of my solution? At heart it's a dirichlet condition on the potential, but it includes a non-local flux integral containing both of my dependent variables, u \& V. Currently I'm using a postprocessor to calculate the integrated flux on either timestep\_begin or timestep\_end and then feeding it to a Dirichlet condition on the potential. This method converges with PJFNK but not with NEWTON, presumably because I don't have a Jacobian for my condition. I would like to be able to use NEWTON if I can (I've been very meticulous about forming Jacobians for all my other kernels and boundary conditions). I was thinking about using something like a PenaltyDirichletBC and then my Jacobian elements might look something like:

\begin{equation}
\frac{\partial R_{v,i}}{\partial u_j} = R \int_{x_1}^{x_2}\left(\phi_j\nabla V\cdot\vec{n} -\nabla\phi_j\cdot\vec{n}\right)dx
\end{equation}

where obviously $\phi_j$ would only be non-zero over two adjacent boundary
elements, but I am not quite sure how I would implement this, e.g. selectively
integrate with respect to a certain shape function. Postprocessors I believe
don't have access to $\phi$. So does anyone have any good ideas or have I just
vomited up a bunch of craziness?

\textbf{Graves, Moisan $H_{\phi}$ equation}

\begin{equation}
  \frac{\partial}{\partial r}\left( \epsilon_r^{-1}
  \frac{1}{r}\frac{rH_{\phi}}{\partial r}\right) + \frac{\partial}{\partial
    z}\left(\epsilon_z^{-1} \frac{\partial H_{\phi}}{\partial z}\right) +
  k_0H_{\phi} = 0
\end{equation}


\end{document}
