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
21SymmetricAdjacencyMatrix<bool> PhasedArrayModel::m_outOfDateAntennaPairChannel;
22
23NS_LOG_COMPONENT_DEFINE("PhasedArrayModel");
24
25NS_OBJECT_ENSURE_REGISTERED(PhasedArrayModel);
26
34
38
41{
42 static TypeId tid =
43 TypeId("ns3::PhasedArrayModel")
45 .SetGroupName("Antenna")
46 .AddAttribute("AntennaElement",
47 "A pointer to the antenna element used by the phased array",
51 return tid;
52}
53
54void
56{
57 NS_LOG_FUNCTION(this << beamformingVector);
58 NS_ASSERT_MSG(beamformingVector.GetSize() == GetNumElems(),
59 beamformingVector.GetSize() << " != " << GetNumElems());
60 m_beamformingVector = beamformingVector;
61 m_isBfVectorValid = true;
62}
63
66{
67 NS_LOG_FUNCTION(this);
69 "The beamforming vector should be Set before it's Get, and should refer to the "
70 "current array configuration");
72}
73
76{
77 NS_LOG_FUNCTION(this);
79 "The beamforming vector should be Set before it's Get, and should refer to the "
80 "current array configuration");
82}
83
86{
87 NS_LOG_FUNCTION(this << a);
88
89 ComplexVector beamformingVector = GetSteeringVector(a);
90 // The normalization takes into account the total number of ports as only a
91 // portion (K,L) of beam weights associated with a specific port are non-zero.
92 // See 3GPP Section 5.2.2 36.897. This normalization corresponds to
93 // a sub-array partition model (which is different from the full-connection
94 // model). Note that the total number of ports used to perform normalization
95 // is the ratio between the total number of antenna elements and the
96 // number of antenna elements per port.
97 double normRes = norm(beamformingVector) / sqrt(GetNumPorts());
98
99 for (size_t i = 0; i < GetNumElems(); i++)
100 {
101 beamformingVector[i] = std::conj(beamformingVector[i]) / normRes;
102 }
103
104 return beamformingVector;
105}
106
109{
110 ComplexVector steeringVector(GetNumElems());
111 for (size_t i = 0; i < GetNumElems(); i++)
112 {
113 Vector loc = GetElementLocation(i);
114 double phase = -2 * M_PI *
115 (sin(a.GetInclination()) * cos(a.GetAzimuth()) * loc.x +
116 sin(a.GetInclination()) * sin(a.GetAzimuth()) * loc.y +
117 cos(a.GetInclination()) * loc.z);
118 steeringVector[i] = std::polar<double>(1.0, phase);
119 }
120 return steeringVector;
121}
122
123void
125{
126 NS_LOG_FUNCTION(this);
127 m_antennaElement = antennaElement;
128}
129
136
139{
140 return m_id;
141}
142
143bool
145{
146 // Check that channel needs update
147 bool needsUpdate = m_outOfDateAntennaPairChannel.GetValue(m_id, antennaB->m_id);
148
149 // Assume the channel will be updated (needsUpdate == true), reset these
150 m_outOfDateAntennaPairChannel.SetValue(m_id, antennaB->m_id, false);
151 return needsUpdate;
152}
153
154void
159
160} /* 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.
static SymmetricAdjacencyMatrix< bool > m_outOfDateAntennaPairChannel
matrix indicating whether a channel matrix between a pair of antennas needs to be updated after a cha...
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.
bool IsChannelOutOfDate(Ptr< const PhasedArrayModel > antennaB) const
Returns whether the channel needs to be updated due to antenna setting changes.
ComplexVector GetBeamformingVector() const
Returns the beamforming vector that is currently being used.
bool m_isBfVectorValid
ensures the validity of the beamforming vector
void InvalidateChannels() const
After changing the antenna settings, InvalidateChannels() should be called to mark up-to-date channel...
~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.
T GetValue(size_t row, size_t column)
Retrieve the value of matrix (row, column) node.
void SetValueAdjacent(size_t row, T value)
Set the value of adjacent nodes of a given node (all columns of a given row, and its reflection)
void AddRow()
Add new row to the adjacency matrix.
void SetValue(size_t row, size_t column, T value)
Set the value of matrix (row, column) node.
a unique identifier for an interface.
Definition type-id.h:49
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.