Struct TimeSliceInfo

Source
pub struct TimeSliceInfo {
    pub times_of_day: IndexSet<TimeOfDay>,
    pub seasons: IndexMap<Season, Dimensionless>,
    pub time_slices: IndexMap<TimeSliceID, Dimensionless>,
}
Expand description

Information about the time slices in the simulation, including names and fractions

Fields§

§times_of_day: IndexSet<TimeOfDay>

Names of times of day (e.g. “evening”)

§seasons: IndexMap<Season, Dimensionless>

Names and fraction of year occupied by each season

§time_slices: IndexMap<TimeSliceID, Dimensionless>

The fraction of the year that this combination of season and time of day occupies

Implementations§

Source§

impl TimeSliceInfo

Source

pub fn get_time_slice_id_from_str( &self, time_slice: &str, ) -> Result<TimeSliceID>

Get the TimeSliceID corresponding to the time_slice.

time_slice must be in the form “season.time_of_day”.

Source

pub fn get_selection(&self, time_slice: &str) -> Result<TimeSliceSelection>

Get a TimeSliceSelection from the specified string.

If the string is empty, the default value is TimeSliceSelection::Annual.

Source

pub fn iter_ids(&self) -> Keys<'_, TimeSliceID, Dimensionless>

Iterate over all TimeSliceIDs

Source

pub fn iter(&self) -> impl Iterator<Item = (&TimeSliceID, Dimensionless)>

Iterate over all time slices

Source

pub fn iter_selections_at_level( &self, level: TimeSliceLevel, ) -> Box<dyn Iterator<Item = TimeSliceSelection> + '_>

Iterate over the different time slice selections for a given time slice level.

For example, if TimeSliceLevel::Season is specified, this function will return an iterator of TimeSliceSelections covering each season.

Source

pub fn iter_selection_share<'a>( &'a self, selection: &'a TimeSliceSelection, level: TimeSliceLevel, ) -> Option<impl Iterator<Item = (TimeSliceSelection, Dimensionless)>>

Iterate over a subset of time slices calculating the relative duration of each.

The relative duration is specified as a fraction of the total time (proportion of year) covered by selection.

§Arguments
  • selection - A subset of time slices
§Returns

An iterator of time slices along with the fraction of the total selection.

Source

pub fn calculate_share<'a>( &'a self, selection: &'a TimeSliceSelection, level: TimeSliceLevel, value: Dimensionless, ) -> Option<impl Iterator<Item = (TimeSliceSelection, Dimensionless)>>

Share a value between a subset of time slices in proportion to their lengths.

For instance, you could use this function to compute how demand is distributed between the different time slices of winter.

§Arguments
  • selection - A subset of time slices
  • value - The value to be shared between the time slices
§Returns

An iterator of time slices along with a fraction of value.

Trait Implementations§

Source§

impl Debug for TimeSliceInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TimeSliceInfo

Source§

fn default() -> Self

The default TimeSliceInfo is a single time slice covering the whole year

Source§

impl PartialEq for TimeSliceInfo

Source§

fn eq(&self, other: &TimeSliceInfo) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TimeSliceInfo

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.