Crate frequenz_microgrid_component_graph

Crate frequenz_microgrid_component_graph 

Source
Expand description

§Frequenz Microgrid Component Graph

This is a library for representing the components of a microgrid and the connections between them as a Directed Acyclic Graph (DAG).

A graph representation makes it easy to reason about the relationships between the components and to come up with formulas for calculating aggregated metrics for the microgrid.

§The Node and Edge traits

The main struct is ComponentGraph, instances of which can be created by passing an iterator of components and the connections between them to the try_new method.

But because component_graph is an independent library, it doesn’t know about the component and connection types and instead uses traits to interact with them.

Therefore, to be usable with this library, the component and connection types must implement the Node and Edge traits, respectively. Check out the documentation for these traits for sample implementations.

§Validation

The try_new method several checks on the graph including checking that:

  • There is exactly one root node.
  • All edges point to existing nodes.
  • All nodes are reachable from the root node.
  • There are no cycles in the graph.
  • The components have sensible neighbor types. For example, a battery shouldn’t have successors and should have a battery inverter as a predecessor.

If any of the validation steps fail, the method will return an Error, and a ComponentGraph instance otherwise.

§Formula generation

The component graph library has methods for generating formulas for various metrics of the microgrid. The following formulas are supported:

Modules§

iterators
Iterators over components and connections in a ComponentGraph.

Structs§

AggregationFormula
CoalesceFormula
Represents a formula that coalesces metrics from multiple components.
ComponentGraph
A graph representation of the electrical components of a microgrid and the connections between them.
ComponentGraphConfig
Configuration options for the ComponentGraph.
Error
An error that can occur during the creation or traversal of a ComponentGraph.

Enums§

BatteryType
Represents the type of a battery.
ComponentCategory
Represents the category of a component.
EvChargerType
Represents the type of an EV charger.
InverterType
Represents the type of an inverter.

Traits§

Edge
This trait needs to be implemented by the type that represents a connection.
Formula
A trait with methods for combining formulas.
Node
This trait needs to be implemented by the type that represents a node.