Kevin - You are correct that there's no way to project a FaceVariable back to a CellVariable. Since this is only for the initial condition, I would just explicitly set it, e.g.,

phi.value = (1 + x) / (gamma * psi.grad[0]) As for the boundary condition, I think FiPy's default no-flux boundary condition will give you this naturally. Constraining the divergence of the gradient will not ever be seen by the solver. - Jon > On Feb 5, 2018, at 4:13 PM, Kevin Blondino <kablond...@gmail.com> wrote: > > Hi, > > I have two questions. > > I have a complicated set of 1D equations. The diffusion coefficient of the > 1st is dependent on the derivative of the 2nd's variable, and the 2nd has a > source term of the first. In addition, the initial condition of one of the > variables is dependent on this diffusion coefficient. This is what I mean, in > TeX: > > \alpha \frac{\partial \phi}{\partial t} = \frac{\partial}{\partial x} > \left(D \frac{\partial \phi}{\partial x}\right) \\ > \beta \frac{\partial \psi}{\partial t} = m \frac{\partial^2 > \psi}{\partial x^2} + \delta\phi \\ > D = \gamma \left(\frac{\partial \psi}{\partial x}\right)^{-1} \\ > \phi_0 = \frac{1 + x}{D} > > alpha, beta, gamma, delta, and m are constants, and phi and psi are the Cell > Variables. How can properly write and implement the diffusion coefficient D? > > So far, I've been trying to implement it by declaring D as a CellVariable, > but as it's a diffusion function, it would seem natural to have it as a > FaceVariable. The problem arises when I try to use it for the initial > condition, as I cannot make phi_0 a function of D as a face variable. > > > In addition, one of the boundary conditions is this (at x=0): > > \frac{\partial \psi^2}{\partial x^2} = 0 > > I've been implementing it as the following, but I am not sure if it works > properly: > > psi.faceGrad.divergence.constrain(0.0, mesh.facesLeft) > > Thank you > > _______________________________________________ > fipy mailing list > fipy@nist.gov > http://www.ctcms.nist.gov/fipy > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] _______________________________________________ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]