Derivative term in only one direction

Hi everyone, thanks for reading!

I reduced the 2D Navier Stokes with energy to a problem that looks like this:

u_x + v_y = 0
p_x = \frac{1}{Re} u_{yy}
p_y = -Ri \ T
\mathbf{u} \cdot \nabla T = \frac{1}{Pr} T_{yy}

where Re, Ri, Pr are constants and \mathbf{u} = (u, w) and p, T are velocity, pressure and temperature, all functions of x and y. I’m not sure how to deal with these derivatives that appear in just one direction.

I tried to formulate it like this:

mesh = UnitSquareMesh(N, N)

P1 = FiniteElement('P', mesh.ufl_cell(), 1)
P2 = VectorElement('P', mesh.ufl_cell(), 2)
mixed_element = MixedElement([P1, P2, P1])
W = FunctionSpace(mesh, mixed_element)
psi_p, psi_u, psi_T = TestFunctions(W)
w = Function(W)
p, u, T = split(w)

# Here I define constants like Re = Constant(1000) etc...

mass = -psi_p*div(u)
momentum = dot(psi_u, -Ri*T*Constant((0., 1.))) - div(psi_u)*p 
           + 2./Re*inner(sym(grad(psi_u)), sym(grad(u))) * Constant(((1,0),(0,0)))
energy = dot(grad(psi_T), 1./Pr*grad(T))[1] - dot(grad(psi_T), T*u)
F = (mass + momentum + energy)*dx

And I get an error: Can’t add expressions with different shapes.

Through trying different things I also got at some point: UFLException: Symmetric part of tensor with rank != 2 is undefined.

Any help would be very much appreciated! :slight_smile:

1 Like

Might not be the most efficient solution, but you could multiply your div(u) vector by [0,1] to get the u_y derivative: u_y=dot(np.array([0,1]), div(u) )

I haven’t tried it myself, but this could work. Hope this helps!

Thank you for this! I can’t test this at the moment, but I might be able to use it for T_{yy} :slight_smile: For u_{yy} I not only need to “extract” just that term (which your method might do), but I also need to make sure it doesn’t appear in the equation for p_y. Do you have an idea how I could do that please? :slight_smile:

Hi,
u.dx(0) is \partial u /\partial x and u.dx(1) is \partial u / \partial y.

2 Likes

Hi, thank you! I did see this but I haven’t seen it used in this case, I’ve only seen it be used in Expressions. Could you please tell me how I could use this in my variational formulation? What happens with the test functions then? :slight_smile: