A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
li-ion-energy-source.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Andrea Sacco
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Andrea Sacco <andrea.sacco85@gmail.com>
18 */
19
20#ifndef LI_ION_ENERGY_SOURCE_H
21#define LI_ION_ENERGY_SOURCE_H
22
23#include "energy-source.h"
24
25#include "ns3/deprecated.h"
26#include "ns3/event-id.h"
27#include "ns3/nstime.h"
28#include "ns3/traced-value.h"
29
30namespace ns3
31{
32
33/**
34 * \ingroup energy
35 * \brief Model a generic Lithium Ion Battery basing on [1][2].
36 *
37 * \deprecated The LiIonEnergySource was deprecated in ns-3.40 in favor of GenericBatteryModel, and
38 * will be removed in a future release.
39 *
40 * The model can be fitted to any type of Li-Ion Battery, simply changing the
41 * model parameters.
42 * The default values are fitted for the Panasonic CGR18650DA Li-Ion Battery [3].
43 *
44 * The energy is drained as defined from the EnergySource interface but, this class
45 * consider the non-linear behaviour of Li-Ion cell. Each time energy is drained from
46 * the cell, the class evaluates the discharge curve to get the actual cell's voltage,
47 * accordingly to State of Charge (SOC) and current's drain.
48 *
49 * If the actual voltage of the cell goes below the minimum threshold voltage, the
50 * cell is considered depleted and the energy drained event fired up.
51 *
52 *
53 * The model requires several parameters to approximates the discharge curves:
54 * - InitialCellVoltage, maximum voltage of the fully charged cell
55 * - NominalCellVoltage, nominal cell's voltage, is used to determine the end of the
56 * nominal zone.
57 * - ExpCellVoltage, cell's voltage at the end of the exponential zone
58 * - RatedCapacity, rated capacity of the cell, in Ah
59 * - NomCapacity, cell's capacity at the end of the nominal zone, in Ah
60 * - ExpCapacity, cell's capacity at the end of the exponential zone, in Ah
61 * - InternalResistance, internal resistance of the cell, in Ohms
62 * - TypCurrent, typical discharge current value, used during the fitting process, in Ah
63 * - ThresholdVoltage, minimum threshold voltage below which the cell is considered
64 * depleted
65 *
66 * For a complete reference of the energy source model and model's fitting please refer
67 * to <a href="http://www.nsnam.org/wiki/GSOC2010UANFramework">UAN Framework</a>
68 * page and <a href="http://www.nsnam.org/wiki/Li-Ion_model_fitting">Li-Ion model
69 * fitting</a> page.
70 *
71 * References:
72 * [1] C. M. Shepherd, "Design of Primary and Secondary Cells - Part 3. Battery discharge equation,"
73 * U.S. Naval Research Laboratory, 1963 [2] Tremblay, O.; Dessaint, L.-A.; Dekkiche, A.-I., "A
74 * Generic Battery Model for the Dynamic Simulation of Hybrid Electric Vehicles," Ecole de
75 * Technologie Superieure, Universite du Quebec, 2007 [3]
76 * http://www.panasonic.com/industrial/includes/pdf/Panasonic_LiIon_CGR18650DA.pdf
77 *
78 */
80{
81 public:
82 /**
83 * \brief Get the type ID.
84 * \return The object TypeId.
85 */
86 static TypeId GetTypeId();
88 ~LiIonEnergySource() override;
89
90 /**
91 * \return Initial energy stored in energy source, in Joules.
92 *
93 * Implements GetInitialEnergy.
94 */
95 double GetInitialEnergy() const override;
96
97 /**
98 * \param initialEnergyJ Initial energy, in Joules
99 *
100 * Implements SetInitialEnergy. Note that initial energy is assumed to be set
101 * before simulation starts and is set only once per simulation.
102 */
103 void SetInitialEnergy(double initialEnergyJ);
104
105 /**
106 * \returns Supply voltage at the energy source.
107 *
108 * Implements GetSupplyVoltage.
109 */
110 double GetSupplyVoltage() const override;
111
112 /**
113 * \param supplyVoltageV Initial Supply voltage at the energy source, in Volts.
114 *
115 * Sets the initial supply voltage of the energy source.
116 * To be called only once.
117 */
118 void SetInitialSupplyVoltage(double supplyVoltageV);
119
120 /**
121 * \return Remaining energy in energy source, in Joules
122 *
123 * Implements GetRemainingEnergy.
124 */
125 double GetRemainingEnergy() override;
126
127 /**
128 * \returns Energy fraction.
129 *
130 * Implements GetEnergyFraction.
131 */
132 double GetEnergyFraction() override;
133
134 /**
135 * \param energyJ Amount of energy (in Joules) to decrease from energy source.
136 *
137 * Implements DecreaseRemainingEnergy.
138 */
139 NS_DEPRECATED_3_40("Use GenericBatteryModel instead")
140 virtual void DecreaseRemainingEnergy(double energyJ);
141
142 /**
143 * \param energyJ Amount of energy (in Joules) to increase from energy source.
144 *
145 * Implements IncreaseRemainingEnergy.
146 */
147 NS_DEPRECATED_3_40("Use GenericBatteryModel instead")
148 virtual void IncreaseRemainingEnergy(double energyJ);
149
150 /**
151 * Implements UpdateEnergySource.
152 */
153 void UpdateEnergySource() override;
154
155 /**
156 * \param interval Energy update interval.
157 *
158 * This function sets the interval between each energy update.
159 */
160 void SetEnergyUpdateInterval(Time interval);
161
162 /**
163 * \returns The interval between each energy update.
164 */
166
167 private:
168 void DoInitialize() override;
169 void DoDispose() override;
170
171 /**
172 * Handles the remaining energy going to zero event. This function notifies
173 * all the energy models aggregated to the node about the energy being
174 * depleted. Each energy model is then responsible for its own handler.
175 */
177
178 /**
179 * Calculates remaining energy. This function uses the total current from all
180 * device models to calculate the amount of energy to decrease. The energy to
181 * decrease is given by:
182 * energy to decrease = total current * supply voltage * time duration
183 * This function subtracts the calculated energy to decrease from remaining
184 * energy.
185 */
187
188 /**
189 * Get the cell voltage in function of the discharge current.
190 * It consider different discharge curves for different discharge currents
191 * and the remaining energy of the cell.
192 *
193 * \param current the actual discharge current value.
194 * \return the cell voltage
195 */
196 double GetVoltage(double current) const;
197
198 private:
199 double m_initialEnergyJ; //!< initial energy, in Joules
200 TracedValue<double> m_remainingEnergyJ; //!< remaining energy, in Joules
201 double m_drainedCapacity; //!< capacity drained from the cell, in Ah
202 double m_supplyVoltageV; //!< actual voltage of the cell
203 double m_lowBatteryTh; //!< low battery threshold, as a fraction of the initial energy
204 EventId m_energyUpdateEvent; //!< energy update event
205 Time m_lastUpdateTime; //!< last update time
206 Time m_energyUpdateInterval; //!< energy update interval
207 double m_eFull; //!< initial voltage of the cell, in Volts
208 double m_eNom; //!< nominal voltage of the cell, in Volts
209 double m_eExp; //!< cell voltage at the end of the exponential zone, in Volts
210 double m_internalResistance; //!< internal resistance of the cell, in Ohms
211 double m_qRated; //!< rated capacity of the cell, in Ah
212 double m_qNom; //!< cell capacity at the end of the nominal zone, in Ah
213 double m_qExp; //!< capacity value at the end of the exponential zone, in Ah
214 double m_typCurrent; //!< typical discharge current used to fit the curves
215 double m_minVoltTh; //!< minimum threshold voltage to consider the battery depleted
216};
217
218} // namespace ns3
219
220#endif /* LI_ION_ENERGY_SOURCE_H */
Introspection did not find any typical Config paths.
Definition: energy-source.h:87
An identifier for simulation events.
Definition: event-id.h:55
Model a generic Lithium Ion Battery basing on [1][2].
void DoDispose() override
All child's implementation must call BreakDeviceEnergyModelRefCycle to ensure reference cycles to Dev...
void UpdateEnergySource() override
Implements UpdateEnergySource.
double m_drainedCapacity
capacity drained from the cell, in Ah
void SetInitialEnergy(double initialEnergyJ)
double m_minVoltTh
minimum threshold voltage to consider the battery depleted
virtual void IncreaseRemainingEnergy(double energyJ)
void DoInitialize() override
Initialize() implementation.
double m_supplyVoltageV
actual voltage of the cell
TracedValue< double > m_remainingEnergyJ
remaining energy, in Joules
double m_initialEnergyJ
initial energy, in Joules
double GetRemainingEnergy() override
double m_eFull
initial voltage of the cell, in Volts
void SetEnergyUpdateInterval(Time interval)
double m_internalResistance
internal resistance of the cell, in Ohms
Time m_energyUpdateInterval
energy update interval
void SetInitialSupplyVoltage(double supplyVoltageV)
double m_eNom
nominal voltage of the cell, in Volts
double m_lowBatteryTh
low battery threshold, as a fraction of the initial energy
double m_eExp
cell voltage at the end of the exponential zone, in Volts
EventId m_energyUpdateEvent
energy update event
double GetEnergyFraction() override
void CalculateRemainingEnergy()
Calculates remaining energy.
double GetInitialEnergy() const override
static TypeId GetTypeId()
Get the type ID.
double m_qNom
cell capacity at the end of the nominal zone, in Ah
double m_qExp
capacity value at the end of the exponential zone, in Ah
double GetVoltage(double current) const
Get the cell voltage in function of the discharge current.
double m_qRated
rated capacity of the cell, in Ah
double GetSupplyVoltage() const override
virtual void DecreaseRemainingEnergy(double energyJ)
double m_typCurrent
typical discharge current used to fit the curves
void HandleEnergyDrainedEvent()
Handles the remaining energy going to zero event.
Time m_lastUpdateTime
last update time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Trace classes with value semantics.
Definition: traced-value.h:116
a unique identifier for an interface.
Definition: type-id.h:59
#define NS_DEPRECATED_3_40(msg)
Tag for things deprecated in version ns-3.40.
Definition: deprecated.h:116
Every class exported by the ns3 library is enclosed in the ns3 namespace.