ComponentGraph

Struct ComponentGraph 

Source
pub struct ComponentGraph<N, E>
where N: Node, E: Edge,
{ /* private fields */ }
Expand description

A graph representation of the electrical components of a microgrid and the connections between them.

Implementations§

Source§

impl<N, E> ComponentGraph<N, E>
where N: Node, E: Edge,

ComponentGraph instantiation.

Source

pub fn try_new<NodeIterator: IntoIterator<Item = N>, EdgeIterator: IntoIterator<Item = E>>( components: NodeIterator, connections: EdgeIterator, config: ComponentGraphConfig, ) -> Result<Self, Error>

Creates a new ComponentGraph from the given components and connections.

Returns an error if the graph is invalid.

Source§

impl<N, E> ComponentGraph<N, E>
where N: Node, E: Edge,

Meter role identification.

Source

pub fn is_pv_meter(&self, component_id: u64) -> Result<bool, Error>

Returns true if the node is a PV meter.

A meter is identified as a PV meter if:

  • it has atleast one successor,
  • all its successors are PV inverters.
Source

pub fn is_battery_meter(&self, component_id: u64) -> Result<bool, Error>

Returns true if the node is a battery meter.

A meter is identified as a battery meter if

  • it has atleast one successor,
  • all its successors are battery inverters.
Source

pub fn is_ev_charger_meter(&self, component_id: u64) -> Result<bool, Error>

Returns true if the node is an EV charger meter.

A meter is identified as an EV charger meter if

  • it has atleast one successor,
  • all its successors are EV chargers.
Source

pub fn is_chp_meter(&self, component_id: u64) -> Result<bool, Error>

Returns true if the node is a CHP meter.

A meter is identified as a CHP meter if

  • has atleast one successor,
  • all its successors are CHPs.
Source

pub fn is_component_meter(&self, component_id: u64) -> Result<bool, Error>

Returns true if the node is a component meter.

A meter is a component meter if it is one of the following:

  • a PV meter,
  • a battery meter,
  • an EV charger meter,
  • a CHP meter.
Source§

impl<N, E> ComponentGraph<N, E>
where N: Node, E: Edge,

Component and Connection retrieval.

Source

pub fn component(&self, component_id: u64) -> Result<&N, Error>

Returns the component with the given component_id, if it exists.

Source

pub fn components(&self) -> Components<'_, N>

Returns an iterator over the components in the graph.

Source

pub fn connections(&self) -> Connections<'_, N, E>

Returns an iterator over the connections in the graph.

Source

pub fn predecessors(&self, component_id: u64) -> Result<Neighbors<'_, N>, Error>

Returns an iterator over the predecessors of the component with the given component_id.

Returns an error if the given component_id does not exist.

Source

pub fn successors(&self, component_id: u64) -> Result<Neighbors<'_, N>, Error>

Returns an iterator over the successors of the component with the given component_id.

Returns an error if the given component_id does not exist.

Source§

impl<N, E> ComponentGraph<N, E>
where N: Node, E: Edge,

Formulas for various microgrid metrics.

Source

pub fn consumer_formula(&self) -> Result<AggregationFormula, Error>

Returns the consumer formula for the graph.

Source

pub fn grid_formula(&self) -> Result<AggregationFormula, Error>

Returns the grid formula for the graph.

Source

pub fn producer_formula(&self) -> Result<AggregationFormula, Error>

Returns the producer formula for the graph.

Source

pub fn battery_formula( &self, battery_ids: Option<BTreeSet<u64>>, ) -> Result<AggregationFormula, Error>

Returns the battery formula with the given battery IDs.

If battery_ids is None, the formula will contain all batteries in the graph.

Source

pub fn chp_formula( &self, chp_ids: Option<BTreeSet<u64>>, ) -> Result<AggregationFormula, Error>

Returns the CHP formula for the graph.

Source

pub fn pv_formula( &self, pv_inverter_ids: Option<BTreeSet<u64>>, ) -> Result<AggregationFormula, Error>

Returns the PV formula for the graph.

Source

pub fn ev_charger_formula( &self, ev_charger_ids: Option<BTreeSet<u64>>, ) -> Result<AggregationFormula, Error>

Returns the EV charger formula for the graph.

Source

pub fn component_formula( &self, component_id: u64, ) -> Result<AggregationFormula, Error>

Returns the formula for a specific component by its ID.

Source

pub fn grid_coalesce_formula(&self) -> Result<CoalesceFormula, Error>

Returns the grid coalesce formula for the graph.

This formula is used for non-aggregating metrics like AC voltage or frequency.

The formula is a COALESCE expression that includes all meters, PV inverters, and battery inverters that are directly connected to the grid.

Source

pub fn battery_ac_coalesce_formula( &self, battery_ids: Option<BTreeSet<u64>>, ) -> Result<CoalesceFormula, Error>

Returns the battery AC coalesce formula for the given components.

This formula is used for non-aggregating metrics like AC voltage or frequency.

The formula is a COALESCE expression that includes all the specified battery meters and corresponding inverters.

When the battery_ids parameter is None, it will include all the battery meters and inverters in the graph.

Source

pub fn pv_ac_coalesce_formula( &self, pv_inverter_ids: Option<BTreeSet<u64>>, ) -> Result<CoalesceFormula, Error>

Returns the PV AC coalesce formula for the given components.

This formula is used for non-aggregating metrics like AC voltage or frequency.

The formula is a COALESCE expression that includes all the specified PV meters and corresponding inverters.

When the pv_inverter_ids parameter is None, it will include all the PV meters and inverters in the graph.

Source

pub fn component_ac_coalesce_formula( &self, component_id: u64, ) -> Result<CoalesceFormula, Error>

Returns the AC coalesce formula for a specific component by its ID.

Trait Implementations§

Source§

impl<N, E> Clone for ComponentGraph<N, E>
where N: Node + Clone, E: Edge + Clone,

Implement Clone for ComponentGraph when the Nodes and Edges implement Clone.

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<N, E> Freeze for ComponentGraph<N, E>

§

impl<N, E> RefUnwindSafe for ComponentGraph<N, E>

§

impl<N, E> Send for ComponentGraph<N, E>
where E: Send, N: Send,

§

impl<N, E> Sync for ComponentGraph<N, E>
where E: Sync, N: Sync,

§

impl<N, E> Unpin for ComponentGraph<N, E>
where N: Unpin, E: Unpin,

§

impl<N, E> UnwindSafe for ComponentGraph<N, E>
where E: UnwindSafe, N: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more