Struct fastsim_core::simdrive::RustSimDrive
source · pub struct RustSimDrive {Show 124 fields
pub hev_sim_count: usize,
pub veh: RustVehicle,
pub cyc: RustCycle,
pub cyc0: RustCycle,
pub sim_params: RustSimDriveParams,
pub props: RustPhysicalProperties,
pub i: usize,
pub cur_max_fs_kw_out: Array1<f64>,
pub fc_trans_lim_kw: Array1<f64>,
pub fc_fs_lim_kw: Array1<f64>,
pub fc_max_kw_in: Array1<f64>,
pub cur_max_fc_kw_out: Array1<f64>,
pub ess_cap_lim_dischg_kw: Array1<f64>,
pub cur_ess_max_kw_out: Array1<f64>,
pub cur_max_avail_elec_kw: Array1<f64>,
pub ess_cap_lim_chg_kw: Array1<f64>,
pub cur_max_ess_chg_kw: Array1<f64>,
pub cur_max_elec_kw: Array1<f64>,
pub mc_elec_in_lim_kw: Array1<f64>,
pub mc_transi_lim_kw: Array1<f64>,
pub cur_max_mc_kw_out: Array1<f64>,
pub ess_lim_mc_regen_perc_kw: Array1<f64>,
pub ess_lim_mc_regen_kw: Array1<f64>,
pub cur_max_mech_mc_kw_in: Array1<f64>,
pub cur_max_trans_kw_out: Array1<f64>,
pub cyc_trac_kw_req: Array1<f64>,
pub cur_max_trac_kw: Array1<f64>,
pub spare_trac_kw: Array1<f64>,
pub cyc_whl_rad_per_sec: Array1<f64>,
pub cyc_tire_inertia_kw: Array1<f64>,
pub cyc_whl_kw_req: Array1<f64>,
pub regen_contrl_lim_kw_perc: Array1<f64>,
pub cyc_regen_brake_kw: Array1<f64>,
pub cyc_fric_brake_kw: Array1<f64>,
pub cyc_trans_kw_out_req: Array1<f64>,
pub cyc_met: Array1<bool>,
pub trans_kw_out_ach: Array1<f64>,
pub trans_kw_in_ach: Array1<f64>,
pub cur_soc_target: Array1<f64>,
pub min_mc_kw_2help_fc: Array1<f64>,
pub mc_mech_kw_out_ach: Array1<f64>,
pub mc_elec_kw_in_ach: Array1<f64>,
pub aux_in_kw: Array1<f64>,
pub impose_coast: Array1<bool>,
pub roadway_chg_kw_out_ach: Array1<f64>,
pub min_ess_kw_2help_fc: Array1<f64>,
pub ess_kw_out_ach: Array1<f64>,
pub fc_kw_out_ach: Array1<f64>,
pub fc_kw_out_ach_pct: Array1<f64>,
pub fc_kw_in_ach: Array1<f64>,
pub fs_kw_out_ach: Array1<f64>,
pub fs_kwh_out_ach: Array1<f64>,
pub ess_cur_kwh: Array1<f64>,
pub soc: Array1<f64>,
pub regen_buff_soc: Array1<f64>,
pub ess_regen_buff_dischg_kw: Array1<f64>,
pub max_ess_regen_buff_chg_kw: Array1<f64>,
pub ess_accel_buff_chg_kw: Array1<f64>,
pub accel_buff_soc: Array1<f64>,
pub max_ess_accell_buff_dischg_kw: Array1<f64>,
pub ess_accel_regen_dischg_kw: Array1<f64>,
pub mc_elec_in_kw_for_max_fc_eff: Array1<f64>,
pub elec_kw_req_4ae: Array1<f64>,
pub can_pwr_all_elec: Array1<bool>,
pub desired_ess_kw_out_for_ae: Array1<f64>,
pub ess_ae_kw_out: Array1<f64>,
pub er_ae_kw_out: Array1<f64>,
pub ess_desired_kw_4fc_eff: Array1<f64>,
pub ess_kw_if_fc_req: Array1<f64>,
pub cur_max_mc_elec_kw_in: Array1<f64>,
pub fc_kw_gap_fr_eff: Array1<f64>,
pub er_kw_if_fc_req: Array1<f64>,
pub mc_elec_kw_in_if_fc_req: Array1<f64>,
pub mc_kw_if_fc_req: Array1<f64>,
pub fc_forced_on: Array1<bool>,
pub fc_forced_state: Array1<u32>,
pub mc_mech_kw_4forced_fc: Array1<f64>,
pub fc_time_on: Array1<f64>,
pub prev_fc_time_on: Array1<f64>,
pub mps_ach: Array1<f64>,
pub mph_ach: Array1<f64>,
pub dist_m: Array1<f64>,
pub dist_mi: Array1<f64>,
pub high_acc_fc_on_tag: Array1<bool>,
pub reached_buff: Array1<bool>,
pub max_trac_mps: Array1<f64>,
pub add_kwh: Array1<f64>,
pub dod_cycs: Array1<f64>,
pub ess_perc_dead: Array1<f64>,
pub drag_kw: Array1<f64>,
pub ess_loss_kw: Array1<f64>,
pub accel_kw: Array1<f64>,
pub ascent_kw: Array1<f64>,
pub rr_kw: Array1<f64>,
pub cur_max_roadway_chg_kw: Array1<f64>,
pub trace_miss_iters: Array1<u32>,
pub newton_iters: Array1<u32>,
pub fuel_kj: f64,
pub ess_dischg_kj: f64,
pub energy_audit_error: f64,
pub mpgge: f64,
pub roadway_chg_kj: f64,
pub battery_kwh_per_mi: f64,
pub electric_kwh_per_mi: f64,
pub ess2fuel_kwh: f64,
pub drag_kj: f64,
pub ascent_kj: f64,
pub rr_kj: f64,
pub brake_kj: f64,
pub trans_kj: f64,
pub mc_kj: f64,
pub ess_eff_kj: f64,
pub aux_kj: f64,
pub fc_kj: f64,
pub net_kj: f64,
pub ke_kj: f64,
pub trace_miss: bool,
pub trace_miss_dist_frac: f64,
pub trace_miss_time_frac: f64,
pub trace_miss_speed_mps: f64,
pub orphaned: bool,
pub coast_delay_index: Array1<i32>,
pub idm_target_speed_m_per_s: Array1<f64>,
pub cyc0_cache: RustCycleCache,
}Fields§
§hev_sim_count: usize§veh: RustVehicle§cyc: RustCycle§cyc0: RustCycle§sim_params: RustSimDriveParams§props: RustPhysicalProperties§i: usize§cur_max_fs_kw_out: Array1<f64>§fc_trans_lim_kw: Array1<f64>§fc_fs_lim_kw: Array1<f64>§fc_max_kw_in: Array1<f64>§cur_max_fc_kw_out: Array1<f64>§ess_cap_lim_dischg_kw: Array1<f64>§cur_ess_max_kw_out: Array1<f64>§cur_max_avail_elec_kw: Array1<f64>§ess_cap_lim_chg_kw: Array1<f64>§cur_max_ess_chg_kw: Array1<f64>§cur_max_elec_kw: Array1<f64>§mc_elec_in_lim_kw: Array1<f64>§mc_transi_lim_kw: Array1<f64>§cur_max_mc_kw_out: Array1<f64>§ess_lim_mc_regen_perc_kw: Array1<f64>§ess_lim_mc_regen_kw: Array1<f64>§cur_max_mech_mc_kw_in: Array1<f64>§cur_max_trans_kw_out: Array1<f64>§cyc_trac_kw_req: Array1<f64>§cur_max_trac_kw: Array1<f64>§spare_trac_kw: Array1<f64>§cyc_whl_rad_per_sec: Array1<f64>§cyc_tire_inertia_kw: Array1<f64>§cyc_whl_kw_req: Array1<f64>§regen_contrl_lim_kw_perc: Array1<f64>§cyc_regen_brake_kw: Array1<f64>§cyc_fric_brake_kw: Array1<f64>§cyc_trans_kw_out_req: Array1<f64>§cyc_met: Array1<bool>§trans_kw_out_ach: Array1<f64>§trans_kw_in_ach: Array1<f64>§cur_soc_target: Array1<f64>§min_mc_kw_2help_fc: Array1<f64>§mc_mech_kw_out_ach: Array1<f64>§mc_elec_kw_in_ach: Array1<f64>§aux_in_kw: Array1<f64>§impose_coast: Array1<bool>§roadway_chg_kw_out_ach: Array1<f64>§min_ess_kw_2help_fc: Array1<f64>§ess_kw_out_ach: Array1<f64>§fc_kw_out_ach: Array1<f64>§fc_kw_out_ach_pct: Array1<f64>§fc_kw_in_ach: Array1<f64>§fs_kw_out_ach: Array1<f64>§fs_kwh_out_ach: Array1<f64>§ess_cur_kwh: Array1<f64>§soc: Array1<f64>§regen_buff_soc: Array1<f64>§ess_regen_buff_dischg_kw: Array1<f64>§max_ess_regen_buff_chg_kw: Array1<f64>§ess_accel_buff_chg_kw: Array1<f64>§accel_buff_soc: Array1<f64>§max_ess_accell_buff_dischg_kw: Array1<f64>§ess_accel_regen_dischg_kw: Array1<f64>§mc_elec_in_kw_for_max_fc_eff: Array1<f64>§elec_kw_req_4ae: Array1<f64>§can_pwr_all_elec: Array1<bool>§desired_ess_kw_out_for_ae: Array1<f64>§ess_ae_kw_out: Array1<f64>§er_ae_kw_out: Array1<f64>§ess_desired_kw_4fc_eff: Array1<f64>§ess_kw_if_fc_req: Array1<f64>§cur_max_mc_elec_kw_in: Array1<f64>§fc_kw_gap_fr_eff: Array1<f64>§er_kw_if_fc_req: Array1<f64>§mc_elec_kw_in_if_fc_req: Array1<f64>§mc_kw_if_fc_req: Array1<f64>§fc_forced_on: Array1<bool>§fc_forced_state: Array1<u32>§mc_mech_kw_4forced_fc: Array1<f64>§fc_time_on: Array1<f64>§prev_fc_time_on: Array1<f64>§mps_ach: Array1<f64>§mph_ach: Array1<f64>§dist_m: Array1<f64>§dist_mi: Array1<f64>§high_acc_fc_on_tag: Array1<bool>§reached_buff: Array1<bool>§max_trac_mps: Array1<f64>§add_kwh: Array1<f64>§dod_cycs: Array1<f64>§ess_perc_dead: Array1<f64>§drag_kw: Array1<f64>§ess_loss_kw: Array1<f64>§accel_kw: Array1<f64>§ascent_kw: Array1<f64>§rr_kw: Array1<f64>§cur_max_roadway_chg_kw: Array1<f64>§trace_miss_iters: Array1<u32>§newton_iters: Array1<u32>§fuel_kj: f64§ess_dischg_kj: f64§energy_audit_error: f64§mpgge: f64§roadway_chg_kj: f64§battery_kwh_per_mi: f64§electric_kwh_per_mi: f64§ess2fuel_kwh: f64§drag_kj: f64§ascent_kj: f64§rr_kj: f64§brake_kj: f64§trans_kj: f64§mc_kj: f64§ess_eff_kj: f64§aux_kj: f64§fc_kj: f64§net_kj: f64§ke_kj: f64§trace_miss: bool§trace_miss_dist_frac: f64§trace_miss_time_frac: f64§trace_miss_speed_mps: f64§orphaned: bool§coast_delay_index: Array1<i32>§idm_target_speed_m_per_s: Array1<f64>§cyc0_cache: RustCycleCacheImplementations§
source§impl RustSimDrive
impl RustSimDrive
sourcepub fn gap_to_lead_vehicle_m(&self) -> Array1<f64>
pub fn gap_to_lead_vehicle_m(&self) -> Array1<f64>
Provides the gap-with lead vehicle from start to finish
sourcepub fn activate_eco_cruise_rust(
&mut self,
by_microtrip: bool,
extend_fraction: f64,
blend_factor: f64,
min_target_speed_m_per_s: f64
) -> Result<(), Error>
pub fn activate_eco_cruise_rust( &mut self, by_microtrip: bool, extend_fraction: f64, blend_factor: f64, min_target_speed_m_per_s: f64 ) -> Result<(), Error>
Sets the intelligent driver model parameters for an eco-cruise driving trajectory. This is a convenience method instead of setting the sim_params.idm* parameters yourself.
- by_microtrip: bool, if True, target speed is set by microtrip, else by cycle
- extend_fraction: float, the fraction of time to extend the cycle to allow for catch-up of the following vehicle
- blend_factor: float, a value between 0 and 1; only used of by_microtrip is True, blends between microtrip average speed and microtrip average speed when moving. Must be between 0 and 1 inclusive
- min_target_speed_m_per_s: float, the minimum speed allowed by the eco-cruise algorithm Mutates the current SimDrive object for eco-cruise.
sourcepub fn next_speed_by_idm(
&mut self,
i: usize,
a_m_per_s2: f64,
b_m_per_s2: f64,
dt_headway_s: f64,
s0_m: f64,
v_desired_m_per_s: f64,
delta: f64
) -> f64
pub fn next_speed_by_idm( &mut self, i: usize, a_m_per_s2: f64, b_m_per_s2: f64, dt_headway_s: f64, s0_m: f64, v_desired_m_per_s: f64, delta: f64 ) -> f64
Calculate the next speed by the Intelligent Driver Model
- i: int, the index
- a_m_per_s2: number, max acceleration (m/s2)
- b_m_per_s2: number, max deceleration (m/s2)
- dt_headway_s: number, the headway between us and the lead vehicle in seconds
- s0_m: number, the initial gap between us and the lead vehicle in meters
- v_desired_m_per_s: number, the desired speed in (m/s)
- delta: number, a shape parameter; typical value is 4.0 RETURN: number, the next speed (m/s) REFERENCE: Treiber, Martin and Kesting, Arne. 2013. “Chapter 11: Car-Following Models Based on Driving Strategies”. Traffic Flow Dynamics: Data, Models and Simulation. Springer-Verlag. Springer, Berlin, Heidelberg. DOI: https://doi.org/10.1007/978-3-642-32460-4.
sourcepub fn set_speed_for_target_gap_using_idm(&mut self, i: usize)
pub fn set_speed_for_target_gap_using_idm(&mut self, i: usize)
Set gap
- i: non-negative integer, the step index RETURN: None EFFECTS:
- sets the next speed (m/s)
EQUATION:
parameters:
- v_desired: the desired speed (m/s)
- delta: number, typical value is 4.0
- a: max acceleration, (m/s2)
- b: max deceleration, (m/s2) s = d_lead - d dv/dt = a * (1 - (v/v_desired)**delta - (s_desired(v,v-v_lead)/s)**2) s_desired(v, dv) = s0 + max(0, vdt_headway + (v * dv)/(2.0 * sqrt(ab))) REFERENCE: Treiber, Martin and Kesting, Arne. 2013. “Chapter 11: Car-Following Models Based on Driving Strategies”. Traffic Flow Dynamics: Data, Models and Simulation. Springer-Verlag. Springer, Berlin, Heidelberg. DOI: https://doi.org/10.1007/978-3-642-32460-4
sourcepub fn set_speed_for_target_gap(&mut self, i: usize)
pub fn set_speed_for_target_gap(&mut self, i: usize)
- i: non-negative integer, the step index RETURN: None EFFECTS:
- sets the next speed (m/s)
sourcepub fn estimate_grade_for_step(&self, i: usize) -> f64
pub fn estimate_grade_for_step(&self, i: usize) -> f64
Provides a quick estimate for grade based only on the distance traveled at the start of the current step. If the grade is constant over the step, this is both quick and accurate. NOTE: If not allowing coasting (i.e., sim_params.coast_allow == False) and not allowing IDM/following (i.e., self.sim_params.idm_allow == False) then returns self.cyc.grade[i]
sourcepub fn lookup_grade_for_step(&self, i: usize, mps_ach: Option<f64>) -> f64
pub fn lookup_grade_for_step(&self, i: usize, mps_ach: Option<f64>) -> f64
For situations where cyc can deviate from cyc0, this method looks up and accurately interpolates what the average grade over the step should be. If mps_ach is not None, the mps_ach value is used to predict the distance traveled over the step. NOTE: If not allowing coasting (i.e., sim_params.coast_allow == False) and not allowing IDM/following (i.e., self.sim_params.idm_allow == False) then returns self.cyc.grade[i]
pub fn set_time_dilation(&mut self, i: usize) -> Result<(), Error>
source§impl RustSimDrive
impl RustSimDrive
pub fn new(cyc: RustCycle, veh: RustVehicle) -> Self
pub fn init_arrays(&mut self)
sourcepub fn sim_drive(
&mut self,
init_soc: Option<f64>,
aux_in_kw_override: Option<Array1<f64>>
) -> Result<(), Error>
pub fn sim_drive( &mut self, init_soc: Option<f64>, aux_in_kw_override: Option<Array1<f64>> ) -> Result<(), Error>
Initialize and run sim_drive_walk as appropriate for vehicle attribute vehPtType. Arguments
init_soc: initial SOC for electrified vehicles.
aux_in_kw: aux_in_kw override. Array of same length as cyc.time_s.
Default of None causes veh.aux_kw to be used.
pub fn sim_drive_accel( &mut self, init_soc: Option<f64>, aux_in_kw_override: Option<Array1<f64>> ) -> Result<(), Error>
sourcepub fn walk(
&mut self,
init_soc: f64,
aux_in_kw_override: Option<Array1<f64>>
) -> Result<(), Error>
pub fn walk( &mut self, init_soc: f64, aux_in_kw_override: Option<Array1<f64>> ) -> Result<(), Error>
Receives second-by-second cycle information, vehicle properties,
and an initial state of charge and runs sim_drive_step to perform a
backward facing powertrain simulation. Method sim_drive runs this
iteratively to achieve correct SOC initial and final conditions, as
needed.
Arguments
init_soc: initial battery state-of-charge (SOC) for electrified vehicles aux_in_kw: (Optional) aux_in_kw override. Array of same length as cyc.time_s. None causes veh.aux_kw to be used.
sourcepub fn init_for_step(
&mut self,
init_soc: f64,
aux_in_kw_override: Option<Array1<f64>>
) -> Result<(), Error>
pub fn init_for_step( &mut self, init_soc: f64, aux_in_kw_override: Option<Array1<f64>> ) -> Result<(), Error>
This is a specialty method which should be called prior to using sim_drive_step in a loop. Arguments
init_soc: initial battery state-of-charge (SOC) for electrified vehicles
aux_in_kw: aux_in_kw override. Array of same length as cyc.time_s.
Default of None causes veh.aux_kw to be used.
sourcepub fn solve_step(&mut self, i: usize) -> Result<(), Error>
pub fn solve_step(&mut self, i: usize) -> Result<(), Error>
Perform all the calculations to solve 1 time step.
sourcepub fn set_misc_calcs(&mut self, i: usize) -> Result<(), Error>
pub fn set_misc_calcs(&mut self, i: usize) -> Result<(), Error>
Sets misc. calculations at time step ‘i’ Arguments:
i: index of time step
sourcepub fn set_comp_lims(&mut self, i: usize) -> Result<(), Error>
pub fn set_comp_lims(&mut self, i: usize) -> Result<(), Error>
Sets component limits for time step ‘i’ Arguments
i: index of time step initSoc: initial SOC for electrified vehicles
sourcepub fn set_power_calcs(&mut self, i: usize) -> Result<(), Error>
pub fn set_power_calcs(&mut self, i: usize) -> Result<(), Error>
Calculate power requirements to meet cycle and determine if cycle can be met. Arguments
i: index of time step
pub fn set_ach_speed(&mut self, i: usize) -> Result<(), Error>
sourcepub fn set_hybrid_cont_calcs(&mut self, i: usize) -> Result<(), Error>
pub fn set_hybrid_cont_calcs(&mut self, i: usize) -> Result<(), Error>
Hybrid control calculations. Arguments
i: index of time step
sourcepub fn set_fc_forced_state_rust(&mut self, i: usize) -> Result<(), Error>
pub fn set_fc_forced_state_rust(&mut self, i: usize) -> Result<(), Error>
Calculate control variables related to engine on/off state Arguments
i: index of time step
sourcepub fn set_hybrid_cont_decisions(&mut self, i: usize) -> Result<(), Error>
pub fn set_hybrid_cont_decisions(&mut self, i: usize) -> Result<(), Error>
Hybrid control decisions. Arguments
i: index of time step
sourcepub fn set_fc_power(&mut self, i: usize) -> Result<(), Error>
pub fn set_fc_power(&mut self, i: usize) -> Result<(), Error>
Sets power consumption values for the current time step. Arguments
i: index of time step
sourcepub fn set_post_scalars(&mut self) -> Result<(), Error>
pub fn set_post_scalars(&mut self) -> Result<(), Error>
Sets scalar variables that can be calculated after a cycle is run. This includes mpgge, various energy metrics, and others
Trait Implementations§
source§impl Clone for RustSimDrive
impl Clone for RustSimDrive
source§fn clone(&self) -> RustSimDrive
fn clone(&self) -> RustSimDrive
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for RustSimDrive
impl Debug for RustSimDrive
source§impl<'de> Deserialize<'de> for RustSimDrive
impl<'de> Deserialize<'de> for RustSimDrive
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>,
source§impl PartialEq<RustSimDrive> for RustSimDrive
impl PartialEq<RustSimDrive> for RustSimDrive
source§fn eq(&self, other: &RustSimDrive) -> bool
fn eq(&self, other: &RustSimDrive) -> bool
self and other values to be equal, and is used
by ==.