fix: resolve CLI solver state dimension mismatch

Removed mathematical singularity in HeatExchanger models (q_hot - q_cold = 0 was redundant) causing them to incorrectly request 3 equations without internal variables. Fixed ScrewEconomizerCompressor internal_state_len to perfectly align with the solver dimensions.
This commit is contained in:
Sepehr
2026-02-28 22:45:51 +01:00
parent c5a51d82dc
commit fdd124eefd
35 changed files with 10969 additions and 123 deletions

View File

@@ -101,6 +101,20 @@ impl Condenser {
self.saturation_temp = temp;
}
/// Overrides the effective UA value [W/K] at runtime.
///
/// Sets the UA scale factor so that `UA_nominal × scale = ua_value`.
/// Used by `MchxCondenserCoil` to apply fan-speed and air-density corrections.
pub fn set_ua(&mut self, ua_value: f64) {
let ua_nominal = self.inner.ua_nominal();
let scale = if ua_nominal > 0.0 {
ua_value / ua_nominal
} else {
1.0
};
self.inner.set_ua_scale(scale.max(0.0));
}
/// Validates that the outlet quality is <= 1 (fully condensed or subcooled).
///
/// # Arguments
@@ -243,7 +257,7 @@ mod tests {
fn test_condenser_creation() {
let condenser = Condenser::new(10_000.0);
assert_eq!(condenser.ua(), 10_000.0);
assert_eq!(condenser.n_equations(), 3);
assert_eq!(condenser.n_equations(), 2);
}
#[test]
@@ -305,7 +319,7 @@ mod tests {
let condenser = Condenser::new(10_000.0);
let state = vec![0.0; 10];
let mut residuals = vec![0.0; 3];
let mut residuals = vec![0.0; 2];
let result = condenser.compute_residuals(&state, &mut residuals);
assert!(result.is_ok());