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: RelayTestConfigRelay configuration (settings, ratios, characteristic).
simulation_noise_pct: f64Fractional timing noise amplitude (e.g. 0.005 = ±0.25 %).
seed: u64Internal LCG state for reproducible pseudo-randomness.
Implementations§
Source§impl ProtectionTester
impl ProtectionTester
Sourcepub fn new(relay_config: RelayTestConfig) -> Self
pub fn new(relay_config: RelayTestConfig) -> Self
Create a new tester with default 0.5 % noise.
Sourcepub fn compute_expected_operate_time(&self, current_a: f64) -> f64
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:
| Key | Formula (t in seconds) |
|---|---|
IEC_SI | TDS × 0.14 / ((I/Is)^0.02 − 1) |
IEC_VI | TDS × 13.5 / ((I/Is) − 1) |
IEC_EI | TDS × 80 / ((I/Is)² − 1) |
ANSI_MI | TDS × (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.
Sourcepub fn simulate_relay_operation(&mut self, case: &TestCase) -> (bool, f64)
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.
Sourcepub fn run_test_case(&mut self, case: &TestCase) -> TestResult
pub fn run_test_case(&mut self, case: &TestCase) -> TestResult
Execute a single test case and return its result.
Sourcepub fn run_suite<'s>(&mut self, suite: &'s mut TestSuite) -> &'s TestSuite
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.
Sourcepub fn generate_pickup_tests(&self) -> Vec<TestCase>
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.
Sourcepub fn generate_timing_tests(&self, multiples: &[f64]) -> Vec<TestCase>
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.
Sourcepub fn generate_characteristic_tests(&self, n_points: usize) -> Vec<TestCase>
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
impl Clone for ProtectionTester
Source§fn clone(&self) -> ProtectionTester
fn clone(&self) -> ProtectionTester
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ProtectionTester
impl RefUnwindSafe for ProtectionTester
impl Send for ProtectionTester
impl Sync for ProtectionTester
impl Unpin for ProtectionTester
impl UnsafeUnpin for ProtectionTester
impl UnwindSafe for ProtectionTester
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.