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