A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ns3::RvBatteryModel Class Reference

Rakhmatov Vrudhula non-linear battery model. More...

#include <rv-battery-model.h>

+ Inheritance diagram for ns3::RvBatteryModel:

Public Member Functions

double GetAlpha (void) const
 
double GetBatteryLevel (void)
 
double GetBeta (void) const
 
double GetCutoffVoltage (void) const
 
virtual double GetEnergyFraction (void)
 
virtual double GetInitialEnergy (void) const
 
Time GetLifetime (void) const
 
int GetNumOfTerms (void) const
 
double GetOpenCircuitVoltage (void) const
 
virtual double GetRemainingEnergy (void)
 
Time GetSamplingInterval (void) const
 
virtual double GetSupplyVoltage (void) const
 
void SetAlpha (double alpha)
 Sets the alpha value for the battery model. More...
 
void SetBeta (double beta)
 Sets the beta value for the battery model. More...
 
void SetCutoffVoltage (double voltage)
 Sets cutoff voltage of battery. More...
 
void SetNumOfTerms (int num)
 Sets the number of terms of the infinite sum for estimating battery level. More...
 
void SetOpenCircuitVoltage (double voltage)
 Sets open circuit voltage of battery. More...
 
void SetSamplingInterval (Time interval)
 
virtual void UpdateEnergySource (void)
 
- Public Member Functions inherited from ns3::EnergySource
void AppendDeviceEnergyModel (Ptr< DeviceEnergyModel > deviceEnergyModelPtr)
 
void DisposeDeviceModels (void)
 
DeviceEnergyModelContainer FindDeviceEnergyModels (TypeId tid)
 
DeviceEnergyModelContainer FindDeviceEnergyModels (std::string name)
 
Ptr< NodeGetNode (void) const
 
void InitializeDeviceModels (void)
 
void SetNode (Ptr< Node > node)
 Sets pointer to node containing this EnergySource. More...
 
- Public Member Functions inherited from ns3::Object
void AggregateObject (Ptr< Object > other)
 
void Dispose (void)
 
AggregateIterator GetAggregateIterator (void) const
 
virtual TypeId GetInstanceTypeId (void) const
 
template<typename T >
Ptr< T > GetObject (void) const
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 
void Initialize (void)
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount (const SimpleRefCount &o)
 
uint32_t GetReferenceCount (void) const
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 
void Ref (void) const
 
void Unref (void) const
 
- Public Member Functions inherited from ns3::ObjectBase
void GetAttribute (std::string name, AttributeValue &value) const
 
bool GetAttributeFailSafe (std::string name, AttributeValue &attribute) const
 
void SetAttribute (std::string name, const AttributeValue &value)
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 

Static Public Member Functions

static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::EnergySource
static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
static void Cleanup (void)
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 

Private Member Functions

double Discharge (double load, Time t)
 Discharges the battery. More...
 
virtual void DoDispose (void)
 Defined in ns3::Object.
 
virtual void DoInitialize (void)
 Defined in ns3::Object.
 
void HandleEnergyDrainedEvent (void)
 
double RvModelAFunction (Time t, Time sk, Time sk_1, double beta)
 RV model A function. More...
 

Private Attributes

double m_alpha
 
TracedValue< double > m_batteryLevel
 
double m_beta
 
uint64_t m_counter
 
EventId m_currentSampleEvent
 
double m_cutoffVoltage
 
Time m_lastSampleTime
 
TracedValue< Timem_lifetime
 
std::vector< double > m_load
 
int m_numOfTerms
 
double m_openCircuitVoltage
 
double m_previousLoad
 
Time m_samplingInterval
 
std::vector< Timem_timeStamps
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::EnergySource
void BreakDeviceEnergyModelRefCycle (void)
 
double CalculateTotalCurrent (void)
 
void NotifyEnergyDrained (void)
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 
virtual void NotifyNewAggregate (void)
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 
virtual void NotifyConstructionCompleted (void)
 

Detailed Description

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.

Doxygen introspection did not find any typical Config paths.

Attributes

  • RvBatteryModelPeriodicEnergyUpdateInterval: RV battery model sampling interval.
    • Set with class: TimeValue
    • Underlying type: Time
    • Initial value: +1000000000.0ns
    • Flags: construct write read
  • RvBatteryModelOpenCircuitVoltage: RV battery model open circuit voltage.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 4.1
    • Flags: construct write read
  • RvBatteryModelCutoffVoltage: RV battery model cutoff voltage.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 3
    • Flags: construct write read
  • RvBatteryModelAlphaValue: RV battery model alpha value.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 35220
    • Flags: construct write read
  • RvBatteryModelBetaValue: RV battery model beta value.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 0.637
    • Flags: construct write read
  • RvBatteryModelNumOfTerms: The number of terms of the infinite sum for estimating battery level.
    • Set with class: ns3::IntegerValue
    • Underlying type: int32_t -2147483648:2147483647
    • Initial value: 10
    • Flags: construct write read

TraceSources

  • RvBatteryModelBatteryLevel: RV battery model battery level.
  • RvBatteryModelBatteryLifetime: RV battery model battery lifetime.

Definition at line 50 of file rv-battery-model.h.

Member Function Documentation

double ns3::RvBatteryModel::Discharge ( double  load,
Time  t 
)
private

Discharges the battery.

Parameters
loadLoad value (total current form devices, in mA).
tTime stamp of the load value.
Returns
Calculated alpha 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 313 of file rv-battery-model.cc.

References NS_ASSERT, NS_LOG_FUNCTION, RvModelAFunction(), and ns3::Seconds().

Referenced by UpdateEnergySource().

double ns3::RvBatteryModel::GetAlpha ( void  ) const
Returns
The alpha value used by the battery model.

Definition at line 235 of file rv-battery-model.cc.

References NS_LOG_FUNCTION.

double ns3::RvBatteryModel::GetBatteryLevel ( void  )
Returns
Battery level [0, 1].

Definition at line 257 of file rv-battery-model.cc.

References m_batteryLevel, NS_LOG_FUNCTION, and UpdateEnergySource().

Referenced by GetEnergyFraction().

double ns3::RvBatteryModel::GetBeta ( void  ) const
Returns
The beta value used by the battery model.

Definition at line 250 of file rv-battery-model.cc.

References NS_LOG_FUNCTION.

double ns3::RvBatteryModel::GetCutoffVoltage ( void  ) const
Returns
Cutoff voltage of battery.

Definition at line 220 of file rv-battery-model.cc.

References NS_LOG_FUNCTION.

double ns3::RvBatteryModel::GetEnergyFraction ( void  )
virtual
Returns
Energy fraction.

Implements GetEnergyFraction. For the RV battery model, energy fraction is equivalent to battery level.

Implements ns3::EnergySource.

Definition at line 125 of file rv-battery-model.cc.

References GetBatteryLevel(), and NS_LOG_FUNCTION.

double ns3::RvBatteryModel::GetInitialEnergy ( void  ) const
virtual
Returns
Initial energy stored (theoretical capacity) in the battery.

Implements GetInitialEnergy.

Implements ns3::EnergySource.

Definition at line 102 of file rv-battery-model.cc.

References GetSupplyVoltage(), and NS_LOG_FUNCTION.

Time ns3::RvBatteryModel::GetLifetime ( void  ) const
Returns
Lifetime of the battery.

Definition at line 265 of file rv-battery-model.cc.

References NS_LOG_FUNCTION.

Referenced by BatteryLifetimeTest::ConstantLoadTest(), and BatteryLifetimeTest::VariableLoadTest().

int ns3::RvBatteryModel::GetNumOfTerms ( void  ) const
Returns
The number of terms of the infinite sum for estimating battery level.

Definition at line 279 of file rv-battery-model.cc.

References NS_LOG_FUNCTION.

double ns3::RvBatteryModel::GetOpenCircuitVoltage ( void  ) const
Returns
Open circuit voltage of battery.

Definition at line 205 of file rv-battery-model.cc.

References NS_LOG_FUNCTION.

double ns3::RvBatteryModel::GetRemainingEnergy ( void  )
virtual
Returns
Remaining energy in energy source, in Joules

Implements GetRemainingEnergy.

Implements ns3::EnergySource.

Definition at line 117 of file rv-battery-model.cc.

References GetSupplyVoltage(), m_batteryLevel, NS_LOG_FUNCTION, and UpdateEnergySource().

Time ns3::RvBatteryModel::GetSamplingInterval ( void  ) const
Returns
The interval between each energy update.

Definition at line 190 of file rv-battery-model.cc.

References m_samplingInterval, and NS_LOG_FUNCTION.

double ns3::RvBatteryModel::GetSupplyVoltage ( void  ) const
virtual
Returns
Supply voltage at the energy source.

Implements GetSupplyVoltage.

Implements ns3::EnergySource.

Definition at line 109 of file rv-battery-model.cc.

References NS_LOG_FUNCTION.

Referenced by GetInitialEnergy(), and GetRemainingEnergy().

void ns3::RvBatteryModel::HandleEnergyDrainedEvent ( void  )
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 305 of file rv-battery-model.cc.

References ns3::EnergySource::NotifyEnergyDrained(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.

Referenced by UpdateEnergySource().

double ns3::RvBatteryModel::RvModelAFunction ( Time  t,
Time  sk,
Time  sk_1,
double  beta 
)
private

RV model A function.

Parameters
tCurrent time.
skTime stamp in array position k
sk_1Time stamp in array position k-1
betaBeta value used by the battery model.
Returns
Result of A function.

This function computes alpha value using the recorded load profile.

Definition at line 363 of file rv-battery-model.cc.

References ns3::Time::GetSeconds(), and NS_LOG_FUNCTION.

Referenced by Discharge().

void ns3::RvBatteryModel::SetAlpha ( double  alpha)

Sets the alpha value for the battery model.

Parameters
alphaAlpha.

Definition at line 227 of file rv-battery-model.cc.

References NS_ASSERT, and NS_LOG_FUNCTION.

void ns3::RvBatteryModel::SetBeta ( double  beta)

Sets the beta value for the battery model.

Parameters
betaBeta.

Definition at line 242 of file rv-battery-model.cc.

References NS_ASSERT, and NS_LOG_FUNCTION.

void ns3::RvBatteryModel::SetCutoffVoltage ( double  voltage)

Sets cutoff voltage of battery.

Parameters
voltageCutoff voltage.

Definition at line 212 of file rv-battery-model.cc.

References NS_ASSERT, and NS_LOG_FUNCTION.

void ns3::RvBatteryModel::SetNumOfTerms ( int  num)

Sets the number of terms of the infinite sum for estimating battery level.

Parameters
numNumber of terms.

Definition at line 272 of file rv-battery-model.cc.

References NS_LOG_FUNCTION.

void ns3::RvBatteryModel::SetOpenCircuitVoltage ( double  voltage)

Sets open circuit voltage of battery.

Parameters
voltageOpen circuit voltage.

Definition at line 197 of file rv-battery-model.cc.

References NS_ASSERT, and NS_LOG_FUNCTION.

void ns3::RvBatteryModel::SetSamplingInterval ( Time  interval)
Parameters
intervalEnergy update interval.

This function sets the interval between each energy update.

Definition at line 183 of file rv-battery-model.cc.

References m_samplingInterval, and NS_LOG_FUNCTION.

void ns3::RvBatteryModel::UpdateEnergySource ( void  )
virtual

Implements UpdateEnergySource. This function samples the total load (total current) from all devices to discharge the battery.

Implements ns3::EnergySource.

Definition at line 132 of file rv-battery-model.cc.

References ns3::EnergySource::CalculateTotalCurrent(), ns3::EventId::Cancel(), Discharge(), HandleEnergyDrainedEvent(), ns3::Simulator::IsFinished(), m_batteryLevel, m_samplingInterval, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and ns3::Simulator::Schedule().

Referenced by DoInitialize(), GetBatteryLevel(), and GetRemainingEnergy().

Member Data Documentation

TracedValue<double> ns3::RvBatteryModel::m_batteryLevel
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 248 of file rv-battery-model.h.

Referenced by GetBatteryLevel(), GetRemainingEnergy(), and UpdateEnergySource().

Time ns3::RvBatteryModel::m_samplingInterval
private

(1 / sampling interval) = sampling frequency

Definition at line 253 of file rv-battery-model.h.

Referenced by GetSamplingInterval(), SetSamplingInterval(), and UpdateEnergySource().


The documentation for this class was generated from the following files: