It is certainly not true that "`DiffusionTerm` can only take a constant".
Please see http://www.ctcms.nist.gov/fipy/examples/diffusion/generated/examples.diffusion.mesh1D.html for a general example of a spatially varying diffusion coefficient, and http://www.ctcms.nist.gov/fipy/examples/diffusion/generated/examples.diffusion.electrostatics.html for the setup of the Poisson part of the Poisson-Boltzmann equation. On Apr 10, 2014, at 10:45 AM, travis <[email protected]> wrote: > I've asked this question on Stack Overflow, > http://stackoverflow.com/questions/22971859/space-dependent-diffusion-in-fipy, > but for completeness I'll repost it here. The SO question has pictures and > inline links, but they aren't needed. > > I'm using fipy to model the linearized [Poisson-Boltzmann equation][1]. > > Del . epsilon(x) Del phi(x) = phi(x) + f(x) > > I'll assume I can model f(x) as a boundary condition. If epsilon(x) is a > constant, fipy can handle this: > > phi = CellVariable(mesh) > > dielectric_solvent = 80.0 > dielectric_inner = 4.0 > > LHS = (DiffusionTerm(coeff = dielectric_solvent)) > RHS = phi > eq = LHS == RHS > > dr = np.linalg.norm(mesh.faceCenters, axis=0) > mask = (dr<.5) * mesh.exteriorFaces > phi.constrain(1, mask) > > mask = (dr>.5) * mesh.exteriorFaces > phi.constrain(0, mask) > > sol = eq.solve(var=phi) > > The [complete minimal example is posted as a gist][4], to keep things short > this is the relevant portion. What I'd like to do is let `epsilon(x)` vary as > a function in _space_, but `DiffusionTerm` can only take a constant. How can > I implement the spatially varying dielectric term? > > [1]: http://en.wikipedia.org/wiki/Poisson%E2%80%93Boltzmann_equation > [2]: http://i.stack.imgur.com/R0V5m.gif > [3]: http://i.stack.imgur.com/44D4U.png > [4]: https://gist.github.com/thoppe/10304061 > _______________________________________________ > fipy mailing list > [email protected] > http://www.ctcms.nist.gov/fipy > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] _______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
