MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ make_radiation_coefficients()

MAYAFLUX_API std::optional< RadiationCoefficients > MayaFlux::Kinesis::Acoustics::make_radiation_coefficients ( const RadiationSpec & spec,
double end_area,
double end_pressure_gain )
nodiscardnoexcept

Prepare the coefficients of a radiating end.

Parameters
specNetwork constants, end radius, air constants and time step
end_areaArea of the bore at the end plane, pi a^2 of the end radius
end_pressure_gainGain of the last pressure point from DuctGrid
Returns
The coefficients, or nothing when any value is not positive and finite

Definition at line 5 of file Radiation.cpp.

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)
13 || !positive(spec.radius) || !positive(spec.sound_speed) || !positive(spec.air_density)
14 || !positive(spec.time_step) || !positive(end_area) || !positive(end_pressure_gain)) {
15 return std::nullopt;
16 }
17
18 const double c = spec.sound_speed;
19 const double a = spec.radius;
20 const double k = spec.time_step;
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}