diff --git a/cal_and_val/thermal/f3-vehicles/2020 Chevrolet Bolt EV.yaml b/cal_and_val/thermal/f3-vehicles/2020 Chevrolet Bolt EV.yaml index e2c4b893..1a6c82a8 100644 --- a/cal_and_val/thermal/f3-vehicles/2020 Chevrolet Bolt EV.yaml +++ b/cal_and_val/thermal/f3-vehicles/2020 Chevrolet Bolt EV.yaml @@ -36,9 +36,12 @@ pt_type: res: thrml: RESLumpedThermal: - heat_capacitance_joules_per_kelvin: 0.0 - htc_to_amb_watts_per_kelvin: 0.0 - htc_to_cab_watts_per_kelvin: 0.0 + # 200,000 is Chad's uncalibrated estimate + heat_capacitance_joules_per_kelvin: 200000 + # 0.1 is Chad's uncalibrated estimate + conductance_to_amb_watts_per_kelvin: 0.1 + # 0.5 is Chad's uncalibrated estimate + conductance_to_cab_watts_per_kelvin: 0.5 mass_kilograms: ~ specific_energy_joules_per_kilogram: ~ pwr_out_max_watts: 165000.0 diff --git a/fastsim-core/src/vehicle/hvac/hvac_sys_for_lumped_cabin_and_res.rs b/fastsim-core/src/vehicle/hvac/hvac_sys_for_lumped_cabin_and_res.rs index 2c2746d8..f7802563 100644 --- a/fastsim-core/src/vehicle/hvac/hvac_sys_for_lumped_cabin_and_res.rs +++ b/fastsim-core/src/vehicle/hvac/hvac_sys_for_lumped_cabin_and_res.rs @@ -112,13 +112,15 @@ impl HVACSystemForLumpedCabinAndRES { dt: si::Time, ) -> anyhow::Result<(si::Power, si::Power, si::Power)> { let (res_temp, res_temp_prev) = res_temps; + ensure!(!res_temp.is_nan(), format_dbg!(res_temp)); + ensure!(!res_temp_prev.is_nan(), format_dbg!(res_temp_prev)); let mut pwr_thrml_hvac_to_cabin = self .solve_for_cabin(te_fc, cab_state, cab_heat_cap, dt) .with_context(|| format_dbg!())?; let mut pwr_thrml_hvac_to_res: si::Power = self .solve_for_res(res_temp, res_temp_prev, dt) .with_context(|| format_dbg!())?; - let cop_ideal: si::Ratio = + let (cop_ideal, te_ref) = if pwr_thrml_hvac_to_res + pwr_thrml_hvac_to_cabin > si::Power::ZERO { // heating mode // TODO: account for cabin and battery heat sources in COP calculation!!!! @@ -151,9 +153,9 @@ impl HVACSystemForLumpedCabinAndRES { if te_delta_vs_amb.abs() < 5.0 * uc::KELVIN { // cabin is cooler than ambient + threshold // TODO: make this `5.0` not hardcoded - te_ref / (5.0 * uc::KELVIN) + (te_ref / (5.0 * uc::KELVIN), te_ref) } else { - te_ref / te_delta_vs_amb.abs() + (te_ref / te_delta_vs_amb.abs(), te_ref) } } else if pwr_thrml_hvac_to_res + pwr_thrml_hvac_to_cabin < si::Power::ZERO { // cooling mode @@ -186,15 +188,20 @@ impl HVACSystemForLumpedCabinAndRES { if te_delta_vs_amb.abs() < 5.0 * uc::KELVIN { // cooling-dominating component is cooler than ambient + threshold // TODO: make this `5.0` not hardcoded - te_ref / (5.0 * uc::KELVIN) + (te_ref / (5.0 * uc::KELVIN), te_ref) } else { - te_ref / te_delta_vs_amb.abs() + (te_ref / te_delta_vs_amb.abs(), te_ref) } } else { - si::Ratio::ZERO + (si::Ratio::ZERO, f64::NAN * uc::KELVIN) }; self.state.cop = cop_ideal * self.frac_of_ideal_cop; - ensure!(self.state.cop >= 0.0 * uc::R, "{}", format_dbg!(cop_ideal)); + ensure!( + self.state.cop >= 0.0 * uc::R, + "{}\n{}", + format_dbg!(cop_ideal), + format_dbg!(te_ref) + ); let mut pwr_thrml_fc_to_cabin = si::Power::ZERO; self.state.pwr_aux_for_hvac = if pwr_thrml_hvac_to_cabin > si::Power::ZERO { diff --git a/fastsim-core/src/vehicle/powertrain/reversible_energy_storage.rs b/fastsim-core/src/vehicle/powertrain/reversible_energy_storage.rs index baf1c3c3..caa5a6fd 100644 --- a/fastsim-core/src/vehicle/powertrain/reversible_energy_storage.rs +++ b/fastsim-core/src/vehicle/powertrain/reversible_energy_storage.rs @@ -770,9 +770,9 @@ pub struct RESLumpedThermal { /// [ReversibleEnergyStorage] thermal capacitance pub heat_capacitance: si::HeatCapacity, /// parameter for heat transfer coeff from [ReversibleEnergyStorage::thrml] to ambient - pub htc_to_amb: si::ThermalConductance, + pub conductance_to_amb: si::ThermalConductance, /// parameter for heat transfer coeff from [ReversibleEnergyStorage::thrml] to cabin - pub htc_to_cab: si::ThermalConductance, + pub conductance_to_cab: si::ThermalConductance, /// current state #[serde(default, skip_serializing_if = "EqDefault::eq_default")] pub state: RESLumpedThermalState, @@ -797,8 +797,9 @@ impl RESLumpedThermal { dt: si::Time, ) -> anyhow::Result<()> { self.state.temp_prev = self.state.temperature; - self.state.pwr_thrml_from_cabin = self.htc_to_cab * (te_cab - self.state.temperature); - self.state.pwr_thrml_from_amb = self.htc_to_cab * (te_amb - self.state.temperature); + self.state.pwr_thrml_from_cabin = + self.conductance_to_cab * (te_cab - self.state.temperature); + self.state.pwr_thrml_from_amb = self.conductance_to_cab * (te_amb - self.state.temperature); self.state.temperature += (pwr_thrml_hvac_to_res + res_state.pwr_out_electrical * (1.0 * uc::R - res_state.eff) + self.state.pwr_thrml_from_cabin diff --git a/python/fastsim/demos/demo_bev_thrml.py b/python/fastsim/demos/demo_bev_thrml.py index 381779d1..4df06d7a 100644 --- a/python/fastsim/demos/demo_bev_thrml.py +++ b/python/fastsim/demos/demo_bev_thrml.py @@ -16,8 +16,6 @@ from plot_utils import * -# if enivronment var `DEBUG_LOG=true` is set, turns on debug logging -DEBUG_LOG = os.environ.get("DEBUG_LOG", "false").lower() == "true" # if environment var `SHOW_PLOTS=false` is set, no plots are shown SHOW_PLOTS = os.environ.get("SHOW_PLOTS", "true").lower() == "true" # if environment var `SAVE_FIGS=true` is set, save plots @@ -27,7 +25,9 @@ # %% # load 2012 Ford Fusion from file -veh = fsim.Vehicle.from_file(fsim.package_root() / "../../cal_and_val/thermal/f3-vehicles/2020 Chevrolet Bolt EV.yaml") +veh = fsim.Vehicle.from_file( + fsim.package_root() / "../../cal_and_val/thermal/f3-vehicles/2020 Chevrolet Bolt EV.yaml" +) # Set `save_interval` at vehicle level -- cascades to all sub-components with time-varying states fsim.set_param_from_path(veh, "save_interval" , 1) @@ -41,13 +41,7 @@ # simulation start time t0 = time.perf_counter() # run simulation -# toggle commented code to enable logging -if DEBUG_LOG: - print('Running `sd.walk()` with debug logging') - with fsim.utils.with_logging(): - sd.walk() -else: - sd.walk() +sd.walk() # simulation end time t1 = time.perf_counter() t_fsim3_si1 = t1 - t0