feat: implement mass balance validation for Story 7.1

- Added port_mass_flows to Component trait and implements for core components.
- Added System::check_mass_balance and integrated it into the solver.
- Restored connect methods for ExpansionValve, Compressor, and Pipe to fix integration tests.
- Updated Python and C bindings for validation errors.
- Updated sprint status and story documentation.
This commit is contained in:
Sepehr
2026-02-21 23:21:34 +01:00
parent 4440132b0a
commit fa480ed303
55 changed files with 5987 additions and 31 deletions

View File

@@ -100,6 +100,7 @@ pub use state_machine::{
StateTransitionRecord,
};
use entropyk_core::MassFlow;
use thiserror::Error;
/// Errors that can occur during component operations.
@@ -543,6 +544,23 @@ pub trait Component {
0
}
/// Returns the mass flow vector associated with the component's ports.
///
/// The returned vector matches the order of ports returned by `get_ports()`.
/// Positive values indicate flow *into* the component, negative values flow *out*.
///
/// # Arguments
///
/// * `state` - The global system state vector
///
/// # Returns
///
/// * `Ok(Vec<MassFlow>)` containing the mass flows if calculation is supported
/// * `Err(ComponentError::NotImplemented)` by default
fn port_mass_flows(&self, _state: &SystemState) -> Result<Vec<MassFlow>, ComponentError> {
Err(ComponentError::CalculationFailed("Mass flow calculation not implemented for this component".to_string()))
}
/// Injects control variable indices for calibration parameters into a component.
///
/// Called by the solver (e.g. `System::finalize()`) after matching `BoundedVariable`s