Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code cleanup #171

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions rust/fastsim-core/src/thermal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,7 @@ impl SimDriveHot {
},
None => (
None, // 1st return element
match init_state {
Some(state) => state, // 2nd return element
None => ThermalState::default(),
},
init_state.unwrap_or_default(),
),
};

Expand Down Expand Up @@ -416,8 +413,7 @@ impl SimDriveHot {
// limited between 0 and 1, but should really not get near 1
self.state.fc_qdot_per_net_heat = (self.vehthrm.fc_coeff_from_comb
* (self.state.fc_te_adiabatic_deg_c - self.state.fc_te_deg_c))
.min(1.0)
.max(0.0);
.clamp(0.0, 1.0);

// heat generation
self.state.fc_qdot_kw = self.state.fc_qdot_per_net_heat
Expand Down Expand Up @@ -481,8 +477,7 @@ impl SimDriveHot {
if let CabinHvacModelTypes::Internal(hvac_model) = &mut self.vehthrm.cabin_hvac_model {
// flat plate model for isothermal, mixed-flow from Incropera and deWitt, Fundamentals of Heat and Mass
// Transfer, 7th Edition
let cab_te_film_ext_deg_c =
0.5 * (self.state.cab_te_deg_c + self.state.amb_te_deg_c);
let cab_te_film_ext_deg_c = 0.5 * (self.state.cab_te_deg_c + self.state.amb_te_deg_c);
let re_l = self.air.get_rho(cab_te_film_ext_deg_c, None)
* self.sd.mps_ach[i - 1]
* self.vehthrm.cab_l_length
Expand All @@ -498,20 +493,18 @@ impl SimDriveHot {
(0.037 * re_l.powf(0.8) - a) * self.air.get_pr(cab_te_film_ext_deg_c)
};

if self.sd.mph_ach[i - 1] > 2.0 {
self.state.cab_qdot_to_amb_kw = 1e-3
* (self.vehthrm.cab_l_length * self.vehthrm.cab_l_width)
self.state.cab_qdot_to_amb_kw = if self.sd.mph_ach[i - 1] > 2.0 {
1e-3 * (self.vehthrm.cab_l_length * self.vehthrm.cab_l_width)
/ (1.0
/ (nu_l_bar * self.air.get_k(cab_te_film_ext_deg_c)
/ self.vehthrm.cab_l_length)
+ self.vehthrm.cab_r_to_amb)
* (self.state.cab_te_deg_c - self.state.amb_te_deg_c);
* (self.state.cab_te_deg_c - self.state.amb_te_deg_c)
} else {
self.state.cab_qdot_to_amb_kw = 1e-3
* (self.vehthrm.cab_l_length * self.vehthrm.cab_l_width)
1e-3 * (self.vehthrm.cab_l_length * self.vehthrm.cab_l_width)
/ (1.0 / self.vehthrm.cab_htc_to_amb_stop + self.vehthrm.cab_r_to_amb)
* (self.state.cab_te_deg_c - self.state.amb_te_deg_c);
}
* (self.state.cab_te_deg_c - self.state.amb_te_deg_c)
};

let te_delta_vs_set_deg_c = self.state.cab_te_deg_c - hvac_model.te_set_deg_c;
let te_delta_vs_amb_deg_c = self.state.cab_te_deg_c - self.state.amb_te_deg_c;
Expand Down
4 changes: 2 additions & 2 deletions rust/fastsim-core/src/vehicle_thermal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub struct HVACModel {
/// coefficient between 0 and 1 to calculate HVAC efficiency by multiplying by
/// coefficient of performance (COP)
pub frac_of_ideal_cop: f64,
/// whether heat comes from fuel converter
/// whether heat comes from [FuelConverter]
pub use_fc_waste_heat: bool,
/// max cooling aux load
pub pwr_max_aux_load_for_cooling_kw: f64,
Expand Down Expand Up @@ -481,7 +481,7 @@ impl VehicleThermal {

/// parameter for engine surface area \[m**2\] for heat transfer calcs
pub fn fc_area_ext(&self) -> f64 {
PI * self.fc_l.powf(2.0 / 4.0)
PI * self.fc_l.powf(2.0) / 4.0
}

/// parameter for catalyst surface area \[m**2\] for heat transfer calcs
Expand Down
Loading