iapws-if97 2.1.5 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/README.md +78 -215
  3. package/dist/backward/candidate-resolution.d.ts +8 -0
  4. package/dist/backward/candidate-resolution.js +40 -0
  5. package/dist/backward/fixed-temperature-candidates.d.ts +4 -0
  6. package/dist/backward/fixed-temperature-candidates.js +188 -0
  7. package/dist/backward/fixed-temperature-solver.d.ts +6 -6
  8. package/dist/backward/fixed-temperature-solver.js +56 -9
  9. package/dist/backward/fixed-temperature-stationary.d.ts +4 -0
  10. package/dist/backward/fixed-temperature-stationary.js +146 -0
  11. package/dist/backward/hs-region.d.ts +50 -0
  12. package/dist/backward/hs-region.js +695 -0
  13. package/dist/backward/hs-state.d.ts +15 -0
  14. package/dist/backward/hs-state.js +316 -0
  15. package/dist/backward/hs.d.ts +1 -2
  16. package/dist/backward/hs.js +28 -232
  17. package/dist/backward/ph.d.ts +8 -3
  18. package/dist/backward/ph.js +102 -54
  19. package/dist/backward/pressure-property-region.d.ts +13 -0
  20. package/dist/backward/pressure-property-region.js +262 -0
  21. package/dist/backward/ps.d.ts +6 -1
  22. package/dist/backward/ps.js +103 -38
  23. package/dist/backward/solution-validation.d.ts +7 -2
  24. package/dist/backward/solution-validation.js +162 -37
  25. package/dist/backward/th.d.ts +3 -6
  26. package/dist/backward/th.js +10 -73
  27. package/dist/backward/tolerances.d.ts +3 -1
  28. package/dist/backward/tolerances.js +9 -4
  29. package/dist/backward/ts.d.ts +3 -6
  30. package/dist/backward/ts.js +10 -73
  31. package/dist/boundaries.d.ts +0 -1
  32. package/dist/boundaries.js +0 -1
  33. package/dist/constants.d.ts +11 -24
  34. package/dist/constants.js +17 -28
  35. package/dist/core/floating-point.d.ts +2 -0
  36. package/dist/core/floating-point.js +7 -0
  37. package/dist/core/formulation-seams.d.ts +27 -0
  38. package/dist/core/formulation-seams.js +289 -0
  39. package/dist/core/input-validation.d.ts +1 -1
  40. package/dist/core/input-validation.js +5 -1
  41. package/dist/core/region-detector.d.ts +3 -41
  42. package/dist/core/region-detector.js +39 -597
  43. package/dist/core/region3-pt.d.ts +12 -1
  44. package/dist/core/region3-pt.js +68 -13
  45. package/dist/core/solve-input-normalization.d.ts +0 -1
  46. package/dist/core/solve-input-normalization.js +4 -2
  47. package/dist/core/solver.d.ts +7 -11
  48. package/dist/core/solver.js +26 -18
  49. package/dist/core/thermodynamic-derivatives.d.ts +17 -0
  50. package/dist/core/thermodynamic-derivatives.js +27 -0
  51. package/dist/detect.d.ts +16 -3
  52. package/dist/detect.js +36 -3
  53. package/dist/errors.d.ts +11 -0
  54. package/dist/errors.js +16 -0
  55. package/dist/gas-constant.d.ts +5 -0
  56. package/dist/gas-constant.js +5 -0
  57. package/dist/index.d.ts +4 -6
  58. package/dist/index.js +10 -22
  59. package/dist/regions/boundaries.d.ts +0 -1
  60. package/dist/regions/boundaries.js +0 -1
  61. package/dist/regions/region1.d.ts +2 -2
  62. package/dist/regions/region1.js +1 -2
  63. package/dist/regions/region2.d.ts +2 -2
  64. package/dist/regions/region2.js +1 -2
  65. package/dist/regions/region3-data.d.ts +0 -1
  66. package/dist/regions/region3-data.js +3 -4
  67. package/dist/regions/region3-eval.d.ts +0 -1
  68. package/dist/regions/region3-eval.js +0 -1
  69. package/dist/regions/region3-subregions.d.ts +0 -1
  70. package/dist/regions/region3-subregions.js +15 -11
  71. package/dist/regions/region3.d.ts +4 -2
  72. package/dist/regions/region3.js +32 -3
  73. package/dist/regions/region4.d.ts +2 -1
  74. package/dist/regions/region4.js +39 -13
  75. package/dist/regions/region5.d.ts +2 -2
  76. package/dist/regions/region5.js +2 -3
  77. package/dist/regions.d.ts +0 -1
  78. package/dist/regions.js +0 -1
  79. package/dist/saturation/common.d.ts +2 -9
  80. package/dist/saturation/common.js +66 -45
  81. package/dist/saturation/region4-boundaries.d.ts +0 -5
  82. package/dist/saturation/region4-boundaries.js +17 -18
  83. package/dist/saturation/region4-hs.d.ts +2 -1
  84. package/dist/saturation/region4-hs.js +499 -106
  85. package/dist/saturation/two-phase.d.ts +2 -3
  86. package/dist/saturation/two-phase.js +7 -8
  87. package/dist/saturation.d.ts +0 -1
  88. package/dist/saturation.js +0 -1
  89. package/dist/solvers/bracketed-newton.d.ts +10 -6
  90. package/dist/solvers/bracketed-newton.js +19 -13
  91. package/dist/solvers/damped-newton-2d.d.ts +12 -0
  92. package/dist/solvers/damped-newton-2d.js +68 -0
  93. package/dist/solvers/extended-arithmetic.d.ts +6 -0
  94. package/dist/solvers/extended-arithmetic.js +38 -0
  95. package/dist/solvers/newton-raphson.d.ts +0 -1
  96. package/dist/solvers/newton-raphson.js +0 -1
  97. package/dist/transport/properties.d.ts +4 -3
  98. package/dist/transport/properties.js +14 -5
  99. package/dist/transport.d.ts +0 -1
  100. package/dist/transport.js +0 -1
  101. package/dist/types.d.ts +18 -1
  102. package/dist/types.js +14 -1
  103. package/package.json +18 -10
  104. package/dist/backward/objective-normalization.d.ts +0 -7
  105. package/dist/backward/objective-normalization.js +0 -8
  106. package/dist/core/public-normalization.d.ts +0 -4
  107. package/dist/core/public-normalization.js +0 -54
  108. package/dist/solvers/nelder-mead.d.ts +0 -17
  109. package/dist/solvers/nelder-mead.js +0 -116
@@ -1,21 +1,26 @@
1
1
  export const BACKWARD_REGION4_QUALITY_TOLERANCE = 1e-6;
2
+ export const BACKWARD_HS_NEWTON_TOLERANCE = 1e-12;
3
+ export const BACKWARD_PRESSURE_PROPERTY_TEMPERATURE_TOLERANCE = 1e-13;
4
+ export function fixedTemperatureRootTolerance(property) {
5
+ return property === 'enthalpy' ? 1e-9 : 1e-12;
6
+ }
2
7
  export function backwardConstraintTolerance(label, expected) {
3
8
  switch (label) {
4
9
  case 'pressure':
10
+ return 1e-9 * Math.abs(expected);
5
11
  case 'temperature':
6
12
  return 1e-9 * Math.max(1, Math.abs(expected));
7
13
  case 'enthalpy':
8
- return 1e-6 * Math.max(1, Math.abs(expected));
14
+ return 1e-9 * Math.max(1, Math.abs(expected));
9
15
  case 'entropy':
10
- return 1e-6 * Math.max(1, Math.abs(expected));
16
+ return 1e-9 * Math.max(1, Math.abs(expected));
11
17
  default:
12
18
  return 1e-9;
13
19
  }
14
20
  }
15
21
  export function region4SaturationPressureTolerance(pressure) {
16
- return 1e-8 * Math.max(1, Math.abs(pressure));
22
+ return 1e-8 * Math.abs(pressure);
17
23
  }
18
24
  export function backwardSpecificVolumeTolerance(expected) {
19
25
  return 1e-6 * Math.max(1, Math.abs(expected));
20
26
  }
21
- //# sourceMappingURL=tolerances.js.map
@@ -1,16 +1,13 @@
1
1
  /**
2
2
  * Backward equation T,S → state.
3
3
  *
4
- * Given temperature and specific entropy, determines the IAPWS-IF97 region
5
- * and solves for pressure using a bracketed Newton method, then returns
6
- * the full set of basic thermodynamic properties.
4
+ * Returns a state only when temperature and entropy determine it uniquely.
7
5
  */
8
6
  import type { BasicProperties } from '../types.js';
9
7
  /**
10
8
  * Solve for full basic thermodynamic state from temperature and entropy.
11
9
  *
12
- * Detects the IAPWS-IF97 region, then inverts s(p, T) to recover pressure
13
- * within the appropriate bracket for that region.
10
+ * Searches every valid isotherm branch and rejects ambiguous inputs.
14
11
  *
15
12
  * Temperatures within ±CRITICAL_T_EXCLUSION_BAND of Tc are rejected because
16
13
  * the entropy surface is nearly flat there, making pressure recovery unreliable.
@@ -20,6 +17,6 @@ import type { BasicProperties } from '../types.js';
20
17
  * @returns Basic thermodynamic properties (without transport)
21
18
  * @throws {OutOfRangeError} if T is outside [T_MIN, T_MAX]
22
19
  * @throws {IF97Error} if T is within the critical exclusion band
20
+ * @throws {AmbiguousStateError} if multiple physical states match T and s
23
21
  */
24
22
  export declare function solveTS(T: number, s: number): BasicProperties;
25
- //# sourceMappingURL=ts.d.ts.map
@@ -1,23 +1,11 @@
1
1
  import * as C from '../constants.js';
2
- import { IF97Error, OutOfRangeError, Region } from '../types.js';
3
- import { assertFiniteNumber } from '../core/input-validation.js';
4
- import { detectRegionTS } from '../core/region-detector.js';
5
- import { solveRegion3PTBasic } from '../core/region3-pt.js';
6
- import { region1 } from '../regions/region1.js';
7
- import { region2 } from '../regions/region2.js';
8
- import { region5 } from '../regions/region5.js';
9
- import { boundary23_T_to_P } from '../regions/boundaries.js';
10
- import { saturationPressure } from '../regions/region4.js';
11
- import { mixSaturationState, qualityFromSaturationProperty, saturationEndpointsAtTemperature, } from '../saturation/common.js';
12
- import { assertRegion4StateAllowed } from '../saturation/region4-boundaries.js';
13
- import { solveFixedTemperaturePressure } from './fixed-temperature-solver.js';
14
- import { validateBackwardState } from './solution-validation.js';
15
- const extractS = (s) => s.entropy;
2
+ import { IF97Error, OutOfRangeError } from '../types.js';
3
+ import { assertFiniteNumber, withinClosedLowerBound } from '../core/input-validation.js';
4
+ import { uniqueFixedTemperatureState } from './fixed-temperature-candidates.js';
16
5
  /**
17
6
  * Solve for full basic thermodynamic state from temperature and entropy.
18
7
  *
19
- * Detects the IAPWS-IF97 region, then inverts s(p, T) to recover pressure
20
- * within the appropriate bracket for that region.
8
+ * Searches every valid isotherm branch and rejects ambiguous inputs.
21
9
  *
22
10
  * Temperatures within ±CRITICAL_T_EXCLUSION_BAND of Tc are rejected because
23
11
  * the entropy surface is nearly flat there, making pressure recovery unreliable.
@@ -27,6 +15,7 @@ const extractS = (s) => s.entropy;
27
15
  * @returns Basic thermodynamic properties (without transport)
28
16
  * @throws {OutOfRangeError} if T is outside [T_MIN, T_MAX]
29
17
  * @throws {IF97Error} if T is within the critical exclusion band
18
+ * @throws {AmbiguousStateError} if multiple physical states match T and s
30
19
  */
31
20
  export function solveTS(T, s) {
32
21
  assertFiniteNumber('Temperature', T);
@@ -34,67 +23,15 @@ export function solveTS(T, s) {
34
23
  if (T < C.T_MIN || T > C.T_MAX) {
35
24
  throw new OutOfRangeError('Temperature', T, C.T_MIN, C.T_MAX);
36
25
  }
37
- if (s < C.S_MIN || s > C.S_MAX) {
26
+ if (!withinClosedLowerBound(s, C.S_MIN, 'entropy') || s > C.S_MAX) {
38
27
  throw new OutOfRangeError('Entropy', s, C.S_MIN, C.S_MAX);
39
28
  }
40
29
  if (Math.abs(T - C.Tc) < C.CRITICAL_T_EXCLUSION_BAND) {
41
30
  throw new IF97Error(`solveTS does not support temperatures within ${C.CRITICAL_T_EXCLUSION_BAND} K of the critical-point temperature Tc=${C.Tc} K; received T=${T} K`);
42
31
  }
43
- const region = detectRegionTS(T, s);
44
- switch (region) {
45
- case Region.Region1:
46
- return validateBackwardState(solveFixedTemperaturePressure(region1, T, s, saturationPressure(T), C.P_MAX, extractS, 'solveTS'), [
47
- { label: 'temperature', expected: T },
48
- { label: 'entropy', expected: s },
49
- ], {
50
- solverName: 'solveTS',
51
- expectedRegion: Region.Region1,
52
- });
53
- case Region.Region2: {
54
- const upper = T <= C.Tc
55
- ? saturationPressure(T)
56
- : T <= C.B23_T_MAX
57
- ? boundary23_T_to_P(T)
58
- : C.P_MAX;
59
- return validateBackwardState(solveFixedTemperaturePressure(region2, T, s, C.P_MIN, upper, extractS, 'solveTS'), [
60
- { label: 'temperature', expected: T },
61
- { label: 'entropy', expected: s },
62
- ], {
63
- solverName: 'solveTS',
64
- expectedRegion: Region.Region2,
65
- });
66
- }
67
- case Region.Region3: {
68
- const lower = T <= C.Tc
69
- ? saturationPressure(T)
70
- : boundary23_T_to_P(T);
71
- return validateBackwardState(solveFixedTemperaturePressure(solveRegion3PTBasic, T, s, lower, C.P_MAX, extractS, 'solveTS'), [
72
- { label: 'temperature', expected: T },
73
- { label: 'entropy', expected: s },
74
- ], {
75
- solverName: 'solveTS',
76
- expectedRegion: Region.Region3,
77
- });
78
- }
79
- case Region.Region4: {
80
- const endpoints = saturationEndpointsAtTemperature(T);
81
- assertRegion4StateAllowed(endpoints.pressure, endpoints.temperature, 'solveTS');
82
- const x = qualityFromSaturationProperty(endpoints.liquid.entropy, endpoints.vapor.entropy, s);
83
- return validateBackwardState(mixSaturationState(endpoints, x), [
84
- { label: 'temperature', expected: T },
85
- { label: 'entropy', expected: s },
86
- ], { solverName: 'solveTS', expectedRegion: Region.Region4 });
87
- }
88
- case Region.Region5:
89
- return validateBackwardState(solveFixedTemperaturePressure(region5, T, s, C.P_MIN, C.R5_P_MAX, extractS, 'solveTS'), [
90
- { label: 'temperature', expected: T },
91
- { label: 'entropy', expected: s },
92
- ], {
93
- solverName: 'solveTS',
94
- expectedRegion: Region.Region5,
95
- });
96
- default:
97
- throw new IF97Error(`solveTS cannot determine a valid IF97 state for T=${T} K, s=${s} kJ/(kg·K)`);
32
+ const state = uniqueFixedTemperatureState(T, s, 'entropy');
33
+ if (state === null) {
34
+ throw new IF97Error(`solveTS cannot determine a valid IF97 state for T=${T} K, s=${s} kJ/(kg·K)`);
98
35
  }
36
+ return state;
99
37
  }
100
- //# sourceMappingURL=ts.js.map
@@ -3,4 +3,3 @@
3
3
  */
4
4
  export { boundary23_T_to_P, boundary23_P_to_T } from './regions/boundaries.js';
5
5
  export { region3Volume, region3SatVolume } from './regions/region3-subregions.js';
6
- //# sourceMappingURL=boundaries.d.ts.map
@@ -3,4 +3,3 @@
3
3
  */
4
4
  export { boundary23_T_to_P, boundary23_P_to_T } from './regions/boundaries.js';
5
5
  export { region3Volume, region3SatVolume } from './regions/region3-subregions.js';
6
- //# sourceMappingURL=boundaries.js.map
@@ -4,11 +4,7 @@
4
4
  * Physical constants, critical point properties, and range limits
5
5
  * for the IAPWS Industrial Formulation 1997.
6
6
  */
7
- /** Specific gas constant for water [kJ/(kg·K)].
8
- * IAPWS-IF97, §2 (Table 1). Fixed value for IF97 internal consistency.
9
- * Do not replace transport correlations with this value; thermal conductivity
10
- * critical enhancement intentionally uses `R_IAPWS_2011_THERMAL`. */
11
- export declare const R = 0.461526;
7
+ export { R } from './gas-constant.js';
12
8
  /** Specific gas constant used by the IAPWS 2011 thermal conductivity λ₂ correlation [kJ/(kg·K)].
13
9
  * Intentionally differs from IF97's `R`; keep both constants distinct and named. */
14
10
  export declare const R_IAPWS_2011_THERMAL = 0.46151805;
@@ -16,20 +12,18 @@ export declare const R_IAPWS_2011_THERMAL = 0.46151805;
16
12
  export declare const Tc = 647.096;
17
13
  /** Temperature exclusion half-band around the critical point [K] */
18
14
  export declare const CRITICAL_T_EXCLUSION_BAND = 0.001;
19
- /** Region 4 endpoint snap tolerance for temperatures [K] */
15
+ /** Region 4 tolerance for outward temperature-boundary roundoff [K] */
20
16
  export declare const REGION4_TEMPERATURE_TOLERANCE = 1e-9;
21
17
  /** Safety margin used when clamping Region 4 temperatures below Tc [K] */
22
18
  export declare const REGION4_SUBCRITICAL_TEMPERATURE_MARGIN = 1e-8;
23
19
  /** Critical pressure [MPa] */
24
20
  export declare const Pc = 22.064;
25
- /** Region 4 endpoint snap tolerance for pressures [MPa] */
21
+ /** Relative tolerance for outward Region 4 pressure-boundary roundoff */
26
22
  export declare const REGION4_PRESSURE_TOLERANCE = 1e-9;
27
23
  /** Tolerance for identifying the critical h-s endpoint in Region 4 */
28
24
  export declare const REGION4_CRITICAL_HS_TOLERANCE = 0.000001;
29
25
  /** Residual tolerance for Region 4 h-s temperature inversion */
30
26
  export declare const REGION4_HS_RESIDUAL_TOLERANCE = 1e-10;
31
- /** Scan resolution used when bracketing Region 4 h-s temperature roots */
32
- export declare const REGION4_HS_BRACKET_SEGMENTS = 256;
33
27
  /** Critical density [kg/m³] */
34
28
  export declare const RHOc = 322;
35
29
  /** Triple point pressure [MPa] */
@@ -46,14 +40,14 @@ export declare const P_MAX = 100;
46
40
  export declare const T_MIN = 273.15;
47
41
  /** Maximum temperature [K] (2273.15 K = 2000 °C) */
48
42
  export declare const T_MAX = 2273.15;
49
- /** Minimum specific entropy [kJ/(kg·K)] */
50
- export declare const S_MIN = -0.00015454959194;
51
- /** Maximum specific entropy [kJ/(kg·K)] */
52
- export declare const S_MAX = 13.904956083429227;
53
- /** Minimum specific enthalpy [kJ/kg] */
54
- export declare const H_MIN = -0.041587825987;
55
- /** Maximum specific enthalpy [kJ/kg] */
56
- export declare const H_MAX = 7376.980263598506;
43
+ /** Minimum specific entropy [kJ/(kg·K)], at T_MIN and P_MAX in Region 1. */
44
+ export declare const S_MIN = -0.00858228709261889;
45
+ /** Maximum specific entropy [kJ/(kg·K)], at T_MAX and P_MIN in Region 5. */
46
+ export declare const S_MAX: number;
47
+ /** Minimum specific enthalpy [kJ/kg], at T_MIN and P_MIN in Region 1. */
48
+ export declare const H_MIN = -0.041587825987655716;
49
+ /** Maximum specific enthalpy [kJ/kg], at T_MAX and P_MIN in Region 5. */
50
+ export declare const H_MAX: number;
57
51
  /** Region 2 minimum temperature for high-P subregions [K] (623.15 K = 350 °C) */
58
52
  export declare const R2_T_MIN = 623.15;
59
53
  /** Region 2 maximum temperature for backward eqs [K] (1073.15 K = 800 °C) */
@@ -70,8 +64,6 @@ export declare const R2_P_CRT = 4;
70
64
  export declare const B23_P_MIN = 16.5291642526;
71
65
  /** B23 maximum temperature [K] */
72
66
  export declare const B23_T_MAX = 863.15;
73
- /** Region 3 minimum temperature [K] */
74
- export declare const R3_T_MIN = 623.15;
75
67
  /** Region 3 critical entropy [kJ/(kg·K)] */
76
68
  export declare const R3_S_CRT = 4.41202148223476;
77
69
  /** Region 3 critical enthalpy [kJ/kg] */
@@ -86,8 +78,3 @@ export declare const R5_T_MAX = 2273.15;
86
78
  export declare const B23_S_CURVE_MIN = 5.048096828;
87
79
  /** Maximum entropy along the B23 curve [kJ/(kg·K)], at T ≈ 644 K */
88
80
  export declare const B23_S_CURVE_MAX = 5.260578707;
89
- /** Minimum enthalpy along the B23 curve [kJ/kg], at T = 623.15 K (currently unused) */
90
- export declare const B23_H_CURVE_MIN = 2563.592004;
91
- /** Maximum enthalpy along the B23 curve [kJ/kg], at T = 863.15 K (currently unused) */
92
- export declare const B23_H_CURVE_MAX = 2812.942061;
93
- //# sourceMappingURL=constants.d.ts.map
package/dist/constants.js CHANGED
@@ -4,12 +4,9 @@
4
4
  * Physical constants, critical point properties, and range limits
5
5
  * for the IAPWS Industrial Formulation 1997.
6
6
  */
7
+ import { region5 } from './regions/region5.js';
7
8
  // ─── Fundamental Constants ──────────────────────────────────────────────────
8
- /** Specific gas constant for water [kJ/(kg·K)].
9
- * IAPWS-IF97, §2 (Table 1). Fixed value for IF97 internal consistency.
10
- * Do not replace transport correlations with this value; thermal conductivity
11
- * critical enhancement intentionally uses `R_IAPWS_2011_THERMAL`. */
12
- export const R = 0.461526;
9
+ export { R } from './gas-constant.js';
13
10
  /** Specific gas constant used by the IAPWS 2011 thermal conductivity λ₂ correlation [kJ/(kg·K)].
14
11
  * Intentionally differs from IF97's `R`; keep both constants distinct and named. */
15
12
  export const R_IAPWS_2011_THERMAL = 0.46151805;
@@ -18,20 +15,18 @@ export const R_IAPWS_2011_THERMAL = 0.46151805;
18
15
  export const Tc = 647.096;
19
16
  /** Temperature exclusion half-band around the critical point [K] */
20
17
  export const CRITICAL_T_EXCLUSION_BAND = 1e-3;
21
- /** Region 4 endpoint snap tolerance for temperatures [K] */
18
+ /** Region 4 tolerance for outward temperature-boundary roundoff [K] */
22
19
  export const REGION4_TEMPERATURE_TOLERANCE = 1e-9;
23
20
  /** Safety margin used when clamping Region 4 temperatures below Tc [K] */
24
21
  export const REGION4_SUBCRITICAL_TEMPERATURE_MARGIN = 1e-8;
25
22
  /** Critical pressure [MPa] */
26
23
  export const Pc = 22.064;
27
- /** Region 4 endpoint snap tolerance for pressures [MPa] */
24
+ /** Relative tolerance for outward Region 4 pressure-boundary roundoff */
28
25
  export const REGION4_PRESSURE_TOLERANCE = 1e-9;
29
26
  /** Tolerance for identifying the critical h-s endpoint in Region 4 */
30
27
  export const REGION4_CRITICAL_HS_TOLERANCE = 1e-6;
31
28
  /** Residual tolerance for Region 4 h-s temperature inversion */
32
29
  export const REGION4_HS_RESIDUAL_TOLERANCE = 1e-10;
33
- /** Scan resolution used when bracketing Region 4 h-s temperature roots */
34
- export const REGION4_HS_BRACKET_SEGMENTS = 256;
35
30
  /** Critical density [kg/m³] */
36
31
  export const RHOc = 322;
37
32
  // ─── Triple Point ───────────────────────────────────────────────────────────
@@ -50,14 +45,16 @@ export const P_MAX = 100.0;
50
45
  export const T_MIN = 273.15;
51
46
  /** Maximum temperature [K] (2273.15 K = 2000 °C) */
52
47
  export const T_MAX = 2273.15;
53
- /** Minimum specific entropy [kJ/(kg·K)] */
54
- export const S_MIN = -0.00015454959194;
55
- /** Maximum specific entropy [kJ/(kg·K)] */
56
- export const S_MAX = 13.904956083429227;
57
- /** Minimum specific enthalpy [kJ/kg] */
58
- export const H_MIN = -0.041587825987;
59
- /** Maximum specific enthalpy [kJ/kg] */
60
- export const H_MAX = 7376.980263598506;
48
+ // Match the Region 5 equation's rounding in the current runtime.
49
+ const REGION5_UPPER = region5(P_MIN, T_MAX);
50
+ /** Minimum specific entropy [kJ/(kg·K)], at T_MIN and P_MAX in Region 1. */
51
+ export const S_MIN = -0.00858228709261889;
52
+ /** Maximum specific entropy [kJ/(kg·K)], at T_MAX and P_MIN in Region 5. */
53
+ export const S_MAX = REGION5_UPPER.entropy;
54
+ /** Minimum specific enthalpy [kJ/kg], at T_MIN and P_MIN in Region 1. */
55
+ export const H_MIN = -0.041587825987655716;
56
+ /** Maximum specific enthalpy [kJ/kg], at T_MAX and P_MIN in Region 5. */
57
+ export const H_MAX = REGION5_UPPER.enthalpy;
61
58
  // ─── Region 2 Boundaries ───────────────────────────────────────────────────
62
59
  /** Region 2 minimum temperature for high-P subregions [K] (623.15 K = 350 °C) */
63
60
  export const R2_T_MIN = 623.15;
@@ -77,8 +74,6 @@ export const B23_P_MIN = 16.5291642526;
77
74
  /** B23 maximum temperature [K] */
78
75
  export const B23_T_MAX = 863.15;
79
76
  // ─── Region 3 Boundaries ───────────────────────────────────────────────────
80
- /** Region 3 minimum temperature [K] */
81
- export const R3_T_MIN = 623.15;
82
77
  /** Region 3 critical entropy [kJ/(kg·K)] */
83
78
  export const R3_S_CRT = 4.41202148223476;
84
79
  /** Region 3 critical enthalpy [kJ/kg] */
@@ -90,12 +85,11 @@ export const R5_T_MIN = 1073.15;
90
85
  export const R5_P_MAX = 50;
91
86
  /** Region 5 maximum temperature [K] */
92
87
  export const R5_T_MAX = 2273.15;
93
- // ─── B23 Curve Extrema (Entropy / Enthalpy) ────────────────────────────────
88
+ // ─── B23 Curve Extrema (Entropy) ───────────────────────────────────────────
94
89
  //
95
90
  // These are the GLOBAL EXTREMA along the B23 boundary curve, NOT values at
96
- // the curve endpoints. Entropy has a minimum at T ≈ 777 K and a maximum at
97
- // T ≈ 644 K. Enthalpy is monotonic: min at the low-T endpoint (623.15 K),
98
- // max at the high-T endpoint (863.15 K).
91
+ // the curve endpoints: entropy has a minimum at T ≈ 777 K and a maximum at
92
+ // T ≈ 644 K.
99
93
  //
100
94
  // Ref: Computed from Region 2 properties evaluated along B23(T) for
101
95
  // T ∈ [623.15, 863.15] K.
@@ -103,8 +97,3 @@ export const R5_T_MAX = 2273.15;
103
97
  export const B23_S_CURVE_MIN = 5.048096828;
104
98
  /** Maximum entropy along the B23 curve [kJ/(kg·K)], at T ≈ 644 K */
105
99
  export const B23_S_CURVE_MAX = 5.260578707;
106
- /** Minimum enthalpy along the B23 curve [kJ/kg], at T = 623.15 K (currently unused) */
107
- export const B23_H_CURVE_MIN = 2563.592004;
108
- /** Maximum enthalpy along the B23 curve [kJ/kg], at T = 863.15 K (currently unused) */
109
- export const B23_H_CURVE_MAX = 2812.942061;
110
- //# sourceMappingURL=constants.js.map
@@ -0,0 +1,2 @@
1
+ /** Adjacent IEEE-754 double; value must be positive and finite. */
2
+ export declare function nextPositiveFloat(value: number, direction: 1 | -1): number;
@@ -0,0 +1,7 @@
1
+ const bits = new DataView(new ArrayBuffer(8));
2
+ /** Adjacent IEEE-754 double; value must be positive and finite. */
3
+ export function nextPositiveFloat(value, direction) {
4
+ bits.setFloat64(0, value);
5
+ bits.setBigUint64(0, bits.getBigUint64(0) + BigInt(direction));
6
+ return bits.getFloat64(0);
7
+ }
@@ -0,0 +1,27 @@
1
+ import type { BasicProperties } from '../types.js';
2
+ export type FormulationSeam = '13' | '23' | '25';
3
+ export interface FormulationSeamPair {
4
+ seam: FormulationSeam;
5
+ pressure: number;
6
+ temperature: number;
7
+ /** Equations on the lower and higher temperature sides at fixed pressure. */
8
+ lower: BasicProperties;
9
+ upper: BasicProperties;
10
+ canonical: BasicProperties;
11
+ }
12
+ export interface FormulationSeamResolution {
13
+ pair: FormulationSeamPair;
14
+ kind: 'canonical' | 'gap' | 'overlap';
15
+ state: BasicProperties;
16
+ budgets: {
17
+ enthalpy: number;
18
+ entropy: number;
19
+ };
20
+ }
21
+ export declare function formulationSeamAtPressure(p: number, seam: FormulationSeam): FormulationSeamPair | null;
22
+ /** B13/B25 cannot be crossed while retaining an independently supplied temperature. */
23
+ export declare function formulationSeamAtTemperature(T: number): FormulationSeamPair | null;
24
+ export declare function findPressureSeam(p: number, target: number, property: 'enthalpy' | 'entropy'): FormulationSeamResolution | null;
25
+ export declare function matchFixedSeam(pair: FormulationSeamPair, property: 'enthalpy' | 'entropy', target: number, coordinate?: 'pressure' | 'temperature'): FormulationSeamResolution | null;
26
+ /** Locate both constraints on one bounded ribbon between independently fitted EOS. */
27
+ export declare function findHSSeam(h: number, s: number): FormulationSeamResolution | null;