Skip to main content

ProtectionTester

Struct ProtectionTester 

Source
pub struct ProtectionTester {
    pub relay_config: RelayTestConfig,
    pub simulation_noise_pct: f64,
    pub seed: u64,
}
Expand description

Main protection testing engine.

Simulates relay operation with configurable LCG-based timing noise so that test suites are repeatable yet realistic.

§Noise model

actual_time = ideal_time × (1 + noise_pct × (u − 0.5)) where u ∈ [0,1) is drawn from a Linear Congruential Generator.

Fields§

§relay_config: RelayTestConfig

Relay configuration (settings, ratios, characteristic).

§simulation_noise_pct: f64

Fractional timing noise amplitude (e.g. 0.005 = ±0.25 %).

§seed: u64

Internal LCG state for reproducible pseudo-randomness.

Implementations§

Source§

impl ProtectionTester

Source

pub fn new(relay_config: RelayTestConfig) -> Self

Create a new tester with default 0.5 % noise.

Source

pub fn compute_expected_operate_time(&self, current_a: f64) -> f64

Compute the expected relay operating time for current_a [A secondary].

The formula is selected by RelayTestConfig::characteristic:

KeyFormula (t in seconds)
IEC_SITDS × 0.14 / ((I/Is)^0.02 − 1)
IEC_VITDS × 13.5 / ((I/Is) − 1)
IEC_EITDS × 80 / ((I/Is)² − 1)
ANSI_MITDS × (0.0515/((I/Is)^0.02−1) + 0.114)

Returns milliseconds. Returns 0.0 when current ≤ pickup and f64::INFINITY when the denominator is numerically zero.

Source

pub fn simulate_relay_operation(&mut self, case: &TestCase) -> (bool, f64)

Simulate relay operation for a test case.

Returns (operated: bool, operate_time_ms: f64).

If operated is false, operate_time_ms is 0.0.

Source

pub fn run_test_case(&mut self, case: &TestCase) -> TestResult

Execute a single test case and return its result.

Source

pub fn run_suite<'s>(&mut self, suite: &'s mut TestSuite) -> &'s TestSuite

Run all test cases in a TestSuite and update its counters.

Returns a shared reference to the (now populated) suite.

Source

pub fn generate_pickup_tests(&self) -> Vec<TestCase>

Generate pickup verification tests at 0.8×, 0.9×, 1.0×, 1.05×, 1.1×, 1.5× pickup.

Tests at or below pickup expect no operation; tests above expect operation. Produces exactly 6 test cases.

Source

pub fn generate_timing_tests(&self, multiples: &[f64]) -> Vec<TestCase>

Generate timing tests at the specified current multiples of the pickup setting.

Typically called with &[2.0, 5.0, 10.0, 20.0]. Tolerance is the larger of 5 % of the expected time or 20 ms.

Source

pub fn generate_characteristic_tests(&self, n_points: usize) -> Vec<TestCase>

Generate n_points characteristic curve test cases distributed on a logarithmic scale from 1.05× to 20× pickup.

Returns an empty Vec when n_points == 0.

Trait Implementations§

Source§

impl Clone for ProtectionTester

Source§

fn clone(&self) -> ProtectionTester

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProtectionTester

Source§

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

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.