Model a generic Lithium Ion Battery basing on [1][2]. More...
#include <li-ion-energy-source.h>
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) |
![]() | |
EnergySource () | |
virtual | ~EnergySource () |
void | AppendDeviceEnergyModel (Ptr< DeviceEnergyModel > deviceEnergyModelPtr) |
void | DisposeDeviceModels (void) |
DeviceEnergyModelContainer | FindDeviceEnergyModels (TypeId tid) |
DeviceEnergyModelContainer | FindDeviceEnergyModels (std::string name) |
Ptr< Node > | GetNode (void) const |
void | SetNode (Ptr< Node > node) |
Sets pointer to node containing this EnergySource. | |
void | StartDeviceModels (void) |
![]() | |
Object () | |
virtual | ~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 | Start (void) |
![]() | |
SimpleRefCount () | |
SimpleRefCount (const SimpleRefCount &o) | |
uint32_t | GetReferenceCount (void) const |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
void | Ref (void) const |
void | Unref (void) const |
![]() | |
virtual | ~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) |
This method returns the TypeId associated to ns3::LiIonEnergySource. |
Private Member Functions | |
void | CalculateRemainingEnergy (void) |
void | DoDispose (void) |
void | DoStart (void) |
double | GetVoltage (double current) const |
void | HandleEnergyDrainedEvent (void) |
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 | |
![]() | |
void | BreakDeviceEnergyModelRefCycle (void) |
double | CalculateTotalCurrent (void) |
void | NotifyEnergyDrained (void) |
Model a generic Lithium Ion Battery basing on [1][2].
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:
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
Definition at line 72 of file li-ion-energy-source.h.
ns3::LiIonEnergySource::LiIonEnergySource | ( | ) |
Definition at line 107 of file li-ion-energy-source.cc.
|
virtual |
Definition at line 113 of file li-ion-energy-source.cc.
|
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 264 of file li-ion-energy-source.cc.
References ns3::EnergySource::CalculateTotalCurrent(), ns3::Time::GetSeconds(), GetVoltage(), m_drainedCapacity, m_lastUpdateTime, m_remainingEnergyJ, m_supplyVoltageV, ns3::Now(), NS_ASSERT, NS_LOG_DEBUG, and NS_LOG_FUNCTION.
Referenced by DoDispose(), and UpdateEnergySource().
|
virtual |
energyJ | Amount of energy (in Joules) to decrease from energy source. |
Implements DecreaseRemainingEnergy.
Definition at line 181 of file li-ion-energy-source.cc.
References HandleEnergyDrainedEvent(), m_minVoltTh, m_remainingEnergyJ, m_supplyVoltageV, NS_ASSERT, and NS_LOG_FUNCTION.
|
private |
Definition at line 243 of file li-ion-energy-source.cc.
References ns3::EnergySource::BreakDeviceEnergyModelRefCycle(), CalculateRemainingEnergy(), and NS_LOG_FUNCTION.
|
private |
Definition at line 236 of file li-ion-energy-source.cc.
References NS_LOG_FUNCTION, and UpdateEnergySource().
|
virtual |
Implements GetEnergyFraction.
Implements ns3::EnergySource.
Definition at line 172 of file li-ion-energy-source.cc.
References m_initialEnergyJ, m_remainingEnergyJ, NS_LOG_FUNCTION, and UpdateEnergySource().
Time ns3::LiIonEnergySource::GetEnergyUpdateInterval | ( | void | ) | const |
Definition at line 156 of file li-ion-energy-source.cc.
References m_energyUpdateInterval, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
virtual |
Implements GetInitialEnergy.
Implements ns3::EnergySource.
Definition at line 128 of file li-ion-energy-source.cc.
References m_initialEnergyJ, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
virtual |
Implements GetRemainingEnergy.
Implements ns3::EnergySource.
Definition at line 163 of file li-ion-energy-source.cc.
References m_remainingEnergyJ, NS_LOG_FUNCTION, and UpdateEnergySource().
Referenced by PrintCellInfo().
|
virtual |
Implements GetSupplyVoltage.
Implements ns3::EnergySource.
Definition at line 142 of file li-ion-energy-source.cc.
References m_supplyVoltageV, and NS_LOG_FUNCTION.
Referenced by GetTypeId(), and PrintCellInfo().
|
static |
This method returns the TypeId associated to ns3::LiIonEnergySource.
Attributes defined for this type:
TraceSources defined for this type:
Reimplemented from ns3::EnergySource.
Definition at line 37 of file li-ion-energy-source.cc.
References GetEnergyUpdateInterval(), GetInitialEnergy(), GetSupplyVoltage(), m_eExp, m_eNom, m_internalResistance, m_minVoltTh, m_qExp, m_qNom, m_qRated, m_remainingEnergyJ, m_typCurrent, ns3::MakeTraceSourceAccessor(), ns3::Seconds(), SetEnergyUpdateInterval(), SetInitialEnergy(), SetInitialSupplyVoltage(), and ns3::TypeId::SetParent().
|
private |
current | the 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 280 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().
|
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 253 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().
|
virtual |
energyJ | Amount of energy (in Joules) to increase from energy source. |
Implements IncreaseRemainingEnergy.
Definition at line 195 of file li-ion-energy-source.cc.
References m_remainingEnergyJ, NS_ASSERT, and NS_LOG_FUNCTION.
void ns3::LiIonEnergySource::SetEnergyUpdateInterval | ( | Time | interval | ) |
interval | Energy update interval. |
This function sets the interval between each energy update.
Definition at line 149 of file li-ion-energy-source.cc.
References m_energyUpdateInterval, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::LiIonEnergySource::SetInitialEnergy | ( | double | initialEnergyJ | ) |
initialEnergyJ | Initial 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 118 of file li-ion-energy-source.cc.
References m_initialEnergyJ, m_remainingEnergyJ, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::LiIonEnergySource::SetInitialSupplyVoltage | ( | double | supplyVoltageV | ) |
supplyVoltageV | Initial 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 135 of file li-ion-energy-source.cc.
References m_eFull, and m_supplyVoltageV.
Referenced by GetTypeId().
|
virtual |
Implements UpdateEnergySource.
Implements ns3::EnergySource.
Definition at line 203 of file li-ion-energy-source.cc.
References CalculateRemainingEnergy(), ns3::EventId::Cancel(), ns3::EnergySource::GetNode(), HandleEnergyDrainedEvent(), ns3::Simulator::IsFinished(), m_energyUpdateEvent, m_energyUpdateInterval, m_lastUpdateTime, m_remainingEnergyJ, ns3::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and ns3::Simulator::Schedule().
Referenced by DoStart(), GetEnergyFraction(), and GetRemainingEnergy().
|
private |
Definition at line 186 of file li-ion-energy-source.h.
Referenced by CalculateRemainingEnergy(), and GetVoltage().
|
private |
Definition at line 193 of file li-ion-energy-source.h.
Referenced by GetTypeId(), and GetVoltage().
|
private |
Definition at line 191 of file li-ion-energy-source.h.
Referenced by GetVoltage(), and SetInitialSupplyVoltage().
|
private |
Definition at line 188 of file li-ion-energy-source.h.
Referenced by UpdateEnergySource().
|
private |
Definition at line 190 of file li-ion-energy-source.h.
Referenced by GetEnergyUpdateInterval(), SetEnergyUpdateInterval(), and UpdateEnergySource().
|
private |
Definition at line 192 of file li-ion-energy-source.h.
Referenced by GetTypeId(), and GetVoltage().
|
private |
Definition at line 184 of file li-ion-energy-source.h.
Referenced by GetEnergyFraction(), GetInitialEnergy(), and SetInitialEnergy().
|
private |
Definition at line 194 of file li-ion-energy-source.h.
Referenced by GetTypeId(), and GetVoltage().
|
private |
Definition at line 189 of file li-ion-energy-source.h.
Referenced by CalculateRemainingEnergy(), and UpdateEnergySource().
|
private |
Definition at line 199 of file li-ion-energy-source.h.
Referenced by DecreaseRemainingEnergy(), and GetTypeId().
|
private |
Definition at line 197 of file li-ion-energy-source.h.
Referenced by GetTypeId(), and GetVoltage().
|
private |
Definition at line 196 of file li-ion-energy-source.h.
Referenced by GetTypeId(), and GetVoltage().
|
private |
Definition at line 195 of file li-ion-energy-source.h.
Referenced by GetTypeId(), and GetVoltage().
|
private |
Definition at line 185 of file li-ion-energy-source.h.
Referenced by CalculateRemainingEnergy(), DecreaseRemainingEnergy(), GetEnergyFraction(), GetRemainingEnergy(), GetTypeId(), HandleEnergyDrainedEvent(), IncreaseRemainingEnergy(), SetInitialEnergy(), and UpdateEnergySource().
|
private |
Definition at line 187 of file li-ion-energy-source.h.
Referenced by CalculateRemainingEnergy(), DecreaseRemainingEnergy(), GetSupplyVoltage(), and SetInitialSupplyVoltage().
|
private |
Definition at line 198 of file li-ion-energy-source.h.
Referenced by GetTypeId(), and GetVoltage().