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: bool

Implementations§

source§

impl RustCycle

pure Rust methods that need to be separate due to pymethods incompatibility

source

pub fn new( time_s: Vec<f64>, mps: Vec<f64>, grade: Vec<f64>, road_type: Vec<f64>, name: String ) -> Self

source

pub fn build_cache(&self) -> RustCycleCache

source

pub fn push(&mut self, cyc_elem: RustCycleElement)

source

pub fn len(&self) -> usize

source

pub fn test_cyc() -> Self

source

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]]
source

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
source

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)
source

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
source

pub fn dt_s(&self) -> Array1<f64>

rust-internal time steps

source

pub fn dt_s_at_i(&self, i: usize) -> f64

rust-internal time steps at i

source

pub fn dist_m(&self) -> Array1<f64>

distance covered in each time step

source

pub fn mph_at_i(&self, i: usize) -> f64

get mph from self.mps

source

pub fn from_csv_file(pathstr: &str) -> Result<Self, Error>

Load cycle from csv file

source

pub fn delta_elev_m(&self) -> Array1<f64>

elevation change w.r.t. to initial

source

pub fn from_csv_string(data: &str, name: String) -> Result<Self, Error>

Trait Implementations§

source§

impl Clone for RustCycle

source§

fn clone(&self) -> RustCycle

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RustCycle

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for RustCycle

source§

fn default() -> RustCycle

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for RustCycle

source§

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

source§

fn eq(&self, other: &RustCycle) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl SerdeAPI for RustCycle

source§

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 init(&mut self) -> Result<()>

runs any initialization steps that might be needed
source§

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_json(&self) -> String

json serialization method.
source§

fn from_json(json_str: &str) -> Result<Self, Error>

json deserialization method.
source§

fn to_yaml(&self) -> String

yaml serialization method.
source§

fn from_yaml(yaml_str: &str) -> Result<Self, Error>

yaml deserialization method.
source§

fn to_bincode(&self) -> Vec<u8>

bincode serialization method.
source§

fn from_bincode(encoded: &[u8]) -> Result<Self, Error>

bincode deserialization method.
source§

impl Serialize for RustCycle

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for RustCycle

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

source§

impl<T> DeserializeOwnedAlias for Twhere T: DeserializeOwned,

source§

impl<T> SendAlias for T

§

impl<T> SendSyncUnwindSafe for Twhere T: Send + Sync + UnwindSafe + ?Sized,

source§

impl<T> SerializeAlias for Twhere T: Serialize,

source§

impl<T> SyncAlias for T