A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
phased-array-model.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 University of Padova, Dep. of Information Engineering, SIGNET lab.
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
8
10
11#include <ns3/boolean.h>
12#include <ns3/double.h>
13#include <ns3/log.h>
14#include <ns3/pointer.h>
15#include <ns3/uinteger.h>
16
17namespace ns3
18{
19
21
22NS_LOG_COMPONENT_DEFINE("PhasedArrayModel");
23
24NS_OBJECT_ENSURE_REGISTERED(PhasedArrayModel);
25
27 : m_isBfVectorValid{false}
28{
29 m_id = m_idCounter++;
30}
31
35
38{
39 static TypeId tid =
40 TypeId("ns3::PhasedArrayModel")
42 .SetGroupName("Antenna")
43 .AddAttribute("AntennaElement",
44 "A pointer to the antenna element used by the phased array",
48 return tid;
49}
50
51void
53{
54 NS_LOG_FUNCTION(this << beamformingVector);
55 NS_ASSERT_MSG(beamformingVector.GetSize() == GetNumElems(),
56 beamformingVector.GetSize() << " != " << GetNumElems());
57 m_beamformingVector = beamformingVector;
58 m_isBfVectorValid = true;
59}
60
63{
64 NS_LOG_FUNCTION(this);
66 "The beamforming vector should be Set before it's Get, and should refer to the "
67 "current array configuration");
69}
70
73{
74 NS_LOG_FUNCTION(this);
76 "The beamforming vector should be Set before it's Get, and should refer to the "
77 "current array configuration");
79}
80
83{
84 NS_LOG_FUNCTION(this << a);
85
86 ComplexVector beamformingVector = GetSteeringVector(a);
87 // The normalization takes into account the total number of ports as only a
88 // portion (K,L) of beam weights associated with a specific port are non-zero.
89 // See 3GPP Section 5.2.2 36.897. This normalization corresponds to
90 // a sub-array partition model (which is different from the full-connection
91 // model). Note that the total number of ports used to perform normalization
92 // is the ratio between the total number of antenna elements and the
93 // number of antenna elements per port.
94 double normRes = norm(beamformingVector) / sqrt(GetNumPorts());
95
96 for (size_t i = 0; i < GetNumElems(); i++)
97 {
98 beamformingVector[i] = std::conj(beamformingVector[i]) / normRes;
99 }
100
101 return beamformingVector;
102}
103
106{
107 ComplexVector steeringVector(GetNumElems());
108 for (size_t i = 0; i < GetNumElems(); i++)
109 {
110 Vector loc = GetElementLocation(i);
111 double phase = -2 * M_PI *
112 (sin(a.GetInclination()) * cos(a.GetAzimuth()) * loc.x +
113 sin(a.GetInclination()) * sin(a.GetAzimuth()) * loc.y +
114 cos(a.GetInclination()) * loc.z);
115 steeringVector[i] = std::polar<double>(1.0, phase);
116 }
117 return steeringVector;
118}
119
120void
122{
123 NS_LOG_FUNCTION(this);
124 m_antennaElement = antennaElement;
125}
126
133
136{
137 return m_id;
138}
139
140} /* namespace ns3 */
Class holding the azimuth and inclination angles of spherical coordinates.
Definition angles.h:107
double GetInclination() const
Getter for inclination angle.
Definition angles.cc:236
double GetAzimuth() const
Getter for azimuth angle.
Definition angles.cc:230
A base class which provides memory management and object aggregation.
Definition object.h:78
const PhasedArrayModel::ComplexVector & GetBeamformingVectorRef() const
Returns the const reference of the beamforming vector that is currently being used.
static uint32_t m_idCounter
the ID counter that is used to determine the unique antenna array ID
ComplexVector GetSteeringVector(Angles a) const
Returns the steering vector that points toward the specified position.
virtual Vector GetElementLocation(uint64_t index) const =0
Returns the location of the antenna element with the specified index, normalized with respect to the ...
virtual uint16_t GetNumPorts() const =0
Get the number of ports.
uint32_t GetId() const
Returns the ID of this antenna array instance.
Ptr< AntennaModel > m_antennaElement
the model of the antenna element in use
Ptr< const AntennaModel > GetAntennaElement() const
Returns a pointer to the AntennaModel instance used to model the elements of the array.
void SetAntennaElement(Ptr< AntennaModel > antennaElement)
Sets the antenna model to be used.
ComplexVector GetBeamformingVector() const
Returns the beamforming vector that is currently being used.
bool m_isBfVectorValid
ensures the validity of the beamforming vector
~PhasedArrayModel() override
Destructor.
uint32_t m_id
the ID of this antenna array instance
void SetBeamformingVector(const ComplexVector &beamformingVector)
Sets the beamforming vector to be used.
ComplexVector m_beamformingVector
the beamforming vector in use
virtual size_t GetNumElems() const =0
Returns the number of antenna elements.
static TypeId GetTypeId()
Get the type ID.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
size_t GetSize() const
Definition val-array.h:394
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition pointer.h:248
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Definition pointer.h:269
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
const double norm
Normalization to obtain randoms on [0,1).
Definition rng-stream.cc:55
Every class exported by the ns3 library is enclosed in the ns3 namespace.