20 #include <ns3/core-module.h>
21 #include <ns3/energy-module.h>
22 #include <ns3/gnuplot.h>
75 double cellVoltage = es->GetSupplyVoltage();
90 double cellVoltage = es->GetSupplyVoltage();
105 double cellVoltage = es->GetSupplyVoltage();
106 double dischargeCapacityAh = es->GetDrainedCapacity();
119 double cellVoltage = es->GetSupplyVoltage();
134 double cellVoltage = es->GetSupplyVoltage();
146 main(
int argc,
char** argv)
149 cmd.Parse(argc, argv);
163 node = CreateObject<Node>();
164 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
165 batteryModel = CreateObject<GenericBatteryModel>();
167 batteryModel->SetAttribute(
"FullVoltage",
DoubleValue(1.39));
168 batteryModel->SetAttribute(
"MaxCapacity",
DoubleValue(7.0));
170 batteryModel->SetAttribute(
"NominalVoltage",
DoubleValue(1.18));
171 batteryModel->SetAttribute(
"NominalCapacity",
DoubleValue(6.25));
173 batteryModel->SetAttribute(
"ExponentialVoltage",
DoubleValue(1.28));
174 batteryModel->SetAttribute(
"ExponentialCapacity",
DoubleValue(1.3));
176 batteryModel->SetAttribute(
"InternalResistance",
DoubleValue(0.0046));
177 batteryModel->SetAttribute(
"TypicalDischargeCurrent",
DoubleValue(1.3));
178 batteryModel->SetAttribute(
"CutoffVoltage",
DoubleValue(1.0));
192 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
193 devicesEnergyModel->
SetNode(node);
207 node = CreateObject<Node>();
211 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
213 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
214 devicesEnergyModel->
SetNode(node);
227 node = CreateObject<Node>();
228 batteryModel = CreateObject<GenericBatteryModel>();
232 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
234 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
235 devicesEnergyModel->
SetNode(node);
249 set yrange [0.8:1.8]\n\
253 set style line 1 linewidth 5\n\
254 set style line 2 linewidth 5\n\
255 set style line 3 linewidth 5\n\
256 set style line 4 linewidth 5\n\
257 set style line 5 linewidth 5\n\
258 set style line 6 linewidth 5\n\
259 set style line 7 linewidth 5\n\
260 set style line 8 linewidth 5\n\
261 set style increment user\n\
262 set key reverse Left");
266 std::cout <<
"The end, plotting now\n";
272 node = CreateObject<Node>();
276 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
278 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
279 devicesEnergyModel->
SetNode(node);
292 node = CreateObject<Node>();
296 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
298 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
299 devicesEnergyModel->
SetNode(node);
316 set xtics (1,2,3,5,10,20,30,60,120,180,300,600,1200,1800)\n\
317 set ytics (0,8,9,10,11,12,13,14)\n\
319 set style line 1 linewidth 5\n\
320 set style line 2 linewidth 5\n\
321 set style line 3 linewidth 5\n\
322 set style line 4 linewidth 5\n\
323 set style line 5 linewidth 5\n\
324 set style line 6 linewidth 5\n\
325 set style line 7 linewidth 5\n\
326 set style line 8 linewidth 5\n\
327 set style increment user\n\
328 set key reverse Left");
331 std::cout <<
"The end, plotting now\n";
337 node = CreateObject<Node>();
341 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
343 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
344 devicesEnergyModel->
SetNode(node);
357 node = CreateObject<Node>();
361 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
363 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
364 devicesEnergyModel->
SetNode(node);
377 node = CreateObject<Node>();
381 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
383 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
384 devicesEnergyModel->
SetNode(node);
398 set yrange [2.6:4.4]\n\
402 set style line 1 linewidth 5\n\
403 set style line 2 linewidth 5\n\
404 set style line 3 linewidth 5\n\
405 set style line 4 linewidth 5\n\
406 set style line 5 linewidth 5\n\
407 set style line 6 linewidth 5\n\
408 set style line 7 linewidth 5\n\
409 set style line 8 linewidth 5\n\
410 set style increment user\n\
411 set key reverse Left");
414 std::cout <<
"The end, plotting now\n";
420 node = CreateObject<Node>();
424 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
426 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
427 devicesEnergyModel->
SetNode(node);
440 node = CreateObject<Node>();
444 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
446 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
447 devicesEnergyModel->
SetNode(node);
464 set xtics (1,2,4,6,8,10,20,40,60,120,240,360,480,600,1200)\n\
465 set ytics (7,8,9,10,11,12,13)\n\
467 set style line 1 linewidth 5\n\
468 set style line 2 linewidth 5\n\
469 set style line 3 linewidth 5\n\
470 set style line 4 linewidth 5\n\
471 set style line 5 linewidth 5\n\
472 set style line 6 linewidth 5\n\
473 set style line 7 linewidth 5\n\
474 set style line 8 linewidth 5\n\
475 set style increment user\n\
476 set key reverse Left");
479 std::cout <<
"The end, plotting now\n";
485 node = CreateObject<Node>();
489 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
491 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
492 devicesEnergyModel->
SetNode(node);
505 node = CreateObject<Node>();
509 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
511 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
512 devicesEnergyModel->
SetNode(node);
525 node = CreateObject<Node>();
529 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
531 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
532 devicesEnergyModel->
SetNode(node);
546 set yrange [0.7:1.5]\n\
551 set style line 1 linewidth 5\n\
552 set style line 2 linewidth 5\n\
553 set style line 3 linewidth 5\n\
554 set style line 4 linewidth 5\n\
555 set style line 5 linewidth 5\n\
556 set style line 6 linewidth 5\n\
557 set style line 7 linewidth 5\n\
558 set style line 8 linewidth 5\n\
559 set style increment user\n\
560 set key reverse Left");
563 std::cout <<
"The end, plotting now\n";
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
Creates and assign an assortment of BatteryModels to Nodes.
Ptr< EnergySourceContainer > Install(NodeContainer c) const
This function installs energy sources in a group of nodes in a node container.
Class to represent a 2D points plot.
void Add(double x, double y)
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
void AddDataset(const GnuplotDataset &dataset)
void SetLegend(const std::string &xLegend, const std::string &yLegend)
void SetTerminal(const std::string &terminal)
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
void SetExtra(const std::string &extra)
Smart pointer class similar to boost::intrusive_ptr.
void SetCurrentA(double current)
virtual void SetNode(Ptr< Node > node)
Sets pointer to node.
void SetEnergySource(Ptr< EnergySource > source) override
Sets pointer to EnergySource installed on node.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static bool IsFinished()
Check if the simulation should finish.
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Simulation virtual time values and global simulation resolution.
double GetMinutes() const
Get an approximation of the time stored in this instance in the indicated unit.
double GetHours() const
Get an approximation of the time stored in this instance in the indicated unit.
std::ofstream battDischFile1("BattDischCurve1.plt")
Gnuplot2dDataset battDischDataset2
void GraphBattery1(Ptr< GenericBatteryModel > es)
std::ofstream battDischFile3("BattDischCurve3.plt")
void GraphBattery4(Ptr< GenericBatteryModel > es)
std::ofstream battDischFile5("BattDischCurve5.plt")
void GraphBattery2(Ptr< GenericBatteryModel > es)
std::ofstream battDischFile4("BattDischCurve4.plt")
Gnuplot battDischPlot1
This example shows the use of batteries in ns-3.
Gnuplot2dDataset battDischDataset5
void GraphBattery5(Ptr< GenericBatteryModel > es)
Gnuplot2dDataset battDischDataset1
void GraphBattery3(Ptr< GenericBatteryModel > es)
Gnuplot2dDataset battDischDataset3
Gnuplot2dDataset battDischDataset4
std::ofstream battDischFile2("BattDischCurve2.plt")
@ NIMH_NICD
Nickel-metal hydride and Nickel cadmium batteries.
@ PANASONIC_CGR18650DA_LION
Panasonic CGR18650DA Li-Ion battery.
@ CSB_GP1272_LEADACID
CSB GP1272 Lead acid battery.
@ PANASONIC_HHR650D_NIMH
Panasonic HHR650D NiMh battery.
@ RSPRO_LGP12100_LEADACID
RS Pro LGP12100 Lead acid battery.
@ PANASONIC_N700AAC_NICD
Panasonic N700AAC NiCd battery.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
@ LOG_LEVEL_DEBUG
LOG_DEBUG and above.
enum Gnuplot2dDataset::Style Gnuplot2dDataset