Skip to content

Add RecuperatorGivenOutlet model and compute effectiveness#70

Merged
dyreby merged 5 commits into
mainfrom
feat/recuperator-given-outlet
Mar 4, 2026
Merged

Add RecuperatorGivenOutlet model and compute effectiveness#70
dyreby merged 5 commits into
mainfrom
feat/recuperator-given-outlet

Conversation

@dyreby

@dyreby dyreby commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

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 RecuperatorGivenUa and 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 Recuperator and associated types are renamed to RecuperatorGivenUa. 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.

dyreby added 4 commits March 4, 2026 07:26
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.
@dyreby dyreby requested a review from gdtroszak March 4, 2026 13:31

@gdtroszak gdtroszak left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Two suggestions for test coverage below.

message: String,
},
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@dyreby dyreby merged commit 094442c into main Mar 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add RecuperatorGivenOutlet and rename Recuperator to RecuperatorGivenUa

2 participants