# positive definite tracer advection schemes

**URL:** <https://forum.croco-ocean.org/t/positive-definite-tracer-advection-schemes/360>\
**Category:** dynamics-numerics-params\
**Tags:** physics-params, non-hydro, dynamics-numerics\
**Created:** [May 20, 2022, 5:18pm UTC](https://forum.croco-ocean.org/t/positive-definite-tracer-advection-schemes/360 "2022-05-20T17:18:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![xupeng66](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/x/50afbb/32.png) [@xupeng66](https://forum.croco-ocean.org/u/xupeng66)\
**Post date:** [May 20, 2022, 5:18pm UTC](https://forum.croco-ocean.org/t/positive-definite-tracer-advection-schemes/360/1 "2022-05-20T17:18:08Z")

</div>

Hello CROCO users,

I have a question about the advection schemes for tracers (e.g., temperature, salinity, passive tracer). In my simulation of a buoyancy-driven plume rising from a bottom heat source, I found that the concentration of the passive tracer I added to mark the plume fluid shows bogus negative values near the center of the source (see first image below). The same thing occurs in temperature (i.e., negative temperature anomaly at the source). Also, the negative minimum appears to grow with time (see second image below). I suspect these negative values are artifacts due to advection schemes. I am using WENO5 for trancers and TVD for velocities. The chosen cpp options are below:

# define TS\_HADV\_WENO5

408 # define TS\_VADV\_WENO5  
409 # define BIO\_HADV\_WENO5  
410 # define UV\_HADV\_TVD  
411 # define UV\_VADV\_TVD  
412 # define W\_HADV\_TVD  
413 # define W\_VADV\_TVD

I would like to know if there is a positive definite and monotonic scheme for tracers I can use other than WENO5.

I would appreciate if anyone can provide suggestions on diagnosing this issue.

Thanks!  
Guangyu!

![image description](https://forum.croco-ocean.org/uploads/default/original/1X/0c8593a0a404174c8b6d5e35340c5eb652977524.png)  
 ![image description](https://forum.croco-ocean.org/uploads/default/original/1X/bfcf4667442039db7eb9f03694f1337fa7a824b2.png)

---

<div class="post-metadata">

**Author:** ![Qingyue](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/q/7cd45c/32.png) [@Qingyue](https://forum.croco-ocean.org/u/Qingyue)\
**Post date:** [June 2, 2022, 3:40pm UTC](https://forum.croco-ocean.org/t/positive-definite-tracer-advection-schemes/360/2 "2022-06-02T15:40:29Z")

</div>

Hi Guangyu, I also had a similar problem and I am curious to know if your issue has been resolved yet?

---

<div class="post-metadata">

**Author:** ![xupeng66](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/x/50afbb/32.png) [@xupeng66](https://forum.croco-ocean.org/u/xupeng66)\
**Post date:** [June 2, 2022, 4:59pm UTC](https://forum.croco-ocean.org/t/positive-definite-tracer-advection-schemes/360/3 "2022-06-02T16:59:50Z")

</div>

Hi Qinyue, It is unclear to me what is causing this issue. But I found that the artifacts in temperature tended to appear when the source heat flux was relatively large. So it appeared that these artifacts occur when there are large spatial gradients in temperature.

---

<div class="post-metadata">

**Author:** ![pmarchesiello](https://forum.croco-ocean.org/user_avatar/forum.croco-ocean.org/pmarchesiello/32/378_2.png) [@pmarchesiello](https://forum.croco-ocean.org/u/pmarchesiello)\
**Post date:** [June 2, 2022, 7:05pm UTC](https://forum.croco-ocean.org/t/positive-definite-tracer-advection-schemes/360/4 "2022-06-02T19:05:45Z")

</div>

WENO5 is not the problem per se, but this scheme must be degraded near the bottom because the stencil is reduced there. The problem may simply be that the low-order scheme used at the first temperature point is not monotonic. We can try a first-order upwind scheme (in compute\_vert\_tracer\_fluxes.h) to check this idea (there is a WENO3 scheme at the second point which seems to work well).

---

<div class="post-metadata">

**Author:** ![xupeng66](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/x/50afbb/32.png) [@xupeng66](https://forum.croco-ocean.org/u/xupeng66)\
**Post date:** [June 2, 2022, 9:11pm UTC](https://forum.croco-ocean.org/t/positive-definite-tracer-advection-schemes/360/5 "2022-06-02T21:11:57Z")

</div>

Many thanks for the suggestion, Patrick. I am wondering if you could help revise the source code in ‘compute\_ver\_tracer\_fluxes.h’ to implement first-order upwind scheme for the second sigma layer? I will try to do it myself but more instructions will be much appreciated.

---

<div class="post-metadata">

**Author:** ![pmarchesiello](https://forum.croco-ocean.org/user_avatar/forum.croco-ocean.org/pmarchesiello/32/378_2.png) [@pmarchesiello](https://forum.croco-ocean.org/u/pmarchesiello)\
**Post date:** [June 5, 2022, 5:48am UTC](https://forum.croco-ocean.org/t/positive-definite-tracer-advection-schemes/360/6 "2022-06-05T05:48:56Z")

</div>

Try the following modifications.

in compute\_vert\_tracer\_fluxes.h (WENO5 code), replace :

```
        FC(i, 1)=We(i,j, 1)*( 0.5*t(i,j, 1,nadv,itrc)
 & +0.58333333333333*t(i,j, 2,nadv,itrc)
 & -0.08333333333333*t(i,j, 3,nadv,itrc)
 & )
        FC(i,N-1)=We(i,j,N-1)*( 0.5*t(i,j,N ,nadv,itrc)
 & +0.58333333333333*t(i,j,N-1,nadv,itrc)
 & -0.08333333333333*t(i,j,N-2,nadv,itrc)
 & )

```

by

```
        FC(i,1 )=We(i,j,1 )*flux1( t(i,j,1 ,nadv,itrc),
 & t(i,j,2 ,nadv,itrc), We(i,j,1 ), 1.)

        FC(i,N-1)=We(i,j,N-1)*flux1( t(i,j,N-1,nadv,itrc),
 & t(i,j,N ,nadv,itrc), We(i,j,N-1), 1.)

```

Also, for the same points (1, N-1). In w\_vadv\_order5.h:

replace:

```
        FC(i,1)=We_r(i,1)*FLUX2( wz(i,j,1 ,nrhs),
 & wz(i,j,0 ,nrhs), We_r(i,1), 1.)

        FC(i,N)=We_r(i,N)*FLUX2( wz(i,j,N ,nrhs),
 & wz(i,j,N-1,nrhs), We_r(i,N), 1.)

```

by:

```
        FC(i,1)=We_r(i,1)*FLUX2( wz(i,j,0 ,nrhs),
 & wz(i,j,1 ,nrhs), We_r(i,1), 1.)

        FC(i,N)=We_r(i,N)*FLUX2( wz(i,j,N-1,nrhs),
 & wz(i,j,N ,nrhs), We_r(i,N), 1.)

```

---

<div class="post-metadata">

**Author:** ![xupeng66](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/x/50afbb/32.png) [@xupeng66](https://forum.croco-ocean.org/u/xupeng66)\
**Post date:** [June 5, 2022, 9:36pm UTC](https://forum.croco-ocean.org/t/positive-definite-tracer-advection-schemes/360/7 "2022-06-05T21:36:56Z")

</div>

Hi Patrick, thanks a lot for sending me the revised code. I have implemented it and am now waiting for the test run to finish. It is very encouraging that the simulation has now gone past the previous time step when negative temperature anomalies appeared without showing any sign of that artifact.

---

<div class="post-metadata">

**Author:** ![xupeng66](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/x/50afbb/32.png) [@xupeng66](https://forum.croco-ocean.org/u/xupeng66)\
**Post date:** [June 6, 2022, 2:45pm UTC](https://forum.croco-ocean.org/t/positive-definite-tracer-advection-schemes/360/8 "2022-06-06T14:45:13Z")

</div>

I am happy to report back that this problem has been solved after implementing the changes in ‘comput\_ver\_tracer\_fluxes’ and ‘w\_vadv\_order5’ as suggested by Patrick. Many thanks!!!
