chore: remove deprecated flow_boundary and update docs to match new architecture

This commit is contained in:
Sepehr
2026-03-01 20:00:09 +01:00
parent 20700afce8
commit d88914a44f
105 changed files with 11222 additions and 2994 deletions

View File

@@ -51,3 +51,6 @@ path = "src/bin/macro_chiller.rs"
[[bin]]
name = "inverse-control-demo"
path = "src/bin/inverse_control_demo.rs"
[dev-dependencies]
approx = "0.5"

View File

@@ -16,7 +16,7 @@
use colored::Colorize;
use entropyk_components::heat_exchanger::{CondenserCoil, Evaporator};
use entropyk_components::{
Component, ComponentError, JacobianBuilder, ResidualVector, SystemState,
Component, ComponentError, JacobianBuilder, ResidualVector, StateSlice,
};
use entropyk_core::{MassFlow, Pressure, Temperature, ThermalConductance};
use entropyk_solver::{
@@ -68,7 +68,7 @@ impl PlaceholderComponent {
impl Component for PlaceholderComponent {
fn compute_residuals(
&self,
_state: &SystemState,
_state: &StateSlice,
residuals: &mut ResidualVector,
) -> Result<(), ComponentError> {
for r in residuals.iter_mut() {
@@ -79,7 +79,7 @@ impl Component for PlaceholderComponent {
fn jacobian_entries(
&self,
_state: &SystemState,
_state: &StateSlice,
_jacobian: &mut JacobianBuilder,
) -> Result<(), ComponentError> {
Ok(())

View File

@@ -14,7 +14,7 @@ use entropyk_components::heat_exchanger::{
EvaporatorCoil, FlowConfiguration, HxSideConditions, LmtdModel,
};
use entropyk_components::{
Component, ComponentError, HeatExchanger, JacobianBuilder, ResidualVector, SystemState,
Component, ComponentError, HeatExchanger, JacobianBuilder, ResidualVector, StateSlice,
};
use entropyk_core::{Enthalpy, MassFlow, Pressure, Temperature, ThermalConductance};
use entropyk_fluids::TestBackend;
@@ -46,7 +46,7 @@ impl SimpleComponent {
impl Component for SimpleComponent {
fn compute_residuals(
&self,
state: &SystemState,
state: &StateSlice,
residuals: &mut ResidualVector,
) -> Result<(), ComponentError> {
// Dummy implementation to ensure convergence
@@ -58,7 +58,7 @@ impl Component for SimpleComponent {
fn jacobian_entries(
&self,
_state: &SystemState,
_state: &StateSlice,
jacobian: &mut JacobianBuilder,
) -> Result<(), ComponentError> {
for i in 0..self.n_eqs {

View File

@@ -29,7 +29,7 @@
use colored::Colorize;
use entropyk_components::port::{FluidId, Port};
use entropyk_components::{
Component, ComponentError, ConnectedPort, JacobianBuilder, ResidualVector, SystemState,
Component, ComponentError, ConnectedPort, JacobianBuilder, ResidualVector, StateSlice,
};
use entropyk_core::{Enthalpy, Pressure};
use entropyk_solver::{MacroComponent, NewtonConfig, Solver, System};
@@ -68,7 +68,7 @@ impl fmt::Debug for LinearComponent {
impl Component for LinearComponent {
fn compute_residuals(
&self,
_state: &SystemState,
_state: &StateSlice,
residuals: &mut ResidualVector,
) -> Result<(), ComponentError> {
for (i, res) in residuals.iter_mut().enumerate().take(self.n_eqs) {
@@ -79,7 +79,7 @@ impl Component for LinearComponent {
fn jacobian_entries(
&self,
_state: &SystemState,
_state: &StateSlice,
jacobian: &mut JacobianBuilder,
) -> Result<(), ComponentError> {
for i in 0..self.n_eqs {

View File

@@ -9,7 +9,7 @@
use colored::Colorize;
use entropyk_components::{
Component, ComponentError, JacobianBuilder, ResidualVector, SystemState,
Component, ComponentError, JacobianBuilder, ResidualVector, StateSlice,
};
use entropyk_core::{Temperature, ThermalConductance};
use entropyk_solver::{
@@ -49,7 +49,7 @@ impl SimpleComponent {
impl Component for SimpleComponent {
fn compute_residuals(
&self,
_state: &SystemState,
_state: &StateSlice,
residuals: &mut ResidualVector,
) -> Result<(), ComponentError> {
for r in residuals.iter_mut().take(self.n_eqs) {
@@ -60,7 +60,7 @@ impl Component for SimpleComponent {
fn jacobian_entries(
&self,
_state: &SystemState,
_state: &StateSlice,
_jacobian: &mut JacobianBuilder,
) -> Result<(), ComponentError> {
Ok(())

View File

@@ -15,9 +15,10 @@
use approx::assert_relative_eq;
use entropyk_components::{
Ahri540Coefficients, Compressor, CompressorModel, ConnectedPort, EpsNtuModel, ExchangerType,
ExpansionValve, FlowSink, FlowSource, FlowSplitter, FluidId, HeatExchanger, OperationalState,
Pipe, Port, Pump, SstSdtCoefficients, StateManageable,
ExpansionValve, FluidId, OperationalState, Port, Pump, SstSdtCoefficients,
StateManageable,
};
use entropyk_components::heat_exchanger::HeatTransferModel;
use entropyk_core::{Enthalpy, MassFlow, Pressure, Temperature};
// =============================================================================
@@ -137,10 +138,14 @@ mod story_1_4_compressor {
#[test]
fn test_sst_sdt_coefficients() {
let coeffs = SstSdtCoefficients::default();
// Verify the polynomial structure is correct
assert_eq!(coeffs.mass_flow.len(), 16); // 4x4 matrix
assert_eq!(coeffs.power.len(), 16);
// Use bilinear constructor instead of removed ::default()
let coeffs = SstSdtCoefficients::bilinear(
0.05, 0.001, 0.0005, 0.00001, // mass flow coefficients
1000.0, 50.0, 30.0, 0.5, // power coefficients
);
// Verify evaluation works (bilinear model)
let mass_flow = coeffs.mass_flow_at(263.15, 313.15); // -10°C SST, 40°C SDT
assert!(mass_flow > 0.0);
}
}
@@ -154,6 +159,7 @@ mod story_1_5_heat_exchanger {
#[test]
fn test_eps_ntu_counter_flow() {
let model = EpsNtuModel::counter_flow(5000.0);
// ua() is accessed through the HeatTransferModel trait
assert_eq!(model.ua(), 5000.0);
}
@@ -281,17 +287,15 @@ mod story_1_8_auxiliary {
fn test_pump_curves() {
use entropyk_components::PumpCurves;
let curves = PumpCurves {
h0: 30.0,
h1: -10.0,
h2: -50.0,
eta0: 0.5,
eta1: 0.3,
eta2: -0.5,
};
// Use PumpCurves::quadratic constructor (fields are no longer public)
let curves = PumpCurves::quadratic(
30.0, -10.0, -50.0, // head: H = 30 - 10Q - 50Q²
0.5, 0.3, -0.5, // efficiency: η = 0.5 + 0.3Q - 0.5Q²
)
.unwrap();
// At Q=0, H should be H0
let h_at_zero = curves.head(0.0);
// At Q=0, H should be H0 = 30
let h_at_zero = curves.head_at_flow(0.0);
assert_relative_eq!(h_at_zero, 30.0, epsilon = 1e-6);
}
}
@@ -302,44 +306,64 @@ mod story_1_8_auxiliary {
mod story_1_11_junctions {
use super::*;
use entropyk_components::FlowSplitter;
fn make_connected_port(fluid: &str, p_pa: f64, h_jkg: f64) -> ConnectedPort {
let a = Port::new(
FluidId::new(fluid),
Pressure::from_pascals(p_pa),
Enthalpy::from_joules_per_kg(h_jkg),
);
let b = Port::new(
FluidId::new(fluid),
Pressure::from_pascals(p_pa),
Enthalpy::from_joules_per_kg(h_jkg),
);
a.connect(b).unwrap().0
}
#[test]
fn test_flow_splitter_creation() {
let inlet = Port::new(
FluidId::new("Water"),
Pressure::from_bar(1.0),
Enthalpy::from_joules_per_kg(42_000.0),
);
let outlet1 = Port::new(
FluidId::new("Water"),
Pressure::from_bar(1.0),
Enthalpy::from_joules_per_kg(42_000.0),
);
let outlet2 = Port::new(
FluidId::new("Water"),
Pressure::from_bar(1.0),
Enthalpy::from_joules_per_kg(42_000.0),
);
// FlowSplitter::new() is removed; use ::incompressible()
let inlet = make_connected_port("Water", 100_000.0, 42_000.0);
let outlet1 = make_connected_port("Water", 100_000.0, 42_000.0);
let outlet2 = make_connected_port("Water", 100_000.0, 42_000.0);
let splitter = FlowSplitter::new(inlet, vec![outlet1, outlet2]);
let splitter =
FlowSplitter::incompressible("Water", inlet, vec![outlet1, outlet2]);
assert!(splitter.is_ok());
}
#[test]
fn test_flow_source_creation() {
let source = FlowSource::new(
FluidId::new("Water"),
Pressure::from_bar(1.0),
Enthalpy::from_joules_per_kg(42_000.0),
);
assert_eq!(source.fluid_id().as_str(), "Water");
// FlowSource::new() is removed; use ::incompressible() (deprecated but still functional)
#[allow(deprecated)]
{
use entropyk_components::FlowSource;
let port = make_connected_port("Water", 100_000.0, 42_000.0);
let source = FlowSource::incompressible(
"Water",
100_000.0,
42_000.0,
port,
);
assert!(source.is_ok());
let s = source.unwrap();
assert_eq!(s.fluid_id(), "Water");
}
}
#[test]
fn test_flow_sink_creation() {
let sink = FlowSink::new(FluidId::new("Water"), Pressure::from_bar(1.0));
assert_eq!(sink.fluid_id().as_str(), "Water");
// FlowSink::new() is removed; use ::incompressible() (deprecated but still functional)
#[allow(deprecated)]
{
use entropyk_components::FlowSink;
let port = make_connected_port("Water", 100_000.0, 42_000.0);
let sink = FlowSink::incompressible("Water", 100_000.0, None, port);
assert!(sink.is_ok());
let s = sink.unwrap();
assert_eq!(s.fluid_id(), "Water");
}
}
}