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:

  1. Writes out a powerStorageStatusSimMsg 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).

  2. Allows for multiple powerNodeUsageSimMsg corresponding to individual Module: powerNodeBase instances to be subscribed to using the addPowerNodeToModel method.

  3. Iterates through attached powerNodeUsageSimMsg instances and computes the net power over all messages using sumAllInputs()

  4. Computes the conversion between net power in and storage using the evaluateBatteryModel method, which must be overriden 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 variable name 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.

Module I/O Messages

Msg Variable Name

Msg Type

Description

nodePowerUseMsgNames

powerNodeUsageSimMsg

Input messages. Vector of power node usage usage messages. Set using addPowerNodeToModel

batPowerOutMsgName

powerStorageStatusSimMsg

Output message. Describes battery capacity, charge level, net power.

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 batPowerOutMsgName

  • The input message names are provided by calling the method addPowerNodeToModel()


class PowerStorageBase : public SysModel

Public Functions

PowerStorageBase()

This method initializes some basic parameters for the module.

Return

void

~PowerStorageBase()

Destructor.

Return

void

void SelfInit()

SelfInit creates one PowerStorageSimMsg for the simPowerStorageBase instance.

Return

void

void CrossInit()

Subscribes to messages with the names provided by addPowerNodeToModel. Also calls customCrossInit.

Return

void

void Reset(uint64_t CurrentSimNanos)

This method is used to reset the module.

Return

void

void addPowerNodeToModel(std::string tmpNodeMsgName)

Function to add additional power devices to the storage module.

Adds a simPowerNodeMsg name to be iterated over.

Return

void

Parameters
  • tmpNodeMsgName: Message name corresponding to a PowerNodeUsageSimMsg.

void UpdateState(uint64_t CurrentSimNanos)

Implements readMessages, integratePowerStatus, and writeMessages for the rest of the sim.

Return

void

Parameters
  • CurrentSimNanos: The current simulation time in nanoseconds

Public Members

std::vector<std::string> nodePowerUseMsgNames

Custom Read() method, similar to customSelfInit.

Vector of power node input message names

std::string batPowerOutMsgName

Vector of message names to be written out by the battery.

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 PowerStorageStatusSimMsg

Return

void

Parameters
  • CurrentClock: The current time used for time-stamping the message

bool readMessages()

This method is used to read the incoming power supply/usage messages and store them for future use.

Return

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.

Return

void

double sumAllInputs()

Sums over the input power consumption messages.

This method sums over the power used/generated by the attached simPowerNodes.

Return

double currentSum: current net power in Watts

void evaluateBatteryModel(PowerStorageStatusSimMsg *msg) = 0

Virtual function to represent power storage computation or losses.

void customSelfInit()
void customCrossInit()

Custom SelfInit() method. This allows a child class to add additional functionality to the SelfInit() method.

void customReset(uint64_t CurrentClock)

Custom CrossInit() method, similar to customSelfInit.

void customWriteMessages(uint64_t currentSimNanos)

Custom Reset() method, similar to customSelfInit.

bool customReadMessages()

Custom Write() method, similar to customSelfInit.

Protected Attributes

std::vector<std::int64_t> nodePowerUseMsgIds
int64_t batPowerOutMsgId
PowerStorageStatusSimMsg storageStatusMsg
std::vector<PowerNodeUsageSimMsg> nodeWattMsgs
double previousTime
double currentTimestep

Previous time used for integration.

double storedCharge

[s] Timestep duration in seconds.

[W-s] Stored charge in Watt-hours.

double currentPowerSum

[W] Current net power.

uint64_t outputBufferCount