Aufgrund einer Wartung wird GitLab am 26.10. zwischen 8:00 und 9:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 26.10. between 8:00 and 9:00 am.

Commit 635a3caa authored by Armin Erraji's avatar Armin Erraji
Browse files

Added function for the calculation of the attenuation absorption in decibels...

Added function for the calculation of the attenuation absorption in decibels according to ISO 9613-1.
The air attenuation can also be calculated as an energetic factor between 0 and 1.
parent c8bcb3cb
...@@ -36,12 +36,26 @@ namespace ITABase ...@@ -36,12 +36,26 @@ namespace ITABase
* \param dFrequency Base frequency [Hz] * \param dFrequency Base frequency [Hz]
* \param fDistance Distance [m] * \param fDistance Distance [m]
* \param fTemperature Temperature [C] * \param fTemperature Temperature [C]
* \param fStaticPressure Static air pressure [Pa]
* \param fHumidity Relative humidity [%] * \param fHumidity Relative humidity [%]
* \param fStaticPressure Static air pressure [Pa]
* *
* @return Atmospheric absorption in dB * @return Atmospheric absorption in dB
*/ */
double AtmosphericAbsorption( double dFrequency, double dDistance, double dTemperature, double dStaticPressure, double dHumidity ); ITA_BASE_API double AtmosphericAbsorptionLevel( double dFrequency, double dDistance, double dTemperature, double dHumidity, double dStaticPressure = 101.325);
//! Calculates the atmospheric absorption after ISO 9613-1 for one frequency in linear factors (instead of decibels)
/**
* Standard: ISO 9613-1:1993
*
* \param dFrequency Base frequency [Hz]
* \param fDistance Distance [m]
* \param fTemperature Temperature [C]
* \param fHumidity Relative humidity [%]
* \param fStaticPressure Static air pressure [Pa]
*
* @return Atmospheric absorption in linear factors (instead of decibels)
*/
ITA_BASE_API double AtmosphericAbsorptionFactor(double dFrequency, double dDistance, double dTemperature, double dHumidity, double dStaticPressure = 101.325);
//! Calculates the atmospheric absorption after ISO 9613-1: A_{atm} (formula 8) in decibels //! Calculates the atmospheric absorption after ISO 9613-1: A_{atm} (formula 8) in decibels
/** /**
...@@ -50,13 +64,13 @@ namespace ITABase ...@@ -50,13 +64,13 @@ namespace ITABase
* \param oA_atm_dB Third-octave magnitude spectrum with atmospheric attenuation values in decibel * \param oA_atm_dB Third-octave magnitude spectrum with atmospheric attenuation values in decibel
* \param fDistance Distance [m] * \param fDistance Distance [m]
* \param fTemperature Temperature [C] * \param fTemperature Temperature [C]
* \param fStaticPressure Static air pressure [Pa]
* \param fHumidity Relative humidity [%] * \param fHumidity Relative humidity [%]
* \param fStaticPressure Static air pressure [Pa]
*/ */
void AtmosphericAbsorption( ITABase::CThirdOctaveDecibelMagnitudeSpectrum& oA_atm_dB, double dDistance, double dTemperature, double dStaticPressure, double dHumidity ); ITA_BASE_API void AtmosphericAbsorptionLevel( ITABase::CThirdOctaveDecibelMagnitudeSpectrum& oA_atm_dB, double dDistance, double dTemperature, double dHumidity, double dStaticPressure = 101.325);
//! Calculates the atmospheric absorption in linear factors (instead of decibels) //! Calculates the atmospheric absorption in linear factors (instead of decibels)
void AtmosphericAbsorption( ITABase::CThirdOctaveFactorMagnitudeSpectrum& oA_atm_factor, double dDistance, double dTemperature, double dStaticPressure, double dHumidity ); ITA_BASE_API void AtmosphericAbsorptionFactor( ITABase::CThirdOctaveFactorMagnitudeSpectrum& oA_atm_factor, double dDistance, double dTemperature, double dHumidity, double dStaticPressure = 101.325);
} }
} }
......
...@@ -7,68 +7,91 @@ ...@@ -7,68 +7,91 @@
#include <cassert> #include <cassert>
using namespace ITABase; using namespace ITABase;
using namespace ISO9613;
void AtmosphericAbsorption( ITABase::CThirdOctaveDecibelMagnitudeSpectrum& oA_atm_dB, double dDistance, double dTemperature, double dStaticPressure, double dHumidity )
{
// @todo schleife ber freqs
}
double AtmosphericAbsorption( double dFrequency, double dDistance, double dTemperature, double dStaticPressure, double dHumidity ) double ISO9613::AtmosphericAbsorptionLevel( double dFrequency, double dDistance, double dTemperature, double dHumidity, double dStaticPressure /*= 101.325*/)
{ {
// ISO 9613-1 Acoustics - Attenuation of sound during propagation outdoors // ISO 9613-1 Acoustics - Attenuation of sound during propagation outdoors
// Noch nicht fertig ....
ITA_EXCEPT0( NOT_IMPLEMENTED );
// Reference ambient atmospheric pressure (Standard Ambient Atmosphere) [kPa] // Reference ambient atmospheric pressure (Standard Ambient Atmosphere) [kPa]
// (Referenzatmosphrendruck Umgebung nach ISO Standard) // (Referenzatmosphrendruck Umgebung nach ISO Standard)
const double p_r = 101.325f; const double p_r = 101.325f;
const double p_a = 101.325f;
// Inital sound pressure amplitude [kPa] // Ambient atmospheric pressure [kPa]
const double p_i = p_r + 0.0f; const double p_a = dStaticPressure;
// Sound pressure amplitude [Pa]
const double p_t = 1.0f;
// Reference air temperature [K] // Reference air temperature [K]
const double T_0 = 273.15f + 20.0f; const double T_0 = 273.15 + 20.0;
// Temperature [K] used for equation (B.3)
const double T_01 = 273.15 + 0.01;
// Temperature [K] // Ambient atmospheric temperature [K]
const double T = 273.15f + dTemperature; const double T = 273.15 + dTemperature;
// Molar concentration dry air // Equations (B.3) and (B.2) of Annex B used for calculation of h in (B.1)
const double tmp = ( 10.79586f * ( 1.0f - ( ( T_0 - 20.0f ) / T ) ) ) - const double C = -6.8346 * pow(T_01 / T, 1.261) + 4.6151;
( 5.02808f * log10( ( T / ( T_0 - 20.0f ) ) ) ) + const double p_sat_p_r = pow((double) 10.0f, C);
( 1.50474f * 0.0001f * ( 1.0f - pow( ( double ) 10.0f, ( -8.29692f*( ( T / ( T_0 - 20.0f ) ) - 1.0f ) ) ) ) ) +
( 0.42873f * 0.001f * ( -1.0f + pow( ( double ) 10.0f, ( -4.76955f*( 1.0f - ( ( T_0 - 20.0f ) / T ) ) ) ) ) ) -
2.2195983f;
// Molar concentration of water vapour [%] (Molekldichte Wasserdampf) // Molar concentration of water vapour [%] (Molekldichte Wasserdampf)
// Equation (B.2)
assert( 0.0f <= dHumidity && dHumidity <= 100.0f ); assert( 0.0f <= dHumidity && dHumidity <= 100.0f );
const double h = dHumidity * pow( ( double ) 10.0f, tmp ) / ( p_a / p_r ); const double h = dHumidity * p_sat_p_r / ( p_a / p_r );
// Equation (3) // Oxygen relaxation frequency [Hz]
const double f_r_o = ( p_a / p_r ) * ( 24.0f + 4.04f*10.0e4*h*( 0.02f + h ) / ( 0.391f + h ) ); // Equation (3)
const double f_r_o = ( p_a / p_r ) * ( 24.0 + 4.04e4*h*( 0.02 + h ) / ( 0.391 + h ) );
// Nitrogen relaxation frequency [Hz]
// Equation (4) // Equation (4)
const double f_r_n = ( p_a / p_r ) * pow( T / T_0, ( double ) -1.0f / 2.0f ) * ( 9.0f + 280.0f*h*exp( -4.710f * ( pow( T / T_0, ( double ) -( 1 / 3.0f ) ) - 1.0f ) ) ); const double f_r_n = ( p_a / p_r ) * pow( T / T_0, -1.0 / 2.0 ) * ( 9.0f + 280.0*h*exp( -4.710 * ( pow( T / T_0, -( 1 / 3.0 ) ) - 1.0 ) ) );
// Parts of Equation (5) for the calculation of the attenuation coefficient [dB/m]
// Parts of Equation (5) double dAlpha1 = 8.686 * pow( dFrequency, 2.0 );
double dAlpha1 = 8.686f * pow( dFrequency, ( double ) 2.0f ); double dAlpha2 = 1.84e-11 * pow( p_a / p_r, -1.0 ) * pow( T / T_0, 1.0 / 2.0 );
double dAlpha2 = 1.84f * 10e-11 * pow( p_a / p_r, ( double ) -1.0f ) * pow( T / T_0, ( double ) -1.0f / 2.0f ); double dAlpha3 = pow( T / T_0, -5.0 / 2.0 );
double dAlpha3 = pow( T / T_0, ( double ) -5.0f / 2.0f ); double dAlpha4 = 0.01275f * exp( -2239.1 / T ) * pow( f_r_o + pow( dFrequency, 2.0 ) / f_r_o, -1.0 );
double dAlpha4 = 0.01275f * exp( -2239.1f / T ) * pow( f_r_o + pow( dFrequency, ( double ) 2.0f ) / f_r_o, ( double ) -1.0f ); double dAlpha5 = 0.10680f * exp( -3352.0 / T ) * pow( f_r_n + pow( dFrequency, 2.0 ) / f_r_n, -1.0 );
double dAlpha5 = 0.10680f * exp( -3352.0f / T ) * pow( f_r_n + pow( dFrequency, ( double ) 2.0f ) / f_r_n, ( double ) -1.0f );
// Attenuation coefficient [dB/m], ~f, as assembly of Equation (5) parts // Attenuation coefficient [dB/m], ~f, as assembly of Equation (5) parts
double dAlpha = dAlpha1 * ( dAlpha2 + dAlpha3 * ( dAlpha4 + dAlpha5 ) ); double dAlpha = dAlpha1 * ( dAlpha2 + dAlpha3 * ( dAlpha4 + dAlpha5 ) );
// Resulting attenuation [dB], ~alpha (~f) // Resulting atmospheric absorption [dB], ~alpha (~f)
double dAttenuationAirAbsorptionDecibel = dAlpha * dDistance; // Equation (2)
double dAirAbsorptionDecibel = dAlpha * dDistance;
// Attenuation factor in decibel // Attenuation factor in decibel
return dAttenuationAirAbsorptionDecibel; return dAirAbsorptionDecibel;
}
double ISO9613::AtmosphericAbsorptionFactor(double dFrequency, double dDistance, double dTemperature, double dHumidity, double dStaticPressure)
{
double dAirAbsorptionDecibel = AtmosphericAbsorptionLevel(dFrequency, dDistance, dTemperature, dHumidity, dStaticPressure);
//Factor of absorped signal energy [0:1]
double dAirAbsorptionFactor = 1 - pow(10, -dAirAbsorptionDecibel / 10.0);
return dAirAbsorptionFactor;
}
void ISO9613::AtmosphericAbsorptionLevel(ITABase::CThirdOctaveDecibelMagnitudeSpectrum& oA_atm_dB, double dDistance, double dTemperature, double dHumidity, double dStaticPressure/*= 101.325*/)
{
// loop over all frequencies
for (int i = 0; i < oA_atm_dB.GetNumBands(); i++)
{
double dFrequency = (double) oA_atm_dB.GetCenterFrequencies()[i];
double dAirAbsorptionDecibel = AtmosphericAbsorptionLevel(dFrequency, dDistance, dTemperature, dHumidity, dStaticPressure);
oA_atm_dB.SetMagnitude(i, (float) dAirAbsorptionDecibel);
}
}
void ISO9613::AtmosphericAbsorptionFactor(ITABase::CThirdOctaveFactorMagnitudeSpectrum& oA_atm_factor, double dDistance, double dTemperature, double dHumidity, double dStaticPressure/*= 101.325*/)
{
// loop over all frequencies and converting from decibel to a factor between 0 and 1
for (int i = 0; i < oA_atm_factor.GetNumBands(); i++)
{
double dFrequency = (double)oA_atm_factor.GetCenterFrequencies()[i];
double dAirAbsorptionFactor = AtmosphericAbsorptionFactor(dFrequency, dDistance, dTemperature, dHumidity, dStaticPressure);
oA_atm_factor.SetMagnitude(i, (float)dAirAbsorptionFactor);
}
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment