From ef2206ddd9899ec84eb74a92d20158f09b410d87 Mon Sep 17 00:00:00 2001 From: Chad Baker Date: Fri, 21 Jun 2024 11:02:14 -0600 Subject: [PATCH 1/2] added several doc strings --- rust/fastsim-core/src/simdrive.rs | 15 ++++++++++++++- rust/fastsim-core/src/simdrive/simdrive_impl.rs | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/rust/fastsim-core/src/simdrive.rs b/rust/fastsim-core/src/simdrive.rs index ef7f11a7..3fac21cc 100644 --- a/rust/fastsim-core/src/simdrive.rs +++ b/rust/fastsim-core/src/simdrive.rs @@ -25,8 +25,14 @@ pub struct RustSimDriveParams { pub min_time_dilation: f64, pub time_dilation_tol: f64, pub max_trace_miss_iters: u32, + /// threshold for triggering warning log message if vehicle speed deficit + /// relative to prescribed speed exceeds this amount pub trace_miss_speed_mps_tol: f64, + /// threshold for triggering warning log message if achieved elapsed time + /// relative to prescribed elapsed time exceeds this fractional amount pub trace_miss_time_tol: f64, + /// threshold for triggering warning log message if achieved distance + /// relative to prescribed distance exceeds this fractional amount pub trace_miss_dist_tol: f64, pub sim_count_max: usize, pub newton_gain: f64, @@ -80,7 +86,7 @@ impl Default for RustSimDriveParams { let newton_max_iter = 100; // newton solver max iterations let newton_xtol = 1e-9; // newton solver tolerance let energy_audit_error_tol = 0.002; // tolerance for energy audit error warning, i.e. 0.1% - // Coasting + // Coasting let coast_allow = false; let coast_allow_passing = false; let coast_max_speed_m_per_s = 40.0; @@ -533,9 +539,16 @@ pub struct RustSimDrive { pub fc_kj: f64, pub net_kj: f64, pub ke_kj: f64, + /// `true` when the vehicle misses the prescribed speed trace pub trace_miss: bool, + /// fractional difference between achieved cumulative distance + /// and prescribed cumulative distance pub trace_miss_dist_frac: f64, + /// fractional difference between achieved time when trace miss is + /// and prescribed cumulative distance pub trace_miss_time_frac: f64, + /// Maximum speed by which vehicle's speed falls behind prescribed + /// speed trace pub trace_miss_speed_mps: f64, #[serde(skip)] pub orphaned: bool, diff --git a/rust/fastsim-core/src/simdrive/simdrive_impl.rs b/rust/fastsim-core/src/simdrive/simdrive_impl.rs index 38186339..4a94db7f 100644 --- a/rust/fastsim-core/src/simdrive/simdrive_impl.rs +++ b/rust/fastsim-core/src/simdrive/simdrive_impl.rs @@ -1853,8 +1853,9 @@ impl RustSimDrive { self.trace_miss = false; let dist_m = self.cyc0.dist_m().sum(); self.trace_miss_dist_frac = if dist_m > 0.0 { - (self.dist_m.sum() - self.cyc0.dist_m().sum()).abs() / dist_m + (self.dist_m.sum() - dist_m).abs() / dist_m } else { + bail!("Vehicle did not move forward."); 0.0 }; self.trace_miss_time_frac = (self From 19a30bc16f35cc3a179b0fc012f38cc3da4a7d4e Mon Sep 17 00:00:00 2001 From: Chad Baker Date: Fri, 21 Jun 2024 13:16:30 -0600 Subject: [PATCH 2/2] upgraded and fixed numpy requirement --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 91dd7017..81260ac9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ classifiers = [ dependencies = [ "pandas>=1", "matplotlib>=3.3", - "numpy>=1.18", + "numpy==1.24", "scipy", "seaborn>=0.10", "typing_extensions",