A Discrete-Event Network Simulator
QKDNetSim v2.0 (NS-3 v3.41) @ (+)
API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
parabolic-antenna-model.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 CTTC
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: Nicola Baldo <nbaldo@cttc.es>
18  */
19 
21 
22 #include "antenna-model.h"
23 
24 #include <ns3/double.h>
25 #include <ns3/log.h>
26 
27 #include <cmath>
28 
29 namespace ns3
30 {
31 
32 NS_LOG_COMPONENT_DEFINE("ParabolicAntennaModel");
33 
34 NS_OBJECT_ENSURE_REGISTERED(ParabolicAntennaModel);
35 
36 TypeId
38 {
39  static TypeId tid =
40  TypeId("ns3::ParabolicAntennaModel")
42  .SetGroupName("Antenna")
43  .AddConstructor<ParabolicAntennaModel>()
44  .AddAttribute("Beamwidth",
45  "The 3dB beamwidth (degrees)",
46  DoubleValue(60),
49  MakeDoubleChecker<double>(0, 180))
50  .AddAttribute("Orientation",
51  "The angle (degrees) that expresses the orientation of the antenna on "
52  "the x-y plane relative to the x axis",
53  DoubleValue(0.0),
56  MakeDoubleChecker<double>(-360, 360))
57  .AddAttribute("MaxAttenuation",
58  "The maximum attenuation (dB) of the antenna radiation pattern.",
59  DoubleValue(20.0),
61  MakeDoubleChecker<double>());
62  return tid;
63 }
64 
65 void
66 ParabolicAntennaModel::SetBeamwidth(double beamwidthDegrees)
67 {
68  NS_LOG_FUNCTION(this << beamwidthDegrees);
69  m_beamwidthRadians = DegreesToRadians(beamwidthDegrees);
70 }
71 
72 double
74 {
76 }
77 
78 void
79 ParabolicAntennaModel::SetOrientation(double orientationDegrees)
80 {
81  NS_LOG_FUNCTION(this << orientationDegrees);
82  m_orientationRadians = DegreesToRadians(orientationDegrees);
83 }
84 
85 double
87 {
89 }
90 
91 double
93 {
94  NS_LOG_FUNCTION(this << a);
95  // azimuth angle w.r.t. the reference system of the antenna
96  double phi = a.GetAzimuth() - m_orientationRadians;
97 
98  // make sure phi is in (-pi, pi]
99  while (phi <= -M_PI)
100  {
101  phi += M_PI + M_PI;
102  }
103  while (phi > M_PI)
104  {
105  phi -= M_PI + M_PI;
106  }
107 
108  NS_LOG_LOGIC("phi = " << phi);
109 
110  double gainDb = -std::min(12 * pow(phi / m_beamwidthRadians, 2), m_maxAttenuation);
111 
112  NS_LOG_LOGIC("gain = " << gainDb);
113  return gainDb;
114 }
115 
116 } // namespace ns3
#define min(a, b)
Definition: 80211b.c:41
Class holding the azimuth and inclination angles of spherical coordinates.
Definition: angles.h:118
double GetAzimuth() const
Getter for azimuth angle.
Definition: angles.cc:240
interface for antenna radiation pattern models
Definition: antenna-model.h:55
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Antenna model based on a parabolic approximation of the main lobe radiation pattern.
static TypeId GetTypeId()
Get the type ID.
void SetBeamwidth(double beamwidthDegrees)
Set the Beam width.
double GetGainDb(Angles a) override
this method is expected to be re-implemented by each antenna model
double GetBeamwidth() const
Get the Beam width.
double m_orientationRadians
Antenna orientation in radians.
double GetOrientation() const
Get the antenna orientation.
double m_maxAttenuation
Max attenuation.
void SetOrientation(double orientationDegrees)
Set the antenna orientation.
double m_beamwidthRadians
Beam width in radians.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
double DegreesToRadians(double degrees)
converts degrees to radians
Definition: angles.cc:39
double RadiansToDegrees(double radians)
converts radians to degrees
Definition: angles.cc:45