Rakhmatov Vrudhula non-linear battery model. More...
#include "rv-battery-model.h"
Public Member Functions | |
RvBatteryModel () | |
~RvBatteryModel () override | |
double | GetAlpha () const |
double | GetBatteryLevel () |
double | GetBeta () const |
double | GetCutoffVoltage () const |
double | GetEnergyFraction () override |
double | GetInitialEnergy () const override |
Time | GetLifetime () const |
int | GetNumOfTerms () const |
double | GetOpenCircuitVoltage () const |
double | GetRemainingEnergy () override |
Time | GetSamplingInterval () const |
double | GetSupplyVoltage () const override |
void | SetAlpha (double alpha) |
Sets the alpha value for the battery model. | |
void | SetBeta (double beta) |
Sets the beta value for the battery model. | |
void | SetCutoffVoltage (double voltage) |
Sets cutoff voltage of battery. | |
void | SetNumOfTerms (int num) |
Sets the number of terms of the infinite sum for estimating battery level. | |
void | SetOpenCircuitVoltage (double voltage) |
Sets open circuit voltage of battery. | |
void | SetSamplingInterval (Time interval) |
void | UpdateEnergySource () override |
Implements UpdateEnergySource. | |
Public Member Functions inherited from ns3::energy::EnergySource | |
EnergySource () | |
~EnergySource () override | |
void | AppendDeviceEnergyModel (Ptr< DeviceEnergyModel > deviceEnergyModelPtr) |
void | ConnectEnergyHarvester (Ptr< EnergyHarvester > energyHarvesterPtr) |
void | DisposeDeviceModels () |
Calls Dispose () method of the device energy models. | |
DeviceEnergyModelContainer | FindDeviceEnergyModels (std::string name) |
DeviceEnergyModelContainer | FindDeviceEnergyModels (TypeId tid) |
Ptr< Node > | GetNode () const |
void | InitializeDeviceModels () |
Calls Start () method of the device energy models. | |
void | SetNode (Ptr< Node > node) |
Sets pointer to node containing this EnergySource. | |
Public Member Functions inherited from ns3::Object | |
Object () | |
Constructor. | |
~Object () override | |
Destructor. | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. | |
void | Dispose () |
Dispose of this Object. | |
AggregateIterator | GetAggregateIterator () const |
Get an iterator to the Objects aggregated to this one. | |
TypeId | GetInstanceTypeId () const override |
Get the most derived TypeId for this Object. | |
template<typename T > | |
Ptr< T > | GetObject () const |
Get a pointer to the requested aggregated Object. | |
template<> | |
Ptr< Object > | GetObject () const |
Specialization of () for objects of type ns3::Object. | |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
Get a pointer to the requested aggregated Object by TypeId. | |
template<> | |
Ptr< Object > | GetObject (TypeId tid) const |
Specialization of (TypeId tid) for objects of type ns3::Object. | |
void | Initialize () |
Invoke DoInitialize on all Objects aggregated to this one. | |
bool | IsInitialized () const |
Check if the object has been initialized. | |
void | UnidirectionalAggregateObject (Ptr< Object > other) |
Aggregate an Object to another Object. | |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Default constructor. | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment operator. | |
void | Ref () const |
Increment the reference count. | |
void | Unref () const |
Decrement the reference count. | |
Public Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. | |
void | GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const |
Get the value of an attribute, raising fatal errors if unsuccessful. | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Get the type ID. | |
Static Public Member Functions inherited from ns3::energy::EnergySource | |
static TypeId | GetTypeId () |
Get the type ID. | |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId () |
Register this type. | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId () |
Get the type ID. | |
Private Member Functions | |
double | Discharge (double load, Time t) |
Discharges the battery. | |
void | DoDispose () override |
Defined in ns3::Object. | |
void | DoInitialize () override |
Defined in ns3::Object. | |
void | HandleEnergyDrainedEvent () |
Handles the remaining energy going to zero event. | |
double | RvModelAFunction (Time t, Time sk, Time sk_1, double beta) |
RV model A function. | |
Private Attributes | |
double | m_alpha |
alpha value of RV model, in Coulomb | |
TracedValue< double > | m_batteryLevel |
Battery level is defined as: output of Discharge function / alpha value. | |
double | m_beta |
beta value of RV model, in second^-1 | |
EventId | m_currentSampleEvent |
Current sample event. | |
double | m_cutoffVoltage |
Cutoff voltage (in Volts) | |
Time | m_lastSampleTime |
Last sample time. | |
TracedValue< Time > | m_lifetime |
time of death of the battery | |
std::vector< double > | m_load |
load profile | |
double | m_lowBatteryTh |
low battery threshold, as a fraction of the initial energy | |
int | m_numOfTerms |
Number# of terms for infinite sum in battery level estimation. | |
double | m_openCircuitVoltage |
Open circuit voltage (in Volts) | |
double | m_previousLoad |
load value (total current) of previous sampling | |
Time | m_samplingInterval |
Sampling interval. | |
std::vector< Time > | m_timeStamps |
time stamps of load profile | |
Additional Inherited Members | |
Protected Member Functions inherited from ns3::energy::EnergySource | |
void | BreakDeviceEnergyModelRefCycle () |
This function is called to break reference cycle between EnergySource and DeviceEnergyModel. | |
double | CalculateTotalCurrent () |
void | NotifyEnergyChanged () |
This function notifies all DeviceEnergyModel of energy changed event. | |
void | NotifyEnergyDrained () |
This function notifies all DeviceEnergyModel of energy depletion event. | |
void | NotifyEnergyRecharged () |
This function notifies all DeviceEnergyModel of energy recharged event. | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
Copy an Object. | |
virtual void | NotifyNewAggregate () |
Notify all Objects aggregated to this one of a new Object being aggregated. | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. | |
virtual void | NotifyConstructionCompleted () |
Notifier called once the ObjectBase is fully constructed. | |
Related Symbols inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
Rakhmatov Vrudhula non-linear battery model.
This (energy source) model implements an analytical non-linear battery model. It is capable of capturing load capacity and recovery effects of batteries. Batteries are characterized by 2 parameters, alpha and beta, which can both be obtained from the discharge curve of the batteries.
The model is developed by Daler Rakhmatov & Sarma Vrudhula in: "Battery Lifetime Prediction for Energy-Aware Computing" and "An Analytical High-Level Battery Model for Use in Energy Management of Portable Electronic Systems".
The real-time algorithm is developed by Matthias Handy & Dirk Timmermann in: "Simulation of Mobile Wireless Networks with Accurate Modeling of non-linear battery effects". The real-time algorithm is modified by the authors of this code for improved accuracy and reduced computation (sampling) overhead.
Definition at line 42 of file rv-battery-model.h.
ns3::energy::RvBatteryModel::RvBatteryModel | ( | ) |
Definition at line 86 of file rv-battery-model.cc.
References m_batteryLevel, m_lastSampleTime, m_lifetime, m_previousLoad, m_timeStamps, ns3::Simulator::Now(), NS_LOG_FUNCTION, and ns3::Seconds().
|
override |
Definition at line 96 of file rv-battery-model.cc.
References NS_LOG_FUNCTION.
Discharges the battery.
load | Load value (total current form devices, in mA). |
t | Time stamp of the load value. |
Discharge function calculates a value which is then compared to the alpha value to determine if the battery is dead. It will also update the battery level.
Note that the load value passed to Discharge has to be in mA.
Definition at line 311 of file rv-battery-model.cc.
References m_beta, m_lastSampleTime, m_load, m_previousLoad, m_timeStamps, NS_ASSERT, NS_LOG_FUNCTION, RvModelAFunction(), and ns3::Seconds().
Referenced by UpdateEnergySource().
|
overrideprivatevirtual |
Defined in ns3::Object.
Reimplemented from ns3::energy::EnergySource.
Definition at line 296 of file rv-battery-model.cc.
References ns3::energy::EnergySource::BreakDeviceEnergyModelRefCycle(), and NS_LOG_FUNCTION.
|
overrideprivatevirtual |
Defined in ns3::Object.
Reimplemented from ns3::Object.
Definition at line 288 of file rv-battery-model.cc.
References NS_LOG_DEBUG, NS_LOG_FUNCTION, and UpdateEnergySource().
double ns3::energy::RvBatteryModel::GetAlpha | ( | ) | const |
Definition at line 233 of file rv-battery-model.cc.
References m_alpha, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
double ns3::energy::RvBatteryModel::GetBatteryLevel | ( | ) |
Definition at line 255 of file rv-battery-model.cc.
References m_batteryLevel, NS_LOG_FUNCTION, and UpdateEnergySource().
Referenced by GetEnergyFraction().
double ns3::energy::RvBatteryModel::GetBeta | ( | ) | const |
Definition at line 248 of file rv-battery-model.cc.
References m_beta, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
double ns3::energy::RvBatteryModel::GetCutoffVoltage | ( | ) | const |
Definition at line 218 of file rv-battery-model.cc.
References m_cutoffVoltage, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
overridevirtual |
Implements GetEnergyFraction. For the RV battery model, energy fraction is equivalent to battery level.
Implements ns3::energy::EnergySource.
Definition at line 125 of file rv-battery-model.cc.
References GetBatteryLevel(), and NS_LOG_FUNCTION.
|
overridevirtual |
Implements GetInitialEnergy.
Implements ns3::energy::EnergySource.
Definition at line 102 of file rv-battery-model.cc.
References GetSupplyVoltage(), m_alpha, and NS_LOG_FUNCTION.
Time ns3::energy::RvBatteryModel::GetLifetime | ( | ) | const |
Definition at line 263 of file rv-battery-model.cc.
References m_lifetime, and NS_LOG_FUNCTION.
int ns3::energy::RvBatteryModel::GetNumOfTerms | ( | ) | const |
Definition at line 277 of file rv-battery-model.cc.
References m_numOfTerms, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
double ns3::energy::RvBatteryModel::GetOpenCircuitVoltage | ( | ) | const |
Definition at line 203 of file rv-battery-model.cc.
References m_openCircuitVoltage, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
overridevirtual |
Implements GetRemainingEnergy.
Implements ns3::energy::EnergySource.
Definition at line 117 of file rv-battery-model.cc.
References GetSupplyVoltage(), m_alpha, m_batteryLevel, NS_LOG_FUNCTION, and UpdateEnergySource().
Time ns3::energy::RvBatteryModel::GetSamplingInterval | ( | ) | const |
Definition at line 188 of file rv-battery-model.cc.
References m_samplingInterval, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
overridevirtual |
Implements GetSupplyVoltage.
Implements ns3::energy::EnergySource.
Definition at line 109 of file rv-battery-model.cc.
References m_cutoffVoltage, m_openCircuitVoltage, and NS_LOG_FUNCTION.
Referenced by GetInitialEnergy(), and GetRemainingEnergy().
|
static |
Get the type ID.
Definition at line 28 of file rv-battery-model.cc.
References ns3::TypeId::AddDeprecatedName(), GetAlpha(), GetBeta(), GetCutoffVoltage(), GetNumOfTerms(), GetOpenCircuitVoltage(), GetSamplingInterval(), m_batteryLevel, m_lifetime, m_lowBatteryTh, ns3::MakeDoubleAccessor(), ns3::MakeDoubleChecker(), ns3::MakeIntegerAccessor(), ns3::MakeIntegerChecker(), ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeTraceSourceAccessor(), ns3::Seconds(), SetAlpha(), SetBeta(), SetCutoffVoltage(), SetNumOfTerms(), SetOpenCircuitVoltage(), ns3::TypeId::SetParent(), and SetSamplingInterval().
|
private |
Handles the remaining energy going to zero event.
This function notifies all the energy models aggregated to the node about the energy being depleted. Each energy model is then responsible for its own handler.
Definition at line 303 of file rv-battery-model.cc.
References ns3::energy::EnergySource::NotifyEnergyDrained(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.
Referenced by UpdateEnergySource().
|
private |
RV model A function.
t | Current time. |
sk | Time stamp in array position k |
sk_1 | Time stamp in array position k-1 |
beta | Beta value used by the battery model. |
This function computes alpha value using the recorded load profile.
Definition at line 355 of file rv-battery-model.cc.
References m_numOfTerms, and NS_LOG_FUNCTION.
Referenced by Discharge().
void ns3::energy::RvBatteryModel::SetAlpha | ( | double | alpha | ) |
Sets the alpha value for the battery model.
alpha | Alpha. |
Definition at line 225 of file rv-battery-model.cc.
References m_alpha, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::energy::RvBatteryModel::SetBeta | ( | double | beta | ) |
Sets the beta value for the battery model.
beta | Beta. |
Definition at line 240 of file rv-battery-model.cc.
References m_beta, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::energy::RvBatteryModel::SetCutoffVoltage | ( | double | voltage | ) |
Sets cutoff voltage of battery.
voltage | Cutoff voltage. |
Definition at line 210 of file rv-battery-model.cc.
References m_cutoffVoltage, m_openCircuitVoltage, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::energy::RvBatteryModel::SetNumOfTerms | ( | int | num | ) |
Sets the number of terms of the infinite sum for estimating battery level.
num | Number of terms. |
Definition at line 270 of file rv-battery-model.cc.
References m_numOfTerms, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::energy::RvBatteryModel::SetOpenCircuitVoltage | ( | double | voltage | ) |
Sets open circuit voltage of battery.
voltage | Open circuit voltage. |
Definition at line 195 of file rv-battery-model.cc.
References m_openCircuitVoltage, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::energy::RvBatteryModel::SetSamplingInterval | ( | Time | interval | ) |
interval | Energy update interval. |
This function sets the interval between each energy update.
Definition at line 181 of file rv-battery-model.cc.
References m_samplingInterval, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
overridevirtual |
Implements UpdateEnergySource.
This function samples the total load (total current) from all devices to discharge the battery.
Implements ns3::energy::EnergySource.
Definition at line 132 of file rv-battery-model.cc.
References ns3::energy::EnergySource::CalculateTotalCurrent(), ns3::EventId::Cancel(), Discharge(), HandleEnergyDrainedEvent(), ns3::Simulator::IsFinished(), m_alpha, m_batteryLevel, m_currentSampleEvent, m_lastSampleTime, m_lifetime, m_lowBatteryTh, m_previousLoad, m_samplingInterval, m_timeStamps, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::Time::S, ns3::Simulator::Schedule(), and UpdateEnergySource().
Referenced by DoInitialize(), GetBatteryLevel(), GetRemainingEnergy(), and UpdateEnergySource().
|
private |
alpha value of RV model, in Coulomb
Definition at line 217 of file rv-battery-model.h.
Referenced by GetAlpha(), GetInitialEnergy(), GetRemainingEnergy(), SetAlpha(), and UpdateEnergySource().
|
private |
Battery level is defined as: output of Discharge function / alpha value.
The output of Discharge function is an estimated charge consumption of the battery.
The alpha value is the amount of charges stored in the battery, or battery capacity (in Coulomb).
When the battery is fully charged (no charge is consumed from the battery) the battery level is 1. When the battery is fully discharged, the battery level is 0.
NOTE Note that the definition in Timmermann's paper is the inverse of this definition. In the paper, battery level = 1 when the battery is drained.
Definition at line 243 of file rv-battery-model.h.
Referenced by RvBatteryModel(), GetBatteryLevel(), GetRemainingEnergy(), GetTypeId(), and UpdateEnergySource().
|
private |
beta value of RV model, in second^-1
Definition at line 218 of file rv-battery-model.h.
Referenced by Discharge(), GetBeta(), and SetBeta().
|
private |
Current sample event.
Definition at line 252 of file rv-battery-model.h.
Referenced by UpdateEnergySource().
|
private |
Cutoff voltage (in Volts)
Definition at line 216 of file rv-battery-model.h.
Referenced by GetCutoffVoltage(), GetSupplyVoltage(), and SetCutoffVoltage().
|
private |
Last sample time.
Definition at line 223 of file rv-battery-model.h.
Referenced by RvBatteryModel(), Discharge(), and UpdateEnergySource().
|
private |
time of death of the battery
Definition at line 254 of file rv-battery-model.h.
Referenced by RvBatteryModel(), GetLifetime(), GetTypeId(), and UpdateEnergySource().
|
private |
|
private |
low battery threshold, as a fraction of the initial energy
Definition at line 245 of file rv-battery-model.h.
Referenced by GetTypeId(), and UpdateEnergySource().
|
private |
Number# of terms for infinite sum in battery level estimation.
Definition at line 225 of file rv-battery-model.h.
Referenced by GetNumOfTerms(), RvModelAFunction(), and SetNumOfTerms().
|
private |
Open circuit voltage (in Volts)
Definition at line 215 of file rv-battery-model.h.
Referenced by GetOpenCircuitVoltage(), GetSupplyVoltage(), SetCutoffVoltage(), and SetOpenCircuitVoltage().
|
private |
load value (total current) of previous sampling
Definition at line 220 of file rv-battery-model.h.
Referenced by RvBatteryModel(), Discharge(), and UpdateEnergySource().
|
private |
Sampling interval.
(1 / sampling interval) = sampling frequency
Definition at line 251 of file rv-battery-model.h.
Referenced by GetSamplingInterval(), SetSamplingInterval(), and UpdateEnergySource().
|
private |
time stamps of load profile
Definition at line 222 of file rv-battery-model.h.
Referenced by RvBatteryModel(), Discharge(), and UpdateEnergySource().