Skip to content

Reusable code for component efficiencies#279

Open
kylecarow wants to merge 41 commits into
fastsim-3from
f3/efficiency
Open

Reusable code for component efficiencies#279
kylecarow wants to merge 41 commits into
fastsim-3from
f3/efficiency

Conversation

@kylecarow

@kylecarow kylecarow commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Part of #287

Merge first, or rebase this branch:

  1. Unlink PyO3 versions between FASTSim-2 and FASTSim-3 #265
  2. F3/docs/demos #267

Creates reusable code to implement on types like RESEfficiency that check range of data, interpolated point result, and delegate to underlying interpolator appropriately. Avoids a lot of repeated boilerplate for efficiency enums.

Renames EffInterp, so this has implications for downstream Rust projects. Since we are bumping to 3.1.0 soon, I dont have a problem with this - we should suggest downstream project Rust users pin to a minor version:

[dependencies]
fastsim-core = "~3.1.0"  # Allows 3.1.0, 3.1.1, etc., but never 3.2.0

in this way we can keep the major version 3 and leave breaking changes to increments of minor versions, rather than making a million major versions.

Whereas before this would have a lot of matching code to call underlying interpolators:

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, IsVariant, TryInto)]
/// Determines what [ReversibleEnergyStorage] state variables to use in calculating efficiency
pub enum RESEfficiency {
    /// Efficiency is constant
    Constant(Interp0D<f64>),
    /// Efficiency = f(C-rate)
    CRate(Interp1DOwned<f64, strategy::enums::Strategy1DEnum>),
    /// Efficiency = f(C-rate, soc, temperature)
    CRateSOCTemperature(Interp3DOwned<f64, strategy::enums::Strategy3DEnum>),
    /// Efficiency = f(C-rate, temperature)
    CRateTemperature(Interp2DOwned<f64, strategy::enums::Strategy2DEnum>),
    /// Efficiency = f(C-rate, soc)
    CRateSOC(Interp2DOwned<f64, strategy::enums::Strategy2DEnum>),
    // TODO: finish adding possible variants
}

It now only needs this to implement interpolator methods, which have extra validation code and delegate to the contained interpolator. All other min/max/etc methods are implemented by this automatically too.

impl_efficiency_enum!(RESEfficiency {
    Constant,
    CRate,
    CRateSOCTemperature,
    CRateTemperature,
    CRateSOC,
});

This will make it easier to make e.g. FCEfficiency, EMEfficiency types.

kylecarow and others added 30 commits June 29, 2026 18:10
Updated Anaconda setup instructions to specify environment name and include pip upgrade.
… started to use plotly and new demo conventions, small tweak to test demos to render plots as JSON (replacement for SHOW_PLOTS)
updated getting started demo with mines demo content, updated getting…
…st using pytest --nbmake (which is set to run by default in pyproject.toml with parallelization - you may need to reinstall dev dependencies before use)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant