27#include "ns3/double.h"
29#include "ns3/net-device.h"
31#include "ns3/pointer.h"
32#include "ns3/simulator.h"
33#include "ns3/string.h"
66 TypeId(
"ns3::ThreeGppSpectrumPropagationLossModel")
68 .SetGroupName(
"Spectrum")
72 "The channel model. It needs to implement the MatrixBasedChannelModel interface",
76 MakePointerChecker<MatrixBasedChannelModel>());
122 size_t uAntennaNum = uW.
GetSize();
123 size_t sAntennaNum = sW.
GetSize();
125 NS_ASSERT(uAntennaNum == params->m_channel.GetNumRows());
126 NS_ASSERT(sAntennaNum == params->m_channel.GetNumCols());
128 NS_LOG_DEBUG(
"CalcLongTerm with " << uAntennaNum <<
" u antenna elements and " << sAntennaNum
129 <<
" s antenna elements.");
134 return params->m_channel.MultiplyByLeftAndRightMatrix(uW.
Transpose(), sW);
143 const ns3::Vector& sSpeed,
144 const ns3::Vector& uSpeed)
const
151 uint16_t numCluster = channelMatrix->m_channel.GetNumPages();
157 double factor = 2 * M_PI * slotTime *
GetFrequency() / 3e8;
165 NS_ASSERT(numCluster <= channelParams->m_alpha.size());
166 NS_ASSERT(numCluster <= channelParams->m_D.size());
174 bool isSameDirection = (channelParams->m_nodeIds == channelMatrix->m_nodeIds);
200 for (uint16_t cIndex = 0; cIndex < numCluster; cIndex++)
213 double alpha = channelParams->m_alpha[cIndex];
214 double D = channelParams->m_D[cIndex];
218 factor * ((sin(zoa[cIndex] * M_PI / 180) * cos(aoa[cIndex] * M_PI / 180) * uSpeed.x +
219 sin(zoa[cIndex] * M_PI / 180) * sin(aoa[cIndex] * M_PI / 180) * uSpeed.y +
220 cos(zoa[cIndex] * M_PI / 180) * uSpeed.z) +
221 (sin(zod[cIndex] * M_PI / 180) * cos(aod[cIndex] * M_PI / 180) * sSpeed.x +
222 sin(zod[cIndex] * M_PI / 180) * sin(aod[cIndex] * M_PI / 180) * sSpeed.y +
223 cos(zod[cIndex] * M_PI / 180) * sSpeed.z) +
225 doppler[cIndex] = std::complex<double>(cos(tempDoppler), sin(tempDoppler));
232 auto vit = tempPsd->ValuesBegin();
233 auto sbit = tempPsd->ConstBandsBegin();
234 while (vit != tempPsd->ValuesEnd())
238 std::complex<double> subsbandGain(0.0, 0.0);
239 double fsb = (*sbit).fc;
240 for (uint16_t cIndex = 0; cIndex < numCluster; cIndex++)
242 double delay = -2 * M_PI * fsb * (channelParams->m_delay[cIndex]);
243 subsbandGain = subsbandGain + longTerm[cIndex] * doppler[cIndex] *
244 std::complex<double>(cos(delay), sin(delay));
246 *vit = (*vit) * (
norm(subsbandGain));
267 if (!channelMatrix->IsReverse(aPhasedArrayModel->GetId(), bPhasedArrayModel->GetId()))
269 sW = aPhasedArrayModel->GetBeamformingVector();
270 uW = bPhasedArrayModel->GetBeamformingVector();
274 sW = bPhasedArrayModel->GetBeamformingVector();
275 uW = aPhasedArrayModel->GetBeamformingVector();
279 bool notFound =
false;
282 uint64_t longTermId =
288 NS_LOG_DEBUG(
"found the long term component in the map");
294 update = (
m_longTermMap[longTermId]->m_channel->m_generatedTime !=
295 channelMatrix->m_generatedTime ||
304 if (update || notFound)
312 longTermItem->m_longTerm = longTerm;
313 longTermItem->m_channel = channelMatrix;
314 longTermItem->m_sW = sW;
315 longTermItem->m_uW = uW;
337 "The position of a and b devices cannot be the same");
342 NS_ASSERT_MSG(aPhasedArrayModel,
"Antenna not found for node " << aId);
343 NS_LOG_DEBUG(
"a node " << a->GetObject<
Node>() <<
" antenna " << aPhasedArrayModel);
346 NS_ASSERT_MSG(bPhasedArrayModel,
"Antenna not found for device " << bId);
347 NS_LOG_DEBUG(
"b node " << bId <<
" antenna " << bPhasedArrayModel);
350 m_channelModel->GetChannel(a, b, aPhasedArrayModel, bPhasedArrayModel);
356 GetLongTerm(channelMatrix, aPhasedArrayModel, bPhasedArrayModel);
Hold a value for an Attribute.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
MatrixArray class inherits ValArray class and provides additional interfaces to ValArray which enable...
MatrixArray< T > Transpose() const
This operator interprets the 3D array as an array of matrices, and performs a linear algebra operatio...
std::vector< double > DoubleVector
Type definition for vectors of doubles.
static const uint8_t AOA_INDEX
index of the AOA value in the m_angle array
static const uint8_t ZOD_INDEX
index of the ZOD value in the m_angle array
static const uint8_t AOD_INDEX
index of the AOD value in the m_angle array
static const uint8_t ZOA_INDEX
index of the ZOA value in the m_angle array
static uint64_t GetKey(uint32_t a, uint32_t b)
Generate a unique value for the pair of unsigned integer of 32 bits, where the order does not matter,...
spectrum-aware propagation loss model that is compatible with PhasedArrayModel type of ns-3 antenna
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
Hold variables of type string.
3GPP Spectrum Propagation Loss Model
void GetChannelModelAttribute(const std::string &name, AttributeValue &value) const
Returns the value of an attribute belonging to the associated MatrixBasedChannelModel instance.
Ptr< SpectrumValue > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumSignalParameters > params, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b, Ptr< const PhasedArrayModel > aPhasedArrayModel, Ptr< const PhasedArrayModel > bPhasedArrayModel) const override
Computes the received PSD.
PhasedArrayModel::ComplexVector GetLongTerm(Ptr< const MatrixBasedChannelModel::ChannelMatrix > channelMatrix, Ptr< const PhasedArrayModel > aPhasedArrayModel, Ptr< const PhasedArrayModel > bPhasedArrayModel) const
Looks for the long term component in m_longTermMap.
Ptr< MatrixBasedChannelModel > m_channelModel
the model to generate the channel matrix
void SetChannelModel(Ptr< MatrixBasedChannelModel > channel)
Set the channel model object.
~ThreeGppSpectrumPropagationLossModel() override
Destructor.
std::unordered_map< uint64_t, Ptr< const LongTerm > > m_longTermMap
map containing the long term components
double GetFrequency() const
Get the operating frequency.
void SetChannelModelAttribute(const std::string &name, const AttributeValue &value)
Sets the value of an attribute belonging to the associated MatrixBasedChannelModel instance.
Ptr< MatrixBasedChannelModel > GetChannelModel() const
Get the channel model object.
Ptr< SpectrumValue > CalcBeamformingGain(Ptr< SpectrumValue > txPsd, PhasedArrayModel::ComplexVector longTerm, Ptr< const MatrixBasedChannelModel::ChannelMatrix > channelMatrix, Ptr< const MatrixBasedChannelModel::ChannelParams > channelParams, const Vector &sSpeed, const Vector &uSpeed) const
Computes the beamforming gain and applies it to the tx PSD.
PhasedArrayModel::ComplexVector CalcLongTerm(Ptr< const MatrixBasedChannelModel::ChannelMatrix > channelMatrix, const PhasedArrayModel::ComplexVector &sW, const PhasedArrayModel::ComplexVector &uW) const
Computes the long term component.
void DoDispose() override
Destructor implementation.
static TypeId GetTypeId()
Get the type ID.
ThreeGppSpectrumPropagationLossModel()
Constructor.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
const double norm
Normalization to obtain randoms on [0,1).
Every class exported by the ns3 library is enclosed in the ns3 namespace.