Skip to content

Commit

Permalink
added __new__ method, deleted deprecated comments, formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
calbaker committed Jan 23, 2025
1 parent 9914ea1 commit 442c430
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 49 deletions.
4 changes: 4 additions & 0 deletions fastsim-core/src/gas_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ lazy_static! {
}

#[fastsim_api(
#[new]
fn __new__() -> Self {
Self{}
}
/// Returns density of air \[kg/m^3\]
/// Source: <https://www.grc.nasa.gov/WWW/K-12/rocket/atmosmet.html>
///
Expand Down
68 changes: 19 additions & 49 deletions fastsim-core/src/vehicle/powertrain/reversible_energy_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,69 +202,39 @@ impl ReversibleEnergyStorage {
)
);
}
// state.eff = match (&self.eff_interp, &self.eff_interp_inputs) {
// (Interpolator::Interp0D(eff), RESEffInterpInputs::Constant) => *eff * uc::R,
// (Interpolator::Interp1D(interp1d), RESEffInterpInputs::CRate) => {
// interp1d.interpolate(&[state.pwr_out_electrical.get::<si::watt>()
// / self.energy_capacity.get::<si::watt_hour>()])?
// * uc::R
// }
// (Interpolator::Interp2D(interp2d), RESEffInterpInputs::CRateSOC) => {
// interp2d.interpolate(&[
// state.pwr_out_electrical.get::<si::watt>()
// / self.energy_capacity.get::<si::watt_hour>(),
// state.soc.get::<si::ratio>(),
// ])? * uc::R
// }
// (Interpolator::Interp2D(interp2d), RESEffInterpInputs::CRateTemperature) => {
// interp2d.interpolate(&[
// state.pwr_out_electrical.get::<si::watt>()
// / self.energy_capacity.get::<si::watt_hour>(),
// te_res
// .with_context(|| format_dbg!("Expected thermal model to be configured."))?
// .get::<si::degree_celsius>(),
// ])? * uc::R
// }
// (Interpolator::Interp3D(interp3d), RESEffInterpInputs::CRateSOCTemperature) => {
// interp3d.interpolate(&[
// state.pwr_out_electrical.get::<si::watt>()
// / self.energy_capacity.get::<si::watt_hour>(),
// state.soc.get::<si::ratio>(),
// te_res
// .with_context(|| format_dbg!("Expected thermal model to be configured"))?
// .get::<si::degree_celsius>(),
// ])? * uc::R
// }
// _ => bail!(
// "
// Invalid or not yet enabled interpolator config.
// See docs for `ReversibleEnergyStorage::eff_interp` an `ReversibleEnergyStorage::eff_interp_inputs`"
// ),
let interp_pt: &[f64] = match (&self.eff_interp, &self.eff_interp_inputs) {
(Interpolator::Interp0D(..), RESEffInterpInputs::Constant) => &[],
(Interpolator::Interp1D(..), RESEffInterpInputs::CRate) => &[state.pwr_out_electrical.get::<si::watt>() / self.energy_capacity.get::<si::watt_hour>()],
(Interpolator::Interp1D(..), RESEffInterpInputs::CRate) => {
&[state.pwr_out_electrical.get::<si::watt>()
/ self.energy_capacity.get::<si::watt_hour>()]
}
(Interpolator::Interp2D(..), RESEffInterpInputs::CRateSOC) => &[
state.pwr_out_electrical.get::<si::watt>() / self.energy_capacity.get::<si::watt_hour>(),
state.pwr_out_electrical.get::<si::watt>()
/ self.energy_capacity.get::<si::watt_hour>(),
state.soc.get::<si::ratio>(),
],
(Interpolator::Interp2D(..), RESEffInterpInputs::CRateTemperature) => &[
state.pwr_out_electrical.get::<si::watt>() / self.energy_capacity.get::<si::watt_hour>(),
state.pwr_out_electrical.get::<si::watt>()
/ self.energy_capacity.get::<si::watt_hour>(),
te_res
.with_context(|| format_dbg!("Expected thermal model to be configured"))?
.get::<si::kelvin>() - uc::CELSIUS_TO_KELVIN.value,
.get::<si::kelvin>()
- uc::CELSIUS_TO_KELVIN.value,
],
(Interpolator::Interp3D(..), RESEffInterpInputs::CRateSOCTemperature) => &[
state.pwr_out_electrical.get::<si::watt>(),
state.pwr_out_electrical.get::<si::watt>()
/ self.energy_capacity.get::<si::watt_hour>(),
state.soc.get::<si::ratio>(),
te_res
.with_context(|| format_dbg!("Expected thermal model to be configured"))?
.get::<si::kelvin>() - uc::CELSIUS_TO_KELVIN.value,
.get::<si::kelvin>()
- uc::CELSIUS_TO_KELVIN.value,
],
_ => bail!(
"
Invalid or not yet enabled interpolator config.
See docs for `ReversibleEnergyStorage::eff_interp` an `ReversibleEnergyStorage::eff_interp_inputs`"
),
_ => bail!(
"
Invalid or not yet enabled interpolator config.
See docs for `ReversibleEnergyStorage::eff_interp` an `ReversibleEnergyStorage::eff_interp_inputs`"
),
};
state.eff = self.eff_interp.interpolate(interp_pt)? * uc::R;
ensure!(
Expand Down

0 comments on commit 442c430

Please sign in to comment.