Update project structure and configurations

This commit is contained in:
2026-05-23 10:19:55 +02:00
parent ab5dc7e568
commit 62efea0646
1832 changed files with 83568 additions and 51829 deletions

View File

@@ -787,7 +787,8 @@ impl Compressor<Connected> {
// Calculate volumetric efficiency using inverse pressure ratio
// η_vol = 1 - (P_suction/P_discharge)^(1/M2)
let inverse_pressure_ratio = p_suction / p_discharge;
let volumetric_efficiency = 1.0 - inverse_pressure_ratio.powf(1.0 / coeffs.m2);
let volumetric_efficiency = (1.0 - inverse_pressure_ratio.powf(1.0 / coeffs.m2))
* self.calib.f_etav;
if volumetric_efficiency < 0.0 {
return Err(ComponentError::NumericalError(
@@ -1373,6 +1374,61 @@ impl Component for Compressor<Connected> {
}
}
}
fn signature(&self) -> String {
format!(
"Compressor(fluid={}, circuit={})",
self.fluid_id.as_str(),
self.circuit_id.0
)
}
fn to_params(&self) -> crate::ComponentParams {
use crate::ComponentParams;
let mut params = ComponentParams::new("Compressor")
.with_param("fluid", self.fluid_id.as_str())
.with_param("circuitId", self.circuit_id.0)
.with_param("speedRpm", self.speed_rpm)
.with_param("displacementM3PerRev", self.displacement_m3_per_rev)
.with_param("mechanicalEfficiency", self.mechanical_efficiency)
.with_param("calib", serde_json::to_value(&self.calib).unwrap_or(serde_json::Value::Null));
match &self.model {
CompressorModel::Ahri540(c) => {
params = params
.with_param("modelType", "Ahri540")
.with_param("m1", c.m1)
.with_param("m2", c.m2)
.with_param("m3", c.m3)
.with_param("m4", c.m4)
.with_param("m5", c.m5)
.with_param("m6", c.m6)
.with_param("m7", c.m7)
.with_param("m8", c.m8)
.with_param("m9", c.m9)
.with_param("m10", c.m10);
}
CompressorModel::SstSdt(c) => {
params = params
.with_param("modelType", "SstSdt")
.with_param(
"massFlowCurve",
serde_json::to_value(&c.mass_flow_curve).unwrap_or(serde_json::Value::Null),
)
.with_param("powerCurve", serde_json::to_value(&c.power_curve).unwrap_or(serde_json::Value::Null));
}
}
params
}
fn update_calib_factor(&mut self, factor: &str, value: f64) -> bool {
let mut c = self.calib().clone();
if c.set_factor(factor, value) {
self.set_calib(c);
true
} else {
false
}
}
}
use crate::state_machine::StateManageable;
@@ -1816,6 +1872,29 @@ mod tests {
assert_relative_eq!(p_calib / p_default, 1.1, epsilon = 1e-10);
}
#[test]
fn test_f_etav_scales_volumetric_efficiency() {
let mut compressor = create_test_compressor();
let t_suction_k = 278.15;
let t_discharge_k = 318.15;
let rho = 15.0;
let m_default = compressor
.mass_flow_rate(rho, t_suction_k, t_discharge_k, None)
.unwrap()
.to_kg_per_s();
compressor.set_calib(Calib {
f_etav: 0.9,
..Calib::default()
});
let m_calib = compressor
.mass_flow_rate(rho, t_suction_k, t_discharge_k, None)
.unwrap()
.to_kg_per_s();
assert_relative_eq!(m_calib / m_default, 0.9, epsilon = 1e-10);
}
#[test]
fn test_mass_flow_negative_density() {
let compressor = create_test_compressor();