INET Framework for OMNeT++/OMNEST
inet::physicallayer::DielectricObstacleLoss Class Reference

This class computes obstacle loss based on the actual straight path that the radio signal travels from the transmitter to the receiver. More...

#include <DielectricObstacleLoss.h>

Inheritance diagram for inet::physicallayer::DielectricObstacleLoss:
inet::physicallayer::TracingObstacleLossBase inet::physicallayer::ITracingObstacleLoss inet::physicallayer::IObstacleLoss inet::physicallayer::IPrintableObject

Classes

class  TotalObstacleLossComputation
 

Public Member Functions

 DielectricObstacleLoss ()
 
virtual std::ostream & printToStream (std::ostream &stream, int level) const override
 Prints this object to the provided output stream. More...
 
virtual double computeObstacleLoss (Hz frequency, const Coord &transmissionPosition, const Coord &receptionPosition) const override
 Returns the obstacle loss factor caused by physical objects present in the environment as a function of frequency, transmission position, and reception position. More...
 
- Public Member Functions inherited from inet::physicallayer::IPrintableObject
virtual ~IPrintableObject ()
 
virtual std::string getInfoStringRepresentation () const
 
virtual std::string getDetailStringRepresentation () const
 
virtual std::string getDebugStringRepresentation () const
 
virtual std::string getTraceStringRepresentation () const
 
virtual std::string getCompleteStringRepresentation () const
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void finish () override
 
virtual double computeDielectricLoss (const IMaterial *material, Hz frequency, m distance) const
 
virtual double computeReflectionLoss (const IMaterial *incidentMaterial, const IMaterial *refractiveMaterial, double angle) const
 
virtual double computeObjectLoss (const IPhysicalObject *object, Hz frequency, const Coord &transmissionPosition, const Coord &receptionPosition) const
 

Protected Attributes

Parameters
IRadioMediummedium
 The radio medium where the radio signal propagation takes place. More...
 
IPhysicalEnvironmentphysicalEnvironment
 The physical environment that provides to obstacles. More...
 
Statistics
unsigned int intersectionComputationCount
 Total number of obstacle intersection computations. More...
 
unsigned int intersectionCount
 Total number of actual obstacle intersections. More...
 

Additional Inherited Members

- Public Types inherited from inet::physicallayer::IPrintableObject
enum  PrintLevel {
  PRINT_LEVEL_TRACE, PRINT_LEVEL_DEBUG, PRINT_LEVEL_DETAIL, PRINT_LEVEL_INFO,
  PRINT_LEVEL_COMPLETE = INT_MIN
}
 
- Static Public Attributes inherited from inet::physicallayer::ITracingObstacleLoss
static simsignal_t obstaclePenetratedSignal = cComponent::registerSignal("obstaclePenetrated")
 

Detailed Description

This class computes obstacle loss based on the actual straight path that the radio signal travels from the transmitter to the receiver.

The total loss is the combination of the dielectric losses in the intersected obstacles and the reflection losses of the penetrated faces along this path.

Constructor & Destructor Documentation

inet::physicallayer::DielectricObstacleLoss::DielectricObstacleLoss ( )
30  :
31  medium(nullptr),
32  physicalEnvironment(nullptr),
35 {
36 }
unsigned int intersectionComputationCount
Total number of obstacle intersection computations.
Definition: DielectricObstacleLoss.h:74
unsigned int intersectionCount
Total number of actual obstacle intersections.
Definition: DielectricObstacleLoss.h:78
IRadioMedium * medium
The radio medium where the radio signal propagation takes place.
Definition: DielectricObstacleLoss.h:62
IPhysicalEnvironment * physicalEnvironment
The physical environment that provides to obstacles.
Definition: DielectricObstacleLoss.h:66

Member Function Documentation

double inet::physicallayer::DielectricObstacleLoss::computeDielectricLoss ( const IMaterial material,
Hz  frequency,
m  distance 
) const
protectedvirtual

Referenced by computeObjectLoss().

60 {
61  // NOTE: based on http://en.wikipedia.org/wiki/Dielectric_loss
62  double lossTangent = material->getDielectricLossTangent(frequency);
63  mps propagationSpeed = material->getPropagationSpeed();
64  double factor = std::exp(-atan(lossTangent) * unit(2 * M_PI * frequency * distance / propagationSpeed).get());
65  ASSERT(0 <= factor && factor <= 1);
66  return factor;
67 }
#define M_PI
Definition: PlotFigure.cc:27
pow< internal::none, 0 > unit
Definition: Units.h:60
compose< m, pow< s,-1 > > mps
Definition: Units.h:968
double inet::physicallayer::DielectricObstacleLoss::computeObjectLoss ( const IPhysicalObject object,
Hz  frequency,
const Coord transmissionPosition,
const Coord receptionPosition 
) const
protectedvirtual

Referenced by inet::physicallayer::DielectricObstacleLoss::TotalObstacleLossComputation::visit().

90 {
91  double totalLoss = 1;
92  const ShapeBase *shape = object->getShape();
93  const Coord& position = object->getPosition();
94  const EulerAngles& orientation = object->getOrientation();
95  Rotation rotation(orientation);
96  const LineSegment lineSegment(rotation.rotateVectorCounterClockwise(transmissionPosition - position), rotation.rotateVectorCounterClockwise(receptionPosition - position));
97  Coord intersection1, intersection2, normal1, normal2;
99  bool hasIntersections = shape->computeIntersection(lineSegment, intersection1, intersection2, normal1, normal2);
100  if (hasIntersections && (intersection1 != intersection2))
101  {
103  double intersectionDistance = intersection2.distance(intersection1);
104  const IMaterial *material = object->getMaterial();
105  totalLoss *= computeDielectricLoss(material, frequency, m(intersectionDistance));
106  if (!normal1.isUnspecified()) {
107  double angle1 = (intersection1 - intersection2).angle(normal1);
108  if (!std::isnan(angle1))
109  totalLoss *= computeReflectionLoss(medium->getMaterial(), material, angle1);
110  }
111  // TODO: this returns NaN because n1 > n2
112 // if (!normal2.isUnspecified()) {
113 // double angle2 = (intersection2 - intersection1).angle(normal2);
114 // if (!std::isnan(angle2))
115 // totalLoss *= computeReflectionLoss(material, medium->getMaterial(), angle2);
116 // }
117  ObstaclePenetratedEvent event(object, intersection1, intersection2, normal1, normal2, totalLoss);
118  const_cast<DielectricObstacleLoss *>(this)->emit(obstaclePenetratedSignal, &event);
119  }
120  return totalLoss;
121 }
DielectricObstacleLoss()
Definition: DielectricObstacleLoss.cc:30
virtual double computeDielectricLoss(const IMaterial *material, Hz frequency, m distance) const
Definition: DielectricObstacleLoss.cc:59
unsigned int intersectionComputationCount
Total number of obstacle intersection computations.
Definition: DielectricObstacleLoss.h:74
static simsignal_t obstaclePenetratedSignal
Definition: ITracingObstacleLoss.h:48
virtual const IMaterial * getMaterial() const =0
Returns the material of the radio medium.
unsigned int intersectionCount
Total number of actual obstacle intersections.
Definition: DielectricObstacleLoss.h:78
IRadioMedium * medium
The radio medium where the radio signal propagation takes place.
Definition: DielectricObstacleLoss.h:62
virtual double computeReflectionLoss(const IMaterial *incidentMaterial, const IMaterial *refractiveMaterial, double angle) const
Definition: DielectricObstacleLoss.cc:69
value< double, units::m > m
Definition: Units.h:1047
double inet::physicallayer::DielectricObstacleLoss::computeObstacleLoss ( Hz  frequency,
const Coord transmissionPosition,
const Coord receptionPosition 
) const
overridevirtual

Returns the obstacle loss factor caused by physical objects present in the environment as a function of frequency, transmission position, and reception position.

The value is in the range [0, 1] where 1 means no loss at all and 0 means all power is lost.

Implements inet::physicallayer::IObstacleLoss.

124 {
125  double totalLoss = 1;
126  TotalObstacleLossComputation obstacleLossVisitor(this, frequency, transmissionPosition, receptionPosition);
127  physicalEnvironment->visitObjects(&obstacleLossVisitor, LineSegment(transmissionPosition, receptionPosition));
128  totalLoss = obstacleLossVisitor.getTotalLoss();
129  return totalLoss;
130 }
virtual void visitObjects(const IVisitor *visitor, const LineSegment &lineSegment) const =0
IPhysicalEnvironment * physicalEnvironment
The physical environment that provides to obstacles.
Definition: DielectricObstacleLoss.h:66
double inet::physicallayer::DielectricObstacleLoss::computeReflectionLoss ( const IMaterial incidentMaterial,
const IMaterial refractiveMaterial,
double  angle 
) const
protectedvirtual

Referenced by computeObjectLoss().

70 {
71  // NOTE: based on http://en.wikipedia.org/wiki/Fresnel_equations
72  double n1 = incidentMaterial->getRefractiveIndex();
73  double n2 = refractiveMaterial->getRefractiveIndex();
74  double st = sin(angle);
75  double ct = cos(angle);
76  double n1ct = n1 * ct;
77  double n2ct = n2 * ct;
78  double k = sqrt(1 - pow(n1 / n2 * st, 2));
79  double n1k = n1 * k;
80  double n2k = n2 * k;
81  double rs = pow((n1ct - n2k) / (n1ct + n2k), 2);
82  double rp = pow((n1k - n2ct) / (n1k + n2ct), 2);
83  double r = (rs + rp) / 2;
84  double transmittance = 1 - r;
85  ASSERT(0 <= transmittance && transmittance <= 1);
86  return transmittance;
87 }
Value cos(const value< Value, Unit > &angle)
Definition: Units.h:1201
value< Value, pow< Unit, 1, 2 > > sqrt(const value< Value, Unit > &a)
Definition: Units.h:247
const double k
Definition: QAM16Modulation.cc:24
Value sin(const value< Value, Unit > &angle)
Definition: Units.h:1195
void inet::physicallayer::DielectricObstacleLoss::finish ( )
overrideprotectedvirtual
47 {
48  EV_INFO << "Obstacle loss intersection computation count: " << intersectionComputationCount << endl;
49  EV_INFO << "Obstacle loss intersection count: " << intersectionCount << endl;
50  recordScalar("Obstacle loss intersection computation count", intersectionComputationCount);
51  recordScalar("Obstacle loss intersection count", intersectionCount);
52 }
unsigned int intersectionComputationCount
Total number of obstacle intersection computations.
Definition: DielectricObstacleLoss.h:74
unsigned int intersectionCount
Total number of actual obstacle intersections.
Definition: DielectricObstacleLoss.h:78
void inet::physicallayer::DielectricObstacleLoss::initialize ( int  stage)
overrideprotectedvirtual
39 {
40  if (stage == INITSTAGE_LOCAL) {
41  medium = check_and_cast<IRadioMedium *>(getParentModule());
42  physicalEnvironment = getModuleFromPar<IPhysicalEnvironment>(par("physicalEnvironmentModule"), this);
43  }
44 }
Local initializations.
Definition: InitStages.h:35
IRadioMedium * medium
The radio medium where the radio signal propagation takes place.
Definition: DielectricObstacleLoss.h:62
IPhysicalEnvironment * physicalEnvironment
The physical environment that provides to obstacles.
Definition: DielectricObstacleLoss.h:66
virtual int inet::physicallayer::DielectricObstacleLoss::numInitStages ( ) const
inlineoverrideprotectedvirtual
82 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
std::ostream & inet::physicallayer::DielectricObstacleLoss::printToStream ( std::ostream &  stream,
int  level 
) const
overridevirtual

Prints this object to the provided output stream.

Function calls to operator<< with pointers or references either const or not are all forwarded to this function.

Reimplemented from inet::physicallayer::IPrintableObject.

55 {
56  return stream << "DielectricObstacleLoss";
57 }

Member Data Documentation

unsigned int inet::physicallayer::DielectricObstacleLoss::intersectionComputationCount
mutableprotected

Total number of obstacle intersection computations.

Referenced by computeObjectLoss(), and finish().

unsigned int inet::physicallayer::DielectricObstacleLoss::intersectionCount
mutableprotected

Total number of actual obstacle intersections.

Referenced by computeObjectLoss(), and finish().

IRadioMedium* inet::physicallayer::DielectricObstacleLoss::medium
protected

The radio medium where the radio signal propagation takes place.

Referenced by computeObjectLoss(), and initialize().

IPhysicalEnvironment* inet::physicallayer::DielectricObstacleLoss::physicalEnvironment
protected

The physical environment that provides to obstacles.

Referenced by computeObstacleLoss(), and initialize().


The documentation for this class was generated from the following files: