# Model electrodiffusion using Wolfram Language?

GROUPS:

I am an undergraduate researcher. I have been working with Mathematica for roughly a month. I have been assigned a modeling task. My objective is to model the diffusion of ions in solution under the effect of an electric field and ignoring concentration gradient.

## Part 1: Equations

The model is to be one dimensional for the time being. In the future it will be translated to 2D and ultimately 3D.

The equation used is as follows:

∂C/∂t=∂/∂x(D ∂C/∂x-zμC ∂Φ/∂x)

Where:

C : Concentration of ions

D: Diffusion coefficient

z: Charge per molecule

μ: Ion mobillity

Φ: Electric potential

C is a function of time and space. “t” and “x”.

Φ is a function of space. “x”.

All remaining terms are assumed constant. (D,z, μ)

The model I am making ignores diffusion caused by concentration gradient (The highlighted term).

∂C/∂t=∂/∂x(D ∂C/∂x-zμC ∂Φ/∂x)

D ∂C/∂x=0

z = -1

μ = 1

This leaves us with:

∂C/∂t=∂/∂x(C ∂Φ/∂x)

Finally, performing the product rule gives the final equation.

∂C/∂t=C (∂^2 Φ)/(∂x^2 )+∂C/∂x ∂Φ/∂x

## Part 2: Wolfram

Mathematica’s DSolve function presents a general solution. But despite multiple attempts and combinations of boundary and initial conditions of both the concentration and potential, I can’t get DSolve to present a particular solution. The code is as follows:

enter code h1D Electrodiffusion
The purpose of this program is to model the diffusion of ions under the influence of an electric field ONLY.
The first attempts will use "DSolve"
Later attempts will use "NDSolve" if no prior attempt is successful

The following cell works to describe the partial differential equation to be solved
edeqn = D[u[t, x], t] ==
u[t, x]*D[\[CapitalPhi][x], {x, 2}] +
D[u[t, x], x]*D[\[CapitalPhi][x], x]

The following cell attempts to discern a solution to the differential equation
sol = DSolve[edeqn, u, {t, x}]
Simplify[edeqn /. sol]


This returns the general solution. I have provided a few sample of my attempts to attain a particular solution below.

The following cell shows the effect of adding an initial condition and a boundary condition for the left AND right sides of the channel.

bc = {u[t, 0] == 10, u[t, 2] == 0}
ic = u[0, x] == 8
sol = DSolve[{edeqn, bc, ic}, u, {t, x}]

The following cell attempts to discern a solution to the differential equation.
The solver has been told to solve for "u" and "\[CapitalPhi]".
Both "u" and "\[CapitalPhi]" are given as functions of "t" and "x".

edeqn = D[u[t, x], t] ==
u[t, x]*D[\[CapitalPhi][t, x], {x, 2}] +
D[u[t, x], x]*D[\[CapitalPhi][t, x], x]
sol = DSolve[edeqn, {u, \[CapitalPhi]}, {t, x}]

Boundary condition. "u". Left side.
Boundary condition. "u". Right side.
Initial condition. "u".
Boundary condition "\[CapitalPhi]". Left side.
Boundary condition "\[CapitalPhi]". Right side.
Initial condition. "\[CapitalPhi]".

bc = {u[t, 0] == 10,
u[t, 2] == 0, \[CapitalPhi][t, 0] == 5, \[CapitalPhi][t, 2] == 0}
ic = {u[0, x] == 8, \[CapitalPhi][0, x] == 0}
edeqn = D[u[t, x], t] ==
u[t, x]*D[\[CapitalPhi][t, x], {x, 2}] +
D[u[t, x], x]*D[\[CapitalPhi][t, x], x]
sol = DSolve[{edeqn, bc, ic}, {u, \[CapitalPhi]}, {t, x}]


I apologize for the length of the post. I've never used a forum before.

I do hope you all will consider my dilemma, and are willing and able to provide a solution. I have attached the full code of my attempts. Thank you for your time.

Attachments: