A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
cosine-antenna-model.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 CTTC
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Nicola Baldo <nbaldo@cttc.es>
19
*/
20
21
22
#include <ns3/log.h>
23
#include <ns3/double.h>
24
#include <cmath>
25
26
#include "
antenna-model.h
"
27
#include "
cosine-antenna-model.h
"
28
29
30
NS_LOG_COMPONENT_DEFINE
(
"CosineAntennaModel"
);
31
32
namespace
ns3 {
33
34
NS_OBJECT_ENSURE_REGISTERED
(CosineAntennaModel)
35
;
36
37
38
TypeId
39
CosineAntennaModel::GetTypeId
()
40
{
41
static
TypeId
tid =
TypeId
(
"ns3::CosineAntennaModel"
)
42
.
SetParent
<
AntennaModel
> ()
43
.AddConstructor<CosineAntennaModel> ()
44
.AddAttribute (
"Beamwidth"
,
45
"The 3dB beamwidth (degrees)"
,
46
DoubleValue
(60),
47
MakeDoubleAccessor (&
CosineAntennaModel::SetBeamwidth
,
48
&
CosineAntennaModel::GetBeamwidth
),
49
MakeDoubleChecker<double> (0, 180))
50
.AddAttribute (
"Orientation"
,
51
"The angle (degrees) that expresses the orientation of the antenna on the x-y plane relative to the x axis"
,
52
DoubleValue
(0.0),
53
MakeDoubleAccessor (&
CosineAntennaModel::SetOrientation
,
54
&
CosineAntennaModel::GetOrientation
),
55
MakeDoubleChecker<double> (-360, 360))
56
.AddAttribute (
"MaxGain"
,
57
"The gain (dB) at the antenna boresight (the direction of maximum gain)"
,
58
DoubleValue
(0.0),
59
MakeDoubleAccessor (&
CosineAntennaModel::m_maxGain
),
60
MakeDoubleChecker<double> ())
61
;
62
return
tid;
63
}
64
65
void
66
CosineAntennaModel::SetBeamwidth
(
double
beamwidthDegrees)
67
{
68
NS_LOG_FUNCTION
(
this
<< beamwidthDegrees);
69
m_beamwidthRadians
=
DegreesToRadians
(beamwidthDegrees);
70
m_exponent
= -3.0 / (20 * std::log10 (std::cos (
m_beamwidthRadians
/ 4.0)));
71
NS_LOG_LOGIC
(
this
<<
" m_exponent = "
<<
m_exponent
);
72
}
73
74
double
75
CosineAntennaModel::GetBeamwidth
()
const
76
{
77
return
RadiansToDegrees
(
m_beamwidthRadians
);
78
}
79
80
void
81
CosineAntennaModel::SetOrientation
(
double
orientationDegrees)
82
{
83
NS_LOG_FUNCTION
(
this
<< orientationDegrees);
84
m_orientationRadians
=
DegreesToRadians
(orientationDegrees);
85
}
86
87
double
88
CosineAntennaModel::GetOrientation
()
const
89
{
90
return
RadiansToDegrees
(
m_orientationRadians
);
91
}
92
93
double
94
CosineAntennaModel::GetGainDb
(
Angles
a)
95
{
96
NS_LOG_FUNCTION
(
this
<< a);
97
// azimuth angle w.r.t. the reference system of the antenna
98
double
phi = a.
phi
-
m_orientationRadians
;
99
100
// make sure phi is in (-pi, pi]
101
while
(phi <= -M_PI)
102
{
103
phi += M_PI+M_PI;
104
}
105
while
(phi > M_PI)
106
{
107
phi -= M_PI+M_PI;
108
}
109
110
NS_LOG_LOGIC
(
"phi = "
<< phi );
111
112
// element factor: amplitude gain of a single antenna element in linear units
113
double
ef = std::pow (std::cos (phi / 2.0),
m_exponent
);
114
115
// the array factor is not considered. Note that if we did consider
116
// the array factor, the actual beamwidth would change, and in
117
// particular it would be different from the one specified by the
118
// user. Hence it is not desirable to use the array factor, for the
119
// ease of use of this model.
120
121
double
gainDb = 20 * std::log10 (ef);
122
NS_LOG_LOGIC
(
"gain = "
<< gainDb <<
" + "
<<
m_maxGain
<<
" dB"
);
123
return
gainDb +
m_maxGain
;
124
}
125
126
127
}
128
ns3::CosineAntennaModel::GetGainDb
virtual double GetGainDb(Angles a)
this method is expected to be re-implemented by each antenna model
Definition:
cosine-antenna-model.cc:94
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:345
ns3::CosineAntennaModel::m_orientationRadians
double m_orientationRadians
Definition:
cosine-antenna-model.h:70
ns3::DegreesToRadians
double DegreesToRadians(double degrees)
converts degrees to radians
Definition:
angles.cc:32
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
ns3::CosineAntennaModel::GetBeamwidth
double GetBeamwidth() const
Definition:
cosine-antenna-model.cc:75
ns3::CosineAntennaModel::m_maxGain
double m_maxGain
Definition:
cosine-antenna-model.h:72
ns3::CosineAntennaModel::m_beamwidthRadians
double m_beamwidthRadians
Definition:
cosine-antenna-model.h:68
ns3::CosineAntennaModel::GetTypeId
static TypeId GetTypeId()
Definition:
cosine-antenna-model.cc:39
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Definition:
log.h:368
ns3::CosineAntennaModel::SetOrientation
void SetOrientation(double orientationDegrees)
Definition:
cosine-antenna-model.cc:81
ns3::RadiansToDegrees
double RadiansToDegrees(double radians)
converts radians to degrees
Definition:
angles.cc:38
ns3::CosineAntennaModel::m_exponent
double m_exponent
this is the variable "n" in the paper by Chunjian
Definition:
cosine-antenna-model.h:66
ns3::CosineAntennaModel::GetOrientation
double GetOrientation() const
Definition:
cosine-antenna-model.cc:88
antenna-model.h
ns3::Angles::phi
double phi
the azimuth angle in radians
Definition:
angles.h:111
ns3::Angles
struct holding the azimuth and inclination angles of spherical coordinates.
Definition:
angles.h:71
ns3::DoubleValue
Hold a floating point type.
Definition:
double.h:41
ns3::AntennaModel
interface for antenna radiation pattern models
Definition:
antenna-model.h:44
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:611
ns3::CosineAntennaModel::SetBeamwidth
void SetBeamwidth(double beamwidthDegrees)
Definition:
cosine-antenna-model.cc:66
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("CosineAntennaModel")
cosine-antenna-model.h
src
antenna
model
cosine-antenna-model.cc
Generated on Sat Apr 19 2014 14:06:49 for ns-3 by
1.8.6