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::IPrintableObject

Classes

class  TotalObstacleLossComputation
 

Protected Attributes

Parameters
bool enableDielectricLoss = false
 
bool enableReflectionLoss = false
 
IRadioMediummedium
 The radio medium where the radio signal propagation takes place. More...
 
ModuleRefByPar< physicalenvironment::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...
 
virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void finish () override
 
virtual double computeDielectricLoss (const physicalenvironment::IMaterial *material, Hz frequency, m distance) const
 
virtual double computeReflectionLoss (const physicalenvironment::IMaterial *incidentMaterial, const physicalenvironment::IMaterial *refractiveMaterial, double angle) const
 
virtual double computeObjectLoss (const physicalenvironment::IPhysicalObject *object, Hz frequency, const Coord &transmissionPosition, const Coord &receptionPosition) const
 
 DielectricObstacleLoss ()
 
virtual std::ostream & printToStream (std::ostream &stream, int level, int evFlags=0) 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...
 

Additional Inherited Members

- Public Types inherited from inet::IPrintableObject
enum  PrintLevel {
  PRINT_LEVEL_TRACE, PRINT_LEVEL_DEBUG, PRINT_LEVEL_DETAIL, PRINT_LEVEL_INFO,
  PRINT_LEVEL_COMPLETE = INT_MIN
}
 
enum  PrintFlag { PRINT_FLAG_FORMATTED = (1 << 0), PRINT_FLAG_MULTILINE = (1 << 1) }
 
- Public Member Functions inherited from inet::IPrintableObject
virtual ~IPrintableObject ()
 
virtual std::string printToString () const
 
virtual std::string printToString (int level, int evFlags=0) const
 
virtual std::string getInfoStringRepresentation (int evFlags=0) const
 
virtual std::string getDetailStringRepresentation (int evFlags=0) const
 
virtual std::string getDebugStringRepresentation (int evFlags=0) const
 
virtual std::string getTraceStringRepresentation (int evFlags=0) const
 
virtual std::string getCompleteStringRepresentation (int evFlags=0) const
 
- 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

◆ DielectricObstacleLoss()

inet::physicallayer::DielectricObstacleLoss::DielectricObstacleLoss ( )
23  :
24  medium(nullptr),
27 {
28 }

Member Function Documentation

◆ computeDielectricLoss()

double inet::physicallayer::DielectricObstacleLoss::computeDielectricLoss ( const physicalenvironment::IMaterial material,
Hz  frequency,
m  distance 
) const
protectedvirtual
54 {
55  // NOTE: based on http://en.wikipedia.org/wiki/Dielectric_loss
56  double lossTangent = material->getDielectricLossTangent(frequency);
57  mps propagationSpeed = material->getPropagationSpeed();
58  double factor = std::exp(-atan(lossTangent) * unit(2 * M_PI * frequency * distance / propagationSpeed).get());
59  ASSERT(0 <= factor && factor <= 1);
60  return factor;
61 }

Referenced by computeObjectLoss().

◆ computeObjectLoss()

double inet::physicallayer::DielectricObstacleLoss::computeObjectLoss ( const physicalenvironment::IPhysicalObject object,
Hz  frequency,
const Coord transmissionPosition,
const Coord receptionPosition 
) const
protectedvirtual
84 {
85  double totalLoss = 1;
86  const ShapeBase *shape = object->getShape();
87  const Coord& position = object->getPosition();
88  const Quaternion& orientation = object->getOrientation();
89  RotationMatrix rotation(orientation.toEulerAngles());
90  const LineSegment lineSegment(rotation.rotateVectorInverse(transmissionPosition - position), rotation.rotateVectorInverse(receptionPosition - position));
91  Coord intersection1, intersection2, normal1, normal2;
93  bool hasIntersections = shape->computeIntersection(lineSegment, intersection1, intersection2, normal1, normal2);
94  if (hasIntersections && (intersection1 != intersection2)) {
96  const IMaterial *material = object->getMaterial();
98  double intersectionDistance = intersection2.distance(intersection1);
99  totalLoss *= computeDielectricLoss(material, frequency, m(intersectionDistance));
100  }
101  if (enableReflectionLoss && !normal1.isUnspecified()) {
102  double angle1 = (intersection1 - intersection2).angle(normal1);
103  if (!std::isnan(angle1))
104  totalLoss *= computeReflectionLoss(medium->getMaterial(), material, angle1);
105  }
106  // TODO this returns NaN because n1 > n2
107 // if (enableReflectionLoss && !normal2.isUnspecified()) {
108 // double angle2 = (intersection2 - intersection1).angle(normal2);
109 // if (!std::isnan(angle2))
110 // totalLoss *= computeReflectionLoss(material, medium->getMaterial(), angle2);
111 // }
112  ObstaclePenetratedEvent event(object, intersection1, intersection2, normal1, normal2, totalLoss);
113  const_cast<DielectricObstacleLoss *>(this)->emit(obstaclePenetratedSignal, &event);
114  }
115  return totalLoss;
116 }

◆ computeObstacleLoss()

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.

119 {
120  double totalLoss = 1;
121  TotalObstacleLossComputation obstacleLossVisitor(this, frequency, transmissionPosition, receptionPosition);
122  physicalEnvironment->visitObjects(&obstacleLossVisitor, LineSegment(transmissionPosition, receptionPosition));
123  totalLoss = obstacleLossVisitor.getTotalLoss();
124  return totalLoss;
125 }

◆ computeReflectionLoss()

double inet::physicallayer::DielectricObstacleLoss::computeReflectionLoss ( const physicalenvironment::IMaterial incidentMaterial,
const physicalenvironment::IMaterial refractiveMaterial,
double  angle 
) const
protectedvirtual
64 {
65  // NOTE: based on http://en.wikipedia.org/wiki/Fresnel_equations
66  double n1 = incidentMaterial->getRefractiveIndex();
67  double n2 = refractiveMaterial->getRefractiveIndex();
68  double st = sin(angle);
69  double ct = cos(angle);
70  double n1ct = n1 * ct;
71  double n2ct = n2 * ct;
72  double k = sqrt(1 - pow(n1 / n2 * st, 2));
73  double n1k = n1 * k;
74  double n2k = n2 * k;
75  double rs = pow((n1ct - n2k) / (n1ct + n2k), 2);
76  double rp = pow((n1k - n2ct) / (n1k + n2ct), 2);
77  double r = (rs + rp) / 2;
78  double transmittance = 1 - r;
79  ASSERT(0 <= transmittance && transmittance <= 1);
80  return transmittance;
81 }

Referenced by computeObjectLoss().

◆ finish()

void inet::physicallayer::DielectricObstacleLoss::finish ( )
overrideprotectedvirtual
41 {
42  EV_INFO << "Obstacle loss intersection computation count: " << intersectionComputationCount << endl;
43  EV_INFO << "Obstacle loss intersection count: " << intersectionCount << endl;
44  recordScalar("Obstacle loss intersection computation count", intersectionComputationCount);
45  recordScalar("Obstacle loss intersection count", intersectionCount);
46 }

◆ initialize()

void inet::physicallayer::DielectricObstacleLoss::initialize ( int  stage)
overrideprotectedvirtual
31 {
32  if (stage == INITSTAGE_LOCAL) {
33  enableDielectricLoss = par("enableDielectricLoss");
34  enableReflectionLoss = par("enableReflectionLoss");
35  medium = check_and_cast<IRadioMedium *>(getParentModule());
36  physicalEnvironment.reference(this, "physicalEnvironmentModule", true);
37  }
38 }

◆ numInitStages()

virtual int inet::physicallayer::DielectricObstacleLoss::numInitStages ( ) const
inlineoverrideprotectedvirtual
74 { return NUM_INIT_STAGES; }

◆ printToStream()

std::ostream & inet::physicallayer::DielectricObstacleLoss::printToStream ( std::ostream &  stream,
int  level,
int  evFlags = 0 
) const
overridevirtual

Prints this object to the provided output stream.

Reimplemented from inet::IPrintableObject.

49 {
50  return stream << "DielectricObstacleLoss";
51 }

Member Data Documentation

◆ enableDielectricLoss

bool inet::physicallayer::DielectricObstacleLoss::enableDielectricLoss = false
protected

Referenced by computeObjectLoss(), and initialize().

◆ enableReflectionLoss

bool inet::physicallayer::DielectricObstacleLoss::enableReflectionLoss = false
protected

Referenced by computeObjectLoss(), and initialize().

◆ intersectionComputationCount

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

Total number of obstacle intersection computations.

Referenced by computeObjectLoss(), and finish().

◆ intersectionCount

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

Total number of actual obstacle intersections.

Referenced by computeObjectLoss(), and finish().

◆ medium

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

The radio medium where the radio signal propagation takes place.

Referenced by computeObjectLoss(), and initialize().

◆ physicalEnvironment

ModuleRefByPar<physicalenvironment::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:
inet::physicallayer::DielectricObstacleLoss::intersectionComputationCount
unsigned int intersectionComputationCount
Total number of obstacle intersection computations.
Definition: DielectricObstacleLoss.h:66
inet::physicallayer::ITracingObstacleLoss::obstaclePenetratedSignal
static simsignal_t obstaclePenetratedSignal
Definition: ITracingObstacleLoss.h:35
inet::units::units::mps
compose< m, pow< s, -1 > > mps
Definition: Units.h:1151
inet::physicallayer::DielectricObstacleLoss::enableDielectricLoss
bool enableDielectricLoss
Definition: DielectricObstacleLoss.h:49
inet::physicallayer::DielectricObstacleLoss::physicalEnvironment
ModuleRefByPar< physicalenvironment::IPhysicalEnvironment > physicalEnvironment
The physical environment that provides to obstacles.
Definition: DielectricObstacleLoss.h:58
inet::physicalenvironment::IMaterial
Definition: IMaterial.h:20
inet::physicallayer::DielectricObstacleLoss::computeReflectionLoss
virtual double computeReflectionLoss(const physicalenvironment::IMaterial *incidentMaterial, const physicalenvironment::IMaterial *refractiveMaterial, double angle) const
Definition: DielectricObstacleLoss.cc:63
inet::units::cos
Value cos(const value< Value, Unit > &angle)
Definition: Units.h:1524
inet::units::sqrt
value< Value, pow< Unit, 1, 2 > > sqrt(const value< Value, Unit > &a)
Definition: Units.h:272
inet::physicallayer::DielectricObstacleLoss::enableReflectionLoss
bool enableReflectionLoss
Definition: DielectricObstacleLoss.h:50
inet::physicallayer::DielectricObstacleLoss::computeDielectricLoss
virtual double computeDielectricLoss(const physicalenvironment::IMaterial *material, Hz frequency, m distance) const
Definition: DielectricObstacleLoss.cc:53
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::physicallayer::DielectricObstacleLoss::medium
IRadioMedium * medium
The radio medium where the radio signal propagation takes place.
Definition: DielectricObstacleLoss.h:54
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::units::unit
pow< internal::none, 0 > unit
Definition: Units.h:72
inet::physicallayer::k
const double k
Definition: Qam1024Modulation.cc:14
inet::physicallayer::DielectricObstacleLoss::DielectricObstacleLoss
DielectricObstacleLoss()
Definition: DielectricObstacleLoss.cc:23
inet::physicallayer::IRadioMedium::getMaterial
virtual const physicalenvironment::IMaterial * getMaterial() const =0
Returns the material of this medium.
inet::units::values::m
value< double, units::m > m
Definition: Units.h:1233
M_PI
#define M_PI
Definition: INETMath.h:52
inet::physicallayer::DielectricObstacleLoss::intersectionCount
unsigned int intersectionCount
Total number of actual obstacle intersections.
Definition: DielectricObstacleLoss.h:70
inet::units::sin
Value sin(const value< Value, Unit > &angle)
Definition: Units.h:1518