A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
phased-array-model.h
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
7#ifndef PHASED_ARRAY_MODEL_H
8#define PHASED_ARRAY_MODEL_H
9
10#include "angles.h"
11#include "antenna-model.h"
12
13#include "ns3/matrix-array.h"
14#include "ns3/object.h"
15#include "ns3/symmetric-adjacency-matrix.h"
16
17#include <complex>
18
19namespace ns3
20{
21
22/**
23 * @ingroup antenna
24 *
25 * @brief Class implementing the phased array model virtual base class.
26 */
28{
29 public:
30 /**
31 * Constructor
32 */
34
35 /**
36 * Destructor
37 */
38 ~PhasedArrayModel() override;
39
40 /**
41 * @brief Get the type ID.
42 * @return The object TypeId.
43 */
44 static TypeId GetTypeId();
45
46 //!< type definition for complex vectors
47 using ComplexVector = ComplexMatrixArray; //!< the underlying Valarray
48
49 /**
50 * @brief Computes the Frobenius norm of the complex vector
51 *
52 * @param complexVector on which to calculate Frobenius norm
53 * @return the Frobenius norm of the complex vector
54 */
55 double norm(const ComplexVector& complexVector) const
56 {
57 double norm = 0;
58 for (size_t i = 0; i < complexVector.GetSize(); i++)
59 {
60 norm += std::norm(complexVector[i]);
61 }
62 return std::sqrt(norm);
63 }
64
65 /**
66 * @brief Returns the location of the antenna element with the specified
67 * index, normalized with respect to the wavelength.
68 * @param index the index of the antenna element
69 * @return the 3D vector that represents the position of the element
70 */
71 virtual Vector GetElementLocation(uint64_t index) const = 0;
72
73 /**
74 * @brief Returns the number of antenna elements
75 * @return the number of antenna elements
76 */
77 virtual size_t GetNumElems() const = 0;
78
79 /**
80 * @brief Returns the horizontal and vertical components of the antenna element field
81 * pattern at the specified direction. Single polarization is considered.
82 * @param a the angle indicating the interested direction
83 * @param polIndex the index of the polarization for which will be retrieved the field
84 * pattern
85 * @return a pair in which the first element is the horizontal component of the field
86 * pattern and the second element is the vertical component of the field pattern
87 */
88 virtual std::pair<double, double> GetElementFieldPattern(Angles a,
89 uint8_t polIndex = 0) const = 0;
90
91 /**
92 * @brief Set the vertical number of ports
93 * @param nPorts the vertical number of ports
94 */
95 virtual void SetNumVerticalPorts(uint16_t nPorts) = 0;
96
97 /**
98 * @brief Set the horizontal number of ports
99 * @param nPorts the horizontal number of ports
100 */
101 virtual void SetNumHorizontalPorts(uint16_t nPorts) = 0;
102
103 /**
104 * @brief Get the vertical number of ports
105 * @return the vertical number of ports
106 */
107 virtual uint16_t GetNumVerticalPorts() const = 0;
108
109 /**
110 * @brief Get the horizontal number of ports
111 * @return the horizontal number of ports
112 */
113 virtual uint16_t GetNumHorizontalPorts() const = 0;
114
115 /**
116 * @brief Get the number of ports
117 * @return the number of ports
118 */
119 virtual uint16_t GetNumPorts() const = 0;
120
121 /**
122 * @brief Get the number of polarizations
123 * @return the number of polarizations
124 */
125 virtual uint8_t GetNumPols() const = 0;
126
127 /**
128 * @brief Get the vertical number of antenna elements per port
129 * @return the vertical number of antenna elements per port
130 */
131 virtual size_t GetVElemsPerPort() const = 0;
132 /**
133 * @brief Get the horizontal number of antenna elements per port
134 * @return the horizontal number of antenna elements per port
135 */
136 virtual size_t GetHElemsPerPort() const = 0;
137
138 /**
139 * @brief Get the number of elements per port
140 * @return the number of elements per port
141 */
142 virtual size_t GetNumElemsPerPort() const = 0;
143
144 /**
145 * @brief Set the number of columns
146 * @param nColumns the number of columns to be set
147 */
148 virtual void SetNumColumns(uint32_t nColumns) = 0;
149
150 /**
151 * @brief Set the number of rows
152 * @param nRows the number of rows to be set
153 */
154 virtual void SetNumRows(uint32_t nRows) = 0;
155
156 /**
157 * @brief Get the number of columns
158 * @return the number of columns in the antenna array
159 */
160 virtual uint32_t GetNumColumns() const = 0;
161
162 /**
163 * @brief Get the number of rows
164 * @return the number of rows in the antenna array
165 */
166 virtual uint32_t GetNumRows() const = 0;
167
168 /**
169 * @brief Get the polarization slant angle
170 * @return the polarization slant angle
171 */
172 virtual double GetPolSlant() const = 0;
173
174 /**
175 * @brief Get the indication whether the antenna array is dual polarized
176 * @return Returns true if the antenna array is dual polarized
177 */
178 virtual bool IsDualPol() const = 0;
179
180 /**
181 * @brief Calculate the index in the antenna array from the port index and the element in the
182 * port
183 * @param portIndex the port index
184 * @param subElementIndex the element index in the port
185 * @return the antenna element index in the antenna array
186 */
187 virtual uint16_t ArrayIndexFromPortIndex(uint16_t portIndex,
188 uint16_t subElementIndex) const = 0;
189
190 /**
191 * Returns the index of the polarization to which belongs that antenna element
192 * @param elementIndex the antenna element for which will be returned the polarization index
193 * @return the polarization index
194 */
195 virtual uint8_t GetElemPol(size_t elementIndex) const = 0;
196
197 /**
198 * Sets the beamforming vector to be used
199 * @param beamformingVector the beamforming vector
200 */
201 void SetBeamformingVector(const ComplexVector& beamformingVector);
202
203 /**
204 * Returns the beamforming vector that is currently being used
205 * @return the current beamforming vector
206 */
208
209 /**
210 * Returns the const reference of the beamforming vector that is currently being used
211 * @return the const reference of the current beamforming vector
212 */
214
215 /**
216 * Returns the beamforming vector that points towards the specified position
217 * @param a the beamforming angle
218 * @return the beamforming vector
219 */
221
222 /**
223 * Returns the steering vector that points toward the specified position
224 * @param a the steering angle
225 * @return the steering vector
226 */
228
229 /**
230 * Sets the antenna model to be used
231 * @param antennaElement the antenna model
232 */
233 void SetAntennaElement(Ptr<AntennaModel> antennaElement);
234
235 /**
236 * Returns a pointer to the AntennaModel instance used to model the elements of the array
237 * @return pointer to the AntennaModel instance
238 */
240
241 /**
242 * Returns the ID of this antenna array instance
243 * @return the ID value
244 */
245 uint32_t GetId() const;
246
247 /**
248 * Returns whether the channel needs to be updated due to antenna setting changes.
249 * @param antennaB the second antenna of the pair for the channel we want to check
250 * @return whether a channel update is needed due to antenna settings changes
251 */
253
254 protected:
255 /**
256 * After changing the antenna settings, InvalidateChannels() should be called to mark
257 * up-to-date channels as out-of-date
258 */
259 void InvalidateChannels() const;
260
261 ComplexVector m_beamformingVector; //!< the beamforming vector in use
262 Ptr<AntennaModel> m_antennaElement; //!< the model of the antenna element in use
263 bool m_isBfVectorValid; //!< ensures the validity of the beamforming vector
264 static uint32_t
265 m_idCounter; //!< the ID counter that is used to determine the unique antenna array ID
266 uint32_t m_id{0}; //!< the ID of this antenna array instance
268 m_outOfDateAntennaPairChannel; //!< matrix indicating whether a channel matrix between a
269 //!< pair of antennas needs to be updated after a change in
270 //!< one of the antennas configurations
271};
272
273} /* namespace ns3 */
274
275#endif /* PHASED_ARRAY_MODEL_H */
Class holding the azimuth and inclination angles of spherical coordinates.
Definition angles.h:107
A base class which provides memory management and object aggregation.
Definition object.h:78
Class implementing the phased array model virtual base class.
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
virtual uint32_t GetNumRows() const =0
Get the number of rows.
ComplexVector GetSteeringVector(Angles a) const
Returns the steering vector that points toward the specified position.
virtual void SetNumRows(uint32_t nRows)=0
Set the number of rows.
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.
virtual uint16_t GetNumHorizontalPorts() const =0
Get the horizontal number of ports.
virtual uint16_t GetNumVerticalPorts() const =0
Get the vertical number of ports.
virtual uint32_t GetNumColumns() const =0
Get the number of columns.
static SymmetricAdjacencyMatrix< bool > m_outOfDateAntennaPairChannel
matrix indicating whether a channel matrix between a pair of antennas needs to be updated after a cha...
virtual size_t GetNumElemsPerPort() const =0
Get the number of elements per port.
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.
virtual uint8_t GetNumPols() const =0
Get the number of polarizations.
virtual size_t GetVElemsPerPort() const =0
Get the vertical number of antenna elements per port.
virtual uint8_t GetElemPol(size_t elementIndex) const =0
Returns the index of the polarization to which belongs that antenna element.
virtual void SetNumHorizontalPorts(uint16_t nPorts)=0
Set the horizontal number of ports.
virtual void SetNumColumns(uint32_t nColumns)=0
Set the number of columns.
ComplexVector GetBeamformingVector() const
Returns the beamforming vector that is currently being used.
bool m_isBfVectorValid
ensures the validity of the beamforming vector
double norm(const ComplexVector &complexVector) const
Computes the Frobenius norm of the complex vector.
virtual size_t GetHElemsPerPort() const =0
Get the horizontal number of antenna elements per port.
void InvalidateChannels() const
After changing the antenna settings, InvalidateChannels() should be called to mark up-to-date channel...
~PhasedArrayModel() override
Destructor.
virtual bool IsDualPol() const =0
Get the indication whether the antenna array is dual polarized.
virtual double GetPolSlant() const =0
Get the polarization slant angle.
uint32_t m_id
the ID of this antenna array instance
virtual uint16_t ArrayIndexFromPortIndex(uint16_t portIndex, uint16_t subElementIndex) const =0
Calculate the index in the antenna array from the port index and the element in the port.
void SetBeamformingVector(const ComplexVector &beamformingVector)
Sets the beamforming vector to be used.
virtual std::pair< double, double > GetElementFieldPattern(Angles a, uint8_t polIndex=0) const =0
Returns the horizontal and vertical components of the antenna element field pattern at the specified ...
ComplexVector m_beamformingVector
the beamforming vector in use
virtual size_t GetNumElems() const =0
Returns the number of antenna elements.
virtual void SetNumVerticalPorts(uint16_t nPorts)=0
Set the vertical number of ports.
static TypeId GetTypeId()
Get the type ID.
Smart pointer class similar to boost::intrusive_ptr.
A class representing a symmetric adjacency matrix.
a unique identifier for an interface.
Definition type-id.h:49
size_t GetSize() const
Definition val-array.h:394
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.
MatrixArray< std::complex< double > > ComplexMatrixArray
Create an alias for MatrixArray using complex type.