Prepare the coefficients of a radiating end.
7{
8 const auto positive = [](double value) { return std::isfinite(value) && value > 0.0; };
9
10 const auto [gamma, lambda, theta] = spec.
model;
11
12 if (!positive(gamma) || !positive(lambda) || !positive(theta)
14 || !positive(spec.
time_step) || !positive(end_area) || !positive(end_pressure_gain)) {
15 return std::nullopt;
16 }
17
19 const double a = spec.
radius;
21 const double impedance = spec.
air_density * c / end_area;
22
23 const double inductance = lambda * (a / c) * impedance;
24 const double memory_scale = 2.0 * theta * a / (c * k);
25 const double denominator = 1.0 + 1.0 / gamma + memory_scale;
26 const double branch_weight = 1.0 / denominator;
27 const double branch_memory = memory_scale / denominator;
28
29 RadiationCoefficients coefficients;
30 coefficients.inductor_gain = k / inductance;
31 coefficients.branch_weight = branch_weight;
32 coefficients.branch_memory = branch_memory;
33 coefficients.memory_conductance = branch_memory / impedance;
34 coefficients.conductance = 0.5 * k / inductance + (1.0 - branch_weight) / impedance;
35 coefficients.end_half_gain = 0.5 * end_pressure_gain;
36 coefficients.reciprocal = 1.0 / (1.0 + coefficients.end_half_gain * coefficients.conductance);
37 return coefficients;
38}