Skip to main content

MultiMachineSim

Struct MultiMachineSim 

Source
pub struct MultiMachineSim {
    pub machines: Vec<MachineParams>,
    pub y_red: Vec<Vec<Complex64>>,
    pub use_coi: bool,
}
Expand description

Multi-machine stability model (network-reduced, COI frame).

Fields§

§machines: Vec<MachineParams>§y_red: Vec<Vec<Complex64>>

Generator admittance matrix (n×n dense, complex)

§use_coi: bool

Use COI frame for integration

Implementations§

Source§

impl MultiMachineSim

Source

pub fn new(machines: Vec<MachineParams>, y_red: Vec<Vec<Complex64>>) -> Self

Construct from machine parameters and a pre-built reduced admittance matrix.

y_red_flat is row-major: y_red[i][j] = G_ij + j·B_ij [p.u.].

Source

pub fn two_machine(m1: MachineParams, m2: MachineParams, x_line: f64) -> Self

Build a two-machine system connected via a transfer admittance.

Y_12 = −j / (xd1’ + xline + xd2’) (pure imaginary for lossless line).

Source

pub fn ring_network(machines: Vec<MachineParams>, x_line: f64) -> Self

Build an n-machine ring network (each machine connected to next via x_line).

Source

pub fn electrical_power(&self, states: &[MachineState]) -> Vec<f64>

Compute electrical power output for each machine [p.u.].

P_e_i = Σ_j E_i·E_j·[G_ij·cos(δ_i−δ_j) + B_ij·sin(δ_i−δ_j)]

Source

pub fn coi(&self, states: &[MachineState]) -> (f64, f64)

Compute the COI angle and speed.

Source

pub fn derivatives(&self, states: &[MachineState]) -> Vec<(f64, f64)>

Compute swing-equation derivatives d(δ, ω)/dt for all machines.

In COI frame: the COI acceleration is subtracted from each machine.

Source

pub fn step(&self, states: &[MachineState], dt: f64) -> Vec<MachineState>

Perform one RK4 integration step.

Source

pub fn run( &self, initial: Vec<MachineState>, dt: f64, t_end: f64, fault_fn: Option<&dyn Fn(f64) -> Option<Vec<Vec<Complex64>>>>, ) -> MultiMachineResult

Run a full multi-machine transient simulation.

fault_fn is called at each step to optionally modify the Y_red (e.g., to model a fault being applied/cleared). It receives the current time and returns an optional modified admittance matrix.

Source

pub fn is_transient_stable(result: &MultiMachineResult) -> bool

Check if the system is transiently stable.

Criterion: max(|δ_i − δ_j|) < π rad at all times.

Source

pub fn estimate_cct( &self, initial: &[MachineState], y_red_fault: Vec<Vec<Complex64>>, dt: f64, t_sim: f64, tol: f64, ) -> f64

Estimate critical clearing time (CCT) by bisection.

Applies a fault (Y_red_fault) starting at t=0, clears at t=t_clear. Returns CCT in seconds (within tol precision).

Source

pub fn kinetic_energy(&self, states: &[MachineState]) -> f64

Compute the kinetic energy (relative to COI) stored in generator rotors [p.u.·s].

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.