A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
20
#include "
uan-noise-model-default.h
"
21
22
#include "ns3/double.h"
23
24
#include <cmath>
25
26
namespace
ns3
27
{
28
29
NS_OBJECT_ENSURE_REGISTERED
(UanNoiseModelDefault);
30
31
UanNoiseModelDefault::UanNoiseModelDefault
()
32
{
33
}
34
35
UanNoiseModelDefault::~UanNoiseModelDefault
()
36
{
37
}
38
39
TypeId
40
UanNoiseModelDefault::GetTypeId
()
41
{
42
static
TypeId
tid =
TypeId
(
"ns3::UanNoiseModelDefault"
)
43
.
SetParent
<
UanNoiseModel
>()
44
.SetGroupName(
"Uan"
)
45
.AddConstructor<
UanNoiseModelDefault
>()
46
.AddAttribute(
"Wind"
,
47
"Wind speed in m/s."
,
48
DoubleValue
(1),
49
MakeDoubleAccessor
(&
UanNoiseModelDefault::m_wind
),
50
MakeDoubleChecker<double>(0))
51
.AddAttribute(
"Shipping"
,
52
"Shipping contribution to noise between 0 and 1."
,
53
DoubleValue
(0),
54
MakeDoubleAccessor
(&
UanNoiseModelDefault::m_shipping
),
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
62
UanNoiseModelDefault::GetNoiseDbHz
(
double
fKhz)
const
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
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition:
double.h:42
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:931
ns3::UanNoiseModelDefault
Standard ambient acoustic noise model.
Definition:
uan-noise-model-default.h:50
ns3::UanNoiseModelDefault::m_wind
double m_wind
Wind speed in m/s.
Definition:
uan-noise-model-default.h:65
ns3::UanNoiseModelDefault::GetNoiseDbHz
double GetNoiseDbHz(double fKhz) const override
Compute the noise power at a given frequency.
Definition:
uan-noise-model-default.cc:62
ns3::UanNoiseModelDefault::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition:
uan-noise-model-default.cc:40
ns3::UanNoiseModelDefault::~UanNoiseModelDefault
~UanNoiseModelDefault() override
Dummy destructor, DoDispose.
Definition:
uan-noise-model-default.cc:35
ns3::UanNoiseModelDefault::UanNoiseModelDefault
UanNoiseModelDefault()
Default constructor.
Definition:
uan-noise-model-default.cc:31
ns3::UanNoiseModelDefault::m_shipping
double m_shipping
Shipping contribution to noise between 0 and 1.
Definition:
uan-noise-model-default.h:66
ns3::UanNoiseModel
UAN Noise Model base class.
Definition:
uan-noise-model.h:34
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition:
double.h:43
uan-noise-model-default.h
src
uan
model
uan-noise-model-default.cc
Generated on Sun Mar 3 2024 17:11:09 for ns-3 by
1.9.1