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
parabolic-antenna-model.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012 CTTC
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Nicola Baldo <nbaldo@cttc.es>
7
*/
8
9
#include "
parabolic-antenna-model.h
"
10
11
#include "
antenna-model.h
"
12
13
#include <ns3/double.h>
14
#include <ns3/log.h>
15
16
#include <cmath>
17
18
namespace
ns3
19
{
20
21
NS_LOG_COMPONENT_DEFINE
(
"ParabolicAntennaModel"
);
22
23
NS_OBJECT_ENSURE_REGISTERED
(ParabolicAntennaModel);
24
25
TypeId
26
ParabolicAntennaModel::GetTypeId
()
27
{
28
static
TypeId
tid =
29
TypeId
(
"ns3::ParabolicAntennaModel"
)
30
.
SetParent
<
AntennaModel
>()
31
.SetGroupName(
"Antenna"
)
32
.AddConstructor<
ParabolicAntennaModel
>()
33
.AddAttribute(
"Beamwidth"
,
34
"The 3dB beamwidth (degrees)"
,
35
DoubleValue
(60),
36
MakeDoubleAccessor
(&
ParabolicAntennaModel::SetBeamwidth
,
37
&
ParabolicAntennaModel::GetBeamwidth
),
38
MakeDoubleChecker<double>
(0, 180))
39
.AddAttribute(
"Orientation"
,
40
"The angle (degrees) that expresses the orientation of the antenna on "
41
"the x-y plane relative to the x axis"
,
42
DoubleValue
(0.0),
43
MakeDoubleAccessor
(&
ParabolicAntennaModel::SetOrientation
,
44
&
ParabolicAntennaModel::GetOrientation
),
45
MakeDoubleChecker<double>
(-360, 360))
46
.AddAttribute(
"MaxAttenuation"
,
47
"The maximum attenuation (dB) of the antenna radiation pattern."
,
48
DoubleValue
(20.0),
49
MakeDoubleAccessor
(&
ParabolicAntennaModel::m_maxAttenuation
),
50
MakeDoubleChecker<double>
());
51
return
tid;
52
}
53
54
void
55
ParabolicAntennaModel::SetBeamwidth
(
double
beamwidthDegrees)
56
{
57
NS_LOG_FUNCTION
(
this
<< beamwidthDegrees);
58
m_beamwidthRadians
=
DegreesToRadians
(beamwidthDegrees);
59
}
60
61
double
62
ParabolicAntennaModel::GetBeamwidth
()
const
63
{
64
return
RadiansToDegrees
(
m_beamwidthRadians
);
65
}
66
67
void
68
ParabolicAntennaModel::SetOrientation
(
double
orientationDegrees)
69
{
70
NS_LOG_FUNCTION
(
this
<< orientationDegrees);
71
m_orientationRadians
=
DegreesToRadians
(orientationDegrees);
72
}
73
74
double
75
ParabolicAntennaModel::GetOrientation
()
const
76
{
77
return
RadiansToDegrees
(
m_orientationRadians
);
78
}
79
80
double
81
ParabolicAntennaModel::GetGainDb
(
Angles
a)
82
{
83
NS_LOG_FUNCTION
(
this
<< a);
84
// azimuth angle w.r.t. the reference system of the antenna
85
double
phi = a.
GetAzimuth
() -
m_orientationRadians
;
86
87
// make sure phi is in (-pi, pi]
88
while
(phi <= -M_PI)
89
{
90
phi += M_PI + M_PI;
91
}
92
while
(phi > M_PI)
93
{
94
phi -= M_PI + M_PI;
95
}
96
97
NS_LOG_LOGIC
(
"phi = "
<< phi);
98
99
double
gainDb = -std::min(12 * pow(phi /
m_beamwidthRadians
, 2),
m_maxAttenuation
);
100
101
NS_LOG_LOGIC
(
"gain = "
<< gainDb);
102
return
gainDb;
103
}
104
105
}
// namespace ns3
antenna-model.h
ns3::Angles
Class holding the azimuth and inclination angles of spherical coordinates.
Definition
angles.h:107
ns3::Angles::GetAzimuth
double GetAzimuth() const
Getter for azimuth angle.
Definition
angles.cc:230
ns3::AntennaModel
interface for antenna radiation pattern models
Definition
antenna-model.h:44
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition
double.h:31
ns3::ParabolicAntennaModel
Antenna model based on a parabolic approximation of the main lobe radiation pattern.
Definition
parabolic-antenna-model.h:36
ns3::ParabolicAntennaModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
parabolic-antenna-model.cc:26
ns3::ParabolicAntennaModel::SetBeamwidth
void SetBeamwidth(double beamwidthDegrees)
Set the Beam width.
Definition
parabolic-antenna-model.cc:55
ns3::ParabolicAntennaModel::GetGainDb
double GetGainDb(Angles a) override
this method is expected to be re-implemented by each antenna model
Definition
parabolic-antenna-model.cc:81
ns3::ParabolicAntennaModel::GetBeamwidth
double GetBeamwidth() const
Get the Beam width.
Definition
parabolic-antenna-model.cc:62
ns3::ParabolicAntennaModel::m_orientationRadians
double m_orientationRadians
Antenna orientation in radians.
Definition
parabolic-antenna-model.h:71
ns3::ParabolicAntennaModel::GetOrientation
double GetOrientation() const
Get the antenna orientation.
Definition
parabolic-antenna-model.cc:75
ns3::ParabolicAntennaModel::m_maxAttenuation
double m_maxAttenuation
Max attenuation.
Definition
parabolic-antenna-model.h:72
ns3::ParabolicAntennaModel::SetOrientation
void SetOrientation(double orientationDegrees)
Set the antenna orientation.
Definition
parabolic-antenna-model.cc:68
ns3::ParabolicAntennaModel::m_beamwidthRadians
double m_beamwidthRadians
Beam width in radians.
Definition
parabolic-antenna-model.h:70
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
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition
log.h:271
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
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::DegreesToRadians
double DegreesToRadians(double degrees)
converts degrees to radians
Definition
angles.cc:28
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition
double.h:32
ns3::RadiansToDegrees
double RadiansToDegrees(double radians)
converts radians to degrees
Definition
angles.cc:34
parabolic-antenna-model.h
src
antenna
model
parabolic-antenna-model.cc
Generated on Fri Nov 8 2024 13:58:58 for ns-3 by
1.11.0