# Non homogeneous boundary and initial conditions

**URL:** <https://community.freefem.org/t/non-homogeneous-boundary-and-initial-conditions/154>\
**Category:** General Discussion\
**Created:** [October 12, 2019, 9:10am UTC](https://community.freefem.org/t/non-homogeneous-boundary-and-initial-conditions/154 "2019-10-12T09:10:13Z")\
**Posts on this page:** 1\
**Showing post:** 21

<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 7, 2024, 2:16pm UTC](https://community.freefem.org/t/non-homogeneous-boundary-and-initial-conditions/154/21 "2024-05-07T14:16:44Z")

</div>

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](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/6/6e74ced763c14808bd45b8dde6ec65b88c5aafb6.png)  
Here I put the code:

```auto
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(v, u) ( dx(v) * dx(u) + dy(v) * dy(u) + dx(v#y) * dx(u#y) + dy(v#y) * dy(u#y)) // EOM
varf vR(def(dub), def(v)) = int2d(Th)(ugradu(v, ub, ub) - div(v) * ubp + visc(v, ub) * nu - vp * div(ub)
                          + grad(ubT)' * [ub,uby] * vT+ Kappa * grad(ubT)' * grad(vT)- ubT * vy) //newly added
                          + on(1,2,3,4, dub = ub, duby = uby) + on(1,dubT=ubT-1) + on(3,dubT=ubT);
varf vM(def(dub), def(v)) = int2d(Th)(dot(v, dub))
                          + on(1,2,3,4, dub = ub, duby = uby) + on(1,dubT=ubT-1) + on(3,dubT=ubT);
varf vJ(def(dub), def(v)) = int2d(Th)(sig * dot(v, dub) + ugradu(v, ub, dub) + ugradu(v, dub, ub) 
                          + Kappa * grad(dubT)'* grad(vT)+ grad(dubT)'* [ub,uby] * vT - dubT * vy//newly added
                          - div(v) * dubp + visc(v, dub) * nu - vp * div(dub)+epsp * dubp * vp)
                          + on(1,2,3,4, dub = ub, duby = uby) + on(1,dubT=ubT-1) + on(3,dubT=ubT);

```

Is there anything wrong with my varfs? And how to add a disturbance to `ub[]` to induce the startup? I tried to add a disturbance to `ub[]` but failed.

Also, I tried to run it to t=100, but stopped at step 962, what’s the problem? Should I adopt a finer mesh?  
I monitored the temperature field, it looks reasonable.

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/6/6ad57c6da573601bb9e91e0bf4aa4128660bfb40.png)

---

_[View the full topic](https://community.freefem.org/t/non-homogeneous-boundary-and-initial-conditions/154)._
