Changes between Version 6 and Version 7 of CodeExplanation/SourceTerms


Ignore:
Timestamp:
01/12/12 13:23:03 (13 years ago)
Author:
Jonathan
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • CodeExplanation/SourceTerms

    v6 v7  
    1717[[latex($\Delta p=-\frac{\Delta t}{\Delta x} \left(F_{i+1/2}-F_{i-1/2} \right )$)]]  which is just [[latex($\dot{p} = f_{grav}$)]] where [[latex($f_{grav}=-\nabla \cdot F$)]] which requires [[latex($\nabla \cdot F=\rho \nabla \phi$)]].  Since [[latex($\nabla^2 \phi = 4\pi G (\rho-\bar{\rho})$)]] we can substitute for [[latex($\rho$)]] and we have [[latex($\nabla \cdot F = (\frac{\nabla^2\phi}{4 \pi G}+\bar{\rho}) \nabla \phi$)]] which is equivalent (in 1D) to [[latex($\nabla \cdot \left [\frac{1}{2} \frac{\left (\nabla \phi\right )^2}{4 \pi G}  + \bar{\rho} \phi \right ]$)]] where we can identify the equivalent momentum flux tensor as [[latex($F=\frac{1}{2} \frac{\left (\nabla \phi\right )^2}{4 \pi G} + \bar{\rho} \phi$)]]
    1818
    19 * In more than 1D, [[latex($\nabla \cdot \left [\frac{1}{2} \frac{\left (\nabla \phi : \nabla \phi \right )}{4 \pi G}  + \bar{\rho} \phi I \right ]_i =\partial_j (\partial_j \phi \partial_i \phi) +\bar{\rho} \partial_i \phi$)]]
     19* In more than 1D we have
     20
     21
     22{{{
     23#!latex
     24\begin{align*}
     25\partial_t p_i&=\rho \partial_i \phi \\
     26& = \left (\frac{\partial_j(\partial_j \phi)}{4 \pi G}+\bar{\rho} \right ) \partial_i \phi \\
     27& = \partial_j \left ( \partial_j \phi \partial_i \phi \right) - (\partial_j \phi) \partial_j (\partial_i \phi )+\partial_i (\bar{\rho}\phi) \\
     28& = \partial_j \left ( \partial_j \phi \partial_i \phi \right) - (\partial_j \phi) \partial_i (\partial_j \phi )+\partial_i (\bar{\rho}\phi) \\
     29& = \partial_j \left ( \partial_j \phi \partial_i \phi \right) - \frac{1}{2}\partial_i(\partial_j \phi \partial_j \phi)+\partial_i (\bar{\rho}\phi) \\
     30& = \partial_j \left ( \partial_j \phi \partial_i \phi \right) - \partial_i \left (\frac{\partial_j \phi \partial_j}{2} \phi+\bar{\rho}\phi \right) \\
     31& = \partial_j \left ( \partial_j \phi \partial_i \phi \right) -  \partial_j \left ( \delta ^i_j\left(\frac{\partial_k \phi \partial_k \phi}{2}+\bar{\rho}\phi \right) \right) \\
     32& = \partial_j T_{ij} \mbox{ where } T_{ij} = \left ( \partial_j \phi \partial_i \phi \right) -    \delta ^i_j\left(\frac{\partial_k \phi \partial_k \phi}{2}+\bar{\rho}\phi \right) \\
     33\end{align*}
     34}}}
    2035
    2136* But casting it this way gives you strict momentum conservation.  If the source term were just [[latex($\nabla \phi$)]] then momentum would be conserved but since in each cell there is a factor of [[latex($\rho$)]] that currently enters, it modifies the differenced quantity from cell to cell.  In theory these all cancel but only because [[latex($\nabla^2\phi=\rho$)]]...  In the above treatment - the density used in the source term is derived from the actual potential which allows the source term to be cast as a flux difference.  This allows for the strict momentum conservation.
    2237
    23 * Also athena stores combined kinetic/thermal/magnetic with gravitational...  So [[latex($E_{Athena}=E_{Astrobear}+\rho\phi$)]].  This results in [[latex($\dot{E}_{Athena}=\dot{E}_{Astrobear}+\dot{\rho}\phi = \rho \nabla \phi \cdot \mathbf{v}+\phi \nabla \cdot (\rho \mathbf{v}) = \nabla \cdot (\rho \mathbf{v} \phi)$)]] so the energy source term for self gravity can be written as a total divergence.  We need [[latex($\rho v \phi$)]] at cell edges, but [[latex($\rho v$)]] is available from the mass flux and [[latex($\phi$)]] can be averaged using adjacent cells.
     38* As as the energy is concerned... 
     39Currently the energy added is [[latex($\Delta E_i = \frac{\Delta t}{2\Delta x} \left[(\rho v)_{i-1/2}\Delta x \left(-\frac{\phi_{i}-\phi_{i-1}}{\Delta x} \right) - (\rho v)_{i+1/2}\Delta x \left(+\frac{\phi_{i+1}-\phi_{i}}{\Delta x}\right )\right ]$)]]
     40
     41Which is equivalent to
     42
     43[[latex($-\Delta t \left [ \frac{ (\rho v \nabla \phi)_{i+1/2} + (\rho v \nabla \phi)_{i-1/2}}{2} \right ] $)]]
     44
     45
     46If we try to express the energy source term as a total flux we get
     47
     48[[latex($\dot{E_{kinetic}} = f_{grav} \cdot v = \rho \nabla \phi \cdot v = \rho v \cdot \nabla \phi = \nabla \cdot (\rho v \phi)-\phi \nabla \cdot {\rho v} = \nabla \cdot {\rho v \phi} - \phi \nabla \cdot {v \nabla^2\phi}$)]]
     49
     50The presence of the v will make it impossible to right this as a total flux.
     51
     52What if we store the potential in E?  Then [[latex($\dot{E}= \nabla \cdot (\rho v \phi) - \rho \dot{\phi}$)]] 
     53
     54We now have a flux as well as a source term.  However, the integral of the source term would need to be zero.  So our elliptic equation would have a constraint
     55
     56
     57[[latex($\nabla^2\phi=4 \pi G \rho$)]]
     58
     59[[latex($\int{\rho \dot{\phi}} = 0$)]]
     60
     61
     62
     63
     64
     65We can conserve total energy before and after the hydro step if we add source terms to the Energy [[latex($\dot{E}=f_{grav} \cdot \mathbf{v} = \rho \nabla \phi \cdot \mathbf{v} = \rho \mathbf{v} \cdot \nabla \phi = \nabla \cdot \left (\rho \mathbf{v} \phi \right) - \phi \nabla \cdot \left ( \rho \mathbf{v} \right ) = \nabla \cdot \left (\rho \mathbf{v} \phi \right) - \phi \dot{\rho}$)]]
     66
     67
     68Consider the difference in gravitational energy...
     69
     70[[latex($\dot{E_{grav}} = \dot{(\rho\phi)}=\dot{\rho}{\phi}+\rho\dot{\phi}= \nabla \cdot (\rho v) \phi + \rho \dot{\phi} = \nabla \cdot (\rho v \phi) - \rho v \cdot \nabla \phi + \rho \dot{\phi}$)]]
     71
     72As well as kinetic energy
     73
     74[[latex($\dot{E_{kinetic}} = f_{grav} \cdot v = \rho \nabla \phi \cdot v = \rho v \cdot \nabla \phi$)]]
     75
     76For the sum to be zero we need to have [[latex($\nabla \cdot (\rho v \phi) = \rho \dot{\phi}$)]]
     77
     78The first term [[latex($\dot{\rho}{\phi} = \nabla \cdot (\rho v) \phi = \nabla \cdot (\rho v \phi) - \rho v \cdot \nabla \phi$)]] so we could identify a gravitational energy flux term [[latex($=\rho v \phi$)]]
     79
     80
     81
    2482
    2583