pub struct EnergyMonitor {
pub history: Vec<(f64, f64)>,
pub anomaly_threshold: f64,
pub anomaly_steps: Vec<usize>,
}Expand description
Tracks kinetic and potential energy; detects anomalous jumps.
Fields§
§history: Vec<(f64, f64)>History of (kinetic, potential) energy pairs.
anomaly_threshold: f64Relative jump threshold; a change > threshold * prev_energy triggers an anomaly.
anomaly_steps: Vec<usize>Indices of steps where an anomaly was detected.
Implementations§
Source§impl EnergyMonitor
impl EnergyMonitor
Sourcepub fn new(anomaly_threshold: f64) -> Self
pub fn new(anomaly_threshold: f64) -> Self
Create a new energy monitor with the given relative threshold.
Sourcepub fn record(&mut self, kinetic: f64, potential: f64)
pub fn record(&mut self, kinetic: f64, potential: f64)
Record a new (kinetic, potential) energy measurement.
Sourcepub fn latest_total(&self) -> Option<f64>
pub fn latest_total(&self) -> Option<f64>
Total energy at the most recent step.
Sourcepub fn mean_total(&self) -> f64
pub fn mean_total(&self) -> f64
Mean total energy over all recorded steps.
Sourcepub fn has_anomaly(&self) -> bool
pub fn has_anomaly(&self) -> bool
Returns true if any anomaly was detected.
Trait Implementations§
Source§impl Clone for EnergyMonitor
impl Clone for EnergyMonitor
Source§fn clone(&self) -> EnergyMonitor
fn clone(&self) -> EnergyMonitor
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EnergyMonitor
impl Debug for EnergyMonitor
Source§impl Default for EnergyMonitor
impl Default for EnergyMonitor
Source§fn default() -> EnergyMonitor
fn default() -> EnergyMonitor
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for EnergyMonitor
impl RefUnwindSafe for EnergyMonitor
impl Send for EnergyMonitor
impl Sync for EnergyMonitor
impl Unpin for EnergyMonitor
impl UnsafeUnpin for EnergyMonitor
impl UnwindSafe for EnergyMonitor
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.