# Micropolar Fluid Flow Numerical Simulation: Modified NSEs in Lid-driven cavity flow problem

**URL:** <https://community.freefem.org/t/micropolar-fluid-flow-numerical-simulation-modified-nses-in-lid-driven-cavity-flow-problem/3332>\
**Category:** General Discussion\
**Created:** [June 21, 2024, 7:28am UTC](https://community.freefem.org/t/micropolar-fluid-flow-numerical-simulation-modified-nses-in-lid-driven-cavity-flow-problem/3332 "2024-06-21T07:28:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ozil101](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/ozil101/32/1820_2.png) [@ozil101](https://community.freefem.org/u/ozil101)\
**Post date:** [June 21, 2024, 7:28am UTC](https://community.freefem.org/t/micropolar-fluid-flow-numerical-simulation-modified-nses-in-lid-driven-cavity-flow-problem/3332/1 "2024-06-21T07:28:29Z")

</div>

Hi respected Professor, and thank you so much for your valuable and very kind guidances. I get some errors when I modified my original Lid-driven cavity flow code for mpff specific and modified version of NSEs as following:  
_FF++ Error Prompt_:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/5/5d7723618dfac5fc0b4f80368e717f1c1e0fc28d.png)  
_Modified NSEs_:  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/9/9a698b4d831df367ca5f98d7da32989f0ad9f226.png)

_Bugged Code_:  
[// Micropolar fluid flow in 2D of Lemma 1.  
real n = 100;  
mesh Th = square(n, n);  
plot(Th);  
fespace Vh(Th, P2);  
fespace Mh(Th, P2);  
real al = 0.5, dt = 0.002, dT = dt / 2.0, t = 0, T = 1.0, re = 1000.0, ee = 0.0001;  
real number = 0;

Mh P, p, q;  
Vh w, u, v, uT, vT, uTT, vTT, omega, omegaT, omegaTT;

real rho\_nf = 1.0; // Density  
real beta1 = 0.5, beta2 = 0.5;  
real mu\_nf = 1.0; // Viscosity  
real sigma\_nf = 1.0; // Conductivity  
real B0 = 1.0; // Magnetic field strength  
real[3] Omega = [0.0, 0.0, 1.0]; // Rotation vector

real nv = Th.nv;  
real nt = Th.nt;

real[int] areaphi(nt), areahphi(nt), h(nt);

for (int m = 0; m \<= T / dt; m++) {  
Vh uold = u, vold = v, pold = p, omegaold = omega;  
P = p;

```
// Intermediate velocity uT
solve Adual4unon(uT, w) =
    int2d(Th)(uT * w / dt)
    - int2d(Th)(convect([uold, vold], -dt, uold) * w / dt)
    + int2d(Th)(2 * Omega[2] * v * w) // Coriolis term
    - int2d(Th)(sigma_nf * B0^2 * u * w) // Magnetic field term
    + int2d(Th)((mu_nf * (1 + beta1) / (1 + beta2)) * dx(dx(u)) * w) // Modified viscosity term
    + on(1, 2, 4, uT = 0)
    + on(3, uT = 1.0);

// Intermediate velocity vT
solve Adual4vnon(vT, w) =
    int2d(Th)(vT * w / dt)
    - int2d(Th)(convect([uold, vold], -dt, vold) * w / dt)
    - int2d(Th)(2 * Omega[2] * u * w) // Coriolis term
    - int2d(Th)(sigma_nf * B0^2 * v * w) // Magnetic field term
    + int2d(Th)((mu_nf * (1 + beta1) / (1 + beta2)) * dx(dx(v)) * w) // Modified viscosity term
    + on(1, 2, 3, 4, vT = 0);

// Solve for microrotation omegaT
solve Adual4omeganon(omegaT, w) =
    int2d(Th)(omegaT * w / dt)
    - int2d(Th)(convect([uold, vold], -dt, omegaold) * w / dt)
    + on(1, 2, 3, 4, omegaT = 0);

// Solve for pressure p
solve pb4p(p, q) =
    int2d(Th)((dx(p) * dx(q) + dy(p) * dy(q)))
    + int2d(Th)(((dx(uT) + dy(vT)) * q) / dt);

// Solve for uTT
solve pb4uTT(uTT, w) =
    int2d(Th)(uTT * w / dt)
    - int2d(Th)(uT * w / dt - dx(p) * w)
    + on(1, 2, 4, uTT = 0)
    + on(3, uTT = 1.0);

// Solve for vTT
solve pb4vTT(vTT, w) =
    int2d(Th)(vTT * w / dt)
    - int2d(Th)(vT * w / dt - dy(p) * w)
    + on(1, 2, 3, 4, vTT = 0);

// Solve for microrotation omegaTT
solve pb4omegaTT(omegaTT, w) =
    int2d(Th)(omegaTT * w / dt)
    - int2d(Th)(omegaT * w / dt - dx(p) * w)
    + on(1, 2, 3, 4, omegaTT = 0);

// Update velocity u
solve pb4u(u, w) =
    int2d(Th)((dx(u) * dx(w) + dy(u) * dy(w)) / re + u * w / dt)
    - int2d(Th)(uTT * w / dt)
    + on(1, 2, 4, u = 0)
    + on(3, u = 1.0);

// Update velocity v
solve pb4v(v, w) =
    int2d(Th)((dx(v) * dx(w) + dy(v) * dy(w)) / re + v * w / dt)
    - int2d(Th)(vTT * w / dt)
    + on(1, 2, 3, 4, v = 0);

// Solve for final microrotation omega
solve pb4omega(omega, w) =
    int2d(Th)((dx(omega) * dx(w) + dy(omega) * dy(w)) / re + omega * w / dt)
    - int2d(Th)(omegaTT * w / dt)
    + on(1, 2, 3, 4, omega = 0);

t = t + dt;

if (m % 100 == 0) {
    ofstream os("MPFF" + real(t) + ".plt");
    real m1, m2, m3, m4, m5, m6;
    os << "TITLE = levelset " << endl;
    os << "VARIABLES = X, Y, u, v, omega, p" << endl;
    os << "ZONE, N=" << nv << ", E=" << nt << ", F=FEPOINT, ET=triangle" << endl;
    for (int i = 0; i < nv; i++) {
        m1 = Th(i).x;
        m2 = Th(i).y;
        m3 = u(m1, m2);
        m4 = v(m1, m2);
        m5 = omega(m1, m2);
        m6 = p(m1, m2);

        os << m1 << " " << m2 << " " << m3 << " " << m4 << " " << m5 << " " << m6 << endl;
    }
    os << "\n\n\n\n" << endl;
    int a2, bt2, c2;
    for (int i = 0; i < nt; i++) {
        a2 = Th[i][0] + 1;
        bt2 = Th[i][1] + 1;
        c2 = Th[i][2] + 1;
        os << a2 << " " << bt2 << " " << c2 << endl;
    }
}

```

}  
]

---

<div class="post-metadata">

**Author:** ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)\
**Post date:** [June 21, 2024, 9:14am UTC](https://community.freefem.org/t/micropolar-fluid-flow-numerical-simulation-modified-nses-in-lid-driven-cavity-flow-problem/3332/2 "2024-06-21T09:14:32Z")

</div>

FreeFem syntax does not allow for underscore in the name of variables. You have to change `real rho_nf = 1.0;` for example, to `real rhoNF=1.0;`

---

<div class="post-metadata">

**Author:** ![ozil101](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/ozil101/32/1820_2.png) [@ozil101](https://community.freefem.org/u/ozil101)\
**Post date:** [June 21, 2024, 9:39am UTC](https://community.freefem.org/t/micropolar-fluid-flow-numerical-simulation-modified-nses-in-lid-driven-cavity-flow-problem/3332/3 "2024-06-21T09:39:51Z")

</div>

Still doesn’t solve the issue I get this error

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/1/187a5b3e9ce76c7356aa189d27f41b11530f0d49.png)  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/3/34b73f2ac6a3b7922c4380135d88548dc8b974f4.png)  
for more details on the error this is the \*.log file  
[lemma1\_mpff.log](https://community.freefem.org/uploads/short-url/2i5Z7cxAbKne5bBrUZsQAjGkllu.log) (1.5 KB)  
I need to understand what this error means and how to overcome it to run the code without it.

@fb77

---

<div class="post-metadata">

**Author:** ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)\
**Post date:** [June 21, 2024, 9:54am UTC](https://community.freefem.org/t/micropolar-fluid-flow-numerical-simulation-modified-nses-in-lid-driven-cavity-flow-problem/3332/4 "2024-06-21T09:54:00Z")

</div>

you have error online 19. indeed, you initialize a real by an array…  
so  
`real[int] Omega = [0.0, 0.0, 1.0]; // Rotation vector`

---

<div class="post-metadata">

**Author:** ![ozil101](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/ozil101/32/1820_2.png) [@ozil101](https://community.freefem.org/u/ozil101)\
**Post date:** [July 16, 2024, 2:06pm UTC](https://community.freefem.org/t/micropolar-fluid-flow-numerical-simulation-modified-nses-in-lid-driven-cavity-flow-problem/3332/5 "2024-07-16T14:06:52Z")

</div>

By the way, how I can validate this mathematical model of micropolar fluid flow & NSEs via means other than testing it on CFDs benchmark problems?
