9#include <ns3/core-module.h>
10#include <ns3/energy-module.h>
11#include <ns3/gnuplot.h>
67 double cellVoltage = es->GetSupplyVoltage();
82 double cellVoltage = es->GetSupplyVoltage();
97 double cellVoltage = es->GetSupplyVoltage();
98 double dischargeCapacityAh = es->GetDrainedCapacity();
111 double cellVoltage = es->GetSupplyVoltage();
126 double cellVoltage = es->GetSupplyVoltage();
138main(
int argc,
char** argv)
141 cmd.Parse(argc, argv);
159 batteryModel->SetAttribute(
"FullVoltage",
DoubleValue(1.39));
160 batteryModel->SetAttribute(
"MaxCapacity",
DoubleValue(7.0));
162 batteryModel->SetAttribute(
"NominalVoltage",
DoubleValue(1.18));
163 batteryModel->SetAttribute(
"NominalCapacity",
DoubleValue(6.25));
165 batteryModel->SetAttribute(
"ExponentialVoltage",
DoubleValue(1.28));
166 batteryModel->SetAttribute(
"ExponentialCapacity",
DoubleValue(1.3));
168 batteryModel->SetAttribute(
"InternalResistance",
DoubleValue(0.0046));
169 batteryModel->SetAttribute(
"TypicalDischargeCurrent",
DoubleValue(1.3));
170 batteryModel->SetAttribute(
"CutoffVoltage",
DoubleValue(1.0));
183 devicesEnergyModel->SetEnergySource(batteryModel);
184 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
185 devicesEnergyModel->SetNode(node);
187 devicesEnergyModel->SetCurrentA(6.5);
204 devicesEnergyModel->SetEnergySource(batteryModel);
205 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
206 devicesEnergyModel->SetNode(node);
208 devicesEnergyModel->SetCurrentA(13);
225 devicesEnergyModel->SetEnergySource(batteryModel);
226 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
227 devicesEnergyModel->SetNode(node);
229 devicesEnergyModel->SetCurrentA(32.5);
241 set yrange [0.8:1.8]\n\
245 set style line 1 linewidth 5\n\
246 set style line 2 linewidth 5\n\
247 set style line 3 linewidth 5\n\
248 set style line 4 linewidth 5\n\
249 set style line 5 linewidth 5\n\
250 set style line 6 linewidth 5\n\
251 set style line 7 linewidth 5\n\
252 set style line 8 linewidth 5\n\
253 set style increment user\n\
254 set key reverse Left");
258 std::cout <<
"The end, plotting now\n";
269 devicesEnergyModel->SetEnergySource(batteryModel);
270 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
271 devicesEnergyModel->SetNode(node);
273 devicesEnergyModel->SetCurrentA(0.36);
289 devicesEnergyModel->SetEnergySource(batteryModel);
290 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
291 devicesEnergyModel->SetNode(node);
293 devicesEnergyModel->SetCurrentA(0.648);
308 set xtics (1,2,3,5,10,20,30,60,120,180,300,600,1200,1800)\n\
309 set ytics (0,8,9,10,11,12,13,14)\n\
311 set style line 1 linewidth 5\n\
312 set style line 2 linewidth 5\n\
313 set style line 3 linewidth 5\n\
314 set style line 4 linewidth 5\n\
315 set style line 5 linewidth 5\n\
316 set style line 6 linewidth 5\n\
317 set style line 7 linewidth 5\n\
318 set style line 8 linewidth 5\n\
319 set style increment user\n\
320 set key reverse Left");
323 std::cout <<
"The end, plotting now\n";
334 devicesEnergyModel->SetEnergySource(batteryModel);
335 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
336 devicesEnergyModel->SetNode(node);
338 devicesEnergyModel->SetCurrentA(0.466);
354 devicesEnergyModel->SetEnergySource(batteryModel);
355 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
356 devicesEnergyModel->SetNode(node);
358 devicesEnergyModel->SetCurrentA(2.33);
374 devicesEnergyModel->SetEnergySource(batteryModel);
375 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
376 devicesEnergyModel->SetNode(node);
378 devicesEnergyModel->SetCurrentA(4.66);
390 set yrange [2.6:4.4]\n\
394 set style line 1 linewidth 5\n\
395 set style line 2 linewidth 5\n\
396 set style line 3 linewidth 5\n\
397 set style line 4 linewidth 5\n\
398 set style line 5 linewidth 5\n\
399 set style line 6 linewidth 5\n\
400 set style line 7 linewidth 5\n\
401 set style line 8 linewidth 5\n\
402 set style increment user\n\
403 set key reverse Left");
406 std::cout <<
"The end, plotting now\n";
417 devicesEnergyModel->SetEnergySource(batteryModel);
418 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
419 devicesEnergyModel->SetNode(node);
421 devicesEnergyModel->SetCurrentA(5);
437 devicesEnergyModel->SetEnergySource(batteryModel);
438 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
439 devicesEnergyModel->SetNode(node);
441 devicesEnergyModel->SetCurrentA(100);
456 set xtics (1,2,4,6,8,10,20,40,60,120,240,360,480,600,1200)\n\
457 set ytics (7,8,9,10,11,12,13)\n\
459 set style line 1 linewidth 5\n\
460 set style line 2 linewidth 5\n\
461 set style line 3 linewidth 5\n\
462 set style line 4 linewidth 5\n\
463 set style line 5 linewidth 5\n\
464 set style line 6 linewidth 5\n\
465 set style line 7 linewidth 5\n\
466 set style line 8 linewidth 5\n\
467 set style increment user\n\
468 set key reverse Left");
471 std::cout <<
"The end, plotting now\n";
482 devicesEnergyModel->SetEnergySource(batteryModel);
483 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
484 devicesEnergyModel->SetNode(node);
486 devicesEnergyModel->SetCurrentA(0.07);
502 devicesEnergyModel->SetEnergySource(batteryModel);
503 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
504 devicesEnergyModel->SetNode(node);
506 devicesEnergyModel->SetCurrentA(0.14);
522 devicesEnergyModel->SetEnergySource(batteryModel);
523 batteryModel->AppendDeviceEnergyModel(devicesEnergyModel);
524 devicesEnergyModel->SetNode(node);
526 devicesEnergyModel->SetCurrentA(0.35);
538 set yrange [0.7:1.5]\n\
543 set style line 1 linewidth 5\n\
544 set style line 2 linewidth 5\n\
545 set style line 3 linewidth 5\n\
546 set style line 4 linewidth 5\n\
547 set style line 5 linewidth 5\n\
548 set style line 6 linewidth 5\n\
549 set style line 7 linewidth 5\n\
550 set style line 8 linewidth 5\n\
551 set style increment user\n\
552 set key reverse Left");
555 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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
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.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
@ LOG_LEVEL_DEBUG
LOG_DEBUG and above.