User Manual, Developers Guide and API Documentation

ITUSMa.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * This file is part of openWNS (open Wireless Network Simulator)
00003  * _____________________________________________________________________________
00004  *
00005  * Copyright (C) 2004-2007
00006  * Chair of Communication Networks (ComNets)
00007  * Kopernikusstr. 5, D-52074 Aachen, GeSMany
00008  * phone: ++49-241-80-27910,
00009  * fax: ++49-241-80-22242
00010  * email: info@openwns.org
00011  * www: http://www.openwns.org
00012  * _____________________________________________________________________________
00013  *
00014  * openWNS is free software; you can redistribute it and/or modify it under the
00015  * terms of the GNU Lesser General Public License version 2 as published by the
00016  * Free Software Foundation;
00017  *
00018  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00019  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00020  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00021  * details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public License
00024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00025  *
00026  ******************************************************************************/
00027 
00028 #include <RISE/scenario/pathloss/ITUSMa.hpp>
00029 #include <RISE/scenario/pathloss/HashRNG.hpp>
00030 #include <RISE/stations/station.hpp>
00031 
00032 #include <WNS/distribution/Uniform.hpp>
00033 
00034 #include <boost/random.hpp>
00035 #include <boost/functional/hash.hpp>
00036 
00037 #include <WNS/StaticFactoryBroker.hpp>
00038 
00039 STATIC_FACTORY_BROKER_REGISTER(rise::scenario::pathloss::ITUSMa, rise::scenario::pathloss::Pathloss, "ITUSMa");
00040 
00041 using namespace rise::scenario::pathloss;
00042 
00043 ITUSMa::ITUSMa(const wns::pyconfig::View& pyco):
00044     rise::scenario::pathloss::DistanceDependent(pyco),
00045     losProbabilityCC_("rise.scenario.pathloss.ITUPathloss.losProbability"),
00046     shadowingCC_("rise.scenario.pathloss.ITUPathloss.shadowing"),
00047     useShadowing_(pyco.get<bool>("useShadowing")),
00048     useCarPenetration_(pyco.get<bool>("useCarPenetration"))
00049 {
00050     streetWidth_ = pyco.get<double>("streetWidth");
00051     buildingHeight_ = pyco.get<double>("buildingHeight");
00052 }
00053 
00054 wns::Ratio
00055 ITUSMa::calculatePathloss(const rise::antenna::Antenna& source,
00056                                const rise::antenna::Antenna& target,
00057                                const wns::Frequency& frequency,
00058                                const wns::Distance& distance) const
00059 {
00060     static wns::distribution::Uniform dis(0.0, 1.0, wns::simulator::getRNG());
00061     static unsigned int initialSeed = dis() * pow(2, sizeof(unsigned int)*8);
00062 
00063     detail::HashRNG hrng(initialSeed,
00064                          source.getPosition(),
00065                          target.getPosition(),
00066                          true, true);
00067 
00068     detail::HashRNG hrngOnlyUTPos(initialSeed + 2773,
00069                                   source.getPosition(),
00070                                   target.getPosition(),
00071                                   false, true);
00072 
00073     wns::Ratio pl;
00074 
00075     double bsHeight = source.getPosition().getZ();
00076     double utHeight = target.getPosition().getZ();
00077 
00078     // We must assume here that the higher one is the BS
00079     if (bsHeight < utHeight) std::swap(bsHeight, utHeight);
00080 
00081     assure(bsHeight > 10.0, "BS Height must be at least 10 m");
00082     assure(bsHeight < 150.0, "BS Height cannot be larger than 150 m");
00083     assure(utHeight > 1.0, "BS Height must be at least 1 m");
00084     assure(utHeight < 10.0, "BS Height cannot be larger than 10 m");
00085 
00086     double dBP = 2 * 3.14 * bsHeight * utHeight * frequency / 3.0e02;
00087 
00088     bool isIndoor = hrngOnlyUTPos() < 0.5;
00089     wns::Ratio sh = wns::Ratio::from_dB(0.0);
00090 
00091     if (hrng() < getLOSProbability(distance))
00092     {
00093         losProbabilityCC_.put(distance);
00094 
00095         pl = getLOSPathloss(source, target, frequency, distance);
00096 
00097         double shadowingStd = 0.0;
00098         double shadowingMean = 0.0;
00099         if (isIndoor)
00100         {
00101             if (useShadowing_)
00102             {
00103                 shadowingMean = 20.0;
00104                 if (distance < dBP)
00105                 {
00106                     shadowingStd = 4.0;
00107                 }
00108                 else
00109                 {
00110                     shadowingStd = 6.0;
00111                 }
00112                 boost::normal_distribution<double> shadow(shadowingMean, shadowingStd);
00113                 sh = wns::Ratio::from_dB(shadow(hrng));
00114             }
00115         }else
00116         {
00117             if (useShadowing_)
00118             {
00119                 shadowingMean = 0.0;
00120 
00121                 if (distance < dBP)
00122                 {
00123                     shadowingStd = 4.0;
00124                 }
00125                 else
00126                 {
00127                     shadowingStd = 6.0;
00128                 }
00129             
00130                 boost::normal_distribution<double> shadow(shadowingMean, shadowingStd);
00131                 sh = wns::Ratio::from_dB(shadow(hrng));
00132             }
00133 
00134             if (useCarPenetration_)
00135             {
00136                 boost::normal_distribution<double> carPenetration(9.0, 5.0);
00137                 sh += wns::Ratio::from_dB(carPenetration(hrngOnlyUTPos));
00138             }
00139         }
00140 
00141         shadowingCC_.put(sh.get_dB());
00142         pl += sh;
00143     }
00144     else
00145     {
00146         pl = getNLOSPathloss(source, target, frequency, distance);
00147 
00148         double shadowingStd = 0.0;
00149         double shadowingMean = 0.0;
00150         wns::Ratio sh = wns::Ratio::from_dB(0.0);
00151 
00152         if (isIndoor)
00153         {
00154             if (useShadowing_)
00155             {
00156                 shadowingMean = 20.0;
00157                 shadowingStd = 8.0;
00158                 boost::normal_distribution<double> shadow(shadowingMean, shadowingStd);
00159                 sh = wns::Ratio::from_dB(shadow(hrng));
00160             }
00161         }else
00162         {
00163             if (useShadowing_)
00164             {
00165                 shadowingMean = 0.0;
00166                 shadowingStd = 8.0;
00167                 boost::normal_distribution<double> shadow(shadowingMean, shadowingStd);
00168                 sh = wns::Ratio::from_dB(shadow(hrng));
00169             }
00170 
00171             if (useCarPenetration_)
00172             {
00173                 boost::normal_distribution<double> carPenetration(9.0, 5.0);
00174                 sh += wns::Ratio::from_dB(carPenetration(hrngOnlyUTPos));
00175             }
00176         }
00177         shadowingCC_.put(sh.get_dB());
00178         pl += sh;
00179     }
00180     return pl;
00181 }
00182 
00183 double
00184 ITUSMa::getLOSProbability(double distance) const
00185 {
00186     if (distance <= 10.0)
00187     {
00188         return 1.0;
00189     }
00190 
00191     double pLOS = exp(- (distance-10.0)/200.0);
00192     return pLOS;
00193 }
00194 
00195 wns::Ratio
00196 ITUSMa::getLOSPathloss(const rise::antenna::Antenna& source,
00197                        const rise::antenna::Antenna& target,
00198                        const wns::Frequency& frequency,
00199                        const wns::Distance& distance) const
00200 {
00201     double bsHeight = source.getPosition().getZ();
00202     double utHeight = target.getPosition().getZ();
00203 
00204     // We must assume here that the higher one is the BS
00205     if (bsHeight < utHeight) std::swap(bsHeight, utHeight);
00206 
00207     assure(bsHeight > 10.0, "BS Height must be at least 10 m");
00208     assure(bsHeight < 150.0, "BS Height cannot be larger than 150 m");
00209     assure(utHeight > 1.0, "BS Height must be at least 1 m");
00210     assure(utHeight < 10.0, "BS Height cannot be larger than 10 m");
00211 
00212     double dBP = 2 * 3.14 * bsHeight * utHeight * frequency / 3.0e02;
00213 
00214     if (distance < dBP)
00215     {
00216         double pl = 20.0 * log10(distance * 40 * 3.14 * frequency/3000.0);
00217         pl += std::min(0.03 * pow(buildingHeight_, 1.72), 10.0) * log10(distance);
00218         pl -= std::min(0.044 * pow(buildingHeight_, 1.72), 14.77);
00219         pl += 0.002*log10(buildingHeight_)*distance;
00220 
00221         return wns::Ratio::from_dB(pl);
00222     }
00223     else
00224     {
00225         double pl = 20.0 * log10(dBP * 40 * 3.14 * frequency/3000.0);
00226         pl += std::min(0.03 * pow(buildingHeight_, 1.72), 10.0) * log10(dBP);
00227         pl -= std::min(0.044 * pow(buildingHeight_, 1.72), 14.77);
00228         pl += 0.002*log10(buildingHeight_)*dBP;
00229 
00230         pl += 40 * log10(distance / dBP);
00231         return wns::Ratio::from_dB(pl);
00232     }
00233 }
00234 
00235 wns::Ratio
00236 ITUSMa::getNLOSPathloss(const rise::antenna::Antenna& source,
00237                         const rise::antenna::Antenna& target,
00238                         const wns::Frequency& frequency,
00239                         const wns::Distance& distance) const
00240 {
00241     double bsHeight = source.getPosition().getZ();
00242     double utHeight = target.getPosition().getZ();
00243 
00244     // We must assume here that the higher one is the BS
00245     if (bsHeight < utHeight) std::swap(bsHeight, utHeight);
00246 
00247     assure(bsHeight > 10.0, "BS Height must be at least 10 m");
00248     assure(bsHeight < 150.0, "BS Height cannot be larger than 150 m");
00249     assure(utHeight > 1.0, "BS Height must be at least 1 m");
00250     assure(utHeight < 10.0, "BS Height cannot be larger than 10 m");
00251 
00252     double pl = 161.04 - 7.1 * log10(streetWidth_) + 7.5 * log10(buildingHeight_);
00253     pl -= (24.37 - 3.7 * pow(buildingHeight_ / bsHeight, 2)) * log10(bsHeight);
00254     pl += (43.42 - 3.1 * log10(bsHeight) ) * (log10(distance) - 3.0);
00255     pl += 20.0 * log10(frequency/1000.0);
00256     pl -= 3.2 * pow(log10(11.75 * utHeight), 2) - 4.97;
00257 
00258     return wns::Ratio::from_dB(pl);
00259 }
00260 
00261 double
00262 ITUSMa::getCarPenetrationStd() const
00263 {
00264     // Handled above, because of mix of indoor and outdoor users
00265     return 0.0;
00266 }
00267 
00268 double
00269 ITUSMa::getCarPenetrationMean() const
00270 {
00271     // Handled above, because of mix of indoor and outdoor users
00272     return 0.0;
00273 }

Generated on Thu May 24 03:31:56 2012 for openWNS by  doxygen 1.5.5