criptic v1
Cosmic Ray Interstellar Propagation Tool using Itô Calculus
Loading...
Searching...
No Matches
SplitMonopole.H
Go to the documentation of this file.
1
14#ifndef _SPLITMONOPOLE_H_
15#define _SPLITMONOPOLE_H_
16
17#include "Gas.H"
18#include "../IO/ParmParser.H"
19
20namespace criptic {
21 namespace gas {
22
33 class SplitMonopole : public Gas {
34
35 public:
36
42
43 // Read data from ParmParser
44 pp.get("gas.r0", r0);
45 pp.get("gas.rho0", rho0);
46 pp.get("gas.krho", krho);
47 pp.get("gas.chi", chi);
48 pp.get("gas.B0", B0);
49 rFlat = 0.0;
50 pp.query("gas.rflat", rFlat);
51
52 }
53
57 virtual ~SplitMonopole() { };
58
65 virtual GasData gasData(const RealVec &x,
66 const Real t) const {
67 GasData gd;
68 Real r = x.mag();
69 Real rfac = r > rFlat ? r / r0 : rFlat / r0;
70 RealVec rhat = x / r;
71
72 // Set gas properties
73 gd.den = rho0 * pow(rfac, krho);
74 gd.ionDen = gd.den * chi;
75 gd.dx = r0;
76 gd.v = zeroVec;
77 gd.B = B0 / (rfac * rfac) * rhat;
78 if (x[2] < 0) gd.B = -gd.B;
80
81 // Set gradient properties; note that B = B0 (r/r0)^-2
82 // \hat{r}, and with a bit of algebra one can show that
83 // dB_i / dx_j = B / r^3 (r^2 delta_ij - 3 x_i x_j)
84 if (r > rFlat)
85 gd.denGrad = rho0 * krho * pow(rfac, krho) * rhat / r;
86 else
87 gd.denGrad = zeroVec;
88 gd.ionDenGrad = gd.denGrad * chi;
89 gd.vGrad = zeroTensor;
90 if (r > rFlat)
91 gd.BGrad = gd.B.mag() *
92 (identityTensor/r - 3 * outer(x, x) / (r*r*r));
93 else
94 gd.BGrad = zeroTensor;
95 if (x[2] < 0) gd.BGrad = -gd.BGrad;
96
97 // Return
98 return gd;
99 }
100
111 virtual void frame(const RealVec &x,
112 const Real t,
113 RealVec& v,
114 TNBBasis& tnb) const {
115 v = 0.0;
116 tnb.eT = x.unit();
117 if (x[2] < 0) tnb.eT = -tnb.eT;
118 if (tnb.eT[0] == 0 && tnb.eT[1] == 0) {
119 tnb.eN = xHat;
120 tnb.eB = yHat;
121 } else {
122 tnb.eN = tnb.eT.cross(xHat).unit();
123 tnb.eB = tnb.eT.cross(tnb.eN);
124 }
125 }
126
127 private:
128
136 };
137 }
138}
139#endif
140// _SPLITMONOPOLE_H_
Interface used to describe background gas.
Class to parse the criptic input deck.
Definition ParmParser.H:37
void get(const std::string &name, int &val) const
Return an integer-valued keyword.
Definition ParmParser.cpp:129
bool query(const std::string &name, T &val) const
Return a keyword, or return false if not available.
Definition ParmParser.cpp:299
Real mag() const
Computes the magnitude of the vector.
Definition Vec3.H:470
auto cross(const Vec3< U > &a) const -> Vec3< decltype(this->v[0]+a[0])>
Returns the cross product of this vector with another vector.
Definition Vec3.H:585
Vec3< Real > unit() const
Returns a unit vector parallel to the vector.
Definition Vec3.H:478
Trivial class to hold gas data.
Definition GasData.H:29
Real den
Definition GasData.H:36
void setAtomicComposition()
Set reasonable abundances for atomic ISM.
Definition GasData.H:175
RealVec v
Definition GasData.H:38
RealTensor2 vGrad
Definition GasData.H:44
Real dx
Definition GasData.H:33
RealVec B
Definition GasData.H:39
RealVec denGrad
Definition GasData.H:42
RealVec ionDenGrad
Definition GasData.H:43
Real ionDen
Definition GasData.H:37
RealTensor2 BGrad
Definition GasData.H:45
Interface class to describe background gas.
Definition Gas.H:44
A class to describe a gas with a split monopole field.
Definition SplitMonopole.H:33
Real chi
Definition SplitMonopole.H:133
virtual void frame(const RealVec &x, const Real t, RealVec &v, TNBBasis &tnb) const
Compute the comoving TNB frame for the gas.
Definition SplitMonopole.H:111
virtual ~SplitMonopole()
Virtual destructor – does nothing.
Definition SplitMonopole.H:57
Real B0
Definition SplitMonopole.H:134
virtual GasData gasData(const RealVec &x, const Real t) const
Return background gas state.
Definition SplitMonopole.H:65
SplitMonopole(const ParmParser &pp)
Construct a split monopole gas from the input deck.
Definition SplitMonopole.H:41
Real r0
Definition SplitMonopole.H:129
Real rho0
Definition SplitMonopole.H:131
Real rFlat
Definition SplitMonopole.H:130
Real krho
Definition SplitMonopole.H:132
The primary namespace for criptic objects.
Definition AdvancePacket.H:25
static const RealVec yHat(0, 1, 0)
static const criptic::RealTensor2 identityTensor(1, 0, 0, 0, 1, 0, 0, 0, 1)
static const RealVec xHat(1, 0, 0)
criptic::RealTensor2 outer(const criptic::RealVec &v1, const criptic::RealVec &v2)
Compute the outer product of two RealVec objects.
Definition RealTensor2.H:887
double Real
Definition Types.H:38
static const criptic::RealTensor2 zeroTensor(0, 0, 0, 0, 0, 0, 0, 0, 0)
static const RealVec zeroVec(0, 0, 0)
Structure to hold TNB basis data.
Definition RealTensor2.H:898
RealVec eB
Definition RealTensor2.H:901
RealVec eN
Definition RealTensor2.H:900
RealVec eT
Definition RealTensor2.H:899