# [mesa-users] Quality of mass conservation

Francis Timmes fxt44 at mac.com
Mon Oct 27 02:45:28 EDT 2014

```hi ehsan,

let’s make this simpler. equation 4 of paxton et al 2011,
from which equation 5 is derived, essentially says

density_k = mass_k / volume_k

density_k and mass_k are cell averaged quantities (intensive)
while volume_k depends on the radii at the cell boundaries (extensive).

each cell in mesa has some variables that are mass-averaged (intensive)
and others that are defined at the outer face of a cell (extensive).
this way of defining the variables is a consequence of the finite volume,
flux conservation formulation of the equations.

as the algebraic equality above shows, its perfectly ok to mix
intensive and extensive variables for flux conserving quantities.

fxt

> On Oct 26, 2014, at 2:22 PM, Ehsan Moravveji <e.moravveji at gmail.com> wrote:
>
> Hi everybody,
>
> I’ve been looking at star/private/hydro_eqns.f, and the subroutine do1_density_eqn to figure out how the equality in Eq. (5) in the first instrument paper is fulfilled.
> So, I’m going to present the first few lines of this subroutine in a jumbled way:
>
> the residual of both sides of the equality are stored in
>             equ(equR, k) = lnR(k) - res/3d0
> where
>             lnR(k) = log(s% r(k))
> and
>             res = log_cr(rp13 + dr3)
> since “lnR" is a cell-edge quantity, then “res" must be also evaluated at cell face, if the comparison is going to be fair.
> However, one of the ingredients of “res” is a cell-averaged quantity:
>
>             dm = s% dm(k)
>             rho = s% rho(k)
>             ! dm/rho is cell volume
>             dr3 = (dm/rho)/(pi4/3)
>
> Indeed the cell volume is an extensive quantity, but it seems to me it is evaluated at cell center, due to the definition of s% dm and s% rho.
> I would be grateful is one of the black belts explain to me why this is an allowed operation.
>
> Cheers
> Ehsan.
>
> PS: B.t.w., for a main-sequence 5 Msun model, the equality in Eq. (5) is fulfilled up to ~ 10 decimals, as you can find out in the attached plot.
> Delta = log10((LHS-RHS)/LHS).
> <equR.png>
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> mesa-users mailing list
> mesa-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mesa-users

```