From 09910c9c76693126f357fae3feb91d1ff57ad7ad Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Wed, 12 Mar 2025 13:51:53 +0000 Subject: [PATCH] Remove code deprecated in ns-3.40 --- doc/doxygen.conf | 3 +- src/core/model/deprecated.h | 7 - src/energy/CMakeLists.txt | 3 - src/energy/examples/CMakeLists.txt | 7 - .../examples/li-ion-energy-source-example.cc | 106 ------ src/energy/model/li-ion-energy-source.cc | 312 ------------------ src/energy/model/li-ion-energy-source.h | 215 ------------ src/energy/test/examples-to-run.py | 1 - src/energy/test/li-ion-energy-source-test.cc | 106 ------ 9 files changed, 1 insertion(+), 759 deletions(-) delete mode 100644 src/energy/examples/li-ion-energy-source-example.cc delete mode 100644 src/energy/model/li-ion-energy-source.cc delete mode 100644 src/energy/model/li-ion-energy-source.h delete mode 100644 src/energy/test/li-ion-energy-source-test.cc diff --git a/doc/doxygen.conf b/doc/doxygen.conf index da0c95e0a..721a89980 100644 --- a/doc/doxygen.conf +++ b/doc/doxygen.conf @@ -2304,8 +2304,7 @@ EXPAND_AS_DEFINED = ATTRIBUTE_ACCESSOR_DEFINE \ NS_DEPRECATED_3_44 \ NS_DEPRECATED_3_43 \ NS_DEPRECATED_3_42 \ - NS_DEPRECATED_3_41 \ - NS_DEPRECATED_3_40 + NS_DEPRECATED_3_41 # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will # remove all references to function-like macros that are alone on a line, have diff --git a/src/core/model/deprecated.h b/src/core/model/deprecated.h index 0f66ab4d9..892008559 100644 --- a/src/core/model/deprecated.h +++ b/src/core/model/deprecated.h @@ -125,11 +125,4 @@ */ #define NS_DEPRECATED_3_41(msg) NS_DEPRECATED("Deprecated in ns-3.41: " msg) -/** - * @ingroup deprecation - * @def NS_DEPRECATED_3_40 - * Tag for things deprecated in version ns-3.40. - */ -#define NS_DEPRECATED_3_40(msg) NS_DEPRECATED("Deprecated in ns-3.40: " msg) - #endif /* NS3_DEPRECATED_H */ diff --git a/src/energy/CMakeLists.txt b/src/energy/CMakeLists.txt index d922393e4..b79dd0e56 100644 --- a/src/energy/CMakeLists.txt +++ b/src/energy/CMakeLists.txt @@ -17,7 +17,6 @@ build_lib( model/energy-harvester.cc model/energy-source.cc model/generic-battery-model.cc - model/li-ion-energy-source.cc model/rv-battery-model.cc model/simple-device-energy-model.cc HEADER_FILES @@ -37,10 +36,8 @@ build_lib( model/energy-harvester.h model/energy-source.h model/generic-battery-model.h - model/li-ion-energy-source.h model/rv-battery-model.h model/simple-device-energy-model.h LIBRARIES_TO_LINK ${libnetwork} TEST_SOURCES test/basic-energy-harvester-test.cc - test/li-ion-energy-source-test.cc ) diff --git a/src/energy/examples/CMakeLists.txt b/src/energy/examples/CMakeLists.txt index da1bc0963..eb974c112 100644 --- a/src/energy/examples/CMakeLists.txt +++ b/src/energy/examples/CMakeLists.txt @@ -17,13 +17,6 @@ build_lib_example( ${libwifi} ) -build_lib_example( - NAME li-ion-energy-source-example - SOURCE_FILES li-ion-energy-source-example.cc - LIBRARIES_TO_LINK ${libcore} - ${libenergy} -) - build_lib_example( NAME rv-battery-model-test SOURCE_FILES rv-battery-model-test.cc diff --git a/src/energy/examples/li-ion-energy-source-example.cc b/src/energy/examples/li-ion-energy-source-example.cc deleted file mode 100644 index e02d4fdad..000000000 --- a/src/energy/examples/li-ion-energy-source-example.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2010 Andrea Sacco - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Andrea Sacco - */ - -#include "ns3/command-line.h" -#include "ns3/energy-source-container.h" -#include "ns3/li-ion-energy-source.h" -#include "ns3/log.h" -#include "ns3/simple-device-energy-model.h" -#include "ns3/simulator.h" - -using namespace ns3; -using namespace ns3::energy; - -/** - * In this simple example, we show how to create and drain energy from a - * LiIonEnergySource. - * We make a series of discharge calls to the energy source class with - * different current drain and duration until all the energy is depleted - * from the cell. - * - * Every 20 seconds it is printed out the actual cell voltage to verify - * that it follows the discharge curve of the datasheet [1]. - * - * At the end of the example it is verified that after the energy depletion - * call, the cell voltage is below the threshold voltage. - * - * References: - * [1] Panasonic CGR18650DA Datasheet, - * http://www.panasonic.com/industrial/includes/pdf/Panasonic_LiIon_CGR18650DA.pdf - */ - -// NS_DEPRECATED_3_43() - tag for future removal -// LiIonEnergySource was deprecated in commit -// https://gitlab.com/nsnam/ns-3-dev/-/commit/086913b0 -// -// The new battery model is illustrated in -// `src/energy/examples/generic-battery-discharge-example.cc` - -NS_WARNING_PUSH_DEPRECATED; - -static void -PrintCellInfo(Ptr es) -{ - NS_WARNING_POP; - std::cout << "At " << Simulator::Now().As(Time::S) - << " Cell voltage: " << es->GetSupplyVoltage() - << " V Remaining Capacity: " << es->GetRemainingEnergy() / (3.6 * 3600) << " Ah" - << std::endl; - - if (!Simulator::IsFinished()) - { - Simulator::Schedule(Seconds(20), &PrintCellInfo, es); - } -} - -int -main(int argc, char** argv) -{ - CommandLine cmd(__FILE__); - cmd.Parse(argc, argv); - - // uncomment below to see the energy consumption details - // LogComponentEnable ("LiIonEnergySource", LOG_LEVEL_DEBUG); - - Ptr node = CreateObject(); - - Ptr sem = CreateObject(); - Ptr esCont = CreateObject(); - NS_WARNING_PUSH_DEPRECATED; - Ptr es = CreateObject(); - NS_WARNING_POP; - esCont->Add(es); - es->SetNode(node); - sem->SetEnergySource(es); - es->AppendDeviceEnergyModel(sem); - sem->SetNode(node); - node->AggregateObject(esCont); - - Time now = Simulator::Now(); - - // discharge at 2.33 A for 1700 seconds - sem->SetCurrentA(2.33); - now += Seconds(1701); - - // discharge at 4.66 A for 628 seconds - Simulator::Schedule(now, &SimpleDeviceEnergyModel::SetCurrentA, sem, 4.66); - now += Seconds(600); - - PrintCellInfo(es); - - Simulator::Stop(now); - Simulator::Run(); - Simulator::Destroy(); - - // the cell voltage should be under 3.3v - DoubleValue v; - es->GetAttribute("ThresholdVoltage", v); - NS_ASSERT(es->GetSupplyVoltage() <= v.Get()); - - return 0; -} diff --git a/src/energy/model/li-ion-energy-source.cc b/src/energy/model/li-ion-energy-source.cc deleted file mode 100644 index e68833671..000000000 --- a/src/energy/model/li-ion-energy-source.cc +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright (c) 2010 Andrea Sacco - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Andrea Sacco - */ - -#include "li-ion-energy-source.h" - -#include "ns3/assert.h" -#include "ns3/double.h" -#include "ns3/log.h" -#include "ns3/simulator.h" -#include "ns3/trace-source-accessor.h" - -#include - -namespace ns3 -{ -namespace energy -{ - -NS_LOG_COMPONENT_DEFINE("LiIonEnergySource"); -NS_OBJECT_ENSURE_REGISTERED(LiIonEnergySource); - -TypeId -LiIonEnergySource::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::energy::LiIonEnergySource") - .AddDeprecatedName("ns3::LiIonEnergySource") - .SetParent() - .SetGroupName("Energy") - .AddConstructor() - .AddAttribute("LiIonEnergySourceInitialEnergyJ", - "Initial energy stored in basic energy source.", - DoubleValue(31752.0), // in Joules - MakeDoubleAccessor(&LiIonEnergySource::SetInitialEnergy, - &LiIonEnergySource::GetInitialEnergy), - MakeDoubleChecker()) - .AddAttribute("LiIonEnergyLowBatteryThreshold", - "Low battery threshold for LiIon energy source.", - DoubleValue(0.10), // as a fraction of the initial energy - MakeDoubleAccessor(&LiIonEnergySource::m_lowBatteryTh), - MakeDoubleChecker()) - .AddAttribute("InitialCellVoltage", - "Initial (maximum) voltage of the cell (fully charged).", - DoubleValue(4.05), // in Volts - MakeDoubleAccessor(&LiIonEnergySource::SetInitialSupplyVoltage, - &LiIonEnergySource::GetSupplyVoltage), - MakeDoubleChecker()) - .AddAttribute("NominalCellVoltage", - "Nominal voltage of the cell.", - DoubleValue(3.6), // in Volts - MakeDoubleAccessor(&LiIonEnergySource::m_eNom), - MakeDoubleChecker()) - .AddAttribute("ExpCellVoltage", - "Cell voltage at the end of the exponential zone.", - DoubleValue(3.6), // in Volts - MakeDoubleAccessor(&LiIonEnergySource::m_eExp), - MakeDoubleChecker()) - .AddAttribute("RatedCapacity", - "Rated capacity of the cell.", - DoubleValue(2.45), // in Ah - MakeDoubleAccessor(&LiIonEnergySource::m_qRated), - MakeDoubleChecker()) - .AddAttribute("NomCapacity", - "Cell capacity at the end of the nominal zone.", - DoubleValue(1.1), // in Ah - MakeDoubleAccessor(&LiIonEnergySource::m_qNom), - MakeDoubleChecker()) - .AddAttribute("ExpCapacity", - "Cell Capacity at the end of the exponential zone.", - DoubleValue(1.2), // in Ah - MakeDoubleAccessor(&LiIonEnergySource::m_qExp), - MakeDoubleChecker()) - .AddAttribute("InternalResistance", - "Internal resistance of the cell", - DoubleValue(0.083), // in Ohms - MakeDoubleAccessor(&LiIonEnergySource::m_internalResistance), - MakeDoubleChecker()) - .AddAttribute("TypCurrent", - "Typical discharge current used to fit the curves", - DoubleValue(2.33), // in A - MakeDoubleAccessor(&LiIonEnergySource::m_typCurrent), - MakeDoubleChecker()) - .AddAttribute("ThresholdVoltage", - "Minimum threshold voltage to consider the battery depleted.", - DoubleValue(3.3), // in Volts - MakeDoubleAccessor(&LiIonEnergySource::m_minVoltTh), - MakeDoubleChecker()) - .AddAttribute("PeriodicEnergyUpdateInterval", - "Time between two consecutive periodic energy updates.", - TimeValue(Seconds(1)), - MakeTimeAccessor(&LiIonEnergySource::SetEnergyUpdateInterval, - &LiIonEnergySource::GetEnergyUpdateInterval), - MakeTimeChecker()) - .AddTraceSource("RemainingEnergy", - "Remaining energy at BasicEnergySource.", - MakeTraceSourceAccessor(&LiIonEnergySource::m_remainingEnergyJ), - "ns3::TracedValueCallback::Double"); - return tid; -} - -LiIonEnergySource::LiIonEnergySource() - : m_drainedCapacity(0.0), - m_lastUpdateTime() -{ - NS_LOG_FUNCTION(this); -} - -LiIonEnergySource::~LiIonEnergySource() -{ - NS_LOG_FUNCTION(this); -} - -void -LiIonEnergySource::SetInitialEnergy(double initialEnergyJ) -{ - NS_LOG_FUNCTION(this << initialEnergyJ); - NS_ASSERT(initialEnergyJ >= 0); - m_initialEnergyJ = initialEnergyJ; - // set remaining energy to be initial energy - m_remainingEnergyJ = m_initialEnergyJ; -} - -double -LiIonEnergySource::GetInitialEnergy() const -{ - NS_LOG_FUNCTION(this); - return m_initialEnergyJ; -} - -void -LiIonEnergySource::SetInitialSupplyVoltage(double supplyVoltageV) -{ - NS_LOG_FUNCTION(this << supplyVoltageV); - m_eFull = supplyVoltageV; - m_supplyVoltageV = supplyVoltageV; -} - -double -LiIonEnergySource::GetSupplyVoltage() const -{ - NS_LOG_FUNCTION(this); - return m_supplyVoltageV; -} - -void -LiIonEnergySource::SetEnergyUpdateInterval(Time interval) -{ - NS_LOG_FUNCTION(this << interval); - m_energyUpdateInterval = interval; -} - -Time -LiIonEnergySource::GetEnergyUpdateInterval() const -{ - NS_LOG_FUNCTION(this); - return m_energyUpdateInterval; -} - -double -LiIonEnergySource::GetRemainingEnergy() -{ - NS_LOG_FUNCTION(this); - // update energy source to get the latest remaining energy. - UpdateEnergySource(); - return m_remainingEnergyJ; -} - -double -LiIonEnergySource::GetEnergyFraction() -{ - NS_LOG_FUNCTION(this); - // update energy source to get the latest remaining energy. - UpdateEnergySource(); - return m_remainingEnergyJ / m_initialEnergyJ; -} - -void -LiIonEnergySource::DecreaseRemainingEnergy(double energyJ) -{ - NS_LOG_FUNCTION(this << energyJ); - NS_ASSERT(energyJ >= 0); - m_remainingEnergyJ -= energyJ; - - // check if remaining energy is 0 - if (m_supplyVoltageV <= m_minVoltTh) - { - HandleEnergyDrainedEvent(); - } -} - -void -LiIonEnergySource::IncreaseRemainingEnergy(double energyJ) -{ - NS_LOG_FUNCTION(this << energyJ); - NS_ASSERT(energyJ >= 0); - m_remainingEnergyJ += energyJ; -} - -void -LiIonEnergySource::UpdateEnergySource() -{ - NS_LOG_FUNCTION(this); - NS_LOG_DEBUG("LiIonEnergySource:Updating remaining energy at node #" << GetNode()->GetId()); - - // do not update if simulation has finished - if (Simulator::IsFinished()) - { - return; - } - - m_energyUpdateEvent.Cancel(); - - CalculateRemainingEnergy(); - - m_lastUpdateTime = Simulator::Now(); - - if (m_remainingEnergyJ <= m_lowBatteryTh * m_initialEnergyJ) - { - HandleEnergyDrainedEvent(); - return; // stop periodic update - } - - m_energyUpdateEvent = - Simulator::Schedule(m_energyUpdateInterval, &LiIonEnergySource::UpdateEnergySource, this); -} - -/* - * Private functions start here. - */ -void -LiIonEnergySource::DoInitialize() -{ - NS_LOG_FUNCTION(this); - UpdateEnergySource(); // start periodic update -} - -void -LiIonEnergySource::DoDispose() -{ - NS_LOG_FUNCTION(this); - BreakDeviceEnergyModelRefCycle(); // break reference cycle -} - -void -LiIonEnergySource::HandleEnergyDrainedEvent() -{ - NS_LOG_FUNCTION(this); - NS_LOG_DEBUG("LiIonEnergySource:Energy depleted at node #" << GetNode()->GetId()); - NotifyEnergyDrained(); // notify DeviceEnergyModel objects -} - -void -LiIonEnergySource::CalculateRemainingEnergy() -{ - NS_LOG_FUNCTION(this); - double totalCurrentA = CalculateTotalCurrent(); - Time duration = Simulator::Now() - m_lastUpdateTime; - NS_ASSERT(duration.GetSeconds() >= 0); - // energy = current * voltage * time - double energyToDecreaseJ = totalCurrentA * m_supplyVoltageV * duration.GetSeconds(); - - if (m_remainingEnergyJ < energyToDecreaseJ) - { - m_remainingEnergyJ = 0; // energy never goes below 0 - } - else - { - m_remainingEnergyJ -= energyToDecreaseJ; - } - - m_drainedCapacity += (totalCurrentA * duration).GetHours(); - // update the supply voltage - m_supplyVoltageV = GetVoltage(totalCurrentA); - NS_LOG_DEBUG("LiIonEnergySource:Remaining energy = " << m_remainingEnergyJ); -} - -double -LiIonEnergySource::GetVoltage(double i) const -{ - NS_LOG_FUNCTION(this << i); - - // integral of i in dt, drained capacity in Ah - double it = m_drainedCapacity; - - // empirical factors - double A = m_eFull - m_eExp; - double B = 3 / m_qExp; - - // slope of the polarization curve - double K = std::abs((m_eFull - m_eNom + A * (std::exp(-B * m_qNom) - 1)) * (m_qRated - m_qNom) / - m_qNom); - - // constant voltage - double E0 = m_eFull + K + m_internalResistance * m_typCurrent - A; - - double E = E0 - K * m_qRated / (m_qRated - it) + A * std::exp(-B * it); - - // cell voltage - double V = E - m_internalResistance * i; - - NS_LOG_DEBUG("Voltage: " << V << " with E: " << E); - - return V; -} - -} // namespace energy -} // namespace ns3 diff --git a/src/energy/model/li-ion-energy-source.h b/src/energy/model/li-ion-energy-source.h deleted file mode 100644 index eeeab9658..000000000 --- a/src/energy/model/li-ion-energy-source.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) 2010 Andrea Sacco - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Andrea Sacco - */ - -#ifndef LI_ION_ENERGY_SOURCE_H -#define LI_ION_ENERGY_SOURCE_H - -#include "energy-source.h" - -#include "ns3/deprecated.h" -#include "ns3/event-id.h" -#include "ns3/nstime.h" -#include "ns3/traced-value.h" - -namespace ns3 -{ -namespace energy -{ - -/** - * @ingroup energy - * @brief 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: - * - InitialCellVoltage, 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 - - */ -// clang-format off -class -NS_DEPRECATED_3_40("The LiIonEnergySource was deprecated in ns-3.40 " - "in favor of GenericBatteryModel, and will be removed " - "in a future release.") -LiIonEnergySource : public EnergySource -// clang-format on -{ - public: - /** - * @brief Get the type ID. - * @return The object TypeId. - */ - static TypeId GetTypeId(); - LiIonEnergySource(); - ~LiIonEnergySource() override; - - /** - * @return Initial energy stored in energy source, in Joules. - * - * Implements GetInitialEnergy. - */ - double GetInitialEnergy() const override; - - /** - * @param 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. - */ - void SetInitialEnergy(double initialEnergyJ); - - /** - * @returns Supply voltage at the energy source. - * - * Implements GetSupplyVoltage. - */ - double GetSupplyVoltage() const override; - - /** - * @param supplyVoltageV Initial Supply voltage at the energy source, in Volts. - * - * Sets the initial supply voltage of the energy source. - * To be called only once. - */ - void SetInitialSupplyVoltage(double supplyVoltageV); - - /** - * @return Remaining energy in energy source, in Joules - * - * Implements GetRemainingEnergy. - */ - double GetRemainingEnergy() override; - - /** - * @returns Energy fraction. - * - * Implements GetEnergyFraction. - */ - double GetEnergyFraction() override; - - /** - * @param energyJ Amount of energy (in Joules) to decrease from energy source. - * - * Implements DecreaseRemainingEnergy. - */ - NS_DEPRECATED_3_40("Use GenericBatteryModel instead") - virtual void DecreaseRemainingEnergy(double energyJ); - - /** - * @param energyJ Amount of energy (in Joules) to increase from energy source. - * - * Implements IncreaseRemainingEnergy. - */ - NS_DEPRECATED_3_40("Use GenericBatteryModel instead") - virtual void IncreaseRemainingEnergy(double energyJ); - - /** - * Implements UpdateEnergySource. - */ - void UpdateEnergySource() override; - - /** - * @param interval Energy update interval. - * - * This function sets the interval between each energy update. - */ - void SetEnergyUpdateInterval(Time interval); - - /** - * @returns The interval between each energy update. - */ - Time GetEnergyUpdateInterval() const; - - private: - void DoInitialize() override; - void DoDispose() override; - - /** - * 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. - */ - void HandleEnergyDrainedEvent(); - - /** - * 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. - */ - void CalculateRemainingEnergy(); - - /** - * 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. - * - * @param current the actual discharge current value. - * @return the cell voltage - */ - double GetVoltage(double current) const; - - private: - double m_initialEnergyJ; //!< initial energy, in Joules - TracedValue m_remainingEnergyJ; //!< remaining energy, in Joules - double m_drainedCapacity; //!< capacity drained from the cell, in Ah - double m_supplyVoltageV; //!< actual voltage of the cell - double m_lowBatteryTh; //!< low battery threshold, as a fraction of the initial energy - EventId m_energyUpdateEvent; //!< energy update event - Time m_lastUpdateTime; //!< last update time - Time m_energyUpdateInterval; //!< energy update interval - double m_eFull; //!< initial voltage of the cell, in Volts - double m_eNom; //!< nominal voltage of the cell, in Volts - double m_eExp; //!< cell voltage at the end of the exponential zone, in Volts - double m_internalResistance; //!< internal resistance of the cell, in Ohms - double m_qRated; //!< rated capacity of the cell, in Ah - 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 m_typCurrent; //!< typical discharge current used to fit the curves - double m_minVoltTh; //!< minimum threshold voltage to consider the battery depleted -}; - -} // namespace energy -} // namespace ns3 - -#endif /* LI_ION_ENERGY_SOURCE_H */ diff --git a/src/energy/test/examples-to-run.py b/src/energy/test/examples-to-run.py index 12b7f0940..c620918fa 100644 --- a/src/energy/test/examples-to-run.py +++ b/src/energy/test/examples-to-run.py @@ -7,7 +7,6 @@ # # See test.py for more information. cpp_examples = [ - ("li-ion-energy-source", "True", "True"), ("rv-battery-model-test", "True", "True"), ("basic-energy-model-test", "True", "True"), ] diff --git a/src/energy/test/li-ion-energy-source-test.cc b/src/energy/test/li-ion-energy-source-test.cc deleted file mode 100644 index 33ebc0cf3..000000000 --- a/src/energy/test/li-ion-energy-source-test.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2010 Andrea Sacco - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Andrea Sacco - */ - -#include "ns3/li-ion-energy-source.h" -#include "ns3/log.h" -#include "ns3/node.h" -#include "ns3/simple-device-energy-model.h" -#include "ns3/simulator.h" -#include "ns3/test.h" - -using namespace ns3; -using namespace ns3::energy; - -// NS_DEPRECATED_3_43() - tag for future removal -// LiIonEnergySource was deprecated in commit -// https://gitlab.com/nsnam/ns-3-dev/-/commit/086913b0 -// -// The new battery model is illustrated in -// `src/energy/examples/generic-battery-discharge-example.cc` -// -// A GenericBatteryModelTestCase is being developed in MR 2181 -// https://gitlab.com/nsnam/ns-3-dev/-/merge_requests/2181 -// which will be in -// `src/energy/test/generic-battery-model-test.cc` - -NS_LOG_COMPONENT_DEFINE("LiIonEnergySourceTestSuite"); - -/** - * @ingroup energy-tests - * - * @brief LiIon battery Test - */ -class LiIonEnergyTestCase : public TestCase -{ - public: - LiIonEnergyTestCase(); - ~LiIonEnergyTestCase() override; - - void DoRun() override; - - Ptr m_node; //!< Node to aggreagte the source to. -}; - -LiIonEnergyTestCase::LiIonEnergyTestCase() - : TestCase("Li-Ion energy source test case") -{ -} - -LiIonEnergyTestCase::~LiIonEnergyTestCase() -{ - m_node = nullptr; -} - -void -LiIonEnergyTestCase::DoRun() -{ - m_node = CreateObject(); - - Ptr sem = CreateObject(); - - NS_WARNING_PUSH_DEPRECATED; - Ptr es = CreateObject(); - NS_WARNING_POP; - - es->SetNode(m_node); - sem->SetEnergySource(es); - es->AppendDeviceEnergyModel(sem); - m_node->AggregateObject(es); - - Time now = Simulator::Now(); - - // discharge at 2.33 A for 1700 seconds - sem->SetCurrentA(2.33); - now += Seconds(1701); - - Simulator::Stop(now); - Simulator::Run(); - Simulator::Destroy(); - - NS_TEST_ASSERT_MSG_EQ_TOL(es->GetSupplyVoltage(), 3.6, 1.0e-3, "Incorrect consumed energy!"); -} - -/** - * @ingroup energy-tests - * - * @brief LiIon battery TestSuite - */ -class LiIonEnergySourceTestSuite : public TestSuite -{ - public: - LiIonEnergySourceTestSuite(); -}; - -LiIonEnergySourceTestSuite::LiIonEnergySourceTestSuite() - : TestSuite("li-ion-energy-source", Type::UNIT) -{ - AddTestCase(new LiIonEnergyTestCase, TestCase::Duration::QUICK); -} - -/// create an instance of the test suite -static LiIonEnergySourceTestSuite g_liIonEnergySourceTestSuite;