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