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: boolUse COI frame for integration
Implementations§
Source§impl MultiMachineSim
impl MultiMachineSim
Sourcepub fn new(machines: Vec<MachineParams>, y_red: Vec<Vec<Complex64>>) -> Self
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.].
Sourcepub fn two_machine(m1: MachineParams, m2: MachineParams, x_line: f64) -> Self
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).
Sourcepub fn ring_network(machines: Vec<MachineParams>, x_line: f64) -> Self
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).
Sourcepub fn electrical_power(&self, states: &[MachineState]) -> Vec<f64>
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)]
Sourcepub fn coi(&self, states: &[MachineState]) -> (f64, f64)
pub fn coi(&self, states: &[MachineState]) -> (f64, f64)
Compute the COI angle and speed.
Sourcepub fn derivatives(&self, states: &[MachineState]) -> Vec<(f64, f64)>
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.
Sourcepub fn step(&self, states: &[MachineState], dt: f64) -> Vec<MachineState>
pub fn step(&self, states: &[MachineState], dt: f64) -> Vec<MachineState>
Perform one RK4 integration step.
Sourcepub fn run(
&self,
initial: Vec<MachineState>,
dt: f64,
t_end: f64,
fault_fn: Option<&dyn Fn(f64) -> Option<Vec<Vec<Complex64>>>>,
) -> MultiMachineResult
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.
Sourcepub fn is_transient_stable(result: &MultiMachineResult) -> bool
pub fn is_transient_stable(result: &MultiMachineResult) -> bool
Check if the system is transiently stable.
Criterion: max(|δ_i − δ_j|) < π rad at all times.
Sourcepub fn estimate_cct(
&self,
initial: &[MachineState],
y_red_fault: Vec<Vec<Complex64>>,
dt: f64,
t_sim: f64,
tol: f64,
) -> f64
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).
Sourcepub fn kinetic_energy(&self, states: &[MachineState]) -> f64
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§
impl Freeze for MultiMachineSim
impl RefUnwindSafe for MultiMachineSim
impl Send for MultiMachineSim
impl Sync for MultiMachineSim
impl Unpin for MultiMachineSim
impl UnsafeUnpin for MultiMachineSim
impl UnwindSafe for MultiMachineSim
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.