criptic v1
Cosmic Ray Interstellar Propagation Tool using Itô Calculus
Loading...
Searching...
No Matches
Propagation.H
Go to the documentation of this file.
1
14#ifndef _PROPAGATION_H_
15#define _PROPAGATION_H_
16
17#include "../Core/CRPacket.H"
18#include "../Core/FieldQty.H"
19#include "../Gas/Gas.H"
20#include "../IO/ParmParser.H"
21#include "../Utils/Types.H"
22#include "../Utils/Vec3.H"
23
24namespace criptic {
25
34
38 namespace propagation {
39
46 typedef struct {
50#ifdef TRACK_PITCH_ANGLE
51 Real kMu;
52#else
54#endif
63#ifdef TRACK_PITCH_ANGLE
64 Real dkMudMu;
65#else
67#endif
69
80
81 public:
82
88 if (!pp.query("cr.enforceBohmLimit", enforceBohmLimit)) {
90 }
91 if (!pp.query("cr.kParMax", kParMax)) kParMax = 0;
92 if (!pp.query("cr.kPerpMax", kPerpMax)) kPerpMax = 0;
93 if (!pp.query("cr.kPPMax", kPPMax)) kPPMax = 0;
94 if (!pp.query("cr.vDriftMax", vDriftMax)) vDriftMax = 1.0;
95 }
96
100 virtual ~Propagation() { };
101
113 virtual FieldQtyNeedType fieldQtyNeed() const = 0;
114
129 virtual PropagationData
131 const Real t,
132 const gas::GasData& gd,
133 const CRPacket& packet,
134 const FieldQty& qty,
135 const FieldQtyGrad& qtyGrad) const = 0;
136
148 const gas::GasData& gd,
149 const CRPacket& packet,
150 PropagationData& pd) const
151 {
152 if (enforceBohmLimit) {
153 const Real Bmag = gd.B.mag();
154 const Real kBohm = packet.rG(Bmag) *
155 packet.v() * constants::c / 3;
156 if (pd.kPar < kBohm) {
157 pd.kPar = kBohm;
158 pd.kParGrad = -kBohm * gd.BGrad.contract2(gd.B) / (Bmag*Bmag);
159 }
160 }
161 if (vDriftMax > 0.0) {
162 const Real facPar = pd.kParGrad.mag() / (vDriftMax * constants::c);
163 if (facPar > 1.0) {
164 pd.kParGrad /= facPar;
165 pd.kPerpGrad /= facPar;
166 }
167 const Real facPerp = pd.kPerpGrad.mag() / (vDriftMax * constants::c);
168 if (facPerp > 1.0) {
169 pd.kParGrad /= facPerp;
170 pd.kPerpGrad /= facPerp;
171 }
172 const Real facStr = fabs(pd.vStr + packet.p * pd.dvStr_dp /3) /
174 if (facStr > 1.0) {
175 pd.vStr /= facStr;
176 pd.dvStr_dp /= facStr;
177 }
178 }
179 if (kParMax > 0 && pd.kPar > kParMax) {
180 pd.kPar = kParMax;
181 pd.kParGrad = zeroVec;
182 }
183 if (kPerpMax > 0 && pd.kPerp > kPerpMax) {
184 pd.kPerp = kPerpMax;
185 pd.kPerpGrad = zeroVec;
186 }
187 if (kPPMax > 0 && pd.kPP > kPPMax) {
188 pd.kPP = kPPMax;
189 pd.dkPP_dp = 0;
190 }
191 }
192
193
194 private:
195
201 };
202 }
203}
204
205#endif
206// _PROPAGATION_H_
A class that holds data to describe a CR packet.
Definition CRPacket.H:28
Real rG(const Real B) const
Compute gyroradius of packet.
Definition CRPacket.H:161
Real v() const
Velocity of packet.
Definition CRPacket.H:118
Real p
Definition CRPacket.H:47
Class to hold and compute gradients of field quantities.
Definition FieldQty.H:293
Class to hold and compute field quantities.
Definition FieldQty.H:53
Class to parse the criptic input deck.
Definition ParmParser.H:37
bool query(const std::string &name, T &val) const
Return a keyword, or return false if not available.
Definition ParmParser.cpp:299
RealVec contract2(const RealVec &v) const
Compute the tensor contraction v_j T_ij.
Definition RealTensor2.H:385
Real mag() const
Computes the magnitude of the vector.
Definition Vec3.H:470
Trivial class to hold gas data.
Definition GasData.H:29
RealVec B
Definition GasData.H:39
RealTensor2 BGrad
Definition GasData.H:45
Interface to describe the CR propagation model.
Definition Propagation.H:79
virtual ~Propagation()
Empty virtual destructor.
Definition Propagation.H:100
Real vDriftMax
Definition Propagation.H:200
Real kPerpMax
Definition Propagation.H:198
virtual FieldQtyNeedType fieldQtyNeed() const =0
Access to field quantities needed?
void applyLimits(const gas::GasData &gd, const CRPacket &packet, PropagationData &pd) const
Apply the Bohm limit and manually-set limits.
Definition Propagation.H:147
Propagation(const ParmParser &pp)
Constructor.
Definition Propagation.H:87
virtual PropagationData operator()(const RealVec &x, const Real t, const gas::GasData &gd, const CRPacket &packet, const FieldQty &qty, const FieldQtyGrad &qtyGrad) const =0
Return the propagation data.
Real kParMax
Definition Propagation.H:197
Real kPPMax
Definition Propagation.H:199
int enforceBohmLimit
Definition Propagation.H:196
static constexpr Real c
Definition Constants.H:34
The primary namespace for criptic objects.
Definition AdvancePacket.H:25
FieldQtyNeedType
Enum of types of field quantities to be computed.
Definition Propagation.H:29
@ needFieldQty
Definition Propagation.H:31
@ needFieldQtyGrad
Definition Propagation.H:32
@ noFieldQty
Definition Propagation.H:30
double Real
Definition Types.H:38
static const RealVec zeroVec(0, 0, 0)
Structure contain the requires propagation parameters.
Definition Propagation.H:46
Real kPP
Definition Propagation.H:49
RealVec kParGrad
Definition Propagation.H:59
Real dvStr_dp
Definition Propagation.H:57
Real kPar
Definition Propagation.H:47
Real vStr
Definition Propagation.H:53
Real dkPP_dp
Definition Propagation.H:55
RealVec vStrGrad
Definition Propagation.H:66
RealVec kPerpGrad
Definition Propagation.H:61
Real kPerp
Definition Propagation.H:48