Implement 2D Burgers Equation on FiPy

112 views Asked by At

It is stated here that FiPy was not good at handling Hyperbolic PDE's. However this forum was written in 2016 so maybe things have changed a bit.

I would like to implement the 2D Burgers Equation:

$$

u_t + (u \partial_x + v \partial_y) u = -\nu * \nabla^{2} u \

v_t + (u \partial_x + v \partial_y) v = -\nu * \nabla^{2} v

$$

where $u$ and $v$ are the x and y components of that fluid flow $ U = (u, v) $.

To make my life a bit easier, I employed the chain rule to rewrite the equations as

$$

u_t + \nabla \cdot (U u) = (\nabla \cdot U) u - \nu * \nabla^{2} u \

v_t + \nabla \cdot (U v) = (\nabla \cdot U) v - \nu * \nabla^{2} v

$$

What this translates to in FiPy would be something like this:

u = CellVariable(name='u', mesh=m)
v = CellVariable(name='v', mesh=m)
U = CellVariable(name='U', mesh=m, value=(u, v))

eqn1 = TransientTerm(var=u) + ConvectionTerm(coeff=U, var=u) == DiffusionTerm(coeff=-nu, var=u) + # Not Sure what
eqn2 = TransientTerm(var=v) + ConvectionTerm(coeff=U, var=v) == DiffusionTerm(coeff=-nu, var=v) + # Not Sure what

burgersEq2D = eqn1 & eqn2

My question is: How do I finish implementing eqn1 and eqn2?

1

There are 1 answers

0
jeguyer On BEST ANSWER

I would write

u = fp.CellVariable(mesh=mesh, name="u")
v = fp.CellVariable(mesh=mesh, name="v")
U = u.faceValue * [[1],[0]] + v.faceValue * [[0], [1]]
U.name = "U"

burgersEq2D = eqn1 & eqn2

eqn1 = (TransientTerm(var=u) + ConvectionTerm(coeff=U, var=u)
        == ImplicitSourceTerm(coeff=U.divergence, var=u)
        + DiffusionTerm(coeff=nu, var=u))
eqn2 = (TransientTerm(var=v) + ConvectionTerm(coeff=U, var=v)
        == ImplicitSourceTerm(coeff=U.divergence, var=v)
        + DiffusionTerm(coeff=nu, var=v))

burgersEq2D = eqn1 & eqn2

Writing

U = CellVariable(name='U', mesh=m, value=(u, v))

will leave U with the value of the initial condition and will not update as the problem evolves, whereas the expression I wrote will update as necessary.

Also, I believe you have a sign error in the diffusion term. A negative diffusion coefficient on the right-hand side is destabilizing and is also not consistent with the statements of Burgers' equation I've seen.