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
16#include <complex>
17
18namespace ns3
19{
20
21/**
22 * \ingroup antenna
23 *
24 * \brief Class implementing the phased array model virtual base class.
25 */
27{
28 public:
29 /**
30 * Constructor
31 */
33
34 /**
35 * Destructor
36 */
37 ~PhasedArrayModel() override;
38
39 /**
40 * \brief Get the type ID.
41 * \return The object TypeId.
42 */
43 static TypeId GetTypeId();
44
45 //!< type definition for complex vectors
46 using ComplexVector = ComplexMatrixArray; //!< the underlying Valarray
47
48 /**
49 * \brief Computes the Frobenius norm of the complex vector
50 *
51 * \param complexVector on which to calculate Frobenius norm
52 * \return the Frobenius norm of the complex vector
53 */
54 double norm(const ComplexVector& complexVector) const
55 {
56 double norm = 0;
57 for (size_t i = 0; i < complexVector.GetSize(); i++)
58 {
59 norm += std::norm(complexVector[i]);
60 }
61 return std::sqrt(norm);
62 }
63
64 /**
65 * \brief Returns the location of the antenna element with the specified
66 * index, normalized with respect to the wavelength.
67 * \param index the index of the antenna element
68 * \return the 3D vector that represents the position of the element
69 */
70 virtual Vector GetElementLocation(uint64_t index) const = 0;
71
72 /**
73 * \brief Returns the number of antenna elements
74 * \return the number of antenna elements
75 */
76 virtual size_t GetNumElems() const = 0;
77
78 /**
79 * \brief Returns the horizontal and vertical components of the antenna element field
80 * pattern at the specified direction. Single polarization is considered.
81 * \param a the angle indicating the interested direction
82 * \param polIndex the index of the polarization for which will be retrieved the field
83 * pattern
84 * \return a pair in which the first element is the horizontal component of the field
85 * pattern and the second element is the vertical component of the field pattern
86 */
87 virtual std::pair<double, double> GetElementFieldPattern(Angles a,
88 uint8_t polIndex = 0) const = 0;
89
90 /**
91 * \brief Set the vertical number of ports
92 * \param nPorts the vertical number of ports
93 */
94 virtual void SetNumVerticalPorts(uint16_t nPorts) = 0;
95
96 /**
97 * \brief Set the horizontal number of ports
98 * \param nPorts the horizontal number of ports
99 */
100 virtual void SetNumHorizontalPorts(uint16_t nPorts) = 0;
101
102 /**
103 * \brief Get the vertical number of ports
104 * \return the vertical number of ports
105 */
106 virtual uint16_t GetNumVerticalPorts() const = 0;
107
108 /**
109 * \brief Get the horizontal number of ports
110 * \return the horizontal number of ports
111 */
112 virtual uint16_t GetNumHorizontalPorts() const = 0;
113
114 /**
115 * \brief Get the number of ports
116 * \return the number of ports
117 */
118 virtual uint16_t GetNumPorts() const = 0;
119
120 /**
121 * \brief Get the number of polarizations
122 * \return the number of polarizations
123 */
124 virtual uint8_t GetNumPols() const = 0;
125
126 /**
127 * \brief Get the vertical number of antenna elements per port
128 * \return the vertical number of antenna elements per port
129 */
130 virtual size_t GetVElemsPerPort() const = 0;
131 /**
132 * \brief Get the horizontal number of antenna elements per port
133 * \return the horizontal number of antenna elements per port
134 */
135 virtual size_t GetHElemsPerPort() const = 0;
136
137 /**
138 * \brief Get the number of elements per port
139 * \return the number of elements per port
140 */
141 virtual size_t GetNumElemsPerPort() const = 0;
142
143 /**
144 * \brief Set the number of columns
145 * \param nColumns the number of columns to be set
146 */
147 virtual void SetNumColumns(uint32_t nColumns) = 0;
148
149 /**
150 * \brief Set the number of rows
151 * \param nRows the number of rows to be set
152 */
153 virtual void SetNumRows(uint32_t nRows) = 0;
154
155 /**
156 * \brief Get the number of columns
157 * \return the number of columns in the antenna array
158 */
159 virtual uint32_t GetNumColumns() const = 0;
160
161 /**
162 * \brief Get the number of rows
163 * \return the number of rows in the antenna array
164 */
165 virtual uint32_t GetNumRows() const = 0;
166
167 /**
168 * \brief Get the polarization slant angle
169 * \return the polarization slant angle
170 */
171 virtual double GetPolSlant() const = 0;
172
173 /**
174 * \brief Get the indication whether the antenna array is dual polarized
175 * \return Returns true if the antenna array is dual polarized
176 */
177 virtual bool IsDualPol() const = 0;
178
179 /**
180 * \brief Calculate the index in the antenna array from the port index and the element in the
181 * port
182 * \param portIndex the port index
183 * \param subElementIndex the element index in the port
184 * \return the antenna element index in the antenna array
185 */
186 virtual uint16_t ArrayIndexFromPortIndex(uint16_t portIndex,
187 uint16_t subElementIndex) const = 0;
188
189 /**
190 * Returns the index of the polarization to which belongs that antenna element
191 * \param elementIndex the antenna element for which will be returned the polarization index
192 * \return the polarization index
193 */
194 virtual uint8_t GetElemPol(size_t elementIndex) const = 0;
195
196 /**
197 * Sets the beamforming vector to be used
198 * \param beamformingVector the beamforming vector
199 */
200 void SetBeamformingVector(const ComplexVector& beamformingVector);
201
202 /**
203 * Returns the beamforming vector that is currently being used
204 * \return the current beamforming vector
205 */
207
208 /**
209 * Returns the const reference of the beamforming vector that is currently being used
210 * \return the const reference of the current beamforming vector
211 */
213
214 /**
215 * Returns the beamforming vector that points towards the specified position
216 * \param a the beamforming angle
217 * \return the beamforming vector
218 */
220
221 /**
222 * Returns the steering vector that points toward the specified position
223 * \param a the steering angle
224 * \return the steering vector
225 */
227
228 /**
229 * Sets the antenna model to be used
230 * \param antennaElement the antenna model
231 */
232 void SetAntennaElement(Ptr<AntennaModel> antennaElement);
233
234 /**
235 * Returns a pointer to the AntennaModel instance used to model the elements of the array
236 * \return pointer to the AntennaModel instance
237 */
239
240 /**
241 * Returns the ID of this antenna array instance
242 * \return the ID value
243 */
244 uint32_t GetId() const;
245
246 protected:
247 ComplexVector m_beamformingVector; //!< the beamforming vector in use
248 Ptr<AntennaModel> m_antennaElement; //!< the model of the antenna element in use
249 bool m_isBfVectorValid; //!< ensures the validity of the beamforming vector
250 static uint32_t
251 m_idCounter; //!< the ID counter that is used to determine the unique antenna array ID
252 uint32_t m_id{0}; //!< the ID of this antenna array instance
253};
254
255} /* namespace ns3 */
256
257#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.
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.
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.
~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 unique identifier for an interface.
Definition type-id.h:48
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.