chore: remove deprecated flow_boundary and update docs to match new architecture
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user