PLUTO  4.2
 All Data Structures Files Functions Variables Enumerations Macros Pages
rhs.c File Reference

Compute the right hand side of the conservative HD/MHD equations. More...

#include "pluto.h"


static void TotalFlux (const State_1D *, double *, int, int, Grid *)
void RightHandSide (const State_1D *state, Time_Step *Dts, int beg, int end, double dt, Grid *grid)

Detailed Description

This function constructs the one-dimensional right hand side of the conservative MHD or HD equations in the direction given by g_dir in different geometries. The right hand side in the d direction is computed as a two-point flux difference term plus a source term:

\[ {\cal R}_{\ivec}^{(d)} = -\frac{\Delta t}{\Delta{\cal V}_{\ivec}}\ \Big[ (A{\cal F})_{\ivec+\HALF\hvec{e}_d} -(A{\cal F})_{\ivec-\HALF\hvec{e}_d} \Big] + \Delta t{\cal S}_{\ivec} \]

where $\ivec = (i,j,k)$ while

See also the RHS_page. The right hand side is assembled through the following steps:

Source terms are added later in RightHandSideSource().

For the entropy equation, the dissipative contributions can be recovered from the internal energy equation, for which (Boyd, Eq. [3.27]):

\[ \pd{p}{t} + \vec{v}\cdot\nabla p + \Gamma p \nabla\cdot\vec{v} = (\Gamma-1)\left[\nabla\cdot\left(\kappa\nabla T\right) + \eta\vec{J}\cdot\vec{J} + \mu\left(\pd{v_i}{x_j}+\pd{v_j}{x_i} - \frac{2}{3}\delta_{ij}\nabla\cdot\vec{v}\right)\pd{v_i}{x_j}\right] \]

To obtain the corresponding contribution to the (conservative form of) entropy equation, just divide the previous one by $\rho^{\Gamma-1}$:

\[ \pd{(\rho s)}{t} + \nabla\cdot(\rho s\vec{v}) = (\Gamma-1)\rho^{1-\Gamma}\left[\nabla\cdot\left(\kappa\nabla T\right) + \eta\vec{J}^2 + \mu \Pi_{ij}\pd{v_i}{x_j}\right] \]

See the books by


A. Mignone (
Aug 20, 2015
  • merge GetAreaFlux and TotalFlux ?

Function Documentation

void RightHandSide ( const State_1D state,
Time_Step Dts,
int  beg,
int  end,
double  dt,
Grid grid 
[in,out]statepointer to State_1D structure
[in]Dtspointer to time step structure
[in]beginitial index of computation
[in]endfinal index of computation
[in]dttime increment
[in]gridpointer to Grid structure
This function has no return value.
void TotalFlux ( const State_1D state,
double *  phi_p,
int  beg,
int  end,
Grid grid 

Compute the total flux in order to enforce conservation of angular momentum and energy in presence of FARGO source terms, rotation or gravitational potential.

In Cartesian coordinates, for instance, we modify the energy and the y-momentum flux as:

\begin{eqnarray*} \F^{E}_{i+\HALF} &\quad \to\quad& \F^{E}_{i+\HALF} + w_{i+\HALF}\left(\HALF w_{i+\HALF}\F^{\rho}_{i+\HALF} + \F^{m_y}_{i+\HALF}\right) + \Phi_{i+\HALF}\F^{\rho}_{i+\HALF} \\ \noalign{\medskip} \F^{m_y}_{i+\HALF} &\quad \to\quad& \F^{m_y}_{i+\HALF} + w_{i+\HALF}\F^{\rho}_{i+\HALF} \end{eqnarray*}

where $w$ is the average orbital velocity computed during the FARGO algorithm and $\Phi$ is the gravitational potential. This is described in Mignone et al. (A&A 2012), see appendix there.

This function does not change the fluxes when the Shearing-box and FARGO modules are both enabled. Instead, we incorporate the source terms elsewhere.
[in]statepointer to State_1D structure;
[in,out]phi_p1D array defining the gravitational potential at grid interfaces;
[in]beginitial index of computation;
[in]endfinal index of computation;
[in]gridpointer to Grid structure;


  • "A conservative orbital advection scheme for simulations of magnetized shear flows with the PLUTO code" Mignone et al., A&A (2012) 545A, 152M