MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Radiation.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file Radiation.hpp
5 * @brief Open end of a bore as a passive second order radiation load.
6 *
7 * The end sees an inertance L, standing for the mass of air moving just
8 * outside, in parallel with a series pair: a resistance R1 equal to the
9 * bore's characteristic impedance, then a resistance R2 in parallel with a
10 * capacitance C. Low frequencies are reflected by L, which gives the end
11 * correction, and high frequencies pass through R1 into the room. This is
12 * the lumped network of Bilbao and Chick, and its impedance is exactly the
13 * low order Pade fit to the Levine and Schwinger reflection coefficient
14 * given by Silva et al., with
15 *
16 * L = lambda (a / c) Zc, R1 = Zc, R2 = gamma Zc, C = theta (a / c) / Zc
17 *
18 * for end radius a and bore impedance Zc = rho c / S. The model is
19 * dimensionless in gamma, lambda and theta, so a flanged end is another
20 * set of three numbers.
21 *
22 * The update is the trapezoidal rule on every element, in the end pressure
23 * averaged over the step. That is exact for the energy of a linear passive
24 * network, so the load can only absorb energy, and the end cell and the
25 * load are solved together in closed form with no iteration.
26 */
27
29
30/**
31 * @brief The three dimensionless constants of the radiation network, as
32 * gamma, lambda and theta.
33 */
34using RadiationModel = std::array<double, 3>;
35
36/**
37 * @brief Network constants from the numerator and denominator of the Pade
38 * reflection coefficient R = -(1 - n1 s) / (1 - d1 s + d2 s^2).
39 *
40 * With s = j k a. Fits the model's impedance to that reflection, matching
41 * both the end correction and the radiation resistance at low frequency.
42 * The mapping is solved from the impedance rather than taken from Eq. (20)
43 * of Silva et al., which carries an erratum.
44 */
45[[nodiscard]] constexpr RadiationModel radiation_model_from_pade(double n1, double d1, double d2) noexcept
46{
47 const double lambda = 0.5 * (d1 - n1);
48 const double gamma = 2.0 * lambda * lambda / (lambda * (d1 + n1) - d2) - 1.0;
49 const double theta = (0.5 * (d1 + n1) * (1.0 + gamma) - lambda) / gamma;
50 return { gamma, lambda, theta };
51}
52
53/** @brief Unflanged circular pipe, end correction 0.6133 a. Accurate to about 8 percent in modulus up to ka of 2. */
54inline constexpr RadiationModel unflanged_radiation = radiation_model_from_pade(0.167, 1.393, 0.457);
55
56/** @brief Pipe in an infinite flange, end correction 0.8216 a. */
57inline constexpr RadiationModel flanged_radiation = radiation_model_from_pade(0.182, 1.825, 0.649);
58
59/**
60 * @struct RadiationSpec
61 * @brief What the network constants are scaled by.
62 */
65 double radius {};
66 double sound_speed { 343.0 };
67 double air_density { 1.2 };
68 double time_step {};
69};
70
71/**
72 * @struct RadiationCoefficients
73 * @brief Prepared coefficients of one end, built once per bore or step change.
74 */
76 double inductor_gain {};
77 double branch_weight {};
78 double branch_memory {};
80 double conductance {};
81 double end_half_gain {};
82 double reciprocal {};
83};
84
85/**
86 * @struct RadiationState
87 * @brief Inductor flow and branch pressure, zero at rest.
88 */
90 double inductor_flow {};
91 double branch_pressure {};
92};
93
94/**
95 * @brief Prepare the coefficients of a radiating end.
96 * @param spec Network constants, end radius, air constants and time step
97 * @param end_area Area of the bore at the end plane, pi a^2 of the end radius
98 * @param end_pressure_gain Gain of the last pressure point from DuctGrid
99 * @return The coefficients, or nothing when any value is not positive and finite
100 */
101[[nodiscard]] MAYAFLUX_API std::optional<RadiationCoefficients> make_radiation_coefficients(
102 const RadiationSpec& spec, double end_area, double end_pressure_gain) noexcept;
103
104/**
105 * @brief Advance the end cell and the load one sample.
106 * @param coefficients From make_radiation_coefficients
107 * @param state Updated in place
108 * @param end_pressure Pressure of the last point at the start of the sample
109 * @param upstream_flow Volume velocity of the last half section, from the same sample
110 * @return The end pressure after the sample, then the flow out of the bore at
111 * the half step
112 */
113[[nodiscard]] inline std::pair<double, double> radiation_step(
114 const RadiationCoefficients& coefficients,
115 RadiationState& state,
116 double end_pressure,
117 double upstream_flow) noexcept
118{
119 const double mean = (end_pressure
120 + coefficients.end_half_gain
121 * (upstream_flow - state.inductor_flow
122 + coefficients.memory_conductance * state.branch_pressure))
123 * coefficients.reciprocal;
124
125 const double flow = state.inductor_flow
126 - coefficients.memory_conductance * state.branch_pressure
127 + coefficients.conductance * mean;
128
129 const double branch_mean = coefficients.branch_weight * mean
130 + coefficients.branch_memory * state.branch_pressure;
131
132 state.inductor_flow += coefficients.inductor_gain * mean;
133 state.branch_pressure = 2.0 * branch_mean - state.branch_pressure;
134
135 return { 2.0 * mean - end_pressure, flow };
136}
137
138/**
139 * @brief Pressure radiated into free space by a flow out of the end.
140 * @param flow Flow at the current sample
141 * @param previous_flow Flow at the previous sample
142 * @param time_step Time step in seconds
143 * @param air_density Air density
144 * @param distance Distance from the end in metres
145 * @return rho / (4 pi r) times the rate of change of flow, a point source in
146 * a free field
147 */
148[[nodiscard]] constexpr double radiated_pressure(
149 double flow, double previous_flow, double time_step, double air_density, double distance = 1.0) noexcept
150{
151 return air_density / (4.0 * std::numbers::pi * distance) * (flow - previous_flow) / time_step;
152}
153
154} // namespace MayaFlux::Kinesis::Acoustics
constexpr RadiationModel flanged_radiation
Pipe in an infinite flange, end correction 0.8216 a.
Definition Radiation.hpp:57
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
std::array< double, 3 > RadiationModel
The three dimensionless constants of the radiation network, as gamma, lambda and theta.
Definition Radiation.hpp:34
constexpr RadiationModel radiation_model_from_pade(double n1, double d1, double d2) noexcept
Network constants from the numerator and denominator of the Pade reflection coefficient R = -(1 - n1 ...
Definition Radiation.hpp:45
constexpr RadiationModel unflanged_radiation
Unflanged circular pipe, end correction 0.6133 a.
Definition Radiation.hpp:54
constexpr double radiated_pressure(double flow, double previous_flow, double time_step, double air_density, double distance=1.0) noexcept
Pressure radiated into free space by a flow out of the end.
std::pair< double, double > radiation_step(const RadiationCoefficients &coefficients, RadiationState &state, double end_pressure, double upstream_flow) noexcept
Advance the end cell and the load one sample.
SpatialField distance(const glm::vec3 &anchor, float radius, DistanceMetric metric=DistanceMetric::EUCLIDEAN)
Normalized distance from an anchor point using the specified metric.
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
Inductor flow and branch pressure, zero at rest.
Definition Radiation.hpp:89