I'm using fipy to model the linearized Poisson-Boltzmann equation, which is essentially
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)
giving:
The complete minimal example is posted as a gist, 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?