PLUTO
mean_mol_weight.c File Reference

Compute the mean molecular weight. More...

#include "pluto.h"
Include dependency graph for mean_mol_weight.c:

Go to the source code of this file.

Functions

double MeanMolecularWeight (double *v)
 

Detailed Description

Compute the mean molecular weight.

Compute and return the mean molecular weight as a function of the gas composition under non-equilibrium conditions. The mean molecular weight is usually needed to compute the temperature or mass density from the particle number density:

\[ T = \frac{p}{n_{\rm tot}k_B} = \frac{p}{\rho}\frac{m_u\mu}{k_B} \,,\qquad \rho = \mu m_u n_{\rm tot} \]

where $ m_u $ is the atomic mass unit while $ n_{\rm tot} $ is the number density of all particles. The Mean molecular weight is defined as the average mass of a particle of gas in terms of the atomic mass unit and it is expressed by the weighted sum of the mass of particles in atomic mass unit divided by total number of particles (see book by Ryan & Norton [Eq. 1.7])

\[ \mu = \frac{\DS\sum_k N_k \frac{m_k}{m_u}}{\DS\sum_k N_k} \]

where

  • $ N_k $ is the number of particles in the gas of element k and it can be related to mass fraction $X_k$ as $\DS \frac{N_k}{V} = n_k = \frac{\rho}{m_u}\frac{X_k}{A_k}$, where $A_k$ is the atomic mass number.
  • $ m_k $ is the mass of each particle of element k.

H2_COOL: to compute $\mu$ we proceed as follows:

  1. using standard solar composition $ X_{\odot},\, Y_{\odot},\, Z_{\odot}$ we derive

    \[ \frac{N_{He}}{N_H} = \frac{Y_{\odot}}{A_{He}}\frac{A_H}{X_\odot} ,\,\qquad \frac{N_Z}{N_H} = \frac{Z_{\odot}}{A_{Z}}\frac{A_H}{X_\odot} \]

  2. The weighted sum of the mass of particles in the numerator of $\mu$ is given by

    \[ \sum_k N_k \frac{m_k}{m_u} = N_H \frac{m_H}{m_u} + N_{He}\frac{m_{He}}{m_u} + N_Z \frac{m_Z}{m_u} \]

    Note that since mass of electron is negligible, so is its contribution to the previous summation.
  3. For the denominator we have

    \[ \sum_k N_k = N_{HI} + N_{HII} + N_{H2} + N_e + N_{He} + N_Z + \frac{A_ZN_Z}{2} \]

    where two sources of electrons considered here: $ N_e $ electrons corresponding to $ N_{HII} $ protons due to ionization of hydrogen and $ A_ZN_Z/2 $ number of electrons due to metals. Note that now the electrons contribute to the total number of particles and cannot be neglected.
  4. Next define the total number of hydrogen, $ N_H = N_{HI} + N_{HII} + 2N_{H2} $ as the sum of number of atomic hydrogen (HI), ionized hydrogen (HII, or protons) and twice the number of molecular hydrogen (H2) and the corresponding number fractions:

    \[ f_{HI} = \frac{N_{HI}}{N_H},\quad f_{HII} = \frac{N_{HII}}{N_H},\quad f_{H2} = \frac{N_{H2}}{N_H},\quad \]

    so that $ f_{HI} + 2f_{H2} + f_{HII} = 1 $.

Putting it all together:

\[ \mu = \frac{A_H + A_{He}f_{He} + A_Zf_Z} {f_{HI} + f_{H2} + 2f_{HII} + f_{He} + f_Z + A_Z f_Z/2} \]

where

  • $A_{He}, A_Z $ are atomic mass numbers of helium and metals respectively.
  • $f_{He} = N_{He}/N_H$ is the fixed number fraction of helium with respect to hydrogen;
  • $f_Z = N_Z/N_H$ is the fixed number fraction of metals with respect to hydrogen.

MINEq: please see Eq. [12] of Tesileanu (2008)

SNEq: the derivation is similar to H2_COOL with $ f_{H2} = 0$ yielding

\[ \mu = \frac{A_H + A_{He}f_{He} + A_Zf_Z} {2 - f_{HI} + f_{He} + 2f_Z} \]

where one electron from metals is assumed.

No Chemistry: in case where chemical reaction are not incuded, the mean molecular weight is computed from the mass fractions assuming a fully ionized gas:

\[ \mu = \frac{A_H + A_{He}f_{He} + A_Zf_Z}{2 + f_{He} + f_Z(1 + A_Z/2)} \]

References

  • "Stellar Evolution and Nucleosynthesis" Sean G. Ryan and Andrew J. Norton. The University of Chicago Press
  • "Simulating radiative astrophysical flows with the PLUTO code: a non-equilibrium, multi-species cooling function", Tesileanu, Mignone & Massaglia, A&A (2008) 488, 429
Authors
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
B. Vaidya
Date
Aug 11, 2015

Definition in file mean_mol_weight.c.

Function Documentation

double MeanMolecularWeight ( double *  v)

Return the mean molecular weight.

Parameters
[in]varray of primitive variables (including ions)

Definition at line 120 of file mean_mol_weight.c.

128 {
129  int nv;
130  double mu;
131 
132 #if COOLING == NO
133 
135  (2.0 + FRAC_He + FRAC_Z*(1.0 + CONST_AZ*0.5));
136 
137 #elif COOLING == TABULATED
138 
140  (2.0 + FRAC_He + FRAC_Z*(1.0 + CONST_AZ*0.5));
141 
142 #elif COOLING == SNEq
143 
145  (2.0 + FRAC_He + 2.0*FRAC_Z - v[X_HI]);
146 
147 /*
148  return ( (CONST_AH + frac_He*CONST_AHe + frac_Z*CONST_AZ) /
149  (2.0 + frac_He + 2.0*frac_Z - v[X_HI]));
150 */
151 
152 #elif COOLING == H2_COOL
153 
154  double munum, muden;
155 
156  NIONS_LOOP(nv){
157  v[nv] = MAX(v[nv], 0.0);
158  v[nv] = MIN(v[nv], 1.0);
159  }
160 
161  v[X_H2] = MIN(v[X_H2], 0.5);
162 
163  double fn = v[X_HI];
164  double gn = v[X_H2];
165  double hn = v[X_HII];
166 
168  (fn + gn + 2*hn + FRAC_He + FRAC_Z + 0.5*CONST_AZ*FRAC_Z);
169 
170 /*
171  double N_H = (H_MASS_FRAC/CONST_AH);
172  double N_He = (He_MASS_FRAC/CONST_AHe);
173  double N_Z = ((1.0 - H_MASS_FRAC - He_MASS_FRAC)/CONST_AZ);
174 
175  double fracHe = N_He/N_H;
176  double fracZ = N_Z/N_H;
177 
178  double fn = v[X_HI];
179  double gn = v[X_H2];
180  double hn = v[X_HII];
181 
182  munum = 1.0 + CONST_AHe*(fracHe) + CONST_AZ*(fracZ);
183  muden = fn + gn + 2*hn + fracHe + fracZ + 0.5*CONST_AZ*(fracZ);
184 
185  return munum/muden;
186 */
187 #elif COOLING == MINEq
188 
189  double mmw1, mmw2;
190  int i, j;
191 
192  mmw1 = mmw2 = 0.0;
193  for (i = 0; i < NIONS; i++) {
194  if (v[NFLX+i] < 0.0) v[NFLX+i] = 0.0;
195  if (v[NFLX+i] > 1.0) v[NFLX+i] = 1.0;
197  CoolCoeffs.dmuD_dX[i] = elem_ab[elem_part[i]] *rad_rec_z[i];
198  mmw1 += CoolCoeffs.dmuN_dX[i]*v[NFLX+i]; /* Numerator part of mu */
199  mmw2 += CoolCoeffs.dmuD_dX[i]*v[NFLX+i]; /* Denominator part of mu */
200  }
201 
202 /* -- Add contributions from ionized H -- */
203 
205  CoolCoeffs.dmuD_dX[0] += -2.0*elem_ab[el_H];
206 
207  mmw1 += elem_mass[0]*elem_ab[el_H]*(1.0 - v[X_HI]);
208  mmw2 += elem_ab[el_H]*(1.0 - v[X_HI])*2.;
209 
210  CoolCoeffs.muN = mmw1;
211  CoolCoeffs.muD = mmw2;
212 
213  if (mmw1 != mmw1) {
214  print(">>> Error! MMW1 NaN! %ld\n",g_stepNumber);
215  for (i = 0; i < NIONS; i++) {
216  print ("%d %10.4e\n",i,v[NFLX+i]);
217  }
218  QUIT_PLUTO(1);
219  }
220  if (mmw2 != mmw2) {
221  print(">>> Error! MMW2 NaN!\n");
222  for (i = 0; i < NIONS; i++) {
223  print ("%d %10.4e\n",i,v[NFLX+i]);
224  }
225  QUIT_PLUTO(1);
226  }
227 
228  mu = mmw1/mmw2;
229 
230 #endif
231 
232  return mu;
233 }
#define MAX(a, b)
Definition: macros.h:101
#define NIONS_LOOP(n)
Definition: pluto.h:614
#define CONST_AH
Definition: pluto.h:250
#define FRAC_Z
Definition: pluto.h:556
const double elem_ab[8]
Definition: radiat.c:9
const double rad_rec_z[31]
Definition: radiat.c:24
COOL_COEFF CoolCoeffs
Definition: radiat.c:38
double v[NVAR]
Definition: eos.h:106
const double elem_mass[8]
Definition: radiat.c:14
#define MIN(a, b)
Definition: macros.h:104
long int g_stepNumber
Gives the current integration step number.
Definition: globals.h:97
#define X_HII
Definition: cooling.h:31
#define NFLX
Definition: mod_defs.h:32
double dmuN_dX[NIONS]
Definition: cooling_defs.h:53
#define NIONS
Definition: cooling.h:28
#define CONST_AZ
Mean atomic weight of heavy elements.
Definition: pluto.h:252
int j
Definition: analysis.c:2
Definition: cooling.h:110
const int elem_part[31]
Definition: radiat.c:16
void print(const char *fmt,...)
Definition: amrPluto.cpp:497
double dmuD_dX[NIONS]
Definition: cooling_defs.h:54
int i
Definition: analysis.c:2
#define X_H2
Definition: cooling.h:30
#define CONST_AHe
Atomic weight of Helium.
Definition: pluto.h:251
#define FRAC_He
Definition: pluto.h:555
#define QUIT_PLUTO(e_code)
Definition: macros.h:125
#define el_H
Definition: cooling_defs.h:71

Here is the call graph for this function: