Skip to content

Commit

Permalink
Update compatibility to updated antenna module (#3)
Browse files Browse the repository at this point in the history
Now compatible with master branch, commit 77d60886080e42eb5761dca60dc69145d915e5a6

Changes:
- Update ThreeGppAntennaArrayModel to PhasedArrayModel framework

Co-authored-by: Mattia Lecci <mattia.lecci@gmail.com>
  • Loading branch information
pagmatt and mattia-lecci authored May 24, 2022
1 parent 9778514 commit b42678e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
22 changes: 11 additions & 11 deletions examples/qd-channel-model-example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <fstream>
#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"
Expand All @@ -48,8 +48,8 @@ uint32_t timeRes = 5; // Time resolution in milliseconds
Ptr<QdChannelModel> qdChannel;
Ptr<MobilityModel> txMob;
Ptr<MobilityModel> rxMob;
Ptr<ThreeGppAntennaArrayModel> txAntenna;
Ptr<ThreeGppAntennaArrayModel> rxAntenna;
Ptr<PhasedArrayModel> txAntenna;
Ptr<PhasedArrayModel> rxAntenna;
Ptr<ThreeGppSpectrumPropagationLossModel> spectrumLossModel;

/**
Expand All @@ -59,7 +59,8 @@ Ptr<ThreeGppSpectrumPropagationLossModel> spectrumLossModel;
* \param rxDevice the device towards which point the beam
* \param rxAntenna the antenna object associated to rxDevice
*/
static void DoBeamforming (Ptr<NetDevice> txDevice, Ptr<ThreeGppAntennaArrayModel> txAntenna, Ptr<NetDevice> rxDevice, Ptr<ThreeGppAntennaArrayModel> rxAntenna);
static void DoBeamforming (Ptr<NetDevice> txDevice, Ptr<PhasedArrayModel> txAntenna,
Ptr<NetDevice> rxDevice, Ptr<PhasedArrayModel> rxAntenna);
/*
* Compute the average SNR, print it to both terminal and file
*/
Expand Down Expand Up @@ -109,14 +110,12 @@ main (int argc, char *argv[])
spectrumLossModel = CreateObjectWithAttributes<ThreeGppSpectrumPropagationLossModel> ("ChannelModel", PointerValue (qdChannel));

// Create the antenna objects and set their dimensions
txAntenna = CreateObjectWithAttributes<ThreeGppAntennaArrayModel> ("NumColumns", UintegerValue (2),
"NumRows", UintegerValue (2),
"IsotropicElements", BooleanValue (true));
txAntenna = CreateObjectWithAttributes<UniformPlanarArray> ("NumColumns", UintegerValue (2),
"NumRows", UintegerValue (2));
txNode->AggregateObject (txAntenna);

rxAntenna = CreateObjectWithAttributes<ThreeGppAntennaArrayModel> ("NumColumns", UintegerValue (2),
"NumRows", UintegerValue (2),
"IsotropicElements", BooleanValue (true));
rxAntenna = CreateObjectWithAttributes<UniformPlanarArray> ("NumColumns", UintegerValue (2),
"NumRows", UintegerValue (2));
rxNode->AggregateObject (rxAntenna);

// Initialize the devices in the ThreeGppSpectrumPropagationLossModel
Expand All @@ -134,7 +133,8 @@ main (int argc, char *argv[])

/* UTILITIES */
static void
DoBeamforming (Ptr<NetDevice> txDevice, Ptr<ThreeGppAntennaArrayModel> txAntenna, Ptr<NetDevice> rxDevice, Ptr<ThreeGppAntennaArrayModel> rxAntenna)
DoBeamforming (Ptr<NetDevice> txDevice, Ptr<PhasedArrayModel> txAntenna,
Ptr<NetDevice> rxDevice, Ptr<PhasedArrayModel> rxAntenna)
{
Ptr<MobilityModel> thisMob = txDevice->GetNode ()->GetObject<MobilityModel> ();
Ptr<MobilityModel> otherMob = rxDevice->GetNode ()->GetObject<MobilityModel> ();
Expand Down
8 changes: 4 additions & 4 deletions model/qd-channel-model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,8 @@ QdChannelModel::ChannelMatrixNeedsUpdate (
Ptr<const MatrixBasedChannelModel::ChannelMatrix>
QdChannelModel::GetChannel (Ptr<const MobilityModel> aMob,
Ptr<const MobilityModel> bMob,
Ptr<const ThreeGppAntennaArrayModel> aAntenna,
Ptr<const ThreeGppAntennaArrayModel> bAntenna)
Ptr<const PhasedArrayModel> aAntenna,
Ptr<const PhasedArrayModel> bAntenna)
{
NS_LOG_FUNCTION (this << aMob << bMob << aAntenna << bAntenna);

Expand Down Expand Up @@ -542,8 +542,8 @@ QdChannelModel::GetChannel (Ptr<const MobilityModel> aMob,
Ptr<const MatrixBasedChannelModel::ChannelMatrix>
QdChannelModel::GetNewChannel (Ptr<const MobilityModel> aMob,
Ptr<const MobilityModel> bMob,
Ptr<const ThreeGppAntennaArrayModel> aAntenna,
Ptr<const ThreeGppAntennaArrayModel> bAntenna) const
Ptr<const PhasedArrayModel> aAntenna,
Ptr<const PhasedArrayModel> bAntenna) const
{
NS_LOG_FUNCTION (this << aMob << bMob << aAntenna << bAntenna);

Expand Down
10 changes: 5 additions & 5 deletions model/qd-channel-model.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

namespace ns3 {

class ThreeGppAntennaArrayModel;
class PhasedArrayModel;
class MobilityModel;

/**
Expand Down Expand Up @@ -72,8 +72,8 @@ class QdChannelModel : public MatrixBasedChannelModel
*/
Ptr<const MatrixBasedChannelModel::ChannelMatrix> GetChannel (Ptr<const MobilityModel> aMob,
Ptr<const MobilityModel> bMob,
Ptr<const ThreeGppAntennaArrayModel> aAntenna,
Ptr<const ThreeGppAntennaArrayModel> bAntenna) override;
Ptr<const PhasedArrayModel> aAntenna,
Ptr<const PhasedArrayModel> bAntenna) override;

/*
* Set the folder path containing the scenario of interest
Expand Down Expand Up @@ -140,8 +140,8 @@ class QdChannelModel : public MatrixBasedChannelModel
*/
Ptr<const MatrixBasedChannelModel::ChannelMatrix> GetNewChannel (Ptr<const MobilityModel> aMob,
Ptr<const MobilityModel> bMob,
Ptr<const ThreeGppAntennaArrayModel> aAntenna,
Ptr<const ThreeGppAntennaArrayModel> bAntenna) const;
Ptr<const PhasedArrayModel> aAntenna,
Ptr<const PhasedArrayModel> bAntenna) const;

/**
* Check if the channel matrix has to be updated
Expand Down
14 changes: 7 additions & 7 deletions model/qd-channel-utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand All @@ -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++)
{
Expand Down Expand Up @@ -79,7 +79,7 @@ GetFirstEigenvector (MatrixBasedChannelModel::Complex2DVector A, uint32_t nIter,
return antennaWeights;
}

std::pair<ThreeGppAntennaArrayModel::ComplexVector, ThreeGppAntennaArrayModel::ComplexVector>
std::pair<PhasedArrayModel::ComplexVector, PhasedArrayModel::ComplexVector>
ComputeSvdBeamformingVectors (Ptr<const MatrixBasedChannelModel::ChannelMatrix> params)
{
// params
Expand Down Expand Up @@ -138,7 +138,7 @@ ComputeSvdBeamformingVectors (Ptr<const MatrixBasedChannelModel::ChannelMatrix>
}

// 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;
Expand All @@ -164,7 +164,7 @@ ComputeSvdBeamformingVectors (Ptr<const MatrixBasedChannelModel::ChannelMatrix>
}

// 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)
{
Expand Down
6 changes: 3 additions & 3 deletions model/qd-channel-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
namespace ns3 {

class MatrixBasedChannelModel;
class ThreeGppAntennaArrayModel;
class PhasedArrayModel;

/**
* Compute the eigenvector associated to the largest eigenvalue.
Expand All @@ -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);

/**
Expand All @@ -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<ThreeGppAntennaArrayModel::ComplexVector, ThreeGppAntennaArrayModel::ComplexVector>
std::pair<PhasedArrayModel::ComplexVector, PhasedArrayModel::ComplexVector>
ComputeSvdBeamformingVectors (Ptr<const MatrixBasedChannelModel::ChannelMatrix> params);

} // namespace ns3
Expand Down

0 comments on commit b42678e

Please sign in to comment.