criptic v1
Cosmic Ray Interstellar Propagation Tool using Itô Calculus
Loading...
Searching...
No Matches
GasData.H
Go to the documentation of this file.
1
8#ifndef _GASDATA_H_
9#define _GASDATA_H_
10
11#include <cmath>
12#include <vector>
13#include "../Utils/Constants.H"
14#include "../Utils/Types.H"
15#include "../Utils/RealTensor2.H"
16#include "../Utils/Vec3.H"
17
18namespace criptic {
19
20 namespace gas {
21
29 class GasData {
30
31 public:
32
35 // Quantities
41 // Gradients of quantities
47 // Composition information -- needed for loss calculations
56 // Radiation field information -- needed for inverse Compton losses
57 std::vector<Real> TBB;
58 std::vector<Real> WBB;
60 // Trivial convenience methods
69 Real UB() const {
70#ifdef CRIPTIC_UNITS_CGS
71 return B.mag2() / (8 * M_PI);
72#else
73 return B.mag2() / (2 * constants::mu0);
74#endif
75 }
76
84 constexpr Real xH2() const {
85 return 0.5 * (1 - xH0 - xHp);
86 }
87
92 constexpr Real xHe() const {
93 return xHe0 + xHep + xHep2;
94 }
95
100 constexpr Real X() const {
101 return (1.0 - Z) / (1.0 + 4.0 * (xHe0 + xHep + xHep2));
102 }
103
108 constexpr Real Y() const {
109 return (1.0 - Z) * 4.0 * xHe() / (1.0 + 4.0 * xHe());
110 }
111
120 constexpr Real AxZ() const {
121 return (1.0 + 4.0 * xHe()) * Z / (1.0 - Z);
122 }
123
128 constexpr Real muH() const {
129 return 1.0 / X();
130 }
131
139 constexpr Real mue() const {
140 return (1.0 + 4.0 * xHe() + AxZ()) /
141 (1.0 + 2.0 * xHe() + 0.5 * AxZ());
142 }
143
148 constexpr Real nH() const {
149 return den / (muH() * constants::mH);
150 }
151
159 constexpr Real neTot() const {
160 return den / (mue() * constants::mH);
161 }
162
167 constexpr Real neFree() const {
168 return xe * nH();
169 }
170
176 xH0 = 1.0 - 1.0e-2;
177 xHp = xe = 1.0e-2;
178 xHe0 = 0.0955;
179 xHep = xHep2 = 0.0;
180 Z = 0.0199;
181 }
182
188 xH0 = xHp = 0.0;
189 xe = 1.0e-6;
190 xHe0 = 0.0955;
191 xHep = xHep2 = 0.0;
192 Z = 0.0199;
193 }
194
200 xH0 = xHe0 = 0.0; // No neutral species
201 xHp = 1.0; // H is fully ionized
202 xHep = 0.0; // Treat He as fully ionized
203 xHep2 = 0.0955;
204 xe = 1 + 2 * 0.0955; // Asplund+ (2009) He abundance, fully ionized
205 Z = 0.0199;
206 }
207
208 // Define the the operations of multiplication by a scalar and
209 // addition of two GasData object. These are intended to make it
210 // possible to take weighted averages of GasData objects.
211
221 GasData operator*(const Real& w) const {
222 GasData r;
223 r.dx = w * dx;
224 r.den = w * den;
225 r.ionDen = w * ionDen;
226 r.v = w * v;
227 r.B = w * B;
228 r.denGrad = w * denGrad;
229 r.ionDenGrad = w * ionDenGrad;
230 r.vGrad = w * vGrad;
231 r.BGrad = w * BGrad;
232 r.xH0 = w * xH0;
233 r.xHp = w * xHp;
234 r.xHe0 = w * xHe0;
235 r.xHep = w * xHep;
236 r.xHep2 = w * xHep2;
237 r.xe = w * xe;
238 r.Z = w * Z;
239 r.WBB = WBB;
240 for (IdxType i=0; i<WBB.size(); i++) r.WBB[i] *= w;
241 r.TBB = TBB;
242 return r;
243 }
244
256 GasData operator+(const GasData& gd) const {
257 GasData r;
258 r.dx = gd.dx + dx;
259 r.den = gd.den + den;
260 r.ionDen = gd.ionDen + ionDen;
261 r.v = gd.v + v;
262 r.B = gd.B + B;
263 r.denGrad = gd.denGrad + denGrad;
265 r.vGrad = gd.vGrad + vGrad;
266 r.BGrad = gd.BGrad + BGrad;
267 r.xH0 = gd.xH0 + xH0;
268 r.xHp = gd.xHp + xHp;
269 r.xHe0 = gd.xHe0 + xHe0;
270 r.xHep = gd.xHep + xHep;
271 r.xHep2 = gd.xHep2 + xHep2;
272 r.xe = gd.xe + xe;
273 r.Z = gd.Z + Z;
274 r.WBB = gd.WBB;
275 for (IdxType i=0; i<WBB.size(); i++) r.WBB[i] += WBB[i];
276 r.TBB = TBB;
277 return r;
278 }
279 };
280
281 // Scalar multiplication and addition operators
291 inline GasData operator*(const Real& w,
292 const GasData& gd) {
293 return gd * w;
294 }
295 }
296}
297
298#endif
299// _GASDATA_H_
Class that represents a rank 2 tensor.
Definition RealTensor2.H:34
constexpr T mag2() const
Computes the squared magnitude of the vector.
Definition Vec3.H:462
Trivial class to hold gas data.
Definition GasData.H:29
constexpr Real Y() const
Compute He abundance by mass.
Definition GasData.H:108
Real xHep
Definition GasData.H:51
Real Z
Definition GasData.H:54
Real den
Definition GasData.H:36
constexpr Real nH() const
Compute number density of H nuclei.
Definition GasData.H:148
void setAtomicComposition()
Set reasonable abundances for atomic ISM.
Definition GasData.H:175
Real UB() const
Compute magnetic energy density.
Definition GasData.H:69
Real xe
Definition GasData.H:53
RealVec v
Definition GasData.H:38
RealTensor2 vGrad
Definition GasData.H:44
constexpr Real neTot() const
Compute total number density of electrons.
Definition GasData.H:159
GasData operator+(const GasData &gd) const
Add two GasData objects.
Definition GasData.H:256
void setIonizedComposition()
Set reasonable abundances for fully ionized ISM.
Definition GasData.H:199
constexpr Real muH() const
Compute mean mass per H nucleon.
Definition GasData.H:128
GasData operator*(const Real &w) const
Multiply by a scalar.
Definition GasData.H:221
Real xHp
Definition GasData.H:49
Real dx
Definition GasData.H:33
RealVec B
Definition GasData.H:39
constexpr Real AxZ() const
Return heavy element abundance times mean atomic mass.
Definition GasData.H:120
std::vector< Real > WBB
Definition GasData.H:58
constexpr Real X() const
Compute H abundance by mass.
Definition GasData.H:100
RealVec denGrad
Definition GasData.H:42
constexpr Real xHe() const
Compute total He abundance across all ionization states.
Definition GasData.H:92
constexpr Real mue() const
Compute mean mass per electron.
Definition GasData.H:139
Real xHep2
Definition GasData.H:52
constexpr Real neFree() const
Compute number density of free electrons.
Definition GasData.H:167
constexpr Real xH2() const
Compute H2 abundance.
Definition GasData.H:84
void setMolecularComposition()
Set reasonable abundances for molecular ISM.
Definition GasData.H:187
Real xHe0
Definition GasData.H:50
RealVec ionDenGrad
Definition GasData.H:43
Real ionDen
Definition GasData.H:37
std::vector< Real > TBB
Definition GasData.H:57
RealTensor2 BGrad
Definition GasData.H:45
Real xH0
Definition GasData.H:48
static constexpr Real mH
Definition Constants.H:144
GasData operator*(const Real &w, const GasData &gd)
Multiply a GasData object by a scalar.
Definition GasData.H:291
The primary namespace for criptic objects.
Definition AdvancePacket.H:25
std::vector< Real >::size_type IdxType
Definition Types.H:45
double Real
Definition Types.H:38