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
sourcepub fn from_csv_file<P: AsRef<Path>>(filepath: P) -> Result<Self>
pub fn from_csv_file<P: AsRef<Path>>(filepath: P) -> Result<Self>
Load cycle from CSV file, parsing name from filepath
sourcepub fn from_csv_str<S: AsRef<str>>(csv_str: S, name: String) -> Result<Self>
pub fn from_csv_str<S: AsRef<str>>(csv_str: S, name: String) -> Result<Self>
Load cycle from CSV string
pub fn build_cache(&self) -> RustCycleCache
pub fn push(&mut self, cyc_elem: RustCycleElement)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn is_sorted(&self) -> bool
pub fn are_fields_equal_length(&self) -> bool
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>
) -> Result<(f64, usize)>
pub fn modify_with_braking_trajectory( &mut self, brake_accel_m_per_s2: f64, i: usize, dts_m: Option<f64> ) -> Result<(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 delta_elev_m(&self) -> Array1<f64>
pub fn delta_elev_m(&self) -> Array1<f64>
elevation change w.r.t. to initial
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 for RustCycle
impl PartialEq for RustCycle
source§impl SerdeAPI for RustCycle
impl SerdeAPI for RustCycle
source§fn from_str<S: AsRef<str>>(contents: S, format: &str) -> Result<Self>
fn from_str<S: AsRef<str>>(contents: S, format: &str) -> Result<Self>
Note that using this method to instantiate a RustCycle from CSV, rather
than the from_csv_str method, sets the cycle name to an empty string
const ACCEPTED_BYTE_FORMATS: &'static [&'static str] = _
const ACCEPTED_STR_FORMATS: &'static [&'static str] = _
const CACHE_FOLDER: &'static str = _
fn to_writer<W: Write>(&self, wtr: W, format: &str) -> Result<()>
source§fn to_str(&self, format: &str) -> Result<String>
fn to_str(&self, format: &str) -> Result<String>
Write (serialize) an object into a string Read more
source§fn from_reader<R: Read>(rdr: R, format: &str) -> Result<Self>
fn from_reader<R: Read>(rdr: R, format: &str) -> Result<Self>
Deserialize an object from anything that implements
std::io::Read Read moresource§fn from_resource<P: AsRef<Path>>(filepath: P) -> Result<Self>
fn from_resource<P: AsRef<Path>>(filepath: P) -> Result<Self>
Read (deserialize) an object from a resource file packaged with the
fastsim-core crate Read moresource§fn to_file<P: AsRef<Path>>(&self, filepath: P) -> Result<()>
fn to_file<P: AsRef<Path>>(&self, filepath: P) -> Result<()>
Write (serialize) an object to a file.
Supported file extensions are listed in
ACCEPTED_BYTE_FORMATS.
Creates a new file if it does not already exist, otherwise truncates the existing file. Read moresource§fn from_file<P: AsRef<Path>>(filepath: P) -> Result<Self>
fn from_file<P: AsRef<Path>>(filepath: P) -> Result<Self>
Read (deserialize) an object from a file.
Supported file extensions are listed in
ACCEPTED_BYTE_FORMATS. Read moresource§fn from_json<S: AsRef<str>>(json_str: S) -> Result<Self>
fn from_json<S: AsRef<str>>(json_str: S) -> Result<Self>
Read (deserialize) an object to a JSON string Read more
source§fn from_yaml<S: AsRef<str>>(yaml_str: S) -> Result<Self>
fn from_yaml<S: AsRef<str>>(yaml_str: S) -> Result<Self>
Read (deserialize) an object from a YAML string Read more
source§fn from_bincode(encoded: &[u8]) -> Result<Self>
fn from_bincode(encoded: &[u8]) -> Result<Self>
Read (deserialize) an object from bincode-encoded bytes Read more
source§fn from_url<S: AsRef<str>>(url: S) -> Result<Self>
fn from_url<S: AsRef<str>>(url: S) -> Result<Self>
Instantiates an object from a url. Accepts yaml and json file types Read more
source§fn to_cache<P: AsRef<Path>>(&self, file_path: P) -> Result<()>
fn to_cache<P: AsRef<Path>>(&self, file_path: P) -> Result<()>
Takes an instantiated Rust object and saves it in the FASTSim data directory in
a rust_objects folder.
WARNING: If there is a file already in the data subdirectory with the same name, it will be replaced by the new file. Read more
WARNING: If there is a file already in the data subdirectory with the same name, it will be replaced by the new file. Read more
source§fn from_cache<P: AsRef<Path>>(file_path: P) -> Result<Self>
fn from_cache<P: AsRef<Path>>(file_path: P) -> Result<Self>
Instantiates a Rust object from the subdirectory within the FASTSim data
directory corresponding to the Rust Object (“vehices” for a RustVehice,
“cycles” for a RustCycle, and the root folder of the data directory for
all other objects). Read more
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