21 #include "ns3/double.h"
22 #include "ns3/uinteger.h"
23 #include "ns3/pointer.h"
24 #include "ns3/uniform-planar-array.h"
25 #include "ns3/isotropic-antenna-model.h"
26 #include "ns3/three-gpp-antenna-model.h"
27 #include "ns3/simulator.h"
58 static std::string BuildNameString (
Ptr<AntennaModel> element, uint32_t rows, uint32_t cols,
double rowSpace,
double colSpace,
73 double alpha,
double beta,
Angles direction,
double expectedGainDb);
79 virtual void DoRun (
void);
101 std::ostringstream oss;
102 oss <<
"UPA=" << rows <<
"x" << cols
103 <<
", row spacing=" << rowSpace <<
"*lambda"
104 <<
", col spacing=" << colSpace <<
"*lambda"
108 <<
", direction=" << direction;
114 double alpha,
double beta,
Angles direction,
double expectedGainDb)
115 :
TestCase (BuildNameString (element, rows, cols, rowSpace, colSpace,
alpha, beta, direction)),
119 m_rowSpace (rowSpace),
120 m_colSpace (colSpace),
123 m_direction (direction),
124 m_expectedGain (expectedGainDb)
136 std::pair<double, double> fp = a->GetElementFieldPattern (
m_direction);
139 std::complex<double> prod {0};
140 for (
size_t i = 0; i < sv.size (); i++)
142 prod += sv[i] * bf[i];
144 double bfGain = std::pow (std::abs (prod), 2);
145 double bfGainDb = 10 * std::log10 (bfGain);
148 double elementPowerGain = std::pow (std::get<0> (fp), 2) + std::pow (std::get<1> (fp), 2);
149 double elementPowerGainDb = 10 * std::log10 (elementPowerGain);
152 return bfGainDb + elementPowerGainDb;
187 :
TestSuite (
"uniform-planar-array-test", UNIT)
194 AddTestCase (
new UniformPlanarArrayTestCase (isotropic, 1, 1, 0.5, 0.5,
DegreesToRadians (0),
DegreesToRadians (0),
Angles (
DegreesToRadians (0),
DegreesToRadians (90)), 0.0), TestCase::QUICK);
195 AddTestCase (
new UniformPlanarArrayTestCase ( tgpp, 1, 1, 0.5, 0.5,
DegreesToRadians (0),
DegreesToRadians (0),
Angles (
DegreesToRadians (0),
DegreesToRadians (90)), 8.0), TestCase::QUICK);
196 AddTestCase (
new UniformPlanarArrayTestCase ( tgpp, 1, 1, 0.5, 0.5,
DegreesToRadians (90),
DegreesToRadians (0),
Angles (
DegreesToRadians (90),
DegreesToRadians (90)), 8.0), TestCase::QUICK);
197 AddTestCase (
new UniformPlanarArrayTestCase ( tgpp, 1, 1, 0.5, 0.5,
DegreesToRadians (-90),
DegreesToRadians (0),
Angles (
DegreesToRadians (-90),
DegreesToRadians (90)), 8.0), TestCase::QUICK);
198 AddTestCase (
new UniformPlanarArrayTestCase ( tgpp, 1, 1, 0.5, 0.5,
DegreesToRadians (180),
DegreesToRadians (0),
Angles (
DegreesToRadians (180),
DegreesToRadians (90)), 8.0), TestCase::QUICK);
199 AddTestCase (
new UniformPlanarArrayTestCase ( tgpp, 1, 1, 0.5, 0.5,
DegreesToRadians (-180),
DegreesToRadians (0),
Angles (
DegreesToRadians (-180),
DegreesToRadians (90)), 8.0), TestCase::QUICK);
200 AddTestCase (
new UniformPlanarArrayTestCase ( tgpp, 1, 1, 0.5, 0.5,
DegreesToRadians (0),
DegreesToRadians (45),
Angles (
DegreesToRadians (0),
DegreesToRadians (135)), 8.0), TestCase::QUICK);
201 AddTestCase (
new UniformPlanarArrayTestCase ( tgpp, 1, 1, 0.5, 0.5,
DegreesToRadians (0),
DegreesToRadians (-45),
Angles (
DegreesToRadians (0),
DegreesToRadians (45)), 8.0), TestCase::QUICK);
202 AddTestCase (
new UniformPlanarArrayTestCase ( tgpp, 1, 1, 0.5, 0.5,
DegreesToRadians (0),
DegreesToRadians (90),
Angles (
DegreesToRadians (0),
DegreesToRadians (180)), 8.0), TestCase::QUICK);
203 AddTestCase (
new UniformPlanarArrayTestCase ( tgpp, 1, 1, 0.5, 0.5,
DegreesToRadians (0),
DegreesToRadians (-90),
Angles (
DegreesToRadians (0),
DegreesToRadians (0)), 8.0), TestCase::QUICK);
206 AddTestCase (
new UniformPlanarArrayTestCase ( tgpp, 10, 1, 0.5, 0.5,
DegreesToRadians (0),
DegreesToRadians (0),
Angles (
DegreesToRadians (0),
DegreesToRadians (90)), 18.0), TestCase::QUICK);
207 AddTestCase (
new UniformPlanarArrayTestCase ( tgpp, 10, 1, 0.5, 0.5,
DegreesToRadians (90),
DegreesToRadians (0),
Angles (
DegreesToRadians (90),
DegreesToRadians (90)), 18.0), TestCase::QUICK);
208 AddTestCase (
new UniformPlanarArrayTestCase ( tgpp, 10, 1, 0.5, 0.5,
DegreesToRadians (0),
DegreesToRadians (45),
Angles (
DegreesToRadians (0),
DegreesToRadians (135)), 18.0), TestCase::QUICK);
211 AddTestCase (
new UniformPlanarArrayTestCase ( tgpp, 10, 10, 0.5, 0.5,
DegreesToRadians (0),
DegreesToRadians (0),
Angles (
DegreesToRadians (0),
DegreesToRadians (90)), 28.0), TestCase::QUICK);
212 AddTestCase (
new UniformPlanarArrayTestCase ( tgpp, 10, 10, 0.5, 0.5,
DegreesToRadians (90),
DegreesToRadians (0),
Angles (
DegreesToRadians (90),
DegreesToRadians (90)), 28.0), TestCase::QUICK);
213 AddTestCase (
new UniformPlanarArrayTestCase ( tgpp, 10, 10, 0.5, 0.5,
DegreesToRadians (0),
DegreesToRadians (45),
Angles (
DegreesToRadians (0),
DegreesToRadians (135)), 28.0), TestCase::QUICK);
Class holding the azimuth and inclination angles of spherical coordinates.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
std::vector< std::complex< double > > ComplexVector
type definition for complex vectors
Hold objects of type Ptr<T>.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
std::string GetName(void) const
Get the name.
Hold an unsigned integer type.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
#define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if ...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double DegreesToRadians(double degrees)
converts degrees to radians
double RadiansToDegrees(double radians)
converts radians to degrees
float alpha
Plot alpha value (transparency)