Struct fastsim_core::cycle::RustCycle
source · pub struct RustCycle {
pub time_s: Array1<f64>,
pub mps: Array1<f64>,
pub grade: Array1<f64>,
pub road_type: Array1<f64>,
pub name: String,
pub orphaned: bool,
}Expand description
Struct for containing:
- time_s, cycle time, $s$
- mps, vehicle speed, $\frac{m}{s}$
- grade, road grade/slope, $\frac{rise}{run}$
- road_type, $kW$
- legacy, will likely change to road charging capacity
- Another sublist.
Fields§
§time_s: Array1<f64>array of time s
mps: Array1<f64>array of speed [m/s]
grade: Array1<f64>array of grade [rise/run]
road_type: Array1<f64>array of max possible charge rate from roadway
name: String§orphaned: boolImplementations§
source§impl RustCycle
impl RustCycle
pure Rust methods that need to be separate due to pymethods incompatibility
pub fn new( time_s: Vec<f64>, mps: Vec<f64>, grade: Vec<f64>, road_type: Vec<f64>, name: String ) -> Self
pub fn build_cache(&self) -> RustCycleCache
pub fn push(&mut self, cyc_elem: RustCycleElement)
pub fn len(&self) -> usize
pub fn test_cyc() -> Self
sourcepub fn average_grade_over_range(
&self,
distance_start_m: f64,
delta_distance_m: f64,
cache: Option<&RustCycleCache>
) -> f64
pub fn average_grade_over_range( &self, distance_start_m: f64, delta_distance_m: f64, cache: Option<&RustCycleCache> ) -> f64
Returns the average grade over the given range of distances
- distance_start_m: non-negative-number, the distance at start of evaluation area (m)
- delta_distance_m: non-negative-number, the distance traveled from distance_start_m (m) RETURN: number, the average grade (rise over run) over the given distance range Note: grade is assumed to be constant from just after the previous sample point until the current sample point. That is, grade[i] applies over the range of distances, d, from (d[i - 1], d[i]]
sourcepub fn calc_distance_to_next_stop_from(
&self,
distance_m: f64,
cache: Option<&RustCycleCache>
) -> f64
pub fn calc_distance_to_next_stop_from( &self, distance_m: f64, cache: Option<&RustCycleCache> ) -> f64
Calculate the distance to next stop from distance_m
- distance_m: non-negative-number, the current distance from start (m) RETURN: returns the distance to the next stop from distance_m NOTE: distance may be negative if we’re beyond the last stop
sourcepub fn modify_by_const_jerk_trajectory(
&mut self,
i: usize,
n: usize,
jerk_m_per_s3: f64,
accel0_m_per_s2: f64
) -> f64
pub fn modify_by_const_jerk_trajectory( &mut self, i: usize, n: usize, jerk_m_per_s3: f64, accel0_m_per_s2: f64 ) -> f64
Modifies the cycle using the given constant-jerk trajectory parameters
- idx: non-negative integer, the point in the cycle to initiate modification (note: THIS point is modified since trajectory should be calculated from idx-1)
- n: non-negative integer, the number of steps ahead
- jerk_m__s3: number, the “Jerk” associated with the trajectory (m/s3)
- accel0_m__s2: number, the initial acceleration (m/s2) NOTE:
- modifies cyc in place to hit any critical rendezvous_points by a trajectory adjustment
- CAUTION: NOT ROBUST AGAINST VARIABLE DURATION TIME-STEPS RETURN: Number, final modified speed (m/s)
sourcepub fn modify_with_braking_trajectory(
&mut self,
brake_accel_m_per_s2: f64,
i: usize,
dts_m: Option<f64>
) -> (f64, usize)
pub fn modify_with_braking_trajectory( &mut self, brake_accel_m_per_s2: f64, i: usize, dts_m: Option<f64> ) -> (f64, usize)
Add a braking trajectory that would cover the same distance as the given constant brake deceleration
- brake_accel_m__s2: negative number, the braking acceleration (m/s2)
- idx: non-negative integer, the index where to initiate the stop trajectory, start of the step (i in FASTSim)
- dts_m: None | float: if given, this is the desired distance-to-stop in meters. If not given, it is calculated based on braking deceleration. RETURN: (non-negative-number, positive-integer)
- the final speed of the modified trajectory (m/s)
- the number of time-steps required to complete the braking maneuver NOTE:
- modifies the cycle in place for the braking trajectory
sourcepub fn from_csv_file(pathstr: &str) -> Result<Self, Error>
pub fn from_csv_file(pathstr: &str) -> Result<Self, Error>
Load cycle from csv file
sourcepub fn delta_elev_m(&self) -> Array1<f64>
pub fn delta_elev_m(&self) -> Array1<f64>
elevation change w.r.t. to initial
pub fn from_csv_string(data: &str, name: String) -> Result<Self, Error>
Trait Implementations§
source§impl<'de> Deserialize<'de> for RustCycle
impl<'de> Deserialize<'de> for RustCycle
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq<RustCycle> for RustCycle
impl PartialEq<RustCycle> for RustCycle
source§impl SerdeAPI for RustCycle
impl SerdeAPI for RustCycle
source§fn from_file(filename: &str) -> Result<Self, Error>
fn from_file(filename: &str) -> Result<Self, Error>
Read from file and return instantiated struct. Method adaptively calls deserialization
methods dependent on the suffix of the file name given as str.
Function returns a dynamic Error Result if it fails. Read more
source§fn to_file(&self, filename: &str) -> Result<(), Error>
fn to_file(&self, filename: &str) -> Result<(), Error>
Save current data structure to file. Method adaptively calls serialization methods
dependent on the suffix of the file given as str. Read more
source§fn to_bincode(&self) -> Vec<u8>
fn to_bincode(&self) -> Vec<u8>
bincode serialization method.
impl StructuralPartialEq for RustCycle
Auto Trait Implementations§
impl RefUnwindSafe for RustCycle
impl Send for RustCycle
impl Sync for RustCycle
impl Unpin for RustCycle
impl UnwindSafe for RustCycle
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