Skip to content

Commit

Permalink
rust tests all pass
Browse files Browse the repository at this point in the history
one python test error remaining
  • Loading branch information
calbaker committed Jan 15, 2025
1 parent 93899c1 commit f0d38f5
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 103 deletions.
105 changes: 58 additions & 47 deletions cal_and_val/thermal/f3-vehicles/2021_Hyundai_Sonata_Hybrid_Blue.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,13 @@
# https://www.anl.gov/taps/d3-2021-hyundai-sonata-hybrid
---
name: 2021 Hyundai Sonata Hybrid Blue
year: 2021
cabin:
LumpedCabin:
# 0.05 is Chad's uncalibrated estimate
cab_shell_htc_to_amb_watts_per_square_meter_degree_celsius: 0.05
# 0.05 is Chad's uncalibrated estimate
cab_htc_to_amb_stop_watts_per_square_meter_degree_celsius: 0.05
# 200,000 is Chad's uncalibrated estimate
heat_capacitance_joules_per_kelvin: 200000
# TODO: get actual vehicle length, but calibrate this later
length_meters: 2.5
# TODO: get actual vehicle width, but calibrate this later
width_meters: 2
hvac:
LumpedCabinAndRES:
te_set_kelvin: 295.15
te_deadband_kelvin: 1.5
p_cabin_watts_per_kelvin: 0.0
i_cabin: 0.0
pwr_i_max_cabin_watts: 5000.0
d_cabin: 0.0
p_res_watts_per_kelvin: 0.0
i_res: 0.0
pwr_i_max_res_watts: 0.0
d_res: 0.0
pwr_thermal_max_watts: 10000.0
frac_of_ideal_cop: 0.15
cabin_heat_source: FuelConverter
res_heat_source: None
res_cooling_source: None
pwr_aux_for_hvac_max_watts: 5000.0
pt_type:
HybridElectricVehicle:
res:
thrml:
thrml:
RESLumpedThermal:
# 200,000 is Chad's uncalibrated estimate
heat_capacitance_joules_per_kelvin: 200000
# 0.1 is Chad's uncalibrated estimate
heat_capacitance_joules_per_kelvin: 200000.0
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: ~
Expand All @@ -56,20 +22,33 @@ pt_type:
pwr_out_max_watts: 2000000.0
pwr_ramp_lag_seconds: 1.1
energy_capacity_joules: 1601424000.0
specific_energy_joules_per_kilogram: ~
mass_kilograms: ~
fc:
thrml:
thrml:
FuelConverterThermal:
heat_capacitance_joules_per_kelvin: 200000
heat_capacitance_joules_per_kelvin: 200000.0
length_for_convection_meters: 1.0
htc_to_amb_stop_watts_per_square_meter_degree_celsius: 50.0
conductance_from_comb_watts_per_kelvin: 5.0
max_frac_from_comb: 0.5
tstat_te_sto_kelvin: 358.15
tstat_te_delta_kelvin: 5.0
tstat_interp:
x:
- 358.15
- 363.15
f_x:
- 0.0
- 1.0
strategy: Linear
extrapolate: Clamp
radiator_effectiveness: 0.0
fc_eff_model.Exponential.offset: 273.15
fc_eff_model.Exponential.lag: 25.0
fc_eff_model.Exponential.minimum: 0.2
fc_eff_model:
Exponential:
offset: 273.15
lag: 25.0
minimum: 0.2
mass_kilograms: ~
specific_pwr_watts_per_kilogram: ~
pwr_out_max_watts: 112000.0
Expand Down Expand Up @@ -706,20 +685,22 @@ pt_type:
save_interval: 1
pt_cntrl:
RGWDB:
speed_soc_disch_buffer: 17.8816
speed_soc_disch_buffer_meters_per_second: 17.8816
speed_soc_disch_buffer_coeff: 1.0
speed_soc_fc_on_buffer: 19.66976
speed_soc_fc_on_buffer_meters_per_second: 19.66976
speed_soc_fc_on_buffer_coeff: 1.0
speed_soc_regen_buffer: 13.4112
speed_soc_regen_buffer_meters_per_second: 13.4112
speed_soc_regen_buffer_coeff: 1.0
fc_min_time_on: 5.0
speed_fc_forced_on: 37.9984
fc_min_time_on_seconds: 5.0
speed_fc_forced_on_meters_per_second: 33.528
frac_pwr_demand_fc_forced_on: 0.46357615894039733
frac_of_most_eff_pwr_to_run_fc: 1.0
frac_res_chrg_for_fc: 0.0
frac_res_dschrg_for_fc: 1.0
temp_fc_forced_on_kelvin: 335.15
temp_fc_allowed_off_kelvin: 338.15
aux_cntrl: AuxOnResPriority
mass: ~
mass_kilograms: ~
sim_params:
res_per_fuel_lim: 0.005
soc_balance_iter_err: 5
Expand All @@ -732,11 +713,40 @@ chassis:
wheel_inertia_kilogram_square_meters: 0.815
num_wheels: 4
wheel_radius_meters: 0.33645
tire_code: ~
cg_height_meters: 0.53
wheel_fric_coef: 0.7
drive_type: FWD
drive_axle_weight_frac: 0.59
wheel_base_meters: 2.83972
mass_kilograms: ~
glider_mass_kilograms: ~
cargo_mass_kilograms: ~
cabin:
LumpedCabin:
cab_shell_htc_to_amb_watts_per_square_meter_degree_celsius: 0.05
cab_htc_to_amb_stop_watts_per_square_meter_degree_celsius: 0.05
heat_capacitance_joules_per_kelvin: 200000.0
length_meters: 2.5
width_meters: 2.0
hvac:
LumpedCabinAndRES:
te_set_kelvin: 295.15
te_deadband_kelvin: 1.5
p_cabin_watts_per_kelvin: 0.0
i_cabin: 0.0
pwr_i_max_cabin_watts: 5000.0
d_cabin: 0.0
p_res_watts_per_kelvin: 0.0
i_res: 0.0
pwr_i_max_res_watts: 0.0
d_res: 0.0
pwr_thermal_max_watts: 10000.0
frac_of_ideal_cop: 0.15
cabin_heat_source: FuelConverter
res_heat_source: None
res_cooling_source: None
pwr_aux_for_hvac_max_watts: 5000.0
mass_kilograms: 1508.195
pwr_aux_base_watts: 500.0
trans_eff: 0.98
Expand Down Expand Up @@ -768,4 +778,5 @@ state:
dist_meters: 0.0
grade_curr: 0.0
elev_curr_meters: .nan
air_density_kilograms_per_cubic_meter: 1.172
mass_kilograms: .nan
2 changes: 1 addition & 1 deletion fastsim-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fastsim-proc-macros = { path = "fastsim-proc-macros", version = "3.0.0" }
fastsim-2 = { workspace = true }
csv = { version = "1.1.6", optional = true }
serde = { version = "1.0.136", features = ["derive"] }
rmp-serde = { version = "1.3.0", optional = true }
serde_yaml = { version = "0.8.23", optional = true }
serde_json = { version = "1.0", optional = true }
uom = { workspace = true }
Expand Down Expand Up @@ -38,7 +39,6 @@ derive_more = { version = "1.0.0", features = ["from_str", "from", "is_variant",
ureq = { version = "2.9.1", optional = true }
url = { version = "2.5.0", optional = true }
ninterp = { version = "0.1.0", features = ["serde"] }
rmp-serde = { version = "1.3.0", optional = true }

[dev-dependencies]
pretty_assertions = "1.4.1"
Expand Down
14 changes: 7 additions & 7 deletions fastsim-core/resources/vehicles/2016_TOYOTA_Prius_Two.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -656,20 +656,20 @@ pt_type:
save_interval: 1
pt_cntrl:
RGWDB:
speed_soc_disch_buffer: 17.8816
speed_soc_disch_buffer_meters_per_second: 17.8816
speed_soc_disch_buffer_coeff: 1.0
speed_soc_fc_on_buffer: 19.66976
speed_soc_fc_on_buffer_meters_per_second: 19.66976
speed_soc_fc_on_buffer_coeff: 1.0
speed_soc_regen_buffer: 13.4112
speed_soc_regen_buffer_meters_per_second: 13.4112
speed_soc_regen_buffer_coeff: 1.0
fc_min_time_on: 5.0
speed_fc_forced_on: 37.9984
fc_min_time_on_seconds: 5.0
speed_fc_forced_on_meters_per_second: 37.9984
frac_pwr_demand_fc_forced_on: 0.5645161290322581
frac_of_most_eff_pwr_to_run_fc: 1.0
frac_res_chrg_for_fc: 0.0
frac_res_dschrg_for_fc: 1.0
temp_fc_forced_on: ~
temp_fc_allowed_off: ~
temp_fc_forced_on_kelvin: ~
temp_fc_allowed_off_kelvin: ~
aux_cntrl: AuxOnResPriority
mass_kilograms: ~
sim_params:
Expand Down
3 changes: 2 additions & 1 deletion fastsim-core/src/drive_cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ use fastsim_2::cycle::RustCycle as Cycle2;

#[fastsim_api(
#[pyo3(name = "list_resources")]
#[staticmethod]
/// list available cycle resources
fn list_resources_py(&self) -> Vec<String> {
fn list_resources_py() -> Vec<String> {
resources::list_resources(Self::RESOURCE_PREFIX)
}
Expand Down
2 changes: 1 addition & 1 deletion fastsim-core/src/simdrive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Default for SimParams {
fn default() -> Self {
Self {
ach_speed_max_iter: 3,
ach_speed_tol: 1e-9 * uc::R,
ach_speed_tol: 1.0e-9 * uc::R,
ach_speed_solver_gain: 0.9,
trace_miss_tol: Default::default(),
trace_miss_opts: Default::default(),
Expand Down
7 changes: 5 additions & 2 deletions fastsim-core/src/vehicle/hev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,9 @@ impl HEVPowertrainControls {
_ => {
bail!(
"{}\n`fc.temperature()`, `fc.temp_prev()`, `rgwdb.temp_fc_forced_on`, and
`rgwdb.temp_fc_allowed_off` must all be `None` or `Some`",
format_dbg!()
`rgwdb.temp_fc_allowed_off` must all be `None` or `Some` because these controls are necessary
for an HEV equipped with thermal models or superfluous otherwise",
format_dbg!((fc.temperature(), fc.temp_prev(), rgwdb.temp_fc_forced_on, rgwdb.temp_fc_allowed_off))
);
}
}
Expand Down Expand Up @@ -704,6 +705,7 @@ impl HEVPowertrainControls {
/// and discharge power inside of static min and max SOC range. Also, includes
/// buffer for forcing [FuelConverter] to be active/on. See [Self::init] for
/// default values.
#[fastsim_api]
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, Default)]
#[non_exhaustive]
pub struct RESGreedyWithDynamicBuffers {
Expand Down Expand Up @@ -782,6 +784,7 @@ impl Init for RESGreedyWithDynamicBuffers {
Ok(())
}
}
impl SerdeAPI for RESGreedyWithDynamicBuffers {}

#[fastsim_api]
#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq, HistoryVec, SetCumulative)]
Expand Down
1 change: 0 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,6 @@ 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(skip_deserializing)]
/// Efficiency interpolator corresponding to max input power
/// If `None`, will be set during [Self::init].
///
Expand Down
3 changes: 2 additions & 1 deletion fastsim-core/src/vehicle/vehicle_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ impl Init for AuxSource {}
#[cfg(feature = "resources")]
#[pyo3(name = "list_resources")]
#[staticmethod]
/// list available vehicle resources
fn list_resources_py(&self) -> Vec<String> {
fn list_resources_py() -> Vec<String> {
resources::list_resources(Self::RESOURCE_PREFIX)
}
Expand Down
Loading

0 comments on commit f0d38f5

Please sign in to comment.