MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Radiation.cpp
Go to the documentation of this file.
1#include "Radiation.hpp"
2
4
5std::optional<RadiationCoefficients> make_radiation_coefficients(
6 const RadiationSpec& spec, double end_area, double end_pressure_gain) noexcept
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}
39
40} // namespace MayaFlux::Kinesis::Acoustics
Open end of a bore as a passive second order radiation load.
std::optional< RadiationCoefficients > make_radiation_coefficients(const RadiationSpec &spec, double end_area, double end_pressure_gain) noexcept
Prepare the coefficients of a radiating end.
Definition Radiation.cpp:5
Prepared coefficients of one end, built once per bore or step change.
Definition Radiation.hpp:75
What the network constants are scaled by.
Definition Radiation.hpp:63