5#include "beamforming-vector.h"
8#include <ns3/uinteger.h>
13PhasedArrayModel::ComplexVector
16 auto antennaRows = antenna->GetNumRows();
17 auto antennaColumns = antenna->GetNumColumns();
18 auto numElemsPerPort = antenna->GetNumElemsPerPort();
20 double power = 1 / sqrt(numElemsPerPort);
21 size_t numPolarizations = antenna->IsDualPol() ? 2 : 1;
23 PhasedArrayModel::ComplexVector omni(antennaRows * antennaColumns * numPolarizations);
25 for (
size_t pol = 0; pol < numPolarizations; pol++)
27 for (uint32_t ind = 0; ind < antennaRows; ind++)
29 std::complex<double> c = 0.0;
30 if (antennaRows % 2 == 0)
32 c = exp(std::complex<double>(0, M_PI * ind * ind / antennaRows));
36 c = exp(std::complex<double>(0, M_PI * ind * (ind + 1) / antennaRows));
38 for (uint32_t ind2 = 0; ind2 < antennaColumns; ind2++)
40 std::complex<double> d = 0.0;
41 if (antennaColumns % 2 == 0)
43 d = exp(std::complex<double>(0, M_PI * ind2 * ind2 / antennaColumns));
47 d = exp(std::complex<double>(0, M_PI * ind2 * (ind2 + 1) / antennaColumns));
49 omni[bfIndex] = (c * d * power);
57PhasedArrayModel::ComplexVector
62 UintegerValue uintValueNumRows;
63 antenna->GetAttribute(
"NumRows", uintValueNumRows);
65 double hAngle_radian =
66 M_PI * (
static_cast<double>(sector) /
static_cast<double>(uintValueNumRows.Get())) -
68 double vAngle_radian = elevation * M_PI / 180;
69 uint16_t size = antenna->GetNumElems();
70 PhasedArrayModel::ComplexVector tempVector(size);
71 auto numAnalogBeamElements = (antenna->GetVElemsPerPort() * antenna->GetHElemsPerPort());
72 auto power = 1.0 / sqrt(numAnalogBeamElements);
73 for (
auto ind = 0; ind < size; ind++)
75 Vector loc = antenna->GetElementLocation(ind);
78 (sin(vAngle_radian) * cos(hAngle_radian) * loc.x +
79 sin(vAngle_radian) * sin(hAngle_radian) * loc.y + cos(vAngle_radian) * loc.z);
80 tempVector[ind] = (exp(std::complex<double>(0, phase)) * power);
85PhasedArrayModel::ComplexVector
88 UintegerValue uintValueNumRows;
89 antenna->GetAttribute(
"NumRows", uintValueNumRows);
91 double hAngle_radian = azimuth * M_PI / 180;
92 double vAngle_radian = zenith * M_PI / 180;
93 uint16_t size = antenna->GetNumElems();
94 double power = 1 / sqrt(size);
95 PhasedArrayModel::ComplexVector tempVector(size);
98 tempVector[0] = power;
102 for (
auto ind = 0; ind < size; ind++)
104 Vector loc = antenna->GetElementLocation(ind);
107 (sin(vAngle_radian) * cos(hAngle_radian) * loc.x +
108 sin(vAngle_radian) * sin(hAngle_radian) * loc.y + cos(vAngle_radian) * loc.z);
109 tempVector[ind] = exp(std::complex<double>(0, phase)) * power;
115PhasedArrayModel::ComplexVector
116CreateDirectPathBfv(
const Ptr<MobilityModel>& a,
117 const Ptr<MobilityModel>& b,
118 const Ptr<const UniformPlanarArray>& antenna)
121 Vector aPos = a->GetPosition();
122 Vector bPos = b->GetPosition();
125 Angles completeAngle(bPos, aPos);
127 double hAngleRadian = completeAngle.GetAzimuth();
129 double vAngleRadian = completeAngle.GetInclination();
132 int totNoArrayElements = antenna->GetNumElems();
133 auto numElemsPerPort = antenna->GetNumElemsPerPort();
136 double power = 1 / sqrt(numElemsPerPort);
138 PhasedArrayModel::ComplexVector antennaWeights(totNoArrayElements);
140 for (
int ind = 0; ind < totNoArrayElements; ind++)
142 Vector loc = antenna->GetElementLocation(ind);
143 double phase = -2 * M_PI *
144 (sin(vAngleRadian) * cos(hAngleRadian) * loc.x +
145 sin(vAngleRadian) * sin(hAngleRadian) * loc.y + cos(vAngleRadian) * loc.z);
146 antennaWeights[ind] = exp(std::complex<double>(0, phase)) * power;
149 return antennaWeights;
PhasedArrayModel::ComplexVector CreateDirectionalBfvAz(const Ptr< const UniformPlanarArray > &antenna, double azimuth, double zenith)
Creates a beamforming vector for a given azimuth and zenith.
PhasedArrayModel::ComplexVector CreateQuasiOmniBfv(const Ptr< const UniformPlanarArray > &antenna)
Create a quasi omni beamforming vector.
PhasedArrayModel::ComplexVector CreateDirectionalBfv(const Ptr< const UniformPlanarArray > &antenna, uint16_t sector, double elevation)
Creates a beamforming vector for a given sector and elevation.