I’ve had some trouble using fipy for the 1D, steady-state ternary electrolyte 
problem, which involves coupled, nonlinear migration and diffusion.

A text version of the model is listed below.  A more complete development is at 
http://bit.ly/2wJDXob

from fipy import *

# Parameters
nx=50
C20=4.0/3.0
z1, z2, z3= 2.0, -2.0, 1.0

# Mesh
mesh = Grid1D(nx=nx, dx=1.0/nx)

# Variables
C1= CellVariable(mesh = mesh, value = 1.0)
C2= CellVariable(mesh = mesh, value = 4.0/3.0)
Phi = CellVariable(mesh = mesh, value = -0.5)

# Electroneutrality
C3 = -1/z3 * (z1*C1 + z2*C2)

# Boundary Conditions
C1.constrain(1.0, mesh.facesRight)
C1.constrain(0.0, mesh.facesLeft)
C2.constrain(C20, mesh.facesRight)
Phi.constrain(0, mesh.facesRight)

# Governing Equations
Eq1 = DiffusionTerm(coeff=z1*C1, var=Phi) + DiffusionTerm(coeff=1.0, var=C1)
Eq2 = DiffusionTerm(coeff=z2*C1, var=Phi) + DiffusionTerm(coeff=1.0, var=C2)
Eq3 = DiffusionTerm(coeff=z3*C3, var=Phi) + (C3.faceGrad).divergence 

Eqns = Eq1 & Eq2 & Eq3

# Solution
res = 1e+10
restol= 1e-3

while res > restol:
    res = Eqns.sweep()
    print(res)


However, this system does not converge. I suspect the issue is with boundary 
conditions. I’ve tried zeroing out the diffusion coefficients at the boundary, 
but that does not seem to make a difference here. I am able to use this 
approach for the analogous binary problem: http://bit.ly/2wOzxfK

Any insights or suggestions would be welcome.

Cheers,
Scott☘


_______________________________________________
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to