BaseLoad

Struct BaseLoad 

Source
pub struct BaseLoad {
    pub base_kw: f32,
    pub amp_kw: f32,
    pub phase_rad: f32,
    pub noise_std: f32,
    pub steps_per_day: usize,
    rng: StdRng,
}
Expand description

A baseload generator that models daily electricity consumption patterns.

BaseLoad creates a sinusoidal power demand pattern with configurable baseline, amplitude, phase, and random noise to simulate typical daily load patterns.

§Examples

Note: vpp-sim currently ships as a binary-first crate; this snippet is illustrative.

use vpp_sim::devices::baseload::BaseLoad;
use vpp_sim::devices::types::{Device, DeviceContext};

// Create a baseload with typical parameters
let mut load = BaseLoad::new(
    1.0,   // base_kw - average consumption
    0.5,   // amp_kw - daily variation
    0.0,   // phase_rad - no phase shift (minimum at midnight)
    0.05,  // noise_std - small random variation
    24,    // steps_per_day - hourly resolution
    42,    // seed - for reproducible randomness
);

// Get demand at noon
let demand = load.power_kw(&DeviceContext::new(12));

Fields§

§base_kw: f32

Baseline power consumption in kilowatts

§amp_kw: f32

Amplitude of the sinusoidal variation in kilowatts

§phase_rad: f32

Phase offset of the sinusoidal pattern in radians

§noise_std: f32

Standard deviation of the Gaussian noise in kilowatts

§steps_per_day: usize

Number of time steps per simulated day

§rng: StdRng

Random number generator for noise generation

Implementations§

Source§

impl BaseLoad

Source

pub fn new( base_kw: f32, amp_kw: f32, phase_rad: f32, noise_std: f32, steps_per_day: usize, seed: u64, ) -> Self

Creates a new baseload generator with the specified parameters.

§Arguments
  • base_kw - The baseline power consumption in kilowatts
  • amp_kw - The amplitude of sinusoidal daily variation in kilowatts
  • phase_rad - The phase offset in radians (0 = minimum at start of day)
  • noise_std - The standard deviation of Gaussian noise in kilowatts
  • steps_per_day - The number of time steps per simulated day
  • seed - Random seed for reproducible noise generation
§Returns

A new BaseLoad instance configured with the specified parameters

Trait Implementations§

Source§

impl Debug for BaseLoad

Source§

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

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

impl Device for BaseLoad

Source§

fn power_kw(&mut self, context: &DeviceContext) -> f32

Calculates the power demand at a specific time step.

This method computes the power demand as a combination of:

  • A baseline component (base_kw)
  • A sinusoidal daily pattern with specified amplitude and phase
  • Random Gaussian noise with specified standard deviation

The demand is guaranteed to be non-negative.

§Arguments
  • timestep - The simulation time step
§Returns

The power demand in kilowatts at the specified time step

Source§

fn device_type(&self) -> &'static str

Returns a human-readable type name for the device.

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, 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.