feat(python): implement python bindings for all components and solvers

This commit is contained in:
Sepehr
2026-02-21 20:34:56 +01:00
parent 8ef8cd2eba
commit 4440132b0a
310 changed files with 11577 additions and 397 deletions

View File

@@ -126,11 +126,11 @@ impl Condenser {
let quality = (outlet_enthalpy - h_liquid) / (h_vapor - h_liquid);
if quality <= 1.0 + 1e-6 {
if quality <= 0.0 + 1e-6 {
Ok(true)
} else {
Err(ComponentError::InvalidState(format!(
"Condenser outlet quality {} > 1 (superheated)",
"Condenser outlet quality {} > 0 (not fully condensed)",
quality
)))
}
@@ -145,6 +145,21 @@ impl Condenser {
pub fn cold_inlet_state(&self) -> Result<entropyk_fluids::ThermoState, ComponentError> {
self.inner.cold_inlet_state()
}
/// Returns the hot side fluid identifier, if set.
pub fn hot_fluid_id(&self) -> Option<&entropyk_fluids::FluidId> {
self.inner.hot_fluid_id()
}
/// Sets the cold side boundary conditions.
pub fn set_cold_conditions(&mut self, conditions: super::exchanger::HxSideConditions) {
self.inner.set_cold_conditions(conditions);
}
/// Returns the cold side fluid identifier, if set.
pub fn cold_fluid_id(&self) -> Option<&entropyk_fluids::FluidId> {
self.inner.cold_fluid_id()
}
}
impl Component for Condenser {
@@ -171,6 +186,10 @@ impl Component for Condenser {
fn get_ports(&self) -> &[ConnectedPort] {
self.inner.get_ports()
}
fn set_calib_indices(&mut self, indices: entropyk_core::CalibIndices) {
self.inner.set_calib_indices(indices);
}
}
impl StateManageable for Condenser {
@@ -216,6 +235,18 @@ mod tests {
fn test_validate_outlet_quality_fully_condensed() {
let condenser = Condenser::new(10_000.0);
let h_liquid = 200_000.0;
let h_vapor = 400_000.0;
let outlet_h = 200_000.0;
let result = condenser.validate_outlet_quality(outlet_h, h_liquid, h_vapor);
assert!(result.is_ok());
}
#[test]
fn test_validate_outlet_quality_subcooled() {
let condenser = Condenser::new(10_000.0);
let h_liquid = 200_000.0;
let h_vapor = 400_000.0;
let outlet_h = 180_000.0;
@@ -224,6 +255,18 @@ mod tests {
assert!(result.is_ok());
}
#[test]
fn test_validate_outlet_quality_two_phase() {
let condenser = Condenser::new(10_000.0);
let h_liquid = 200_000.0;
let h_vapor = 400_000.0;
let outlet_h = 300_000.0;
let result = condenser.validate_outlet_quality(outlet_h, h_liquid, h_vapor);
assert!(result.is_err());
}
#[test]
fn test_validate_outlet_quality_superheated() {
let condenser = Condenser::new(10_000.0);