Hi,

I'm trying to implement outflow boundary condition in a very simple 
convection-diffusion problem in a channel (described by me below in previous 
post).
I'm using an ImplicitSourceTerm as described by Benny below. Seems to work, but 
my implementation is a little different ... and I don't understand why this 
would work in the first place ... not even sure I'm doing the right things 
here.  Perhaps someone can enlighten me as to what's going on.

convection-diffusion problem

I have a pipe containing fluid with dissolved protein of concentration phi. I 
have uniform (incompressible) flow and constant diffusion.
I would like to make one end of the pipe "open" so that protein does *not* 
accumulate at the end, but simply flows out and vanishes.

- Richard

There are several ways to do this.
...
Then there is the official way in fipy: set a constraint on faceGrad = 0 on the 
outflow edge, and set velocity  0 on the same edge. Use an explicitSourceTerm 
to mimic correct outflow. So the facegrad constrain avoids flow due to normal 
fluxes, the sourceterm removes the correct amount of material based on velocity.
With the shutdown of USA I don't find the example on the website, but I used 
that here: 
https://gitorious.org/microchanit/microchanit/source/c2c43969b2c7ceee783f84cfa4b977eeb648fbf4:src/stratflowbeam.py


  *       phi.faceGrad.constrain(0, (zfc > Lval - smallall))
  *

  *       vvel.setValue([[0],[0],[0]], where=outletCells)

  *       exteriorCoeff = FaceVariable(mesh, value=vvel.arithmeticFaceValue, 
rank=1)
  *       exteriorCoeff.setValue([[0],[0],[0]], where=~outletFaces)

  *       diffeq = ConvectionTerm(coeff=vvel) \
  *                - DiffusionTerm(mesh, diffcoeff1) \
  *                + ImplicitSourceTerm(exteriorCoeff.getDivergence())

 Benny


Benny: I'm confused by the extra step of going from CellVariable (vvel) to 
FaceVariable  (exteriorCoeff) in your example. Is it simply that your code uses 
CellVariables for the vvel and ImplicitSourceTerm requires a FaceVariable? I 
thought ImplicitSourceTerms were supposed to need CellVariables.

My fluid velocity field starts out as FaceVariable. Here's the code I have 
running:

---- begin example ---

phi = CellVariable(name = "concentration",
                   mesh = mesh,
                   value = 0.)

# set up the fixed fluid velocity field:

x = mesh.faceCenters[0]
y = mesh.faceCenters[1]

vel = FaceVariable(name = "velocity field",
                   mesh = mesh,
                   rank = 1,
                   value = V(umem,w,xshift,x,y))

#set initial concentration in channel
phi.setValue(initConc)

# specify entry concentration

X, Y = mesh.faceCenters
EntryFaces = mesh.facesRight
ExitFaces  = mesh.facesLeft

phi.constrain(entryConc,EntryFaces)

# create an "open" exit

# These terms didn't work for me:
#phi.faceGrad.constrain([0],ExitFaces)    # no diffusion out exit
#vel.setValue([[0],[0]], where=ExitFaces) # no convection out exit

exteriorCoeff = FaceVariable(mesh, value=vel, rank=1)
exteriorCoeff.setValue([[0],[0]], where=~ExitFaces)

eq = TransientTerm() == 
(DiffusionTerm(coeff=D)+VanLeerConvectionTerm(coeff=vel))+ImplicitSourceTerm(exteriorCoeff.divergence())

------ end of example ----
This example seems to do the right thing ... as near as I can tell.

Now, why should this work at all? My fluid is incompressible so that 
vel.divergence = 0. What does setting exteriorCoeff.setValue to zero on the 
ExitFaces do to the divergence?

Richard


_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to