From b42678ee35c8ce61dd4bf98da27d41ab1b73a0db Mon Sep 17 00:00:00 2001 From: Pagin Matteo Date: Tue, 24 May 2022 15:17:27 +0200 Subject: [PATCH] Update compatibility to updated antenna module (#3) Now compatible with master branch, commit 77d60886080e42eb5761dca60dc69145d915e5a6 Changes: - Update ThreeGppAntennaArrayModel to PhasedArrayModel framework Co-authored-by: Mattia Lecci --- examples/qd-channel-model-example.cc | 22 +++++++++++----------- model/qd-channel-model.cc | 8 ++++---- model/qd-channel-model.h | 10 +++++----- model/qd-channel-utils.cc | 14 +++++++------- model/qd-channel-utils.h | 6 +++--- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/examples/qd-channel-model-example.cc b/examples/qd-channel-model-example.cc index 400a71f..cf9f209 100644 --- a/examples/qd-channel-model-example.cc +++ b/examples/qd-channel-model-example.cc @@ -27,7 +27,7 @@ #include #include "ns3/core-module.h" #include "ns3/qd-channel-model.h" -#include "ns3/three-gpp-antenna-array-model.h" +#include "ns3/uniform-planar-array.h" #include "ns3/three-gpp-spectrum-propagation-loss-model.h" #include "ns3/simple-net-device.h" #include "ns3/node-container.h" @@ -48,8 +48,8 @@ uint32_t timeRes = 5; // Time resolution in milliseconds Ptr qdChannel; Ptr txMob; Ptr rxMob; -Ptr txAntenna; -Ptr rxAntenna; +Ptr txAntenna; +Ptr rxAntenna; Ptr spectrumLossModel; /** @@ -59,7 +59,8 @@ Ptr spectrumLossModel; * \param rxDevice the device towards which point the beam * \param rxAntenna the antenna object associated to rxDevice */ -static void DoBeamforming (Ptr txDevice, Ptr txAntenna, Ptr rxDevice, Ptr rxAntenna); +static void DoBeamforming (Ptr txDevice, Ptr txAntenna, + Ptr rxDevice, Ptr rxAntenna); /* * Compute the average SNR, print it to both terminal and file */ @@ -109,14 +110,12 @@ main (int argc, char *argv[]) spectrumLossModel = CreateObjectWithAttributes ("ChannelModel", PointerValue (qdChannel)); // Create the antenna objects and set their dimensions - txAntenna = CreateObjectWithAttributes ("NumColumns", UintegerValue (2), - "NumRows", UintegerValue (2), - "IsotropicElements", BooleanValue (true)); + txAntenna = CreateObjectWithAttributes ("NumColumns", UintegerValue (2), + "NumRows", UintegerValue (2)); txNode->AggregateObject (txAntenna); - rxAntenna = CreateObjectWithAttributes ("NumColumns", UintegerValue (2), - "NumRows", UintegerValue (2), - "IsotropicElements", BooleanValue (true)); + rxAntenna = CreateObjectWithAttributes ("NumColumns", UintegerValue (2), + "NumRows", UintegerValue (2)); rxNode->AggregateObject (rxAntenna); // Initialize the devices in the ThreeGppSpectrumPropagationLossModel @@ -134,7 +133,8 @@ main (int argc, char *argv[]) /* UTILITIES */ static void -DoBeamforming (Ptr txDevice, Ptr txAntenna, Ptr rxDevice, Ptr rxAntenna) +DoBeamforming (Ptr txDevice, Ptr txAntenna, + Ptr rxDevice, Ptr rxAntenna) { Ptr thisMob = txDevice->GetNode ()->GetObject (); Ptr otherMob = rxDevice->GetNode ()->GetObject (); diff --git a/model/qd-channel-model.cc b/model/qd-channel-model.cc index 21b1c71..0151686 100644 --- a/model/qd-channel-model.cc +++ b/model/qd-channel-model.cc @@ -489,8 +489,8 @@ QdChannelModel::ChannelMatrixNeedsUpdate ( Ptr QdChannelModel::GetChannel (Ptr aMob, Ptr bMob, - Ptr aAntenna, - Ptr bAntenna) + Ptr aAntenna, + Ptr bAntenna) { NS_LOG_FUNCTION (this << aMob << bMob << aAntenna << bAntenna); @@ -542,8 +542,8 @@ QdChannelModel::GetChannel (Ptr aMob, Ptr QdChannelModel::GetNewChannel (Ptr aMob, Ptr bMob, - Ptr aAntenna, - Ptr bAntenna) const + Ptr aAntenna, + Ptr bAntenna) const { NS_LOG_FUNCTION (this << aMob << bMob << aAntenna << bAntenna); diff --git a/model/qd-channel-model.h b/model/qd-channel-model.h index b929826..cd4a56a 100644 --- a/model/qd-channel-model.h +++ b/model/qd-channel-model.h @@ -31,7 +31,7 @@ namespace ns3 { -class ThreeGppAntennaArrayModel; +class PhasedArrayModel; class MobilityModel; /** @@ -72,8 +72,8 @@ class QdChannelModel : public MatrixBasedChannelModel */ Ptr GetChannel (Ptr aMob, Ptr bMob, - Ptr aAntenna, - Ptr bAntenna) override; + Ptr aAntenna, + Ptr bAntenna) override; /* * Set the folder path containing the scenario of interest @@ -140,8 +140,8 @@ class QdChannelModel : public MatrixBasedChannelModel */ Ptr GetNewChannel (Ptr aMob, Ptr bMob, - Ptr aAntenna, - Ptr bAntenna) const; + Ptr aAntenna, + Ptr bAntenna) const; /** * Check if the channel matrix has to be updated diff --git a/model/qd-channel-utils.cc b/model/qd-channel-utils.cc index c3acd97..b594323 100644 --- a/model/qd-channel-utils.cc +++ b/model/qd-channel-utils.cc @@ -23,17 +23,17 @@ #include "ns3/core-module.h" #include "ns3/qd-channel-model.h" -#include "ns3/three-gpp-antenna-array-model.h" +#include "ns3/phased-array-model.h" #include "ns3/qd-channel-utils.h" NS_LOG_COMPONENT_DEFINE ("QdChannelUtils"); namespace ns3 { -ThreeGppAntennaArrayModel::ComplexVector +PhasedArrayModel::ComplexVector GetFirstEigenvector (MatrixBasedChannelModel::Complex2DVector A, uint32_t nIter, double threshold) { - ThreeGppAntennaArrayModel::ComplexVector antennaWeights; + PhasedArrayModel::ComplexVector antennaWeights; uint16_t arraySize = A.size (); for (uint16_t eIndex = 0; eIndex < arraySize; eIndex++) { @@ -44,7 +44,7 @@ GetFirstEigenvector (MatrixBasedChannelModel::Complex2DVector A, uint32_t nIter, double diff = 1; while (iter < nIter && diff > threshold) { - ThreeGppAntennaArrayModel::ComplexVector antennaWeightsNew; + PhasedArrayModel::ComplexVector antennaWeightsNew; for (uint16_t row = 0; row < arraySize; row++) { @@ -79,7 +79,7 @@ GetFirstEigenvector (MatrixBasedChannelModel::Complex2DVector A, uint32_t nIter, return antennaWeights; } -std::pair +std::pair ComputeSvdBeamformingVectors (Ptr params) { // params @@ -138,7 +138,7 @@ ComputeSvdBeamformingVectors (Ptr } // Calculate beamforming vector from spatial correlation matrix - ThreeGppAntennaArrayModel::ComplexVector bW = GetFirstEigenvector (bQ, svdIter, svdThresh); + PhasedArrayModel::ComplexVector bW = GetFirstEigenvector (bQ, svdIter, svdThresh); // Compute the receiver side spatial correlation matrix aQ = HH*, where H is the sum of H_n over n clusters. MatrixBasedChannelModel::Complex2DVector aQ; @@ -164,7 +164,7 @@ ComputeSvdBeamformingVectors (Ptr } // Calculate beamforming vector from spatial correlation matrix. - ThreeGppAntennaArrayModel::ComplexVector aW = GetFirstEigenvector (aQ, svdIter, svdThresh); + PhasedArrayModel::ComplexVector aW = GetFirstEigenvector (aQ, svdIter, svdThresh); for (size_t i = 0; i < aW.size (); ++i) { diff --git a/model/qd-channel-utils.h b/model/qd-channel-utils.h index 9f39814..3b482a3 100644 --- a/model/qd-channel-utils.h +++ b/model/qd-channel-utils.h @@ -27,7 +27,7 @@ namespace ns3 { class MatrixBasedChannelModel; -class ThreeGppAntennaArrayModel; +class PhasedArrayModel; /** * Compute the eigenvector associated to the largest eigenvalue. @@ -39,7 +39,7 @@ class ThreeGppAntennaArrayModel; * \param threshold difference threshold for consecutive iterations * \return the eigenvector associated to the largest eigenvalue */ -ThreeGppAntennaArrayModel::ComplexVector +PhasedArrayModel::ComplexVector GetFirstEigenvector (MatrixBasedChannelModel::Complex2DVector A, uint32_t nIter, double threshold); /** @@ -54,7 +54,7 @@ GetFirstEigenvector (MatrixBasedChannelModel::Complex2DVector A, uint32_t nIter, * \param A params * \return the beamforming vectors for the second and first dimension, respectively */ -std::pair +std::pair ComputeSvdBeamformingVectors (Ptr params); } // namespace ns3