Fix code review issues for Story 1.10
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
# Story 1.10: Pipe Helpers for Water and Refrigerant
|
||||
|
||||
Status: done
|
||||
|
||||
<!-- Note: Validation is optional. Run validate-create-story for quality check before dev-story. -->
|
||||
|
||||
## Story
|
||||
|
||||
As a HVAC engineer modeling refrigerant and incompressible fluid circuits (water, seawater, glycol),
|
||||
I want convenient constructors `Pipe::for_incompressible()` and `Pipe::for_refrigerant()` with explicit ρ/μ from a fluid backend,
|
||||
So that I can create pipes without hardcoding fluid properties in the component.
|
||||
|
||||
**Architecture:** Fluid properties (ρ, μ) belong in the fluids crate (Story 2.7 IncompressibleBackend).
|
||||
Pipe must NOT hardcode water/glycol properties—user obtains them from FluidBackend.
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
1. **Pipe::for_incompressible** (AC: #1)
|
||||
- [x] `Pipe::for_incompressible(geometry, port_inlet, port_outlet, density, viscosity)` — explicit ρ, μ from backend
|
||||
- [x] Doc states: obtain ρ, μ from IncompressibleBackend (water, seawater, glycol)—do not hardcode
|
||||
- [x] Doc examples show water and glycol circuit usage
|
||||
|
||||
2. **Pipe::for_refrigerant** (AC: #2)
|
||||
- [x] `Pipe::for_refrigerant(geometry, port_inlet, port_outlet, density, viscosity)` — explicit ρ, μ at design point
|
||||
- [x] Doc states ρ, μ vary with P,T — design-point values from CoolProp/tabular
|
||||
- [x] Doc examples show refrigerant circuit usage
|
||||
|
||||
3. **Documentation** (AC: #3)
|
||||
- [x] Module-level doc: Pipe serves refrigerant and incompressible (water, seawater, glycol)
|
||||
- [x] "Fluid Support" section: refrigerant (ρ/μ from backend) vs incompressible (ρ/μ from IncompressibleBackend)
|
||||
- [x] No hardcoded fluid properties in components crate
|
||||
|
||||
## Tasks / Subtasks
|
||||
|
||||
- [x] Add Pipe::for_incompressible (AC: #1)
|
||||
- [x] Constructor accepting (geometry, ports, density, viscosity)
|
||||
- [x] Doc: obtain from IncompressibleBackend, do not hardcode
|
||||
- [x] Add Pipe::for_refrigerant (AC: #2)
|
||||
- [x] Constructor accepting (geometry, ports, density, viscosity)
|
||||
- [x] Doc: design-point values from CoolProp/tabular
|
||||
- [x] Update documentation (AC: #3)
|
||||
- [x] pipe.rs module doc: Fluid Support section
|
||||
- [x] Pipe struct doc: dual refrigerant/incompressible usage
|
||||
- [x] Doc tests for both constructors
|
||||
- [x] Tests
|
||||
- [x] test_pipe_for_incompressible_creation
|
||||
- [x] test_pipe_for_incompressible_glycol
|
||||
- [x] test_pipe_for_refrigerant_creation
|
||||
- [x] test_pipe_inlet_outlet_same_fluid
|
||||
|
||||
## Dev Notes
|
||||
|
||||
### Previous Story Intelligence
|
||||
|
||||
**From Story 1.8 (Auxiliary & Transport):**
|
||||
- Pipe uses Darcy-Weisbach, Haaland friction factor
|
||||
- PipeGeometry: length_m, diameter_m, roughness_m
|
||||
- Pipe::new(geometry, port_inlet, port_outlet, fluid_density, fluid_viscosity)
|
||||
- Already validates inlet/outlet same FluidId
|
||||
|
||||
### Typical Values
|
||||
|
||||
| Fluid | ρ (kg/m³) | μ (Pa·s) |
|
||||
|-------|-----------|----------|
|
||||
| Water 20°C | 998 | 0.001 |
|
||||
| Water 40°C | 992 | 0.00065 |
|
||||
| R134a liquid 40°C | ~1140 | ~0.0002 |
|
||||
| R410A liquid 40°C | ~1050 | ~0.00015 |
|
||||
|
||||
### References
|
||||
|
||||
- pipe.rs: Pipe::new, PipeGeometry
|
||||
- port.rs: FluidId, Port
|
||||
- Story 2.7: Incompressible fluids (water polynomial when done)
|
||||
|
||||
## Dev Agent Record
|
||||
|
||||
### Implementation Plan
|
||||
|
||||
- Added `Pipe::for_incompressible(geometry, port_inlet, port_outlet, density, viscosity)` — no hardcoding
|
||||
- Added `Pipe::for_refrigerant(geometry, port_inlet, port_outlet, density, viscosity)`
|
||||
- Module doc: Fluid Support section (refrigerant vs incompressible)
|
||||
- Pipe struct doc: dual refrigerant/incompressible usage
|
||||
- **Architecture**: Properties (ρ, μ) obtained from FluidBackend (IncompressibleBackend for water/glycol)
|
||||
|
||||
### Completion Notes
|
||||
|
||||
- for_incompressible and for_refrigerant: explicit ρ, μ from user (who gets from backend)
|
||||
- No hardcoded water/glycol properties in components crate
|
||||
- Unit tests: test_pipe_for_incompressible_creation, test_pipe_for_incompressible_glycol, test_pipe_for_refrigerant_creation
|
||||
|
||||
### Architecture Refactor (2026-02-15)
|
||||
|
||||
- **Removed** for_water, for_water_at_temp — hardcoded water-only properties (violated FR40, Story 2.7)
|
||||
- **Replaced** with for_incompressible(density, viscosity) — user provides ρ, μ from IncompressibleBackend
|
||||
- Water, seawater, glycol have different properties — must not hardcode in components
|
||||
|
||||
### Code Review Fixes (2026-02-21)
|
||||
|
||||
- Fixed solver bug where `jacobian_entries` unconditional numerical gradient calculation applied to `Off`/`Bypass` states.
|
||||
- Fixed `compute_residuals` for `OperationalState::Bypass` to correctly output zero pressure drop (`p_in - p_out`).
|
||||
- Fixed Haaland friction factor clipping the regularized Reynolds number improperly to `1.0`, breaking linear laminar pressure drop curve near 0 flow.
|
||||
- Removed dead and unused code (`swamee_jain` and `simplified` friction factors).
|
||||
- Refined numerical differentiation stepping `h` to avoid numerical instability for zero/tiny mass flows.
|
||||
|
||||
## File List
|
||||
|
||||
- crates/components/src/pipe.rs (modified)
|
||||
|
||||
## Change Log
|
||||
|
||||
- 2026-02-15: Implemented Pipe::for_water, Pipe::for_water_at_temp, Pipe::for_refrigerant
|
||||
- 2026-02-15: Code review fixes
|
||||
- 2026-02-15: **Architecture refactor** — Removed hardcoded water properties; replaced with Pipe::for_incompressible(density, viscosity). Properties from FluidBackend (Story 2.7).
|
||||
- 2026-02-21: Fixed logic and numerical stability issues found during adversarial code review.
|
||||
@@ -34,7 +34,7 @@
|
||||
# - SM typically creates next story after previous one is 'done' to incorporate learnings
|
||||
# - Dev moves story to 'review', then runs code-review (fresh context, different LLM recommended)
|
||||
|
||||
generated: 2026-02-13
|
||||
generated: 2026-02-21
|
||||
project: Entropyk
|
||||
project_key: NOKEY
|
||||
tracking_system: file-system
|
||||
@@ -50,14 +50,11 @@ development_status:
|
||||
1-5-generic-heat-exchanger-framework: done
|
||||
1-6-expansion-valve-component: done
|
||||
1-7-component-state-machine: done
|
||||
1-8-auxiliary-and-transport-components: done
|
||||
1-9-air-coils-evaporator-condenser: done
|
||||
1-10-pipe-helpers-water-refrigerant: done
|
||||
1-11-flow-junction-splitter-merger: done
|
||||
1-12-flow-boundary-source-sink: done
|
||||
epic-1-retrospective: optional
|
||||
|
||||
# Epic 2: Fluid Properties Backend
|
||||
1-8-auxiliary-transport-components: review
|
||||
1-11-flow-junctions-flowsplitter-flowmerger: done
|
||||
1-12-boundary-conditions-flowsource-flowsink: done
|
||||
|
||||
|
||||
epic-2: in-progress
|
||||
2-1-fluid-backend-trait-abstraction: done
|
||||
2-2-coolprop-integration-sys-crate: done
|
||||
@@ -67,7 +64,7 @@ development_status:
|
||||
2-6-critical-point-damping-co2-r744: done
|
||||
2-7-incompressible-fluids-support: done
|
||||
2-8-rich-thermodynamic-state-abstraction: done
|
||||
epic-2-retrospective: optional
|
||||
epic-1-retrospective: optional
|
||||
|
||||
# Epic 3: System Topology (Graph)
|
||||
epic-3: in-progress
|
||||
@@ -76,7 +73,7 @@ development_status:
|
||||
3-3-multi-circuit-machine-definition: done
|
||||
3-4-thermal-coupling-between-circuits: done
|
||||
3-5-zero-flow-branch-handling: done
|
||||
3-6-hierarchical-macro-components: done
|
||||
3-6-hierarchical-subsystems-macrocomponents: done
|
||||
epic-3-retrospective: optional
|
||||
|
||||
# Epic 4: Intelligent Solver Engine
|
||||
@@ -87,7 +84,7 @@ development_status:
|
||||
4-4-intelligent-fallback-strategy: done
|
||||
4-5-time-budgeted-solving: done
|
||||
4-6-smart-initialization-heuristic: done
|
||||
4-7-convergence-criteria-and-validation: done
|
||||
4-7-convergence-criteria-validation: done
|
||||
4-8-jacobian-freezing-optimization: done
|
||||
epic-4-retrospective: optional
|
||||
|
||||
@@ -95,14 +92,15 @@ development_status:
|
||||
epic-5: in-progress
|
||||
5-1-constraint-definition-framework: done
|
||||
5-2-bounded-control-variables: done
|
||||
5-3-residual-embedding-for-inverse-control: review
|
||||
5-4-multi-variable-control: backlog
|
||||
5-5-swappable-calibration-variables: backlog
|
||||
5-3-residual-embedding-for-inverse-control: done
|
||||
5-4-multi-variable-control: in-progress
|
||||
5-5-swappable-calibration-variables-inverse-calibration-one-shot: done
|
||||
5-6-control-variable-step-clipping-in-solver: review
|
||||
epic-5-retrospective: optional
|
||||
|
||||
# Epic 6: Multi-Platform APIs
|
||||
epic-6: backlog
|
||||
6-1-rust-native-api: backlog
|
||||
epic-6: in-progress
|
||||
6-1-rust-native-api: ready-for-dev
|
||||
6-2-python-bindings-pyo3: backlog
|
||||
6-3-c-ffi-bindings-cbindgen: backlog
|
||||
6-4-webassembly-compilation: backlog
|
||||
@@ -115,13 +113,15 @@ development_status:
|
||||
7-2-energy-balance-validation: backlog
|
||||
7-3-traceability-metadata: backlog
|
||||
7-4-debug-verbose-mode: backlog
|
||||
7-5-json-serialization-and-deserialization: backlog
|
||||
7-6-component-calibration-parameters: review
|
||||
7-7-ashrae-140-bestest-validation: backlog
|
||||
7-5-json-serialization-deserialization: backlog
|
||||
7-6-component-calibration-parameters-calib: backlog
|
||||
7-7-ashrae-140-bestest-validation-post-mvp: backlog
|
||||
7-8-inverse-calibration-parameter-estimation: backlog
|
||||
epic-7-retrospective: optional
|
||||
|
||||
# Epic 8: Component-Fluid Integration
|
||||
epic-8: in-progress
|
||||
8-1-fluid-backend-component-integration: done
|
||||
1-9-air-coils-evaporatorcoil-condensercoil-post-mvp: done
|
||||
1-10-pipe-helpers-for-water-and-refrigerant: done
|
||||
epic-8-retrospective: optional
|
||||
|
||||
Reference in New Issue
Block a user