Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1548)

Unified Diff: src/propagation/examples/thz-vs-friis-loss-example.cc

Issue 197290043: Directional and omni-directional THz propagation models and tests
Patch Set: Add directional and omni-directional THz propagation models with test and example files Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/propagation/examples/wscript » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/propagation/examples/thz-vs-friis-loss-example.cc
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/propagation/examples/thz-vs-friis-loss-example.cc
@@ -0,0 +1,102 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2015 Portland state university
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Farnoosh Moshir <moshir2@cs.pdx.edu>
+ * Suresh Singh <singh@cs.pdx.edu>
+ */
+
+
+#include "ns3/log.h"
+#include "ns3/test.h"
+#include "ns3/double.h"
+#include "ns3/thz-propagation-loss-model.h"
+#include "ns3/constant-position-mobility-model.h"
+#include "ns3/wifi-mode.h"
+#include "ns3/gnuplot.h"
+
+
+
+using namespace ns3;
+
+NS_LOG_COMPONENT_DEFINE ("ThzVsFriisLoss");
+
+
+
+Gnuplot2dDataset
+DoRun (Ptr<PropagationLossModel> propagationModel, std::string dataTitle)
+{
+
+ Gnuplot2dDataset dataset;
+ dataset.SetTitle (dataTitle);
+ dataset.SetStyle (Gnuplot2dDataset::LINES_POINTS);
+
+ double txPowerDbm = +20;
+ double rxPowerDbm;
+
+ Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
+ a->SetPosition (Vector (0,0,0));
+ Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
+ for (double distance = 0.0; distance < 100.0; distance += 5.0)
+ {
+ b->SetPosition (Vector (distance, 0, 0));
+
+ rxPowerDbm = propagationModel->CalcRxPower (txPowerDbm, a, b);
+ dataset.Add(distance, rxPowerDbm);
+ }
+
+ return dataset;
+
+}
+
+
+int main (int argc, char *argv[])
+{
+ std::string fileNameWithNoExtension = "thz-vs-friis-loss";
+ std::string graphicsFileName = fileNameWithNoExtension + ".png";
+ std::string plotFileName = fileNameWithNoExtension + ".plt";
+ std::string plotTitle = "Omni-directional THz propagation loss vs Friis propagation loss";
+
+
+ Gnuplot plot(graphicsFileName);
+ plot.SetTitle(plotTitle);
+ plot.SetLegend ("Distance (m)", "Recieved Power (dBm)");
+
+
+ Ptr<ThzOmniDirectionalPropagationLossModel> thzPropagationModel = CreateObject<ThzOmniDirectionalPropagationLossModel> ();
+
+ thzPropagationModel->SetFrequency(237.5e9);
+ Gnuplot2dDataset dataset1 = DoRun(thzPropagationModel, "THz propagation, frequency = 237.5 GHz");
+
+ plot.AddDataset(dataset1);
+
+
+
+ Ptr<FriisPropagationLossModel> friisPropagationModel = CreateObject<FriisPropagationLossModel> ();
+
+ Gnuplot2dDataset dataset2 = DoRun(friisPropagationModel, "Friis propagation, default values");
+
+
+ plot.AddDataset(dataset2);
+
+ std::ofstream plotFile (plotFileName.c_str());
+
+ plot.GenerateOutput (plotFile);
+ plotFile.close ();
+ return 0;
+}
+
+
« no previous file with comments | « no previous file | src/propagation/examples/wscript » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b