Code_TYMPAN  4.4.0
Industrial site acoustic simulation
atmospheric_conditions.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
16 #include <math.h>
17 
19 
20 #ifndef M_PI
21  #define M_PI 3.1415926535897932384626433832795
22 #endif
23 
24 const double AtmosphericConditions::Z_ref = 400.0;
25 const double AtmosphericConditions::reference_pressure = 101325.0;
27 const double AtmosphericConditions::absolute_zero = 273.15;
28 
29 AtmosphericConditions::AtmosphericConditions(double static_pressure_, double temperature_, double hygrometry_)
30  : static_pressure(static_pressure_), temperature(temperature_), hygrometry(hygrometry_)
31 {
32  compute_k();
35 }
36 
38 {
39  double f2 = NAN; // Carre de la frequence de travail
40  double tA_classic = NAN, tA_N = NAN, tA_O = NAN; // Termes d'absoption classique, Azote Oxygene
41 
42  const double tK = temperature + absolute_zero; // temperature absolue exprimee en Kelvin
43  const double pr_rel = static_pressure / reference_pressure; // Pression relative
44  const double t_rel = tK / reference_temperature; // Temperature relative
45 
46  const double h_molaire = compute_hm();
47 
48  // Frequences de relaxation de l'oxygene (frO) et de l'azote (frN)
49  const double frO =
50  pr_rel * (24.0 + (4.04 * 10000.0 * h_molaire * ((0.02 + h_molaire) / (0.391 + h_molaire))));
51  const double frN = pr_rel * pow(t_rel, -0.5) *
52  (9.0 + 280.0 * h_molaire * exp((-4.170 * (pow(t_rel, (-1.0 / 3.0)) - 1))));
53 
55 
56  for (unsigned int i = 0; i < absorption_spectrum.getNbValues(); i++)
57  {
58  f2 = tabFreq[i] * tabFreq[i];
59 
60  tA_classic = 1.84e-11 * (1.0 / pr_rel) * sqrt(t_rel);
61  tA_O = 0.01275 * exp(-2239.1 / tK) * (1.0 / (frO + (f2 / frO)));
62  tA_N = 0.1068 * exp(-3352.0 / tK) * (1.0 / (frN + (f2 / frN)));
63 
65  (8.686 * f2 * (tA_classic + (pow(t_rel, -2.5) * (tA_O + tA_N))));
66  }
67 }
68 
70 {
71  absorption_spectrum_oct.setType(SPECTRE_TYPE_ABSO); // Absorption spectrum
72  unsigned int indiceDepart = 2;
73  unsigned int indice = 0;
74  for (unsigned int i = indiceDepart; i < TY_SPECTRE_DEFAULT_NB_ELMT - 2; i += 3, indice++)
75  {
77  round(absorption_spectrum.getTabValReel()[i + 1] * 10000) /
78  10; // Express absorption coefficient in dB per km round to one decimal place
79  }
80 }
81 
83 {
84  const double gamma = 1.41;
85  const double R = 8.31441;
86  const double M = 0.029;
87  const double tK = temperature + absolute_zero;
88 
89  return sqrt((gamma * R * tK) / M);
90 }
91 
93 {
94  const double R = 8.31441; // Constante des gazs parfaits
95  const double tK = temperature + absolute_zero;
96  const double M = 0.029; // Masse molaire de l'air
97 
98  return (M * (static_pressure / (R * tK))) * compute_c();
99 }
100 
102 {
103  double soundSpeed = compute_c();
105 
106  for (unsigned int i = 0; i < tabFreq.size(); i++)
107  {
108  wave_number.getTabValReel()[i] = (2 * M_PI * tabFreq[i]) / soundSpeed;
109  }
110 }
111 
113 {
114  double T01 = absolute_zero + 0.01; // Temperature isotherme au point triple
115  double tK = temperature + absolute_zero; // Temperature en Kelvin
116  double pr_rel = static_pressure / reference_pressure; // Pression relative
117 
118  double C = -6.8346 * pow((T01 / tK), 1.261) + 4.6151;
119 
120  double prSat_prRef = pow(10, C);
121 
122  return hygrometry * prSat_prRef * pr_rel;
123 }
124 
126 {
127  return absorption_spectrum.mult(-(length / 2.0)).toGPhy();
128 }
129 
131 {
132  return absorption_spectrum_oct * (length / 1000.0);
133 }
const std::vector< double > tabFreq
#define M_PI
void compute_k()
compute wave number
double hygrometry
Hygrometry.
OSpectre compute_length_absorption(double length) const
static const double Z_ref
reference impedance
double compute_z()
compute impedance
OSpectre absorption_spectrum
Absorption spectrum.
static const double absolute_zero
273.15 K
OSpectreOctave compute_length_absorption_oct(double length) const
AtmosphericConditions(double static_pressure_, double temperature_, double hygrometry_)
Constructor.
double static_pressure
Static pressure [Pa].
void compute_absorption_spectrum()
Compute absorption spectrum in dB/m.
OSpectreOctave absorption_spectrum_oct
static const double reference_temperature
Reference temperature [K].
OSpectre wave_number
Wave number spectrum.
static const double reference_pressure
Reference pressure [Pa].
double compute_hm() const
compute molar hygrometry coefficient
void compute_absorption_spectrum_oct()
Compute absorption spectrum in dB/m for octave band computation.
double temperature
Temperature [°C].
double compute_c() const
compute sound speed
OSpectreAbstract & toGPhy() const
Converts to physical quantity.
Definition: spectre.cpp:641
unsigned int getNbValues() const
Number of values in the spectrum.
Definition: spectre.cpp:187
void setType(TYSpectreType type)
Set the spectrum type.
Definition: spectre.h:153
OSpectreAbstract & mult(const OSpectreAbstract &spectre) const
Multiplication of two spectrums.
Definition: spectre.cpp:248
double * getTabValReel() override
Get an array of the real values of the spectrum.
Definition: spectre.h:614
double * getTabValReel() override
Definition: spectre.h:357
static OTabFreq getTabFreqExact()
Definition: spectre.cpp:993
std::vector< double > OTabFreq
Frequencies collection.
Definition: spectre.h:60
@ SPECTRE_TYPE_ABSO
Definition: spectre.h:29