title: Space dependent diffusion in fipy
body: <p>I'm using fipy to model the linearized <a href="http://en.wikipedia.org/wiki/Poisson%E2%80%93Boltzmann_equation" rel="noreferrer">Poisson-Boltzmann equation</a>, which is essentially</p>
  
  <p><img src="https://i.stack.imgur.com/R0V5m.gif" alt="enter image description here"></p>
  
  <p>I'll assume I can model <code>f(x)</code> as a boundary condition. If <code>epsilon(x)</code> is a constant, fipy can handle this:</p>
  
  <pre><code>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&lt;.5) * mesh.exteriorFaces
  phi.constrain(1, mask)
  
  mask = (dr&gt;.5) * mesh.exteriorFaces
  phi.constrain(0, mask)   
  
  sol = eq.solve(var=phi)
  </code></pre>
  
  <p>giving:</p>
  
  <p><img src="https://i.stack.imgur.com/44D4U.png" alt="enter image description here"></p>
  
  <p>The <a href="https://gist.github.com/thoppe/10304061" rel="noreferrer">complete minimal example is posted as a gist</a>, to keep things short this is the relevant portion.</p>
  
  <p>What I'd like to do is let <code>epsilon(x)</code> vary as a function in <em>space</em>, but <code>DiffusionTerm</code> can only take a constant. How can I implement the spatially varying dielectric term?</p>