Skip to content

Commit

Permalink
getting rid of interpolator wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
robinsteuteville committed Aug 16, 2024
1 parent 7b345b2 commit e493e1e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion fastsim-core/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ macro_rules! impl_get_set_eff_range {
];
let eff_interp_fwd = self.eff_interp_fwd.0;
eff_interp_fwd.set_f_x(f_x)?;
self.eff_interp_fwd = InterpolatorWrapper(eff_interp_fwd);
self.eff_interp_fwd = eff_interp_fwd;
Ok(())
} else if (0.0..=1.0).contains(&eff_range) {
let old_min = self.get_eff_min();
Expand Down
10 changes: 4 additions & 6 deletions fastsim-core/src/vehicle/powertrain/electric_machine.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Module for electric machine (i.e. bidirectional electromechanical device), generator, or motor

use utils::interp::InterpolatorWrapper;

use super::*;

#[allow(unused_imports)]
Expand Down Expand Up @@ -68,12 +66,12 @@ pub struct ElectricMachine {
#[api(skip_set)]
/// 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::InterpolatorWrapper,
pub eff_interp_fwd: utils::interp::Interpolator,
#[serde(skip)]
#[api(skip_set)]
// 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::InterpolatorWrapper>,
pub eff_interp_bwd: Option<utils::interp::Interpolator>,
/// Electrical input power fraction array at which efficiencies are evaluated.
/// Calculated during runtime if not provided.
#[serde(skip)]
Expand Down Expand Up @@ -152,7 +150,7 @@ impl ElectricMachine {
.map(|(x, y)| x / y)
.collect(),
);
self.eff_interp_bwd = Some(InterpolatorWrapper(eff_interp_bwd));
self.eff_interp_bwd = Some(eff_interp_bwd);
// self.set_pwr_in_frac_interp()
// .with_context(|| format_dbg!())?;
}
Expand Down Expand Up @@ -342,7 +340,7 @@ impl Init for ElectricMachine {
.map(|(x, y)| x / y)
.collect(),
);
self.eff_interp_bwd = Some(InterpolatorWrapper(eff_interp_bwd));
self.eff_interp_bwd = Some(eff_interp_bwd);
// self.set_pwr_in_frac_interp()
// .with_context(|| format_dbg!())?;
}
Expand Down
2 changes: 1 addition & 1 deletion fastsim-core/src/vehicle/powertrain/fuel_converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub struct FuelConverter {
pub pwr_ramp_lag: si::Time,
/// interpolator for calculating [Self] efficiency as a function of output power
#[api(skip_get, skip_set)]
pub eff_interp_from_pwr_out: utils::interp::InterpolatorWrapper,
pub eff_interp_from_pwr_out: utils::interp::Interpolator,
/// idle fuel power to overcome internal friction (not including aux load) \[W\]
#[serde(rename = "pwr_idle_fuel_watts")]
pub pwr_idle_fuel: si::Power,
Expand Down
6 changes: 3 additions & 3 deletions fastsim-core/src/vehicle/vehicle_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl TryFrom<&fastsim_2::vehicle::RustVehicle> for PowertrainType {
},
em: ElectricMachine {
state: Default::default(),
eff_interp_fwd: InterpolatorWrapper(Interpolator::Interp1D(
eff_interp_fwd: (Interpolator::Interp1D(
Interp1D::new(
f2veh.mc_pwr_out_perc.to_vec(),
f2veh.mc_eff_array.to_vec(),
Expand All @@ -385,7 +385,7 @@ impl TryFrom<&fastsim_2::vehicle::RustVehicle> for PowertrainType {
)
.unwrap(),
)),
eff_interp_bwd: Some(InterpolatorWrapper(Interpolator::Interp1D(
eff_interp_bwd: Some(Interpolator::Interp1D(
Interp1D::new(
// before adding the interpolator, pwr_in_frac_interp was set as Default::default(), can this
// be transferred over as done here, or does a new defualt need to be defined?
Expand All @@ -396,7 +396,7 @@ impl TryFrom<&fastsim_2::vehicle::RustVehicle> for PowertrainType {
Extrapolate::Error,
)
.unwrap(),
))),
)),
// pwr_in_frac_interp: Default::default(),
pwr_out_max: f2veh.mc_max_kw * uc::KW,
specific_pwr: None,
Expand Down

0 comments on commit e493e1e

Please sign in to comment.