Skip to content

Commit

Permalink
as_ref wins the day. working through more errors
Browse files Browse the repository at this point in the history
  • Loading branch information
calbaker committed Aug 16, 2024
1 parent 06c9a7d commit c484c65
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions fastsim-core/src/simdrive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,13 @@ impl SimDrive {
log::debug!("{}", format_dbg!(vs.all_curr_pwr_met));
*self.cyc.grade.get(i).with_context(|| format_dbg!())?
} else {
&self
.cyc
.grade_interp
.with_context(|| format_dbg!("You might have somehow bypassed `init()`"))?
.interpolate(&[vs.dist.get::<si::meter>()])?
* *uc::R
uc::R
* self
.cyc
.grade_interp
.as_ref()
.with_context(|| format_dbg!("You might have somehow bypassed `init()`"))?
.interpolate(&[vs.dist.get::<si::meter>()])?
};

let mass = self.veh.mass.with_context(|| {
Expand Down
6 changes: 3 additions & 3 deletions fastsim-core/src/vehicle/powertrain/electric_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ pub struct ElectricMachine {
/// directionally symmetrical.
// /// this is x-data that will how be in eff_interp_fwd
// pub pwr_out_frac_interp: Vec<f64>,
#[api(skip_set)]
#[api(skip_set, skip_get)]
/// Efficiency array corresponding to [Self::pwr_out_frac_interp] and [Self::pwr_in_frac_interp]
/// eff_interp_fwd and eff_interp_bwd have the same f_x but different x
pub eff_interp_fwd: utils::interp::Interpolator,
#[serde(skip)]
#[api(skip_set)]
#[api(skip_set, skip_get)]
// if it is not provided, needs to be set during init, can figure out what to do
// for that by looking at how pwr_in_frac_interp is initialized
pub eff_interp_bwd: Option<utils::interp::Interpolator>,
Expand Down Expand Up @@ -204,7 +204,7 @@ impl ElectricMachine {

// maximum power in forward direction is minimum of component `pwr_out_max` parameter or time-varying max
// power based on what the ReversibleEnergyStorage can provide
self.state.pwr_mech_fwd_out_max = self.pwr_out_max.min(pwr_in_fwd_max * eff_fwd);
self.state.pwr_mech_fwd_out_max = self.pwr_out_max.min(pwr_in_fwd_max * eff_pos);
// maximum power in backward direction is minimum of component `pwr_out_max` parameter or time-varying max
// power in bacward direction (i.e. regen) based on what the ReversibleEnergyStorage can provide
self.state.pwr_mech_bwd_out_max = self.pwr_out_max.min(pwr_in_bwd_max / eff_neg);
Expand Down

0 comments on commit c484c65

Please sign in to comment.