A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
uan-noise-model-default.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 University of Washington
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Leonard Tracy <lentracy@gmail.com>
7 */
8
10
11#include "ns3/double.h"
12
13#include <cmath>
14
15namespace ns3
16{
17
18NS_OBJECT_ENSURE_REGISTERED(UanNoiseModelDefault);
19
23
27
30{
31 static TypeId tid = TypeId("ns3::UanNoiseModelDefault")
33 .SetGroupName("Uan")
34 .AddConstructor<UanNoiseModelDefault>()
35 .AddAttribute("Wind",
36 "Wind speed in m/s.",
37 DoubleValue(1),
40 .AddAttribute("Shipping",
41 "Shipping contribution to noise between 0 and 1.",
42 DoubleValue(0),
45 return tid;
46}
47
48// Common acoustic noise formulas. These can be found
49// in "Principles of Underwater Sound" by Robert J. Urick
50double
52{
53 double turb;
54 double wind;
55 double ship;
56 double thermal;
57 double turbDb;
58 double windDb;
59 double shipDb;
60 double thermalDb;
61 double noiseDb;
62
63 double log_fKhz = std::log10(fKhz);
64
65 turbDb = 17.0 - 30.0 * log_fKhz;
66 turb = std::pow(10.0, turbDb * 0.1);
67
68 shipDb = 40.0 + 20.0 * (m_shipping - 0.5) + 26.0 * log_fKhz - 60.0 * std::log10(fKhz + 0.03);
69 ship = std::pow(10.0, (shipDb * 0.1));
70
71 windDb = 50.0 + 7.5 * std::pow(m_wind, 0.5) + 20.0 * log_fKhz - 40.0 * std::log10(fKhz + 0.4);
72 wind = std::pow(10.0, windDb * 0.1);
73
74 thermalDb = -15 + 20 * log_fKhz;
75 thermal = std::pow(10, thermalDb * 0.1);
76
77 noiseDb = 10 * std::log10(turb + ship + wind + thermal);
78
79 return noiseDb;
80}
81
82} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
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:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32