Space dependent diffusion in phipi

I use fipy to model the linearized Poisson-Boltzmann equation , which is essentially

enter image description here

I suppose 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:

enter image description here

the complete minimal example is published as an entity so that everything is in order, this is the corresponding part.

What I would like to do, let it epsilon(x)change as a function in space, but DiffusionTermcan only accept a constant. How can I realize a spatially changing dielectric term?

+4
source share
1 answer

FiPy . , :

diffusion_coefficient = dielectric_solvent * ((mesh.x > -0.5) & (mesh.x < 0.5))

LHS = (DiffusionTerm(coeff = diffusion_coefficient))

, , mesh.x mesh.y.

, ,

eq = TransientTerm() == DiffusionTerm(diffusion_coefficient) - ImplicitSourceTerm(phi)

  • phi

  • TransientTerm ,

. .

+3

Source: https://habr.com/ru/post/1535805/


All Articles