WARPXM v1.10.0
Loading...
Searching...
No Matches
2d2v_kh_instability.h
Go to the documentation of this file.
1#ifndef kinetics2d2v_distribution_kelvin_helmholtz_instability_h
2#define kinetics2d2v_distribution_kelvin_helmholtz_instability_h
3
4// WARPXM includes
6
7// STL includes
8#include <cmath>
9
10namespace wxm
11{
12namespace apps
13{
14namespace functions
15{
16namespace kinetics
17{
18
25{
26public:
32
38
43 void setup(const WxCryptSet& wxc) override;
44
50 const std::vector<int>& getOutputVariableIndexes(int flag) const override
51 {
52 return _distribution;
53 }
54
62 void evaluate_function(const real* q,
63 const real* aux,
64 const solverVariables_t* pSV,
65 real* result) const override;
66
67 void bc_q_kinetic(const real* q_in,
68 const real* aux_in,
69 const solverVariables_t* pFV,
70 real* q_out) const override;
71
73 const std::vector<real>& xvec,
74 const std::vector<real>& a,
75 const std::vector<real>& b,
76 std::map<real, real>& cache)
77 {
78 if (cache.count(x)) {
79 return cache[x];
80 }
81
82 size_t n = xvec.size();
83 if ((a.size() != n) || (b.size() != 2))
84 {
85 throw WxExcept(
86 "wxm::apps::functions::kinetics::Kinetics2d2vKelvinHelmholtzInstability::"
87 "compute_spline_fit() : Vector Size Error!\n");
88 }
89
90 real val = 0.0;
91 for (int i = 0; i < n; i++)
92 {
93 val += a[i] * std::pow(std::fabs(x - xvec[i]), 3);
94 }
95 val += b[0] + b[1] * x;
96
97 cache[x] = val;
98
99 return val;
100 }
101
102protected:
103 // Helper Functions
105 {
106 return -_Ex0 * _d_width / 2.0 * std::log(1.0 + std::exp(2.0 * x / _d_width));
107 }
108
110 {
111 return -_Ex0 / _d_width / (1.0 + std::cosh(2.0 * x / _d_width));
112 }
113
114 real compute_gi(const real x) const
115 {
116 return std::pow(1.0 + std::exp(2.0 * x / _d_width), _b_gradient * _d_width / 2.0);
117 }
118
119 real compute_ge(const real x) const
120 {
121 const real ni_aux_fit = compute_spline_fit(
123
124 return -_Zi / _Ze * ni_aux_fit - 1.0 / _Ze * _omega_c_tau / _omega_p_tau /
127 }
128
129 void compute_fi(const solverVariables_t* pSV, real* result) const;
130
131 void compute_fe(const solverVariables_t* pSV, real* result) const;
132
133 // Variables
134 std::vector<int> _distribution; // output variable
135
136 std::string _species; // "ions" or "electrons"
137 real _Ex0; // E0 / omega_c_tau
138 real _d_width; // shear layer width
139 real _b_gradient; // density gradient term
141 real _Zi; // ion charge
142 real _Ze; // electron charge, should only ever be -1
143 real _Ai; // ion mass
144 real _Ae; // electron mass
145 real _Omega_c_i; // omega_c_tau * Zi / Ai
146 real _Omega_c_e; // omega_c_tau * Ze / Ae
147 real _omega_p_tau; // (omega_p tau)
148 real _omega_c_tau; // (omega_c tau)
149
150 std::vector<real> _perturbation_center;
153
154 std::vector<real> _ni_aux_fit_xvec;
155 std::vector<real> _ni_aux_fit_acoeffs;
156 std::vector<real> _ni_aux_fit_bcoeffs;
157
158 std::vector<real> _phi_fit_xvec;
159 std::vector<real> _phi_fit_acoeffs;
160 std::vector<real> _phi_fit_bcoeffs;
161
162 std::vector<real> _Ay_fit_xvec;
163 std::vector<real> _Ay_fit_acoeffs;
164 std::vector<real> _Ay_fit_bcoeffs;
165
166 mutable std::map<real, real> _Ay_fit_cache;
167 mutable std::map<real, real> _ni_aux_fit_cache;
168 mutable std::map<real, real> _phi_fit_cache;
169
170private:
172 operator=(const Kinetics2d2vKelvinHelmholtzInstability& var);
175};
176
177} // namespace kinetics
178} // namespace functions
179} // namespace apps
180} // namespace wxm
181
182#endif
Base Class for physics applications.
Definition: wmapplication.h:93
WxCryptSet extends WxCrypt by providing, in addition to name-value pairs, an set of named WxCryptSets...
Definition: wxcryptset.h:35
2D2V Kelvin-Helmholtz Instability Based on calculated kinetic equilibrium
Definition: 2d2v_kh_instability.h:25
void evaluate_function(const real *q, const real *aux, const solverVariables_t *pSV, real *result) const override
Redefinition of the function evaluator.
std::vector< real > _ni_aux_fit_xvec
Definition: 2d2v_kh_instability.h:154
std::vector< real > _ni_aux_fit_bcoeffs
Definition: 2d2v_kh_instability.h:156
void compute_fi(const solverVariables_t *pSV, real *result) const
std::vector< real > _phi_fit_acoeffs
Definition: 2d2v_kh_instability.h:159
std::vector< real > _phi_fit_xvec
Definition: 2d2v_kh_instability.h:158
void compute_fe(const solverVariables_t *pSV, real *result) const
real compute_phi_star_double_prime(const real x) const
Definition: 2d2v_kh_instability.h:109
void bc_q_kinetic(const real *q_in, const real *aux_in, const solverVariables_t *pFV, real *q_out) const override
std::map< real, real > _phi_fit_cache
Definition: 2d2v_kh_instability.h:168
std::map< real, real > _ni_aux_fit_cache
Definition: 2d2v_kh_instability.h:167
std::vector< real > _perturbation_center
Definition: 2d2v_kh_instability.h:150
std::vector< int > _distribution
Definition: 2d2v_kh_instability.h:134
real compute_ge(const real x) const
Definition: 2d2v_kh_instability.h:119
std::vector< real > _ni_aux_fit_acoeffs
Definition: 2d2v_kh_instability.h:155
std::vector< real > _Ay_fit_acoeffs
Definition: 2d2v_kh_instability.h:163
real _perturbation_amplitude
Definition: 2d2v_kh_instability.h:152
const std::vector< int > & getOutputVariableIndexes(int flag) const override
Grab output variable indices.
Definition: 2d2v_kh_instability.h:50
std::vector< real > _Ay_fit_bcoeffs
Definition: 2d2v_kh_instability.h:164
real _perturbation_wavelength
Definition: 2d2v_kh_instability.h:151
real compute_phi_star(const real x) const
Definition: 2d2v_kh_instability.h:104
std::vector< real > _Ay_fit_xvec
Definition: 2d2v_kh_instability.h:162
std::map< real, real > _Ay_fit_cache
Definition: 2d2v_kh_instability.h:166
std::string _species
Definition: 2d2v_kh_instability.h:136
static real compute_spline_fit(const real x, const std::vector< real > &xvec, const std::vector< real > &a, const std::vector< real > &b, std::map< real, real > &cache)
Definition: 2d2v_kh_instability.h:72
real compute_gi(const real x) const
Definition: 2d2v_kh_instability.h:114
std::vector< real > _phi_fit_bcoeffs
Definition: 2d2v_kh_instability.h:160
real _temperature_uniform
Definition: 2d2v_kh_instability.h:140
list apps
Definition: shock_tube.py:33
Base namespace for everything not included in the global namespace.
Definition: field_source.h:8
Definition: wmapplication.h:38
#define real
Definition: wmoclunstructuredreconstruction.h:11
wxm::lib::Except WxExcept
Definition: wxexcept.h:120