Skip to content

Commit

Permalink
all tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
calbaker committed Jan 31, 2025
1 parent ecfc18c commit 6c55a69
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
12 changes: 10 additions & 2 deletions cal_and_val/thermal/cal_hev.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@
# - wide range of initial and ambient temperatures
# - good signal quality -- somewhat subjective

# HWY x2, hot (M155), HVAC active (B155)
# HWYx2, 2 bag in 95°F test cell with solar @850W/m^2, HVAC-ON-AUTO-72°F, ECO drive mode
"62202004 Test Data.txt",

# US06 x2, hot, HVAC active
# US06x2, 4 (split) bag in 95°F test cell with solar @850W/m^2, HVAC-ON-AUTO-72°F, ECO drive mode
"62202005 Test Data.txt",

# UDDS, 2 bag, warm start in ECO mode
# UDDS x1, room temperature ambient
"62201013 Test Data.txt",

# Hwyx2, 2 bag, warm start in ECO mode
# HWY x2, room temperature ambient
"62201014 Test Data.txt",

Expand All @@ -72,12 +74,17 @@
# use random or manual selection to retain ~70% of cycles for calibration,
# and reserve the remaining for validation
cyc_files_for_cal: List[str] = [
# HWY x2, hot (M155), HVAC active (B155)
"62202004 Test Data.txt",
# "62202005 Test Data.txt",
# UDDS x1, room temperature ambient
"62201013 Test Data.txt",
# HWY x2, room temperature ambient
"62201014 Test Data.txt",
# UDDSx2, 4 bag (FTP), cold start, in COLD (20°F) test cell, HVAC-AUTO-72°F, ECO drive mode
"62202013 Test Data.txt",
# "62202014 Test Data.txt",
# US06x2, 4 (split) bag, warm start, in COLD (20°F) test cell, HVAC-AUTO-72°F, ECO drive mode
"62202016 Test Data.txt",
]
cyc_files_for_cal: List[Path] = [cyc_file for cyc_file in cyc_files if cyc_file.name in cyc_files_for_cal]
Expand All @@ -103,6 +110,7 @@ def df_to_cyc(df: pd.DataFrame) -> fsim.Cycle:
return fsim.Cycle.from_pydict(cyc_dict, skip_init=False)

def veh_init(cyc_file_stem: str, dfs: Dict[str, pd.DataFrame]) -> fsim.Vehicle:
# TODO: turn off HVAC for 22*C ambient
vd = deepcopy(veh_dict)
# initialize SOC
vd['pt_type']['HybridElectricVehicle']['res']['state']['soc'] = \
Expand Down
18 changes: 11 additions & 7 deletions fastsim-core/src/vehicle/hvac/hvac_sys_for_lumped_cabin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use super::*;
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, HistoryMethods)]
/// HVAC system for [LumpedCabin]
pub struct HVACSystemForLumpedCabin {
/// set point temperature
pub te_set: si::Temperature,
/// set point temperature, `None` means HVAC is inactive
pub te_set: Option<si::Temperature>,
/// deadband range. any cabin temperature within this range of
/// `te_set` results in no HVAC power draw
pub te_deadband: si::TemperatureInterval,
Expand Down Expand Up @@ -46,7 +46,7 @@ pub struct HVACSystemForLumpedCabin {
impl Default for HVACSystemForLumpedCabin {
fn default() -> Self {
Self {
te_set: *TE_STD_AIR,
te_set: Some(*TE_STD_AIR),
te_deadband: 1.5 * uc::KELVIN_INT,
p: Default::default(),
i: Default::default(),
Expand Down Expand Up @@ -86,9 +86,13 @@ impl HVACSystemForLumpedCabin {
cab_heat_cap: si::HeatCapacity,
dt: si::Time,
) -> anyhow::Result<(si::Power, si::Power)> {
let te_set = match self.te_set {
Some(te_set) => te_set,
None => return Ok((si::Power::ZERO, si::Power::ZERO)),
};
let (pwr_thrml_hvac_to_cabin, pwr_thrml_fc_to_cabin, cop) = if cab_state.temperature
<= self.te_set + self.te_deadband
&& cab_state.temperature >= self.te_set - self.te_deadband
<= te_set + self.te_deadband
&& cab_state.temperature >= te_set - self.te_deadband
{
// inside deadband; no hvac power is needed

Expand All @@ -101,7 +105,7 @@ impl HVACSystemForLumpedCabin {
} else {
// outside deadband
let te_delta_vs_set = (cab_state.temperature.get::<si::degree_celsius>()
- self.te_set.get::<si::degree_celsius>())
- te_set.get::<si::degree_celsius>())
* uc::KELVIN_INT;
let te_delta_vs_amb: si::TemperatureInterval =
(cab_state.temperature.get::<si::degree_celsius>()
Expand All @@ -120,7 +124,7 @@ impl HVACSystemForLumpedCabin {
/ dt);

let (pwr_thrml_hvac_to_cabin, pwr_thrml_fc_to_cabin, cop) =
if cab_state.temperature > self.te_set + self.te_deadband {
if cab_state.temperature > te_set + self.te_deadband {
// COOLING MODE; cabin is hotter than set point

// https://en.wikipedia.org/wiki/Coefficient_of_performance#Theoretical_performance_limits
Expand Down

0 comments on commit 6c55a69

Please sign in to comment.