Add RecuperatorGivenOutlet model and compute effectiveness#70
Conversation
Introduces an Effectiveness newtype in the discretized HX core and computes it per-segment alongside UA. Each segment contributes C_min * (T_hot_in - T_cold_in) to q_dot_max; the overall effectiveness is q_dot / q_dot_max. This resolves internal pinch points that a single-segment analysis would miss, with accuracy improving as segment count increases. The Effectiveness type is surfaced through Results and the existing Recuperator output. Part of #68.
Renames all associated types (Config, Input, Output, Error) to include the GivenUa qualifier. The old names are preserved as deprecated type aliases for backward compatibility. Part of #68.
Adds a new Model that computes UA directly from a specified outlet temperature, without internal iteration. The caller selects which stream's outlet is specified via the OutletStream enum. This complements RecuperatorGivenUa for use in cycle solvers where outlet temperatures are iteration variables (e.g., recompression Brayton). The recuperator module is restructured from a single file into a module directory with given_ua and given_outlet submodules. Closes #68.
gdtroszak
left a comment
There was a problem hiding this comment.
Looks good. Two suggestions for test coverage below.
| message: String, | ||
| }, | ||
| } | ||
|
|
There was a problem hiding this comment.
The SecondLawViolation variant is defined and the From<SolveError> impl maps it, but no test exercises this path. Consider a test that specifies a top outlet temp above the bottom inlet (e.g., input_top(400.0, 600.0, 700.0)) to confirm the error is surfaced correctly.
There was a problem hiding this comment.
Added second_law_violation_returns_error — specifies top outlet at 700 K against a 600 K bottom inlet, confirms the error surfaces correctly. b0bcca7
| #[test] | ||
| fn new_rejects_unsupported_segment_counts() { | ||
| for n in [0, 2, 3, 100] { | ||
| assert!( |
There was a problem hiding this comment.
This test (and the others) checks UA and temperatures but never asserts on effectiveness. A smoke check here — e.g., assert!(out.effectiveness.get() > 0.0 && out.effectiveness.get() < 1.0) — would exercise the new field end-to-end through the model layer. Same for the zero-transfer case (outlet_at_inlet_temp_gives_zero_ua could assert effectiveness.get() == 0.0).
There was a problem hiding this comment.
Added effectiveness assertions: smoke checks on both normal-transfer tests (> 0.0 && < 1.0) and assert_relative_eq!(effectiveness, 0.0) on the zero-transfer case. b0bcca7
Adds a second recuperator model direction and heat exchanger effectiveness to the discretized solver.
RecuperatorGivenOutlet — given an outlet temperature, compute UA directly without iteration. This is the complement to
RecuperatorGivenUaand is needed for cycle solvers where outlet temperatures are the iteration variables (e.g., recompression Brayton).Effectiveness — computed per-segment alongside UA, resolving internal pinch points that a single-segment analysis would miss. Exposed as a newtype in the core and surfaced through both recuperator output types.
The existing
Recuperatorand associated types are renamed toRecuperatorGivenUa. This is a breaking change with no deprecated aliases — brayton is the only downstream crate right now, so a clean break is simpler than maintaining shims. As the consumer base grows, renames like this would warrant a deprecation cycle, but keeping things simple for now.Closes #68.