A Discrete-Event Network Simulator
API
uan-noise-model-default.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 University of Washington
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program 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. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Leonard Tracy <lentracy@gmail.com>
18  */
19 
21 
22 #include "ns3/double.h"
23 
24 #include <cmath>
25 
26 namespace ns3
27 {
28 
29 NS_OBJECT_ENSURE_REGISTERED(UanNoiseModelDefault);
30 
32 {
33 }
34 
36 {
37 }
38 
39 TypeId
41 {
42  static TypeId tid = TypeId("ns3::UanNoiseModelDefault")
44  .SetGroupName("Uan")
45  .AddConstructor<UanNoiseModelDefault>()
46  .AddAttribute("Wind",
47  "Wind speed in m/s.",
48  DoubleValue(1),
50  MakeDoubleChecker<double>(0))
51  .AddAttribute("Shipping",
52  "Shipping contribution to noise between 0 and 1.",
53  DoubleValue(0),
55  MakeDoubleChecker<double>(0, 1));
56  return tid;
57 }
58 
59 // Common acoustic noise formulas. These can be found
60 // in "Principles of Underwater Sound" by Robert J. Urick
61 double
63 {
64  double turb;
65  double wind;
66  double ship;
67  double thermal;
68  double turbDb;
69  double windDb;
70  double shipDb;
71  double thermalDb;
72  double noiseDb;
73 
74  double log_fKhz = std::log10(fKhz);
75 
76  turbDb = 17.0 - 30.0 * log_fKhz;
77  turb = std::pow(10.0, turbDb * 0.1);
78 
79  shipDb = 40.0 + 20.0 * (m_shipping - 0.5) + 26.0 * log_fKhz - 60.0 * std::log10(fKhz + 0.03);
80  ship = std::pow(10.0, (shipDb * 0.1));
81 
82  windDb = 50.0 + 7.5 * std::pow(m_wind, 0.5) + 20.0 * log_fKhz - 40.0 * std::log10(fKhz + 0.4);
83  wind = std::pow(10.0, windDb * 0.1);
84 
85  thermalDb = -15 + 20 * log_fKhz;
86  thermal = std::pow(10, thermalDb * 0.1);
87 
88  noiseDb = 10 * std::log10(turb + ship + wind + thermal);
89 
90  return noiseDb;
91 }
92 
93 } // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
Standard ambient acoustic noise model.
double m_wind
Wind speed in m/s.
double GetNoiseDbHz(double fKhz) const override
Compute the noise power at a given frequency.
static TypeId GetTypeId()
Register this type.
~UanNoiseModelDefault() override
Dummy destructor, DoDispose.
UanNoiseModelDefault()
Default constructor.
double m_shipping
Shipping contribution to noise between 0 and 1.
UAN Noise Model base class.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43