23 #include "ns3/assert.h"
24 #include "ns3/double.h"
25 #include "ns3/trace-source-accessor.h"
26 #include "ns3/simulator.h"
40 .SetGroupName (
"Energy")
42 .AddAttribute (
"RvBatteryModelPeriodicEnergyUpdateInterval",
43 "RV battery model sampling interval.",
48 .AddAttribute (
"RvBatteryModelLowBatteryThreshold",
49 "Low battery threshold.",
52 MakeDoubleChecker<double> ())
53 .AddAttribute (
"RvBatteryModelOpenCircuitVoltage",
54 "RV battery model open circuit voltage.",
58 MakeDoubleChecker<double> ())
59 .AddAttribute (
"RvBatteryModelCutoffVoltage",
60 "RV battery model cutoff voltage.",
64 MakeDoubleChecker<double> ())
65 .AddAttribute (
"RvBatteryModelAlphaValue",
66 "RV battery model alpha value.",
70 MakeDoubleChecker<double> ())
71 .AddAttribute (
"RvBatteryModelBetaValue",
72 "RV battery model beta value.",
76 MakeDoubleChecker<double> ())
77 .AddAttribute (
"RvBatteryModelNumOfTerms",
78 "The number of terms of the infinite sum for estimating battery level.",
82 MakeIntegerChecker<int> ())
83 .AddTraceSource (
"RvBatteryModelBatteryLevel",
84 "RV battery model battery level.",
86 "ns3::TracedValueCallback::Double")
87 .AddTraceSource (
"RvBatteryModelBatteryLifetime",
88 "RV battery model battery lifetime.",
90 "ns3::TracedValueCallback::Time")
158 NS_LOG_DEBUG (
"RvBatteryModel:Updating remaining energy!");
165 NS_LOG_DEBUG (
"RvBatteryModel:Calculated alpha = " << calculatedAlpha <<
179 NS_LOG_DEBUG (
"RvBatteryModel:Battery level below threshold!");
301 NS_LOG_DEBUG (
"RvBatteryModel:Starting battery level update!");
345 double calculatedAlpha = 0.0;
363 return calculatedAlpha;
372 double firstDelta = (t - sk).GetMinutes ();
373 double secondDelta = (t - sk_1).GetMinutes ();
374 double delta = (sk - sk_1).GetMinutes ();
379 double square = beta * beta * m * m;
380 sum += (std::exp (-square * (firstDelta)) - std::exp (-square * (secondDelta))) / square;
382 return delta + 2 * sum;
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Introspection did not find any typical Config paths.
void BreakDeviceEnergyModelRefCycle(void)
This function is called to break reference cycle between EnergySource and DeviceEnergyModel.
double CalculateTotalCurrent(void)
void NotifyEnergyDrained(void)
This function notifies all DeviceEnergyModel of energy depletion event.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Hold a signed integer type.
Rakhmatov Vrudhula non-linear battery model.
double m_lowBatteryTh
low battery threshold, as a fraction of the initial energy
int GetNumOfTerms(void) const
double m_openCircuitVoltage
Open circuit voltage (in Volts)
virtual double GetSupplyVoltage(void) const
void SetNumOfTerms(int num)
Sets the number of terms of the infinite sum for estimating battery level.
virtual void DoInitialize(void)
Defined in ns3::Object.
double m_cutoffVoltage
Cutoff voltage (in Volts)
virtual double GetEnergyFraction(void)
Time GetSamplingInterval(void) const
EventId m_currentSampleEvent
Current sample event.
static TypeId GetTypeId(void)
Get the type ID.
double GetAlpha(void) const
void SetSamplingInterval(Time interval)
Time m_lastSampleTime
Last sample time.
virtual double GetInitialEnergy(void) const
double m_previousLoad
load value (total current) of previous sampling
std::vector< Time > m_timeStamps
time stamps of load profile
int m_numOfTerms
Number# of terms for infinite sum in battery level estimation.
double GetCutoffVoltage(void) const
double Discharge(double load, Time t)
Discharges the battery.
void SetCutoffVoltage(double voltage)
Sets cutoff voltage of battery.
virtual double GetRemainingEnergy(void)
void SetBeta(double beta)
Sets the beta value for the battery model.
Time GetLifetime(void) const
virtual void DoDispose(void)
Defined in ns3::Object.
std::vector< double > m_load
load profile
TracedValue< Time > m_lifetime
time of death of the battery
Time m_samplingInterval
Sampling interval.
void SetOpenCircuitVoltage(double voltage)
Sets open circuit voltage of battery.
double RvModelAFunction(Time t, Time sk, Time sk_1, double beta)
RV model A function.
void SetAlpha(double alpha)
Sets the alpha value for the battery model.
double GetOpenCircuitVoltage(void) const
virtual void UpdateEnergySource(void)
Implements UpdateEnergySource.
void HandleEnergyDrainedEvent(void)
Handles the remaining energy going to zero event.
virtual ~RvBatteryModel()
double GetBeta(void) const
double m_alpha
alpha value of RV model, in Coulomb
double GetBatteryLevel(void)
TracedValue< double > m_batteryLevel
Battery level is defined as: output of Discharge function / alpha value.
double m_beta
beta value of RV model, in second^-1
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static bool IsFinished(void)
Check if the simulation should finish.
static Time Now(void)
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
float alpha
Plot alpha value (transparency)