Module: powerStorageBase
Executive Summary
The PowerStorageBase is a base class that is used generate a standard interface and list of features for modules that store electrical power. This class is used by other modules as a parent class and cannot be instantiated by itself. All Basilisk power storage modules based on this PowerStorageBase inherit the following common properties:
Writes out a PowerStorageStatusMsgPayload containing the current stored power (in Watt-Seconds or Joules), the current net power (in Watts), and the battery storage capacity (in Watt-Seconds or Joules).
Allows for multiple PowerNodeUsageMsgPayload corresponding to individual Module: powerNodeBase instances to be subscribed to using the addPowerNodeToModel method.
Iterates through attached PowerNodeUsageMsgPayload instances and computes the net power over all messages using
sumAllInputs()
Computes the conversion between net power in and storage using the
evaluateBatteryModel
method, which must be overridden in child classes and is therefore module-specific.
Core functionality is wrapped in the evaluateBatteryModel
protected virtual void method, which is assumed to compute power storage on a module specific mathematical model.
Protected methods prepended with custom
are intended for module developers to override with additional, module-specific functionality.
For more information on how to set up and use classes derived from this module, see the simple power system example: scenarioPowerDemo
Module Assumptions and Limitations
The base class makes no specific energy storage device related assumptions.
Message Connection Descriptions
The following table lists all the module input and output messages. The module msg connection is set by the user from python. The msg type contains a link to the message structure definition, while the description provides information on what this message is used for.
Msg Variable Name |
Msg Type |
Description |
---|---|---|
batPowerOutMsg |
power storage status output message |
|
nodePowerUseInMsgs |
vector of power node input messages (these are linked through the |
User Guide
The base class behavior requires the initial energy storage to be specified through
storedCharge_Init
.The integration time step is evaluated as the time between module calls.
The user must set the output message name variable
batPowerOutMsg
The input message names are provided by calling the method
addPowerNodeToModel(msg)
-
class PowerStorageBase : public SysModel
- #include <powerStorageBase.h>
power storage base class
Public Functions
-
PowerStorageBase()
This method initializes some basic parameters for the module.
- Returns:
void
-
~PowerStorageBase()
Destructor.
- Returns:
void
-
void Reset(uint64_t CurrentSimNanos)
This method is used to reset the module.
- Returns:
void
-
void addPowerNodeToModel(Message<PowerNodeUsageMsgPayload> *tmpNodeMsg)
Adds a PowerNodeUsageMsgPayload input message to iterate over
- Parameters:
tmpNodeMsg – Message name corresponding to a PowerNodeUsageMsgPayload.
- Returns:
void
-
void UpdateState(uint64_t CurrentSimNanos)
Implements readMessages, integratePowerStatus, and writeMessages for the rest of the sim.
- Parameters:
currentSimNanos – The current simulation time in nanoseconds
- Returns:
void
Public Members
-
std::vector<ReadFunctor<PowerNodeUsageMsgPayload>> nodePowerUseInMsgs
Vector of power node input message names.
-
Message<PowerStorageStatusMsgPayload> batPowerOutMsg
power storage status output message
-
double storedCharge_Init
[W-s] Initial stored charge set by the user. Defaults to 0.
-
BSKLogger bskLogger
— BSK Logging
Protected Functions
-
void writeMessages(uint64_t CurrentClock)
Writes out one PowerStorageStatusMsgPayload
- Parameters:
CurrentClock – The current time used for time-stamping the message
- Returns:
void
-
bool readMessages()
This method is used to read the incoming power supply/usage messages and store them for future use.
- Returns:
void
-
void integratePowerStatus(double currentTime)
Integrates the net power given the current time using a simple Euler method.
This method integrates the power use provided by the attached modules.
- Returns:
void
-
double sumAllInputs()
Sums over the input power consumption messages.
This method sums over the power used/generated by the attached simPowerNodes.
- Returns:
double currentSum: current net power in Watts
-
virtual void evaluateBatteryModel(PowerStorageStatusMsgPayload *msg) = 0
Virtual function to represent power storage computation or losses.
-
virtual void customReset(uint64_t CurrentClock)
Custom Reset() method, similar to customSelfInit.
Custom Reset() method. This allows a child class to add additional functionality to the Reset() method
- Returns:
void
-
virtual void customWriteMessages(uint64_t currentSimNanos)
Custom Write() method, similar to customSelfInit.
custom Write method, similar to customSelfInit.
- Returns:
void
-
virtual bool customReadMessages()
Custom Read() method, similar to customSelfInit.
Custom read method, similar to customSelfInit; returns true by default.
- Returns:
void
Protected Attributes
-
PowerStorageStatusMsgPayload storageStatusMsg
class variable
-
std::vector<PowerNodeUsageMsgPayload> nodeWattMsgs
class variable
-
double previousTime
Previous time used for integration.
-
double currentTimestep
[s] Timestep duration in seconds.
-
double storedCharge
[W-s] Stored charge in Watt-hours.
-
double currentPowerSum
[W] Current net power.
-
PowerStorageBase()