Several f0s cases added, to be tested

This commit is contained in:
Vasco C. B. Ferreira
2026-07-30 16:06:22 +02:00
parent 67766d8bd1
commit e90b43d506
2 changed files with 48 additions and 13 deletions
+41 -11
View File
@@ -35,21 +35,51 @@ inline double f0(const double x, const double v,
const double eps = Parameters::EPS; const double eps = Parameters::EPS;
const double k = Parameters::WAVE_NR; const double k = Parameters::WAVE_NR;
double result; const double factor = Parameters::F0_FACTOR;
auto maxwell = [factor](double u, double v = 0, double v_th = 1) {
return 1 / v_th * factor *
std::exp(-0.5 * (u - v) * (u - v) / (v_th * v_th));
};
double prefactor; double prefactor;
double gaussian; double computed_max;
double result;
switch (f0_type) { switch (f0_type) {
case 0: case 0: // two-stream
prefactor = Parameters::F0_FACTOR * (1.0 + eps * std::cos(k * x)); {
gaussian = v * v * std::exp(-0.5 * v * v); computed_max = maxwell(v);
result = prefactor * gaussian; prefactor = (1.0 + eps * std::cos(k * x)) * v * v;
case 1: result = prefactor * computed_max;
// test break;
prefactor = Parameters::F0_FACTOR * (1.0 + eps * std::cos(k * x)); }
gaussian = v * v * std::exp(-0.5 * v * v); case 1: // Landau-damping
result = prefactor * gaussian; {
computed_max = maxwell(v);
prefactor = (1.0 + eps * std::cos(k * x));
result = prefactor * computed_max;
break;
}
case 2: // Maxwellian
{
result = maxwell(v);
break;
}
case 3: // Bump-on tail
{
const double beam_density = 0.05;
const double beam_v_th = 0.2;
const double beam_v = 3;
const double alpha = beam_density / (1 - beam_density);
const double beam_max = maxwell(v, beam_v, beam_v_th);
computed_max = maxwell(v);
result = (1 - alpha) * computed_max + alpha * beam_max;
break;
}
default:
throw std::invalid_argument("Invalid f0_type");
} }
return result; return result;
+7 -2
View File
@@ -23,10 +23,15 @@ constexpr double V_DOMAIN_RIGHT = 10.;
constexpr unsigned int NV = 128; constexpr unsigned int NV = 128;
constexpr double DV = std::abs(V_DOMAIN_RIGHT - V_DOMAIN_LEFT) / NV; constexpr double DV = std::abs(V_DOMAIN_RIGHT - V_DOMAIN_LEFT) / NV;
constexpr size_t f0_TYPE = 0; // for switch case // f0_TYPE:
// 0 -> twos-stream
// 1 -> landau-damping
// 2 -> maxwellian
// 3 -> bump-on-tail
constexpr size_t f0_TYPE = 3;
// deal.ii options // deal.ii options
constexpr unsigned int GLOBAL_REFINEMENT = 6; constexpr unsigned int GLOBAL_REFINEMENT = 7;
constexpr unsigned int FE_DEGREE = 3; constexpr unsigned int FE_DEGREE = 3;
constexpr unsigned int CONVERGENCE_ITERATIONS = 5000; constexpr unsigned int CONVERGENCE_ITERATIONS = 5000;
constexpr double CONVERGENCE_LIMIT = 1e-8; constexpr double CONVERGENCE_LIMIT = 1e-8;