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.
- package/CHANGELOG.md +32 -1
- package/README.md +78 -215
- package/dist/backward/candidate-resolution.d.ts +8 -0
- package/dist/backward/candidate-resolution.js +40 -0
- package/dist/backward/fixed-temperature-candidates.d.ts +4 -0
- package/dist/backward/fixed-temperature-candidates.js +188 -0
- package/dist/backward/fixed-temperature-solver.d.ts +6 -6
- package/dist/backward/fixed-temperature-solver.js +56 -9
- package/dist/backward/fixed-temperature-stationary.d.ts +4 -0
- package/dist/backward/fixed-temperature-stationary.js +146 -0
- package/dist/backward/hs-region.d.ts +50 -0
- package/dist/backward/hs-region.js +695 -0
- package/dist/backward/hs-state.d.ts +15 -0
- package/dist/backward/hs-state.js +316 -0
- package/dist/backward/hs.d.ts +1 -2
- package/dist/backward/hs.js +28 -232
- package/dist/backward/ph.d.ts +8 -3
- package/dist/backward/ph.js +102 -54
- package/dist/backward/pressure-property-region.d.ts +13 -0
- package/dist/backward/pressure-property-region.js +262 -0
- package/dist/backward/ps.d.ts +6 -1
- package/dist/backward/ps.js +103 -38
- package/dist/backward/solution-validation.d.ts +7 -2
- package/dist/backward/solution-validation.js +162 -37
- package/dist/backward/th.d.ts +3 -6
- package/dist/backward/th.js +10 -73
- package/dist/backward/tolerances.d.ts +3 -1
- package/dist/backward/tolerances.js +9 -4
- package/dist/backward/ts.d.ts +3 -6
- package/dist/backward/ts.js +10 -73
- package/dist/boundaries.d.ts +0 -1
- package/dist/boundaries.js +0 -1
- package/dist/constants.d.ts +11 -24
- package/dist/constants.js +17 -28
- package/dist/core/floating-point.d.ts +2 -0
- package/dist/core/floating-point.js +7 -0
- package/dist/core/formulation-seams.d.ts +27 -0
- package/dist/core/formulation-seams.js +289 -0
- package/dist/core/input-validation.d.ts +1 -1
- package/dist/core/input-validation.js +5 -1
- package/dist/core/region-detector.d.ts +3 -41
- package/dist/core/region-detector.js +39 -597
- package/dist/core/region3-pt.d.ts +12 -1
- package/dist/core/region3-pt.js +68 -13
- package/dist/core/solve-input-normalization.d.ts +0 -1
- package/dist/core/solve-input-normalization.js +4 -2
- package/dist/core/solver.d.ts +7 -11
- package/dist/core/solver.js +26 -18
- package/dist/core/thermodynamic-derivatives.d.ts +17 -0
- package/dist/core/thermodynamic-derivatives.js +27 -0
- package/dist/detect.d.ts +16 -3
- package/dist/detect.js +36 -3
- package/dist/errors.d.ts +11 -0
- package/dist/errors.js +16 -0
- package/dist/gas-constant.d.ts +5 -0
- package/dist/gas-constant.js +5 -0
- package/dist/index.d.ts +4 -6
- package/dist/index.js +10 -22
- package/dist/regions/boundaries.d.ts +0 -1
- package/dist/regions/boundaries.js +0 -1
- package/dist/regions/region1.d.ts +2 -2
- package/dist/regions/region1.js +1 -2
- package/dist/regions/region2.d.ts +2 -2
- package/dist/regions/region2.js +1 -2
- package/dist/regions/region3-data.d.ts +0 -1
- package/dist/regions/region3-data.js +3 -4
- package/dist/regions/region3-eval.d.ts +0 -1
- package/dist/regions/region3-eval.js +0 -1
- package/dist/regions/region3-subregions.d.ts +0 -1
- package/dist/regions/region3-subregions.js +15 -11
- package/dist/regions/region3.d.ts +4 -2
- package/dist/regions/region3.js +32 -3
- package/dist/regions/region4.d.ts +2 -1
- package/dist/regions/region4.js +39 -13
- package/dist/regions/region5.d.ts +2 -2
- package/dist/regions/region5.js +2 -3
- package/dist/regions.d.ts +0 -1
- package/dist/regions.js +0 -1
- package/dist/saturation/common.d.ts +2 -9
- package/dist/saturation/common.js +66 -45
- package/dist/saturation/region4-boundaries.d.ts +0 -5
- package/dist/saturation/region4-boundaries.js +17 -18
- package/dist/saturation/region4-hs.d.ts +2 -1
- package/dist/saturation/region4-hs.js +499 -106
- package/dist/saturation/two-phase.d.ts +2 -3
- package/dist/saturation/two-phase.js +7 -8
- package/dist/saturation.d.ts +0 -1
- package/dist/saturation.js +0 -1
- package/dist/solvers/bracketed-newton.d.ts +10 -6
- package/dist/solvers/bracketed-newton.js +19 -13
- package/dist/solvers/damped-newton-2d.d.ts +12 -0
- package/dist/solvers/damped-newton-2d.js +68 -0
- package/dist/solvers/extended-arithmetic.d.ts +6 -0
- package/dist/solvers/extended-arithmetic.js +38 -0
- package/dist/solvers/newton-raphson.d.ts +0 -1
- package/dist/solvers/newton-raphson.js +0 -1
- package/dist/transport/properties.d.ts +4 -3
- package/dist/transport/properties.js +14 -5
- package/dist/transport.d.ts +0 -1
- package/dist/transport.js +0 -1
- package/dist/types.d.ts +18 -1
- package/dist/types.js +14 -1
- package/package.json +18 -10
- package/dist/backward/objective-normalization.d.ts +0 -7
- package/dist/backward/objective-normalization.js +0 -8
- package/dist/core/public-normalization.d.ts +0 -4
- package/dist/core/public-normalization.js +0 -54
- package/dist/solvers/nelder-mead.d.ts +0 -17
- 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-
|
|
14
|
+
return 1e-9 * Math.max(1, Math.abs(expected));
|
|
9
15
|
case 'entropy':
|
|
10
|
-
return 1e-
|
|
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.
|
|
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
|
package/dist/backward/ts.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Backward equation T,S → state.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
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
|
-
*
|
|
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
|
package/dist/backward/ts.js
CHANGED
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
import * as C from '../constants.js';
|
|
2
|
-
import { IF97Error, OutOfRangeError
|
|
3
|
-
import { assertFiniteNumber } from '../core/input-validation.js';
|
|
4
|
-
import {
|
|
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
|
-
*
|
|
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
|
|
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
|
|
44
|
-
|
|
45
|
-
|
|
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
|
package/dist/boundaries.d.ts
CHANGED
package/dist/boundaries.js
CHANGED
package/dist/constants.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
-
/**
|
|
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.
|
|
51
|
-
/** Maximum specific entropy [kJ/(kg·K)] */
|
|
52
|
-
export declare const S_MAX
|
|
53
|
-
/** Minimum specific enthalpy [kJ/kg] */
|
|
54
|
-
export declare const H_MIN = -0.
|
|
55
|
-
/** Maximum specific enthalpy [kJ/kg] */
|
|
56
|
-
export declare const H_MAX
|
|
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
|
-
|
|
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
|
|
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
|
-
/**
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
export const
|
|
57
|
-
/**
|
|
58
|
-
export const
|
|
59
|
-
/**
|
|
60
|
-
export const
|
|
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
|
|
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
|
|
97
|
-
// T ≈ 644 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,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;
|