include/pops/validation/physics/two_fluid_isothermal.hpp Source FileΒΆ

adc_cpp: include/pops/validation/physics/two_fluid_isothermal.hpp Source File
adc_cpp 0.3.0
Model-free C++23 core for coupled hyperbolic-elliptic systems on adaptive (AMR) meshes, with MPI and GPU (Kokkos) backends
two_fluid_isothermal.hpp
Go to the documentation of this file.
1#pragma once
2
12
14
15#include <cmath>
16
17namespace pops::validation {
18
45 Real cse2k2 = 0, csi2k2 = 0;
46
54 POPS_HD void explicit_step(Real& Ae, Real& Ai, Real& Be, Real& Bi, Real dt) const {
55 Be += dt * (-cse2k2 * Ae);
56 Bi += dt * (-csi2k2 * Ai);
57 }
58
69 POPS_HD void implicit_solve(Real& Ae, Real& Ai, Real& Be, Real& Bi, Real dt) const {
70 const Real wpe2 = omega_pe * omega_pe, wpi2 = omega_pi * omega_pi, d2 = dt * dt;
71 const Real re = Ae + dt * Be, ri = Ai + dt * Bi; // known right-hand sides
72 const Real a = 1 + d2 * wpe2, b = -d2 * wpe2; // I - dt^2 M_s
73 const Real c = -d2 * wpi2, dd = 1 + d2 * wpi2;
74 const Real det = a * dd - b * c;
75 Ae = (dd * re - b * ri) / det;
76 Ai = (-c * re + a * ri) / det;
77 Be = Be + dt * (-wpe2 * Ae + wpe2 * Ai); // B* + dt M_s A^{n+1}
78 Bi = Bi + dt * (wpi2 * Ae - wpi2 * Ai);
79 }
80
87 void dispersion(Real& w_fast, Real& w_slow) const {
88 const Real wpe2 = omega_pe * omega_pe, wpi2 = omega_pi * omega_pi;
89 const Real S = cse2k2 + csi2k2 + wpe2 + wpi2; // = w_fast^2 + w_slow^2
90 const Real P = cse2k2 * csi2k2 + wpe2 * csi2k2 + wpi2 * cse2k2; // = product
91 const Real disc = std::sqrt(std::fmax(S * S - 4 * P, Real(0)));
92 w_fast = std::sqrt(Real(0.5) * (S + disc));
93 w_slow = std::sqrt(std::fmax(Real(0.5) * (S - disc), Real(0)));
94 }
95};
96
97} // namespace pops::validation
Definition advection_diffusion.hpp:22
double Real
Definition types.hpp:30
Isothermal two-fluid electrostatic, linear mode (single Fourier k).
Definition two_fluid_isothermal.hpp:43
Real omega_pe
Definition two_fluid_isothermal.hpp:44
void dispersion(Real &w_fast, Real &w_slow) const
Roots of the dispersion relation, w_fast (Langmuir) >= w_slow (ion-acoustic) >= 0.
Definition two_fluid_isothermal.hpp:87
Real csi2k2
c_se^2 k^2, c_si^2 k^2 (acoustic terms)
Definition two_fluid_isothermal.hpp:45
Real omega_pi
plasma frequencies electron / ion
Definition two_fluid_isothermal.hpp:44
POPS_HD void explicit_step(Real &Ae, Real &Ai, Real &Be, Real &Bi, Real dt) const
Explicit step (slow acoustic term) in place: B_s += dt (-c_s^2 k^2 A_s).
Definition two_fluid_isothermal.hpp:54
Real cse2k2
Definition two_fluid_isothermal.hpp:45
POPS_HD void implicit_solve(Real &Ae, Real &Ai, Real &Be, Real &Bi, Real dt) const
Implicit step (stiff plasma term) in place: (A,B) <- (A*,B*) + dt S.
Definition two_fluid_isothermal.hpp:69
Base scalar types and the POPS_HD macro (host+device portability).
#define POPS_HD
Definition types.hpp:25