# Inquiries about solving the N-S equation, projection algorithm and parallel

**URL:** <https://community.freefem.org/t/inquiries-about-solving-the-n-s-equation-projection-algorithm-and-parallel/3006>\
**Category:** General Discussion\
**Created:** [February 28, 2024, 6:08pm UTC](https://community.freefem.org/t/inquiries-about-solving-the-n-s-equation-projection-algorithm-and-parallel/3006 "2024-02-28T18:08:38Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![quentin](https://avatars.discourse-cdn.com/v4/letter/q/e47c2d/32.png) [@quentin](https://community.freefem.org/u/quentin)\
**Post date:** [May 14, 2024, 9:02am UTC](https://community.freefem.org/t/inquiries-about-solving-the-n-s-equation-projection-algorithm-and-parallel/3006/11 "2024-05-14T09:02:20Z")

</div>

Dear Prof. Bouchut,  
The vorticity formulation gives somewhat abnormal results, which conflicted with previous ones. I don’t have much time left to complete my paper, so I go back to solve the original N-S equation, but in parallel. I am working on a convection problem, unlike Boussinesq approximation, the density is modelled nonlinearly: \rho=\rho\_0(1-\beta|T-T\_M|^q),where β \> 0 is the thermal expansion coefficient and ρ\_0 is the density at T = T\_M.  
Conventionally, q=2, and the dimensionless equation set reads

\left\{ \begin{aligned} &\frac{\partial \textbf{u}}{\partial t}+\textbf{u}\cdot\nabla\textbf{u}=-\nabla p+\sqrt{\frac{Pr}{Ra}}\nabla^2\textbf{u}+(T-T\_M)^2\textbf{e}\_z \\ &\frac{\partial T}{\partial t}+\nabla\cdot (\textbf{u} T)=\frac{1}{\sqrt{PrRa}}\nabla^2T \end{aligned} \right.

I modified [cmd](https://community.freefem.org/u/cmd)’s parallel code. I added the temperature equation and a linear buoyancy term `dubT * vy` referring to T\textbf{e}\_z.

> [@Non homogeneous boundary and initial conditions](https://community.freefem.org/t/non-homogeneous-boundary-and-initial-conditions/154/21):
>
> Dear Chris: I added a componet T for temperature and modified vR and vJ, but I am uncertain about the derivation of residual and Jacobian. the equations are: [image] Here I put the code: macro def(u)[u, u#y, u#T, u#p]// macro grad(u) [dx(u),dy(u)]//EOM macro dot(v, u) ( v \* u + v#y \* u#y + v#T \* u#T ) //EOM macro div(u) ( dx(u) + dy(u#y) ) // velocity divergence macro ugradu(v, U, u) ( v \* (U \* dx(u) + U#y \* dy(u)) + v#y \* (U \* dx(u#y) + U#y \* dy(u#y)) ) // scaled convection term macro visc…

When I turned to the nonlinear buoyancy term: (T-T\_M)^2\textbf{e}\_z, it reported an error with

```auto
varf vJ([u1,u2,uT,up],[v1,v2,vT,vp])=int2d(Th)(...-(uT-TM)^2*v2)

```

,other terms are omitted. I found in **varf** , a term should be either bilinear or linear, so the `uT^2*v2` referred to trilinear term, is illegal.  
I tried to substitute `uT^2*v2` to `uT*uTb*v2`, uTb is temperature at previous step, and I can run code. If it is a right doing? I also tried to use fully explicit term `(uTb-TM)^2`, but instability won’t be observed: the system remains stable at a high Rayleigh number, and the growing of time step does not have an effect.

---

_[View the full topic](https://community.freefem.org/t/inquiries-about-solving-the-n-s-equation-projection-algorithm-and-parallel/3006)._
