Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
calbaker committed Jan 14, 2025
1 parent dfac71c commit 1d21dd2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
16 changes: 8 additions & 8 deletions cal_and_val/thermal/cal_hev.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
"""
# # TODO Calibration Tasks
# - [x] put vehicle test data in a sharepoint folder, grant Robin access, and paste link in here
# - [ ] develop means of skewing curves via setter or similar
# - [ ] develop means of skewing curves via setter or similar -- Kyle is doing this
# - [ ] show what signals should be used for objectives
# - [x] and how to access them in code
# - [ ] play with things in the meantime

# critical import
from pathlib import Path
Expand All @@ -26,6 +25,7 @@
# TODO: Kyle or Robin:
# - [ ] in the `./f3-vehicles`, reduce all ~100 element arrays to just the ~10
# element arrays,
# - [ ] for FC, grab Atkinson efficiency map from fastsim-2
# - [x] and make sure linear interpolation is used
# - [ ] make sure temp- and current/c-rate-dependent battery efficiency interp is being used
veh = fsim.Vehicle.from_file(Path(__file__).parent / "f3-vehicles/2021_Hyundai_Sonata_Hybrid_Blue.yaml")
Expand Down Expand Up @@ -95,9 +95,9 @@

# Setup model objectives
## Parameter Functions
def new_em_eff_peak(sd_dict, new_eff_peak):
def new_em_eff_max(sd_dict, new_eff_peak):
"""
Set `new_eff_peak` in `ElectricMachine`
Set `new_eff_max` in `ElectricMachine`
"""
em = fsim.ElectricMachine.from_pydict(sd_dict['veh']['pt_type']['HybridElectricVehicle']['em'])
em.set_eff_peak(new_eff_peak)
Expand All @@ -113,9 +113,9 @@ def new_em_eff_range(sd_dict, new_eff_range):
sd_dict['veh']['pt_type']['HybridElectricVehicle']['em'] = em.to_pydict()
# TODO: check that `sd_dict` is mutably modified outside the scope of this function, e.g. with a debugger

def new_fc_eff_peak(sd_dict, new_eff_peak):
def new_fc_eff_max(sd_dict, new_eff_peak):
"""
Set `new_eff_peak` in `FuelConverter`
Set `new_eff_max` in `FuelConverter`
"""
fc = fsim.FuelConverter.from_pydict(sd_dict['veh']['pt_type']['HybridElectricVehicle']['fc'])
fc.set_eff_peak(new_eff_peak)
Expand Down Expand Up @@ -149,9 +149,9 @@ def new_fc_eff_range(sd_dict, new_eff_range):
# - HVAC power, if available
),
param_fns=(
new_em_eff_peak,
new_em_eff_max,
new_em_eff_range,
new_fc_eff_peak,
new_fc_eff_max,
# new_fc_eff_range, # not sure I want to include this one
# TODO: make sure this has functions for modifying
# - HVAC PID controls for cabin (not for battery because Sonata has
Expand Down
5 changes: 4 additions & 1 deletion fastsim-core/src/vehicle/powertrain/electric_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub struct ElectricMachine {
///
/// Note that the Extrapolate field of this variable is changed in [Self::get_pwr_in_req]
pub eff_interp_achieved: Interpolator,
#[serde(default)]
#[serde(skip_deserializing)]
/// Efficiency interpolator corresponding to max input power
/// If `None`, will be set during [Self::init].
///
Expand Down Expand Up @@ -331,6 +331,9 @@ impl Init for ElectricMachine {
self.eff_interp_achieved.extrapolate()?.to_owned(),
)?;
self.eff_interp_at_max_input = Some(Interpolator::Interp1D(eff_interp_at_max_input));
} else {
// This should be impossible to reach
bail!("`ReversibleEnergyStorage::eff_interp_at_max_input` is not `None`")
}
Ok(())
}
Expand Down

0 comments on commit 1d21dd2

Please sign in to comment.