dave1368/cluster-09-thermal-exergy
Cluster 9: Thermal Exergy & Macro-Thermodynamics
A neuro-symbolic system pairing exact classical efficiency limits ("Symetria Engine") with a trained neural network that predicts local entropy generation, exergy destruction, and cycle efficiency across a heat engine operating between a hot and cold reservoir, under LangGraph rollback/HITL supervision with two safety checks.
This is the final cluster in the series. Give it a hot and cold reservoir temperature; it computes the exact Carnot and Curzon-Ahlborn efficiency limits, runs a GPU network to predict how much useful work-potential ("exergy") is being destroyed at different points in the cycle, and checks the result against two physics safeguards before returning it.
How it works
- Symetria Engine (exact): two classical efficiency limits for a heat engine running between temperatures Th (hot) and Tc (cold) —
η_Carnot = 1 − Tc/Th(the absolute reversible upper bound, Carnot 1824) andη_CA = 1 − √(Tc/Th)(the efficiency a real engine actually achieves at maximum power output, Curzon & Ahlborn 1975). - GPU Exergy Field Network: a neural network that predicts entropy generation, exergy destruction, and cycle efficiency at any point between the two reservoirs, for any (Th, Tc) pair.
- Physics safeguards:
- Second Law check — entropy generation can never be negative.
- Carnot-limit check — predicted efficiency can never exceed the reversible Carnot bound.
- LangGraph orchestration — if either check fails, the pipeline rolls back and retries (bounded attempts) before surfacing a human-in-the-loop flag.
Validated against classical sources
Cluster 9's Master Specification cites Carnot (1824), Clausius (1865), Gouy (1889) & Stodola (1905), and Curzon & Ahlborn (1975). Each was independently re-derived in a fresh script and cross-checked against both the exact solver and the trained network — not read back from the project's own logs.
1. The two classical efficiency formulas, checked independently
Exact match at every point, as expected for closed-form formulas.
2. A structural fact, checked across the whole slider range: the real-engine limit never beats the reversible one
A real heat engine running at its maximum-power operating point (Curzon- Ahlborn) can never be more efficient than the theoretical reversible limit (Carnot) — that's not just true at a few sample points, it has to hold everywhere. Checked across 420 (Th, Tc) pairs spanning the full slider range: zero violations of ηCA ≤ ηCarnot.
3. Re-deriving the efficiency/entropy-generation identity from scratch
The exact identity linking cycle efficiency to entropy generation (η = η_Carnot − Tc·s_gen, where s_gen is entropy generated per unit of heat input) was re-derived independently here from the Clausius inequality and basic energy balance, not copied from the project's own code:
Starting from S_gen = Qc/Tc − Qh/Th ≥ 0 (Clausius), W = Qh − Qc, and η = W/Qh: substituting Qc = Qh·(1−η) gives s_gen = S_gen/Qh = (1−η)/Tc − 1/Th, which rearranges to η = η_Carnot − Tc·s_gen — matching the identity the project's own code uses. Plugging a chosen s_gen in, computing η, then working the Clausius formula backward from that η reproduces the same s_gen to 9 decimal places, confirming the identity is self-consistent, not just asserted.
4. Gouy-Stodola (1889/1905): exergy destruction, checked independently
Exergy destroyed = T₀ × entropy generated, where T₀ is the environment's reference temperature (298.15 K here). Recomputed with an independently typed-in T₀ rather than the code's own constant — matches exactly at every tested entropy-generation value.
5. Trained network vs. the exact identity, across several reservoir pairs
Errors stay small (under ~1% of the efficiency scale) across the whole tested range.
6. Two safety checks, two different stories
The Second Law check is structurally guaranteed to pass. The entropy-generation output is built using a mathematical function (Softplus) that can only ever produce zero or positive numbers, by construction — not something training could get wrong even if it tried. Confirmed by feeding the network deliberately broken (randomly scaled, sign-flipped) weights and checking the output anyway: minimum entropy generation across 20,000 points was exactly 0.0, never negative. This means the check can't tell a good model from a bad one, but it does guarantee this particular physical requirement is never violated.
The Carnot-limit check is a real, meaningful check — with one asymmetry worth knowing about. Unlike the Second Law check, this one genuinely can fail: feeding the network moderately scaled-up broken weights produced a mean efficiency of 1.89 (188.6%), and the check correctly caught it as exceeding the Carnot limit. But pushing the weights further (more extreme corruption) produced a wildly negative mean efficiency (as low as −22.8), and the check passed that too — it only checks whether efficiency is too high, not whether it's physically nonsensical in the other direction. In practice, the trained network's efficiency predictions stay well-behaved (see table above), so this asymmetry hasn't caused an actual wrong pass/fail in normal use — but it's worth knowing the check isn't a complete sanity test on its own.
Try it
Set a hot and cold reservoir temperature and run the pipeline. The app reports the exact Carnot and Curzon-Ahlborn limits, the total exergy destruction across the sampled field, the network's predicted efficiency, and whether both safety checks passed.
Limitations
- The Second Law check can't distinguish a good model from a bad one — see finding 6 above. Its only value is a structural guarantee, not a quality measure.
- The Carnot-limit check only catches efficiency being too high, not being nonsensically negative — see finding 6 above.
- This models the general thermodynamic identities of a heat engine, not a specific engine cycle (Rankine, Brayton, etc.) — the spatial field being sampled represents an abstract operating-point sweep, not a real engine's physical geometry.
Dependencies
torch— GPU network inferencelanggraph— rollback/HITL orchestration state machinegradio— this interfacewolframclient/neo4jare optional; both degrade gracefully to in-code fallbacks when absent (as here).
