20#include <ns3/core-module.h>
21#include <ns3/energy-module.h>
22#include <ns3/gnuplot.h>
78 double cellVoltage = es->GetSupplyVoltage();
93 double cellVoltage = es->GetSupplyVoltage();
108 double cellVoltage = es->GetSupplyVoltage();
109 double dischargeCapacityAh = es->GetDrainedCapacity();
122 double cellVoltage = es->GetSupplyVoltage();
137 double cellVoltage = es->GetSupplyVoltage();
149main(
int argc,
char** argv)
152 cmd.Parse(argc, argv);
166 node = CreateObject<Node>();
167 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
168 batteryModel = CreateObject<GenericBatteryModel>();
170 batteryModel->SetAttribute(
"FullVoltage",
DoubleValue(1.39));
171 batteryModel->SetAttribute(
"MaxCapacity",
DoubleValue(7.0));
173 batteryModel->SetAttribute(
"NominalVoltage",
DoubleValue(1.18));
174 batteryModel->SetAttribute(
"NominalCapacity",
DoubleValue(6.25));
176 batteryModel->SetAttribute(
"ExponentialVoltage",
DoubleValue(1.28));
177 batteryModel->SetAttribute(
"ExponentialCapacity",
DoubleValue(1.3));
179 batteryModel->SetAttribute(
"InternalResistance",
DoubleValue(0.0046));
180 batteryModel->SetAttribute(
"TypicalDischargeCurrent",
DoubleValue(1.3));
181 batteryModel->SetAttribute(
"CutoffVoltage",
DoubleValue(1.0));
194 devicesEnergyModel->SetEnergySource(batteryModel);
195 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
196 devicesEnergyModel->SetNode(node);
198 devicesEnergyModel->SetCurrentA(6.5);
210 node = CreateObject<Node>();
214 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
215 devicesEnergyModel->SetEnergySource(batteryModel);
216 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
217 devicesEnergyModel->SetNode(node);
219 devicesEnergyModel->SetCurrentA(13);
230 node = CreateObject<Node>();
231 batteryModel = CreateObject<GenericBatteryModel>();
235 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
236 devicesEnergyModel->SetEnergySource(batteryModel);
237 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
238 devicesEnergyModel->SetNode(node);
240 devicesEnergyModel->SetCurrentA(32.5);
252 set yrange [0.8:1.8]\n\
256 set style line 1 linewidth 5\n\
257 set style line 2 linewidth 5\n\
258 set style line 3 linewidth 5\n\
259 set style line 4 linewidth 5\n\
260 set style line 5 linewidth 5\n\
261 set style line 6 linewidth 5\n\
262 set style line 7 linewidth 5\n\
263 set style line 8 linewidth 5\n\
264 set style increment user\n\
265 set key reverse Left");
269 std::cout <<
"The end, plotting now\n";
275 node = CreateObject<Node>();
279 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
280 devicesEnergyModel->SetEnergySource(batteryModel);
281 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
282 devicesEnergyModel->SetNode(node);
284 devicesEnergyModel->SetCurrentA(0.36);
295 node = CreateObject<Node>();
299 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
300 devicesEnergyModel->SetEnergySource(batteryModel);
301 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
302 devicesEnergyModel->SetNode(node);
304 devicesEnergyModel->SetCurrentA(0.648);
319 set xtics (1,2,3,5,10,20,30,60,120,180,300,600,1200,1800)\n\
320 set ytics (0,8,9,10,11,12,13,14)\n\
322 set style line 1 linewidth 5\n\
323 set style line 2 linewidth 5\n\
324 set style line 3 linewidth 5\n\
325 set style line 4 linewidth 5\n\
326 set style line 5 linewidth 5\n\
327 set style line 6 linewidth 5\n\
328 set style line 7 linewidth 5\n\
329 set style line 8 linewidth 5\n\
330 set style increment user\n\
331 set key reverse Left");
334 std::cout <<
"The end, plotting now\n";
340 node = CreateObject<Node>();
344 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
345 devicesEnergyModel->SetEnergySource(batteryModel);
346 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
347 devicesEnergyModel->SetNode(node);
349 devicesEnergyModel->SetCurrentA(0.466);
360 node = CreateObject<Node>();
364 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
365 devicesEnergyModel->SetEnergySource(batteryModel);
366 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
367 devicesEnergyModel->SetNode(node);
369 devicesEnergyModel->SetCurrentA(2.33);
380 node = CreateObject<Node>();
384 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
385 devicesEnergyModel->SetEnergySource(batteryModel);
386 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
387 devicesEnergyModel->SetNode(node);
389 devicesEnergyModel->SetCurrentA(4.66);
401 set yrange [2.6:4.4]\n\
405 set style line 1 linewidth 5\n\
406 set style line 2 linewidth 5\n\
407 set style line 3 linewidth 5\n\
408 set style line 4 linewidth 5\n\
409 set style line 5 linewidth 5\n\
410 set style line 6 linewidth 5\n\
411 set style line 7 linewidth 5\n\
412 set style line 8 linewidth 5\n\
413 set style increment user\n\
414 set key reverse Left");
417 std::cout <<
"The end, plotting now\n";
423 node = CreateObject<Node>();
427 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
428 devicesEnergyModel->SetEnergySource(batteryModel);
429 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
430 devicesEnergyModel->SetNode(node);
432 devicesEnergyModel->SetCurrentA(5);
443 node = CreateObject<Node>();
447 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
448 devicesEnergyModel->SetEnergySource(batteryModel);
449 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
450 devicesEnergyModel->SetNode(node);
452 devicesEnergyModel->SetCurrentA(100);
467 set xtics (1,2,4,6,8,10,20,40,60,120,240,360,480,600,1200)\n\
468 set ytics (7,8,9,10,11,12,13)\n\
470 set style line 1 linewidth 5\n\
471 set style line 2 linewidth 5\n\
472 set style line 3 linewidth 5\n\
473 set style line 4 linewidth 5\n\
474 set style line 5 linewidth 5\n\
475 set style line 6 linewidth 5\n\
476 set style line 7 linewidth 5\n\
477 set style line 8 linewidth 5\n\
478 set style increment user\n\
479 set key reverse Left");
482 std::cout <<
"The end, plotting now\n";
488 node = CreateObject<Node>();
492 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
493 devicesEnergyModel->SetEnergySource(batteryModel);
494 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
495 devicesEnergyModel->SetNode(node);
497 devicesEnergyModel->SetCurrentA(0.07);
508 node = CreateObject<Node>();
512 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
513 devicesEnergyModel->SetEnergySource(batteryModel);
514 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
515 devicesEnergyModel->SetNode(node);
517 devicesEnergyModel->SetCurrentA(0.14);
528 node = CreateObject<Node>();
532 devicesEnergyModel = CreateObject<SimpleDeviceEnergyModel>();
533 devicesEnergyModel->SetEnergySource(batteryModel);
534 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
535 devicesEnergyModel->SetNode(node);
537 devicesEnergyModel->SetCurrentA(0.35);
549 set yrange [0.7:1.5]\n\
554 set style line 1 linewidth 5\n\
555 set style line 2 linewidth 5\n\
556 set style line 3 linewidth 5\n\
557 set style line 4 linewidth 5\n\
558 set style line 5 linewidth 5\n\
559 set style line 6 linewidth 5\n\
560 set style line 7 linewidth 5\n\
561 set style line 8 linewidth 5\n\
562 set style increment user\n\
563 set key reverse Left");
566 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< energy::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.
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")
@ PANASONIC_HHR650D_NIMH
Panasonic HHR650D NiMh battery.
@ CSB_GP1272_LEADACID
CSB GP1272 Lead acid battery.
@ PANASONIC_CGR18650DA_LION
Panasonic CGR18650DA Li-Ion battery.
@ PANASONIC_N700AAC_NICD
Panasonic N700AAC NiCd battery.
@ RSPRO_LGP12100_LEADACID
RS Pro LGP12100 Lead acid battery.
@ NIMH_NICD
Nickel-metal hydride and Nickel cadmium batteries.
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.