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

Model a generic Lithium Ion Battery basing on [1][2]. More...

#include <li-ion-energy-source.h>

+ Inheritance diagram for ns3::LiIonEnergySource:
+ Collaboration diagram for ns3::LiIonEnergySource:

Public Member Functions

 LiIonEnergySource ()
 
virtual ~LiIonEnergySource ()
 
virtual void DecreaseRemainingEnergy (double energyJ)
 
virtual double GetEnergyFraction (void)
 
Time GetEnergyUpdateInterval (void) const
 
virtual double GetInitialEnergy (void) const
 
virtual double GetRemainingEnergy (void)
 
virtual double GetSupplyVoltage (void) const
 
virtual void IncreaseRemainingEnergy (double energyJ)
 
void SetEnergyUpdateInterval (Time interval)
 
void SetInitialEnergy (double initialEnergyJ)
 
void SetInitialSupplyVoltage (double supplyVoltageV)
 
virtual void UpdateEnergySource (void)
 Implements UpdateEnergySource. More...
 
- Public Member Functions inherited from ns3::EnergySource
 EnergySource ()
 
virtual ~EnergySource ()
 
void AppendDeviceEnergyModel (Ptr< DeviceEnergyModel > deviceEnergyModelPtr)
 
void DisposeDeviceModels (void)
 Calls Dispose () method of the device energy models. More...
 
DeviceEnergyModelContainer FindDeviceEnergyModels (TypeId tid)
 
DeviceEnergyModelContainer FindDeviceEnergyModels (std::string name)
 
Ptr< NodeGetNode (void) const
 
void InitializeDeviceModels (void)
 Calls Start () method of the device energy models. More...
 
void SetNode (Ptr< Node > node)
 Sets pointer to node containing this EnergySource. More...
 
- Public Member Functions inherited from ns3::Object
 Object ()
 
virtual ~Object ()
 
void AggregateObject (Ptr< Object > other)
 
void Dispose (void)
 Run the DoDispose methods of this object and all the objects aggregated to it. More...
 
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)
 This method calls the virtual DoInitialize method on all the objects aggregated to this object. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
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)
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
static void Cleanup (void)
 Noop. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Private Member Functions

void CalculateRemainingEnergy (void)
 Calculates remaining energy. More...
 
void DoDispose (void)
 All child's implementation must call BreakDeviceEnergyModelRefCycle to ensure reference cycles to DeviceEnergyModel objects are broken. More...
 
void DoInitialize (void)
 This method is called only once by Object::Initialize. More...
 
double GetVoltage (double current) const
 
void HandleEnergyDrainedEvent (void)
 Handles the remaining energy going to zero event. More...
 

Private Attributes

double m_drainedCapacity
 
double m_eExp
 
double m_eFull
 
EventId m_energyUpdateEvent
 
Time m_energyUpdateInterval
 
double m_eNom
 
double m_initialEnergyJ
 
double m_internalResistance
 
Time m_lastUpdateTime
 
double m_minVoltTh
 
double m_qExp
 
double m_qNom
 
double m_qRated
 
TracedValue< double > m_remainingEnergyJ
 
double m_supplyVoltageV
 
double m_typCurrent
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::EnergySource
void BreakDeviceEnergyModelRefCycle (void)
 This function is called to break reference cycle between EnergySource and DeviceEnergyModel. More...
 
double CalculateTotalCurrent (void)
 
void NotifyEnergyDrained (void)
 This function notifies all DeviceEnergyModel of energy depletion event. More...
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 
virtual void NotifyNewAggregate (void)
 This method is invoked whenever two sets of objects are aggregated together. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 
virtual void NotifyConstructionCompleted (void)
 This method is invoked once all member attributes have been initialized. More...
 

Detailed Description

Model a generic Lithium Ion Battery basing on [1][2].

Doxygen introspection did not find any typical Config paths.

The model can be fitted to any type of Li-Ion Battery, simply changing the model parameters. The default values are fitted for the Panasonic CGR18650DA Li-Ion Battery [3].

The energy is drained as defined from the EnergySource interface but, this class consider the non-linear behaviour of Li-Ion cell. Each time energy is drained from the cell, the class evaluates the discharge curve to get the actual cell's voltage, accordingly to State of Charge (SOC) and current's drain.

If the actual voltage of the cell goes below the minimum threshold voltage, the cell is considered depleted and the energy drained event fired up.

The model requires several parameters to approximates the discharge curves:

  • IntialCellVoltage, maximum voltage of the fully charged cell
  • NominalCellVoltage, nominal cell's voltage, is used to determine the end of the nominal zone.
  • ExpCellVoltage, cell's voltage at the end of the exponential zone
  • RatedCapacity, rated capacity of the cell, in Ah
  • NomCapacity, cell's capacity at the end of the nominal zone, in Ah
  • ExpCapacity, cell's capacity at the end of the exponential zone, in Ah
  • InternalResistance, internal resistance of the cell, in Ohms
  • TypCurrent, typical discharge current value, used during the fitting process, in Ah
  • ThresholdVoltage, minimum threshold voltage below which the cell is considered depleted

For a complete reference of the energy source model and model's fitting please refer to UAN Framework page and Li-Ion model fitting page.

References: [1] C. M. Shepherd, "Design of Primary and Secondary Cells - Part 3. Battery discharge equation," U.S. Naval Research Laboratory, 1963 [2] Tremblay, O.; Dessaint, L.-A.; Dekkiche, A.-I., "A Generic Battery Model for the Dynamic Simulation of Hybrid Electric Vehicles," Ecole de Technologie Superieure, Universite du Quebec, 2007 [3] http://www.panasonic.com/industrial/includes/pdf/Panasonic_LiIon_CGR18650DA.pdf


Attributes

  • LiIonEnergySourceInitialEnergyJ: Initial energy stored in basic energy source.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 31752
    • Flags: construct write read
  • InitialCellVoltage: Initial (maximum) voltage of the cell (fully charged).
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 4.05
    • Flags: construct write read
  • NominalCellVoltage: Nominal voltage of the cell.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 3.6
    • Flags: construct write read
  • ExpCellVoltage: Cell voltage at the end of the exponential zone.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 3.6
    • Flags: construct write read
  • RatedCapacity: Rated capacity of the cell.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 2.45
    • Flags: construct write read
  • NomCapacity: Cell capacity at the end of the nominal zone.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 1.1
    • Flags: construct write read
  • ExpCapacity: Cell Capacity at the end of the exponential zone.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 1.2
    • Flags: construct write read
  • InternalResistance: Internal resistance of the cell
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 0.083
    • Flags: construct write read
  • TypCurrent: Typical discharge current used to fit the curves
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 2.33
    • Flags: construct write read
  • ThresholdVoltage: Minimum threshold voltage to consider the battery depleted.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 3.3
    • Flags: construct write read
  • PeriodicEnergyUpdateInterval: Time between two consecutive periodic energy updates.
    • Set with class: ns3::TimeValue
    • Underlying type: Time -9223372036854775808.0ns:+9223372036854775807.0ns
    • Initial value: +1000000000.0ns
    • Flags: construct write read

TraceSources

Definition at line 72 of file li-ion-energy-source.h.

Constructor & Destructor Documentation

ns3::LiIonEnergySource::LiIonEnergySource ( )

Definition at line 108 of file li-ion-energy-source.cc.

References NS_LOG_FUNCTION.

ns3::LiIonEnergySource::~LiIonEnergySource ( )
virtual

Definition at line 115 of file li-ion-energy-source.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

void ns3::LiIonEnergySource::CalculateRemainingEnergy ( void  )
private

Calculates remaining energy.

This function uses the total current from all device models to calculate the amount of energy to decrease. The energy to decrease is given by: energy to decrease = total current * supply voltage * time duration This function subtracts the calculated energy to decrease from remaining energy.

Definition at line 268 of file li-ion-energy-source.cc.

References ns3::EnergySource::CalculateTotalCurrent(), ns3::Time::GetSeconds(), GetVoltage(), m_drainedCapacity, m_lastUpdateTime, m_remainingEnergyJ, m_supplyVoltageV, ns3::Simulator::Now(), NS_ASSERT, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

Referenced by DoDispose(), and UpdateEnergySource().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::LiIonEnergySource::DecreaseRemainingEnergy ( double  energyJ)
virtual
Parameters
energyJAmount of energy (in Joules) to decrease from energy source.

Implements DecreaseRemainingEnergy.

Definition at line 185 of file li-ion-energy-source.cc.

References HandleEnergyDrainedEvent(), m_minVoltTh, m_remainingEnergyJ, m_supplyVoltageV, NS_ASSERT, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

void ns3::LiIonEnergySource::DoDispose ( void  )
privatevirtual

All child's implementation must call BreakDeviceEnergyModelRefCycle to ensure reference cycles to DeviceEnergyModel objects are broken.

Defined in ns3::Object

Reimplemented from ns3::EnergySource.

Definition at line 247 of file li-ion-energy-source.cc.

References ns3::EnergySource::BreakDeviceEnergyModelRefCycle(), CalculateRemainingEnergy(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

void ns3::LiIonEnergySource::DoInitialize ( void  )
privatevirtual

This method is called only once by Object::Initialize.

If the user calls Object::Initialize multiple times, DoInitialize is called only the first time.

Subclasses are expected to override this method and chain up to their parent's implementation once they are done. It is safe to call GetObject and AggregateObject from within this method.

Reimplemented from ns3::Object.

Definition at line 240 of file li-ion-energy-source.cc.

References NS_LOG_FUNCTION, and UpdateEnergySource().

+ Here is the call graph for this function:

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

Implements GetEnergyFraction.

Implements ns3::EnergySource.

Definition at line 176 of file li-ion-energy-source.cc.

References m_initialEnergyJ, m_remainingEnergyJ, NS_LOG_FUNCTION, and UpdateEnergySource().

+ Here is the call graph for this function:

Time ns3::LiIonEnergySource::GetEnergyUpdateInterval ( void  ) const
Returns
The interval between each energy update.

Definition at line 160 of file li-ion-energy-source.cc.

References m_energyUpdateInterval, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

double ns3::LiIonEnergySource::GetInitialEnergy ( void  ) const
virtual
Returns
Initial energy stored in energy source, in Joules.

Implements GetInitialEnergy.

Implements ns3::EnergySource.

Definition at line 131 of file li-ion-energy-source.cc.

References m_initialEnergyJ, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

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

Implements GetRemainingEnergy.

Implements ns3::EnergySource.

Definition at line 167 of file li-ion-energy-source.cc.

References m_remainingEnergyJ, NS_LOG_FUNCTION, and UpdateEnergySource().

Referenced by PrintCellInfo().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Implements GetSupplyVoltage.

Implements ns3::EnergySource.

Definition at line 146 of file li-ion-energy-source.cc.

References m_supplyVoltageV, and NS_LOG_FUNCTION.

Referenced by GetTypeId(), and PrintCellInfo().

+ Here is the caller graph for this function:

double ns3::LiIonEnergySource::GetVoltage ( double  current) const
private
Parameters
currentthe actual discharge current value.

Get the cell voltage in function of the discharge current. It consider different discharge curves for different discharge currents and the remaining energy of the cell.

Definition at line 284 of file li-ion-energy-source.cc.

References E, m_drainedCapacity, m_eExp, m_eFull, m_eNom, m_internalResistance, m_qExp, m_qNom, m_qRated, m_typCurrent, NS_LOG_DEBUG, NS_LOG_FUNCTION, and V.

Referenced by CalculateRemainingEnergy().

+ Here is the caller graph for this function:

void ns3::LiIonEnergySource::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 257 of file li-ion-energy-source.cc.

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

Referenced by DecreaseRemainingEnergy(), and UpdateEnergySource().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::LiIonEnergySource::IncreaseRemainingEnergy ( double  energyJ)
virtual
Parameters
energyJAmount of energy (in Joules) to increase from energy source.

Implements IncreaseRemainingEnergy.

Definition at line 199 of file li-ion-energy-source.cc.

References m_remainingEnergyJ, NS_ASSERT, and NS_LOG_FUNCTION.

void ns3::LiIonEnergySource::SetEnergyUpdateInterval ( Time  interval)
Parameters
intervalEnergy update interval.

This function sets the interval between each energy update.

Definition at line 153 of file li-ion-energy-source.cc.

References m_energyUpdateInterval, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

void ns3::LiIonEnergySource::SetInitialEnergy ( double  initialEnergyJ)
Parameters
initialEnergyJInitial energy, in Joules

Implements SetInitialEnergy. Note that initial energy is assumed to be set before simulation starts and is set only once per simulation.

Definition at line 121 of file li-ion-energy-source.cc.

References m_initialEnergyJ, m_remainingEnergyJ, NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

void ns3::LiIonEnergySource::SetInitialSupplyVoltage ( double  supplyVoltageV)
Parameters
supplyVoltageVInitial Supply voltage at the energy source, in Volts.

Sets the initial supply voltage of the energy source. To be called only once.

Definition at line 138 of file li-ion-energy-source.cc.

References m_eFull, m_supplyVoltageV, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

void ns3::LiIonEnergySource::UpdateEnergySource ( void  )
virtual

Member Data Documentation

double ns3::LiIonEnergySource::m_drainedCapacity
private

Definition at line 186 of file li-ion-energy-source.h.

Referenced by CalculateRemainingEnergy(), and GetVoltage().

double ns3::LiIonEnergySource::m_eExp
private

Definition at line 193 of file li-ion-energy-source.h.

Referenced by GetTypeId(), and GetVoltage().

double ns3::LiIonEnergySource::m_eFull
private

Definition at line 191 of file li-ion-energy-source.h.

Referenced by GetVoltage(), and SetInitialSupplyVoltage().

EventId ns3::LiIonEnergySource::m_energyUpdateEvent
private

Definition at line 188 of file li-ion-energy-source.h.

Referenced by UpdateEnergySource().

Time ns3::LiIonEnergySource::m_energyUpdateInterval
private
double ns3::LiIonEnergySource::m_eNom
private

Definition at line 192 of file li-ion-energy-source.h.

Referenced by GetTypeId(), and GetVoltage().

double ns3::LiIonEnergySource::m_initialEnergyJ
private

Definition at line 184 of file li-ion-energy-source.h.

Referenced by GetEnergyFraction(), GetInitialEnergy(), and SetInitialEnergy().

double ns3::LiIonEnergySource::m_internalResistance
private

Definition at line 194 of file li-ion-energy-source.h.

Referenced by GetTypeId(), and GetVoltage().

Time ns3::LiIonEnergySource::m_lastUpdateTime
private

Definition at line 189 of file li-ion-energy-source.h.

Referenced by CalculateRemainingEnergy(), and UpdateEnergySource().

double ns3::LiIonEnergySource::m_minVoltTh
private

Definition at line 199 of file li-ion-energy-source.h.

Referenced by DecreaseRemainingEnergy(), and GetTypeId().

double ns3::LiIonEnergySource::m_qExp
private

Definition at line 197 of file li-ion-energy-source.h.

Referenced by GetTypeId(), and GetVoltage().

double ns3::LiIonEnergySource::m_qNom
private

Definition at line 196 of file li-ion-energy-source.h.

Referenced by GetTypeId(), and GetVoltage().

double ns3::LiIonEnergySource::m_qRated
private

Definition at line 195 of file li-ion-energy-source.h.

Referenced by GetTypeId(), and GetVoltage().

double ns3::LiIonEnergySource::m_supplyVoltageV
private
double ns3::LiIonEnergySource::m_typCurrent
private

Definition at line 198 of file li-ion-energy-source.h.

Referenced by GetTypeId(), and GetVoltage().


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