25 except ModuleNotFoundError:
27 "Error: ns3 Python module not found;"
28 " Python bindings may not be enabled"
29 " or your PYTHONPATH might not be properly configured"
34 """The main function in this Battery discharge example
37 argv: System parameters to use if necessary
40 ns.core.LogComponentEnable(
"GenericBatteryModel", ns.core.LOG_LEVEL_DEBUG)
42 node = ns.network.Node()
43 batteryHelper = ns.energy.GenericBatteryModelHelper()
44 batteryModel = ns.CreateObject(
"GenericBatteryModel")
45 devicesEnergyModel = ns.energy.SimpleDeviceEnergyModel()
47 batteryModel.SetAttribute(
"FullVoltage", ns.core.DoubleValue(1.39))
48 batteryModel.SetAttribute(
"MaxCapacity", ns.core.DoubleValue(7.0))
50 batteryModel.SetAttribute(
"NominalVoltage", ns.core.DoubleValue(1.18))
51 batteryModel.SetAttribute(
"NominalCapacity", ns.core.DoubleValue(6.25))
53 batteryModel.SetAttribute(
"ExponentialVoltage", ns.core.DoubleValue(1.28))
54 batteryModel.SetAttribute(
"ExponentialCapacity", ns.core.DoubleValue(1.3))
56 batteryModel.SetAttribute(
"InternalResistance", ns.core.DoubleValue(0.0046))
57 batteryModel.SetAttribute(
"TypicalDischargeCurrent", ns.core.DoubleValue(1.3))
58 batteryModel.SetAttribute(
"CutoffVoltage", ns.core.DoubleValue(1.0))
60 batteryModel.SetAttribute(
"BatteryType", ns.core.EnumValue(ns.NIMH_NICD))
62 devicesEnergyModel.SetEnergySource(batteryModel)
63 batteryModel.AppendDeviceEnergyModel(devicesEnergyModel)
64 devicesEnergyModel.SetNode(node)
66 devicesEnergyModel.SetCurrentA(6.5)
68 ns.core.Simulator.Stop(ns.core.Seconds(3600))
69 ns.core.Simulator.Run()
70 ns.core.Simulator.Destroy()
73 if __name__ ==
"__main__":