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

Implementations§

Source§

impl RustCycle

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

Source

pub fn from_csv_file<P: AsRef<Path>>( filepath: P, skip_init: bool, ) -> Result<Self>

Load cycle from CSV file, parsing name from filepath

Source

pub fn from_csv_str<S: AsRef<str>>( csv_str: S, name: String, skip_init: bool, ) -> Result<Self>

Load cycle from CSV string

Source

pub fn to_csv(&self) -> Result<String>

Write (serialize) cycle to a CSV string

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 is_empty(&self) -> bool

Source

pub fn is_sorted(&self) -> bool

Source

pub fn are_fields_equal_length(&self) -> bool

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>, ) -> Result<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>, ) -> 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
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 delta_elev_m(&self) -> Array1<f64>

elevation change w.r.t. to initial

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 From<RustCycle> for HashMap<String, Vec<f64>>

Source§

fn from(cyc: RustCycle) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for RustCycle

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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_str<S: AsRef<str>>( contents: S, format: &str, skip_init: bool, ) -> 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

Source§

const ACCEPTED_BYTE_FORMATS: &'static [&'static str]

Source§

const ACCEPTED_STR_FORMATS: &'static [&'static str]

Source§

const RESOURCE_PREFIX: &'static str = "cycles"

Source§

const CACHE_FOLDER: &'static str = "cycles"

Source§

fn init(&mut self) -> Result<()>

Specialized code to execute upon initialization
Source§

fn to_writer<W: Write>(&self, wtr: W, format: &str) -> Result<()>

Source§

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, skip_init: bool) -> Result<Self>

Deserialize an object from anything that implements std::io::Read Read more
Source§

fn list_resources() -> Vec<String>

List available (compiled) resources (stored in the rust binary) Read more
Source§

fn from_resource<P: AsRef<Path>>(filepath: P, skip_init: bool) -> Result<Self>

Read (deserialize) an object from a resource file packaged with the fastsim-core crate Read more
Source§

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 more
Source§

fn from_file<P: AsRef<Path>>(filepath: P, skip_init: bool) -> Result<Self>

Read (deserialize) an object from a file. Supported file extensions are listed in ACCEPTED_BYTE_FORMATS. Read more
Source§

fn to_json(&self) -> Result<String>

Write (serialize) an object to a JSON string
Source§

fn from_json<S: AsRef<str>>(json_str: S, skip_init: bool) -> Result<Self>

Read (deserialize) an object to a JSON string Read more
Source§

fn to_yaml(&self) -> Result<String>

Write (serialize) an object to a YAML string
Source§

fn from_yaml<S: AsRef<str>>(yaml_str: S, skip_init: bool) -> Result<Self>

Read (deserialize) an object from a YAML string Read more
Source§

fn to_toml(&self) -> Result<String>

Source§

fn from_toml<S: AsRef<str>>(toml_str: S, skip_init: bool) -> Result<Self>

Source§

fn from_url<S: AsRef<str>>(url: S, skip_init: bool) -> 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<()>

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
Source§

fn from_cache<P: AsRef<Path>>(file_path: P, skip_init: bool) -> 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
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 TryFrom<HashMap<String, Vec<f64>>> for RustCycle

Source§

type Error = Error

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

fn try_from(hashmap: HashMap<String, Vec<f64>>) -> Result<Self>

Performs the conversion.
Source§

impl StructuralPartialEq for RustCycle

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

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

Source§

impl<T> DeserializeOwnedAlias for T

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> SendAlias for T

Source§

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

Source§

impl<T> SerializeAlias for T
where T: Serialize,

Source§

impl<T> SyncAlias for T