0

Clearly an 1D Poisson equation with a constant source has an unique solution even if both Dirichlet and Newmann boundary conditions are on the same side. However I can't think of a way to solve this in FiPy. Please advise. I tried:

from fipy import CellVariable, Grid1D, DiffusionTerm
import matplotlib.pyplot as plt


L = 1.
nx = 20
dx = L/nx
mesh = Grid1D(nx=nx, dx=dx)


D = 1.
valueLeft = 1.
gradValue = 0.
source = 1.


var = CellVariable(mesh=mesh)
var.constrain(valueLeft, where=mesh.facesLeft)
var.faceGrad.constrain(gradValue, where=mesh.facesLeft)


eq = 0.0 == DiffusionTerm(coeff=D) + source
eq.solve(var=var)


plt.plot(var.value);

This is not setting gradValue at facesLeft. However, it can set the needed gradValue at facesRight.

DKS
  • 188
  • 10
  • This might be of help: https://www.ctcms.nist.gov/fipy/examples/diffusion/generated/examples.diffusion.electrostatics.html – Hackinet Dec 04 '21 at 06:35
  • 1
    What have you tried? I ask this because, as I'm guessing you know, questions without either code or research are magnets for downvotes or closure. – hrokr Dec 05 '21 at 02:50

1 Answers1

1

Having both a Dirichlet and a Neumann on the same face in FV turns the nature of the problem from a boundary value problem into an initial value problem. In that sense the problem becomes over-specified as the right hand side boundary condition is still required. There may be ways to handle it with FD/FV with some hacks. However, FiPy certainly isn't set up to handle this type of problem.

wd15
  • 1,068
  • 5
  • 8