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: f32Baseline power consumption in kilowatts
amp_kw: f32Amplitude of the sinusoidal variation in kilowatts
phase_rad: f32Phase offset of the sinusoidal pattern in radians
noise_std: f32Standard deviation of the Gaussian noise in kilowatts
steps_per_day: usizeNumber of time steps per simulated day
rng: StdRngRandom number generator for noise generation
Implementations§
Source§impl BaseLoad
impl BaseLoad
Sourcepub fn new(
base_kw: f32,
amp_kw: f32,
phase_rad: f32,
noise_std: f32,
steps_per_day: usize,
seed: u64,
) -> Self
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 kilowattsamp_kw- The amplitude of sinusoidal daily variation in kilowattsphase_rad- The phase offset in radians (0 = minimum at start of day)noise_std- The standard deviation of Gaussian noise in kilowattssteps_per_day- The number of time steps per simulated dayseed- Random seed for reproducible noise generation
§Returns
A new BaseLoad instance configured with the specified parameters
Trait Implementations§
Source§impl Device for BaseLoad
impl Device for BaseLoad
Source§fn power_kw(&mut self, context: &DeviceContext) -> f32
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