Skip to content

How can I define a convection term that includes an independent variable? #956

Answered by guyer
LiuDongDong1989 asked this question in Q&A
Discussion options

You must be logged in to vote
  • If self.g is a float, then self.g * [[1]] is attempting to multiply a float by a list. Python doesn't know how to do that. The reason that self.u * [[1]] works is because self.u is a FiPy CellVariable. A CellVariable "knows" that when it's multiplied with a list, that it should try to interpret that list as a vector. You could get the same behavior with self.g if you wrote
    self.g = fp.Variable(9.8)
    ConvectionTerm(coeff=self.g * [[1]], var=h)
    
  • (self.g * self.h.arithmeticFaceValue).divergence represents $\nabla\cdot(g h)$ (or $\partial(g h)/\partial x$ in 1D). While, when and only when $g$ is constant, this is mathematically equivalent to $g (\partial h/\partial x)$, the expression (self…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@LiuDongDong1989
Comment options

@guyer
Comment options

Answer selected by LiuDongDong1989
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants