A Discrete-Event Network Simulator
API
li-ion-energy-source.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 Andrea Sacco
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Andrea Sacco <andrea.sacco85@gmail.com>
19  */
20 
21 #ifndef LI_ION_ENERGY_SOURCE_H
22 #define LI_ION_ENERGY_SOURCE_H
23 
24 #include "ns3/traced-value.h"
25 #include "ns3/energy-source.h"
26 #include "ns3/nstime.h"
27 #include "ns3/event-id.h"
28 
29 namespace ns3 {
30 
73 {
74 public:
75  static TypeId GetTypeId (void);
77  virtual ~LiIonEnergySource ();
78 
84  virtual double GetInitialEnergy (void) const;
85 
92  void SetInitialEnergy (double initialEnergyJ);
93 
99  virtual double GetSupplyVoltage (void) const;
100 
107  void SetInitialSupplyVoltage (double supplyVoltageV);
108 
114  virtual double GetRemainingEnergy (void);
115 
121  virtual double GetEnergyFraction (void);
122 
128  virtual void DecreaseRemainingEnergy (double energyJ);
129 
135  virtual void IncreaseRemainingEnergy (double energyJ);
136 
140  virtual void UpdateEnergySource (void);
141 
147  void SetEnergyUpdateInterval (Time interval);
148 
152  Time GetEnergyUpdateInterval (void) const;
153 private:
154  void DoInitialize (void);
155  void DoDispose (void);
156 
162  void HandleEnergyDrainedEvent (void);
163 
172  void CalculateRemainingEnergy (void);
173 
181  double GetVoltage (double current) const;
182 
183 private:
184  double m_initialEnergyJ; // initial energy, in Joules
185  TracedValue<double> m_remainingEnergyJ; // remaining energy, in Joules
186  double m_drainedCapacity; // capacity drained from the cell, in Ah
187  double m_supplyVoltageV; // actual voltage of the cell
188  double m_lowBatteryTh; // low battery threshold, as a fraction of the initial energy
189  EventId m_energyUpdateEvent; // energy update event
190  Time m_lastUpdateTime; // last update time
191  Time m_energyUpdateInterval; // energy update interval
192  double m_eFull; // initial voltage of the cell, in Volts
193  double m_eNom; // nominal voltage of the cell, in Volts
194  double m_eExp; // cell voltage at the end of the exponential zone, in Volts
195  double m_internalResistance; // internal resistance of the cell, in Ohms
196  double m_qRated; // rated capacity of the cell, in Ah
197  double m_qNom; // cell capacity at the end of the nominal zone, in Ah
198  double m_qExp; // capacity value at the end of the exponential zone, in Ah
199  double m_typCurrent; // typical discharge current used to fit the curves
200  double m_minVoltTh; // minimum threshold voltage to consider the battery depleted
201 };
202 
203 } // namespace ns3
204 
205 #endif /* LI_ION_ENERGY_SOURCE_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::LiIonEnergySource::SetEnergyUpdateInterval
void SetEnergyUpdateInterval(Time interval)
Definition: li-ion-energy-source.cc:159
ns3::LiIonEnergySource::m_qRated
double m_qRated
Definition: li-ion-energy-source.h:196
ns3::LiIonEnergySource::m_drainedCapacity
double m_drainedCapacity
Definition: li-ion-energy-source.h:186
ns3::EventId
An identifier for simulation events.
Definition: event-id.h:54
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::LiIonEnergySource::m_qNom
double m_qNom
Definition: li-ion-energy-source.h:197
ns3::LiIonEnergySource::m_remainingEnergyJ
TracedValue< double > m_remainingEnergyJ
Definition: li-ion-energy-source.h:185
ns3::LiIonEnergySource::GetVoltage
double GetVoltage(double current) const
Definition: li-ion-energy-source.cc:296
ns3::LiIonEnergySource::DoDispose
void DoDispose(void)
All child's implementation must call BreakDeviceEnergyModelRefCycle to ensure reference cycles to Dev...
Definition: li-ion-energy-source.cc:253
ns3::LiIonEnergySource::m_lastUpdateTime
Time m_lastUpdateTime
Definition: li-ion-energy-source.h:190
ns3::LiIonEnergySource::m_energyUpdateInterval
Time m_energyUpdateInterval
Definition: li-ion-energy-source.h:191
ns3::LiIonEnergySource::m_qExp
double m_qExp
Definition: li-ion-energy-source.h:198
ns3::LiIonEnergySource::m_initialEnergyJ
double m_initialEnergyJ
Definition: li-ion-energy-source.h:184
ns3::LiIonEnergySource::LiIonEnergySource
LiIonEnergySource()
Definition: li-ion-energy-source.cc:114
ns3::LiIonEnergySource::GetTypeId
static TypeId GetTypeId(void)
Definition: li-ion-energy-source.cc:37
ns3::LiIonEnergySource::DecreaseRemainingEnergy
virtual void DecreaseRemainingEnergy(double energyJ)
Definition: li-ion-energy-source.cc:191
ns3::LiIonEnergySource::m_typCurrent
double m_typCurrent
Definition: li-ion-energy-source.h:199
ns3::LiIonEnergySource::m_internalResistance
double m_internalResistance
Definition: li-ion-energy-source.h:195
ns3::LiIonEnergySource::m_supplyVoltageV
double m_supplyVoltageV
Definition: li-ion-energy-source.h:187
ns3::LiIonEnergySource::SetInitialSupplyVoltage
void SetInitialSupplyVoltage(double supplyVoltageV)
Definition: li-ion-energy-source.cc:144
ns3::EnergySource
Introspection did not find any typical Config paths.
Definition: energy-source.h:82
ns3::LiIonEnergySource::CalculateRemainingEnergy
void CalculateRemainingEnergy(void)
Calculates remaining energy.
Definition: li-ion-energy-source.cc:271
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::LiIonEnergySource::HandleEnergyDrainedEvent
void HandleEnergyDrainedEvent(void)
Handles the remaining energy going to zero event.
Definition: li-ion-energy-source.cc:261
ns3::LiIonEnergySource::IncreaseRemainingEnergy
virtual void IncreaseRemainingEnergy(double energyJ)
Definition: li-ion-energy-source.cc:205
ns3::LiIonEnergySource::m_eFull
double m_eFull
Definition: li-ion-energy-source.h:192
ns3::LiIonEnergySource::m_minVoltTh
double m_minVoltTh
Definition: li-ion-energy-source.h:200
ns3::LiIonEnergySource::m_energyUpdateEvent
EventId m_energyUpdateEvent
Definition: li-ion-energy-source.h:189
ns3::LiIonEnergySource
Model a generic Lithium Ion Battery basing on [1][2].
Definition: li-ion-energy-source.h:73
ns3::LiIonEnergySource::m_eNom
double m_eNom
Definition: li-ion-energy-source.h:193
ns3::LiIonEnergySource::GetEnergyFraction
virtual double GetEnergyFraction(void)
Definition: li-ion-energy-source.cc:182
ns3::TracedValue< double >
ns3::LiIonEnergySource::GetInitialEnergy
virtual double GetInitialEnergy(void) const
Definition: li-ion-energy-source.cc:137
ns3::LiIonEnergySource::~LiIonEnergySource
virtual ~LiIonEnergySource()
Definition: li-ion-energy-source.cc:121
ns3::LiIonEnergySource::GetSupplyVoltage
virtual double GetSupplyVoltage(void) const
Definition: li-ion-energy-source.cc:152
ns3::LiIonEnergySource::GetEnergyUpdateInterval
Time GetEnergyUpdateInterval(void) const
Definition: li-ion-energy-source.cc:166
ns3::LiIonEnergySource::DoInitialize
void DoInitialize(void)
Initialize() implementation.
Definition: li-ion-energy-source.cc:246
ns3::LiIonEnergySource::m_lowBatteryTh
double m_lowBatteryTh
Definition: li-ion-energy-source.h:188
ns3::LiIonEnergySource::UpdateEnergySource
virtual void UpdateEnergySource(void)
Implements UpdateEnergySource.
Definition: li-ion-energy-source.cc:213
ns3::LiIonEnergySource::GetRemainingEnergy
virtual double GetRemainingEnergy(void)
Definition: li-ion-energy-source.cc:173
ns3::LiIonEnergySource::m_eExp
double m_eExp
Definition: li-ion-energy-source.h:194
ns3::LiIonEnergySource::SetInitialEnergy
void SetInitialEnergy(double initialEnergyJ)
Definition: li-ion-energy-source.cc:127