NeTrainSim 0.1.1 beta
The Open-Source Network Trains Simulator
 
Loading...
Searching...
No Matches
Battery Class Reference

#include <battery.h>

Inheritance diagram for Battery:
TrainComponent Car Locomotive

Public Member Functions

void setBattery (double maxCharge, double initialChargePercentage, double depthOfDischarge, double batteryCRate, double maxRechargeSOC=0.9, double minRechargeSOC=0.5)
 Sets the battery properties.
 
double getBatteryMaxCharge () const
 Gets the maximum charge of the battery.
 
void setBatteryMaxCharge (double newMaxCharge)
 Sets the maximum charge of the battery.
 
double getBatteryInitialCharge () const
 Gets the initial charge of the battery.
 
void setBatteryInitialCharge (double newInitialCharge)
 Sets the initial charge of the battery.
 
double getBatteryCurrentCharge () const
 Gets the current charge of the battery.
 
std::pair< bool, double > consumeBattery (double timeStep, double consumedCharge)
 Consumes charge from the battery.
 
double rechargeBatteryForHybrids (double timeStep, double recharge)
 Recharges the battery for hybrid vehicles.
 
double rechargeBatteryByRegeneratedEnergy (double timeStep, double recharge)
 Recharges the battery by regenerated energy.
 
double getBatteryStateOfCharge () const
 Gets the state of charge of the battery.
 
double getBatteryDOD () const
 Gets the depth of discharge of the battery.
 
void setBatteryDOD (double newBatteryDOD)
 Sets the depth of discharge of the battery.
 
double getBatteryCRate () const
 Gets the C-Rate of discharge for the battery.
 
void setBatteryCRate (double newBatteryCRate)
 Sets the C-Rate of discharge for the battery.
 
bool isBatteryDrainable (double requiredCharge)
 Checks if the battery can be drained by the required charge.
 
bool isBatteryRechargable ()
 Checks if the battery can be recharged.
 
double getBatteryMaxDischarge (double timeStep)
 Gets the maximum discharge of the battery.
 
double getBatteryMaxRecharge (double timeStep)
 Gets the maximum recharge of the battery.
 
bool isRechargeRequired () const
 Checks if the battery requires a recharge.
 
double getBatteryRechargeSOCUpperBound () const
 Gets the upper bound of the battery's recharge state of charge.
 
void setBatteryRechargeSOCUpperBound (double newBatteryMaxSOC)
 Sets the upper bound of the battery's recharge state of charge.
 
double getBatteryRechargeSOCLowerBound () const
 Gets the lower bound of the battery's recharge state of charge.
 
void setBatteryRechargeSOCLowerBound (double newBatteryRechargeSOCLowerBound)
 Sets the lower bound of the battery's recharge state of charge.
 
double getBatteryCumEnergyConsumption ()
 Gets the cumulative energy consumption for this battery only.
 
double getBatteryCumEnergyRegenerated ()
 Gets the cumulative energy regenerated for this battery only.
 
double getBatteryCumNetEnergyConsumption ()
 Gets the cumulative net energy consumption for this battery.
 
bool batteryHasCharge ()
 Checks if the battery has enough charge.
 
bool IsBatteryExceedingThresholds ()
 Checks if the battery exceeds certain thresholds.
 

Member Function Documentation

◆ batteryHasCharge()

bool Battery::batteryHasCharge ( )

Checks if the battery has enough charge.

Returns
True if the battery has enough charge, false otherwise.

◆ consumeBattery()

std::pair< bool, double > Battery::consumeBattery ( double  timeStep,
double  consumedCharge 
)

Consumes charge from the battery.

Parameters
timeStepThe time step in seconds.
consumedChargeThe amount of charge to be consumed.
Returns
A pair containing a boolean indicating whether the consumption was successful and the actual amount of charge consumed.

◆ getBatteryCRate()

double Battery::getBatteryCRate ( ) const

Gets the C-Rate of discharge for the battery.

Returns
The C-Rate of discharge for the battery.

◆ getBatteryCumEnergyConsumption()

double Battery::getBatteryCumEnergyConsumption ( )

Gets the cumulative energy consumption for this battery only.

Returns
The cumulative energy consumption for this battery.

◆ getBatteryCumEnergyRegenerated()

double Battery::getBatteryCumEnergyRegenerated ( )

Gets the cumulative energy regenerated for this battery only.

Returns
The cumulative energy regenerated for this battery.

◆ getBatteryCumNetEnergyConsumption()

double Battery::getBatteryCumNetEnergyConsumption ( )

Gets the cumulative net energy consumption for this battery.

Returns
The cumulative net energy consumption for this battery.

◆ getBatteryCurrentCharge()

double Battery::getBatteryCurrentCharge ( ) const

Gets the current charge of the battery.

Returns
The current charge of the battery in kWh.

◆ getBatteryDOD()

double Battery::getBatteryDOD ( ) const

Gets the depth of discharge of the battery.

Returns
The depth of discharge of the battery as a percentage.

◆ getBatteryInitialCharge()

double Battery::getBatteryInitialCharge ( ) const

Gets the initial charge of the battery.

Returns
The initial charge of the battery in kWh.

◆ getBatteryMaxCharge()

double Battery::getBatteryMaxCharge ( ) const

Gets the maximum charge of the battery.

Returns
The maximum charge of the battery in kWh.

◆ getBatteryMaxDischarge()

double Battery::getBatteryMaxDischarge ( double  timeStep)

Gets the maximum discharge of the battery.

Parameters
timeStepThe time step in seconds.
Returns
The maximum discharge of the battery in kWh.

◆ getBatteryMaxRecharge()

double Battery::getBatteryMaxRecharge ( double  timeStep)

Gets the maximum recharge of the battery.

Parameters
timeStepThe time step in seconds.
Returns
The maximum recharge of the battery in kWh.

◆ getBatteryRechargeSOCLowerBound()

double Battery::getBatteryRechargeSOCLowerBound ( ) const

Gets the lower bound of the battery's recharge state of charge.

Returns
The lower bound of the recharge state of charge.

◆ getBatteryRechargeSOCUpperBound()

double Battery::getBatteryRechargeSOCUpperBound ( ) const

Gets the upper bound of the battery's recharge state of charge.

Returns
The upper bound of the recharge state of charge.

◆ getBatteryStateOfCharge()

double Battery::getBatteryStateOfCharge ( ) const

Gets the state of charge of the battery.

Returns
The state of charge of the battery as a percentage.

◆ isBatteryDrainable()

bool Battery::isBatteryDrainable ( double  requiredCharge)

Checks if the battery can be drained by the required charge.

Parameters
requiredChargeThe required charge to be drained.
Returns
True if the battery can be drained, false otherwise.

◆ IsBatteryExceedingThresholds()

bool Battery::IsBatteryExceedingThresholds ( )

Checks if the battery exceeds certain thresholds.

Returns
True if the battery exceeds the thresholds, false otherwise.

◆ isBatteryRechargable()

bool Battery::isBatteryRechargable ( )

Checks if the battery can be recharged.

Returns
True if the battery can be recharged, false otherwise.

◆ isRechargeRequired()

bool Battery::isRechargeRequired ( ) const

Checks if the battery requires a recharge.

Returns
True if a recharge is required, false otherwise.

◆ rechargeBatteryByRegeneratedEnergy()

double Battery::rechargeBatteryByRegeneratedEnergy ( double  timeStep,
double  recharge 
)

Recharges the battery by regenerated energy.

Parameters
timeStepThe time step in seconds.
rechargeThe amount of charge to be recharged.
Returns
The actual amount of charge recharged.

◆ rechargeBatteryForHybrids()

double Battery::rechargeBatteryForHybrids ( double  timeStep,
double  recharge 
)

Recharges the battery for hybrid vehicles.

Parameters
timeStepThe time step in seconds.
rechargeThe amount of charge to be recharged.
Returns
The actual amount of charge recharged.

◆ setBattery()

void Battery::setBattery ( double  maxCharge,
double  initialChargePercentage,
double  depthOfDischarge,
double  batteryCRate,
double  maxRechargeSOC = 0.9,
double  minRechargeSOC = 0.5 
)

Sets the battery properties.

Parameters
maxChargeThe maximum charge the battery can hold in kWh.
initialChargePercentageThe initial charge percentage of the battery.
depthOfDischargeThe allowable depth of discharge for the battery.
batteryCRateThe C-Rate of discharge for the battery.
maxRechargeSOCThe maximum State of Charge the battery reaches when recharging (optional).
minRechargeSOCThe minimum State of Charge the battery reaches when being drained (optional).

◆ setBatteryCRate()

void Battery::setBatteryCRate ( double  newBatteryCRate)

Sets the C-Rate of discharge for the battery.

Parameters
newBatteryCRateThe new C-Rate of discharge for the battery.

◆ setBatteryDOD()

void Battery::setBatteryDOD ( double  newBatteryDOD)

Sets the depth of discharge of the battery.

Parameters
newBatteryDODThe new depth of discharge of the battery as a percentage.

◆ setBatteryInitialCharge()

void Battery::setBatteryInitialCharge ( double  newInitialCharge)

Sets the initial charge of the battery.

Parameters
newInitialChargeThe new initial charge of the battery in kWh.

◆ setBatteryMaxCharge()

void Battery::setBatteryMaxCharge ( double  newMaxCharge)

Sets the maximum charge of the battery.

Parameters
newMaxChargeThe new maximum charge of the battery in kWh.

◆ setBatteryRechargeSOCLowerBound()

void Battery::setBatteryRechargeSOCLowerBound ( double  newBatteryRechargeSOCLowerBound)

Sets the lower bound of the battery's recharge state of charge.

Parameters
newBatteryRechargeSOCLowerBoundThe new lower bound of the recharge state of charge.

◆ setBatteryRechargeSOCUpperBound()

void Battery::setBatteryRechargeSOCUpperBound ( double  newBatteryMaxSOC)

Sets the upper bound of the battery's recharge state of charge.

Parameters
newBatteryMaxSOCThe new upper bound of the recharge state of charge.