iapws-if97 2.0.0 → 2.0.2

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 (36) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +75 -65
  3. package/dist/core/public-normalization.d.ts +5 -0
  4. package/dist/core/public-normalization.d.ts.map +1 -0
  5. package/dist/core/public-normalization.js +31 -0
  6. package/dist/core/public-normalization.js.map +1 -0
  7. package/dist/core/solve-input-normalization.d.ts +36 -0
  8. package/dist/core/solve-input-normalization.d.ts.map +1 -0
  9. package/dist/core/solve-input-normalization.js +71 -0
  10. package/dist/core/solve-input-normalization.js.map +1 -0
  11. package/dist/core/solver.d.ts +2 -1
  12. package/dist/core/solver.d.ts.map +1 -1
  13. package/dist/core/solver.js +13 -10
  14. package/dist/core/solver.js.map +1 -1
  15. package/dist/index.d.ts +10 -7
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +43 -12
  18. package/dist/index.js.map +1 -1
  19. package/dist/regions/region3-data.d.ts +61 -0
  20. package/dist/regions/region3-data.d.ts.map +1 -0
  21. package/dist/regions/{region3-data-am.js → region3-data.js} +81 -1
  22. package/dist/regions/region3-data.js.map +1 -0
  23. package/dist/regions/region3-subregions.d.ts.map +1 -1
  24. package/dist/regions/region3-subregions.js +61 -62
  25. package/dist/regions/region3-subregions.js.map +1 -1
  26. package/dist/types.d.ts +26 -48
  27. package/dist/types.d.ts.map +1 -1
  28. package/dist/types.js.map +1 -1
  29. package/package.json +1 -1
  30. package/dist/regions/region3-data-am.d.ts +0 -19
  31. package/dist/regions/region3-data-am.d.ts.map +0 -1
  32. package/dist/regions/region3-data-am.js.map +0 -1
  33. package/dist/regions/region3-data-nz.d.ts +0 -18
  34. package/dist/regions/region3-data-nz.d.ts.map +0 -1
  35. package/dist/regions/region3-data-nz.js +0 -53
  36. package/dist/regions/region3-data-nz.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 2.0.2
6
+
7
+ - Consolidated Region 3 subregion coefficient tables into a single module.
8
+ - Simplified Region 3 dispatcher data access through a single aggregate lookup table.
9
+ - Added structural test coverage to ensure the full Region 3 subregion table remains intact.
10
+
11
+ ## 2.0.1
12
+
13
+ - Added long-form aliases to `solve({ mode, ... })` inputs while keeping shorthand fields fully supported.
14
+ - Normalized tiny floating-point residue at the public API boundary.
15
+
5
16
  ## 2.0.0
6
17
 
7
18
  - Narrowed the root export surface to the main solver API, core types, and error classes.
package/README.md CHANGED
@@ -1,21 +1,21 @@
1
1
  # `iapws-if97`
2
2
 
3
- Industrial water and steam properties for Node.js and TypeScript, based on IAPWS-IF97 (The International Association for the Properties of Water and Steam - Industrial Formulation 1997).
3
+ Calculate industrial water and steam properties in Node.js and TypeScript, based on the [IAPWS-IF97](https://www.iapws.org/) standard (International Association for the Properties of Water and Steam Industrial Formulation 1997).
4
4
 
5
- `iapws-if97` provides forward and backward state solvers, saturation solvers, and transport-property helpers for engineering calculations involving water and steam. For the standards organization and official releases, see [IAPWS](https://www.iapws.org/).
5
+ The library provides forward and backward state solvers, saturation solvers, and transport-property helpers for engineering calculations involving water and steam.
6
6
 
7
7
  ## Features
8
8
 
9
- - IF97 Regions 1 to 5, including Region 5 high-temperature support
10
- - Forward, backward, and saturation solvers from a consistent public API
11
- - Transport properties including viscosity, thermal conductivity, surface tension, dielectric constant, and ionization constant
12
- - Typed ESM package with bundled declarations
13
- - `2.0` export split: root import for main solvers, subpaths for advanced helpers
14
- - Verified against IAPWS tables and published engineering references
9
+ - Covers IF97 Regions 15, including high-temperature Region 5
10
+ - Forward, backward, and saturation solvers behind a consistent API
11
+ - Transport properties: viscosity, thermal conductivity, surface tension, dielectric constant, and ionization constant
12
+ - Typed ESM package with bundled TypeScript declarations
13
+ - Clean export split in `2.0`: root import for main solvers, subpaths for advanced helpers
14
+ - Verified against official IAPWS tables and published engineering references
15
15
 
16
16
  ## Project Origin
17
17
 
18
- > `iapws-if97` is the core calculation library behind the WeChat MiniProgram "汽水计算器" (`wxid: wx7201fd1713b524e5`). First launched in 2019, it has served nearly 20,000 users. With the help of AI, this edition has now been updated through `R11-24 (2024)`. I am open-sourcing it in the hope that it can help others with similar engineering needs.
18
+ > `iapws-if97` is the core calculation engine behind the WeChat Mini Program "汽水计算器" (`wxid: wx7201fd1713b524e5`). Since its launch in 2019, it has served nearly 20,000 users. With the help of AI, this edition has been updated to incorporate `R11-24 (2024)`. I am open-sourcing it in the hope that it will help others with similar engineering needs.
19
19
 
20
20
  <p align="right">-- Retired Thermodynamic Engineer, Shuping</p>
21
21
 
@@ -51,7 +51,7 @@ console.log(c.quality); // 0.5
51
51
  - `solveTx(T, x)` // `K`, quality `[0, 1]`
52
52
  - `solve(input)` // same units as the selected `mode`
53
53
 
54
- Use `solve({ mode, ... })` when the input pair varies at runtime:
54
+ Use `solve({ mode, ... })` when the input pair is determined at runtime:
55
55
 
56
56
  ```ts
57
57
  import { solve } from 'iapws-if97';
@@ -59,7 +59,14 @@ import { solve } from 'iapws-if97';
59
59
  const state = solve({ mode: 'PT', p: 16, T: 823.15 });
60
60
  ```
61
61
 
62
- Supported `mode`:
62
+ `solve` accepts both short-form and long-form property names:
63
+
64
+ ```ts
65
+ const a = solve({ mode: 'PT', p: 16, T: 823.15 });
66
+ const b = solve({ mode: 'PT', pressure: 16, temperature: 823.15 });
67
+ ```
68
+
69
+ Supported modes:
63
70
 
64
71
  ```ts
65
72
  type SolveInput =
@@ -73,10 +80,11 @@ type SolveInput =
73
80
  | { mode: 'TS'; T: number; s: number };
74
81
  ```
75
82
 
83
+ You can use either form for each property. If you provide both, their values must match.
84
+
76
85
  ## Solver Return Value
77
86
 
78
- All public solvers return a `SteamState` object with thermodynamic and transport properties already populated.
79
- For user-facing documentation, it is best understood as the solver return object. The exported TypeScript type name is `SteamState`.
87
+ All solvers return a `SteamState` object containing both thermodynamic and transport properties:
80
88
 
81
89
  ```ts
82
90
  type SteamState = {
@@ -102,13 +110,15 @@ type SteamState = {
102
110
  };
103
111
  ```
104
112
 
105
- Notes:
113
+ `SteamState` always uses canonical property names. Input aliases like `p`/`pressure` do not create duplicate fields.
114
+
115
+ **Notes:**
106
116
 
107
- - `quality` is only defined for saturated states and is `null` elsewhere.
108
- - In two-phase mixture states (`0 < x < 1`), `cp`, `cv`, `speedOfSound`, `isobaricExpansion`, and `isothermalCompressibility` return `null`.
109
- - `surfaceTension` is only returned on Region 4 saturation states below the critical point. In bulk single-phase states it returns `null`.
110
- - `density` is included directly, so you do not need to invert `specificVolume` yourself.
111
- - `ionizationConstant` is returned as `null` outside the released IAPWS validity range for that correlation.
117
+ - `quality` is `null` for single-phase states it is only defined on the saturation line.
118
+ - In two-phase mixtures (`0 < x < 1`), `cp`, `cv`, `speedOfSound`, `isobaricExpansion`, and `isothermalCompressibility` are `null`.
119
+ - `surfaceTension` is only available for Region 4 saturation states below the critical point; otherwise `null`.
120
+ - `density` is provided directly no need to invert `specificVolume`.
121
+ - `ionizationConstant` is `null` outside the IAPWS validity range for that correlation.
112
122
 
113
123
  ## Units
114
124
 
@@ -119,7 +129,7 @@ Notes:
119
129
  - Enthalpy, internal energy: `kJ/kg`
120
130
  - Entropy, heat capacities: `kJ/(kg·K)`
121
131
  - Speed of sound: `m/s`
122
- - Quality: dimensionless, `0` to `1` on the saturation line
132
+ - Quality: dimensionless, `0`–`1` (saturation line only)
123
133
  - Viscosity: `Pa·s`
124
134
  - Thermal conductivity: `W/(m·K)`
125
135
  - Surface tension: `N/m`
@@ -128,12 +138,12 @@ Notes:
128
138
  - Isobaric expansion coefficient: `1/K`
129
139
  - Isothermal compressibility: `1/MPa`
130
140
 
131
- Fields documented as `number | null` return `null` when the property is not defined for the requested state.
141
+ Any field typed as `number | null` returns `null` when the property is undefined for the given state.
132
142
 
133
143
  ## Advanced Imports
134
144
 
135
- The package root is intentionally limited to the main solver API, core types, and error classes.
136
- Lower-level helpers are available from dedicated subpaths:
145
+ The package root exports only the main solver API, core types, and error classes.
146
+ Lower-level helpers are available through dedicated subpaths:
137
147
 
138
148
  - `iapws-if97/transport`: `viscosity`, `thermalConductivity`, `surfaceTension`, `dielectricConstant`, `ionizationConstant`
139
149
  - `iapws-if97/regions`: `region1`, `region2`, `region3ByRhoT`, `region5`
@@ -152,8 +162,8 @@ import { detectRegionPT } from 'iapws-if97/detect';
152
162
 
153
163
  ## Migration to 2.0
154
164
 
155
- Version `2.0.0` narrows the root export surface to the main solver API.
156
- If you imported lower-level helpers from the package root in `1.x`, move them to subpath imports:
165
+ Version `2.0` limits the root export to the main solver API.
166
+ If you imported lower-level helpers from the package root in `1.x`, update them to use subpath imports:
157
167
 
158
168
  - `import { viscosity } from 'iapws-if97'` → `import { viscosity } from 'iapws-if97/transport'`
159
169
  - `import { region1 } from 'iapws-if97'` → `import { region1 } from 'iapws-if97/regions'`
@@ -162,54 +172,56 @@ If you imported lower-level helpers from the package root in `1.x`, move them to
162
172
 
163
173
  ## Advanced Usage Notes
164
174
 
165
- - `region1`, `region2`, `region3ByRhoT`, and `region5` return core thermodynamic properties without transport-property enrichment.
166
- - `detectRegion*` helpers return a `Region` enum value or `-1` when the input pair is outside IF97 validity.
167
- - `viscosity(T, rho)` and `dielectricConstant(T, rho)` require temperature and density, not a `SteamState`.
168
- - `ionizationConstant(T, rho)` also requires temperature and density, and returns `null` outside its released validity range.
169
- - `thermalConductivity(T, rho, cp?, cv?, drhodP_T?, mu?)` supports two levels:
170
- - minimal call: base conductivity from `T` and `rho`
171
- - full call: include `cp`, `cv`, `drhodP_T`, and `mu` to evaluate the IAPWS 2011 critical-enhancement term
172
- - `surfaceTension(T)` returns `null` outside its valid temperature range and should be interpreted as a saturation-line property.
173
- - `solveTH(T, h)` prefers the compressed-liquid branch when a subcritical liquid state and a two-phase state are both thermodynamically possible at the same `T` and `h`; exact saturation endpoints still return Region 4 metadata.
175
+ - `region1`, `region2`, `region3ByRhoT`, and `region5` return core thermodynamic properties **without** transport-property enrichment.
176
+ - `detectRegion*` helpers return a `Region` enum value, or `-1` if the input falls outside IF97 validity.
177
+ - `viscosity(T, rho)` and `dielectricConstant(T, rho)` take temperature and density directly — not a `SteamState`.
178
+ - `ionizationConstant(T, rho)` also takes temperature and density; returns `null` outside its validity range.
179
+ - `thermalConductivity(T, rho, cp?, cv?, drhodP_T?, mu?)` supports two calling levels:
180
+ - **Minimal:** pass `T` and `rho` for base conductivity.
181
+ - **Full:** additionally pass `cp`, `cv`, `drhodP_T`, and `mu` to include the IAPWS 2011 critical-enhancement term.
182
+ - `surfaceTension(T)` returns `null` outside its valid temperature range. It applies only along the saturation line.
183
+ - `solveTH(T, h)` prefers the compressed-liquid branch when both a subcritical liquid state and a two-phase state are possible at the same `T` and `h`. Exact saturation endpoints still return Region 4 metadata.
174
184
 
175
185
  ## Errors and Limits
176
186
 
177
- The library throws typed errors from the public API:
187
+ The library throws typed errors:
178
188
 
179
- - `OutOfRangeError`: an input is outside the supported IF97 range
180
- - `ConvergenceError`: an internal numerical solve failed to converge
181
- - `IF97Error`: base class for library-specific failures
189
+ | Error | Meaning |
190
+ | --- | --- |
191
+ | `OutOfRangeError` | Input is outside the supported IF97 range |
192
+ | `ConvergenceError` | An internal iterative solve failed to converge |
193
+ | `IF97Error` | Base class for all library-specific errors |
182
194
 
183
- Typical boundary rules:
195
+ **Boundary rules:**
184
196
 
185
- - `solvePT(p, T)` supports the IF97 industrial range up to `100 MPa` and `2273.15 K`, with Region 5 limited to `50 MPa`.
186
- - The exact critical point (`22.064 MPa`, `647.096 K`) is rejected with `IF97Error` because derivative properties are singular there.
187
- - `solvePx(p, x)` is only valid on the saturation line for `Pt <= p <= Pc`.
188
- - `solveTx(T, x)` is only valid on the saturation line for `273.15 K <= T <= Tc`.
189
- - `solveTH(T, h)` and `solveTS(T, s)` currently support Region 1 to Region 5. Inputs within `0.001 K` of the critical-point temperature are rejected conservatively with `IF97Error`.
197
+ - `solvePT(p, T)` covers the IF97 industrial range up to `100 MPa` / `2273.15 K`. Region 5 is limited to `50 MPa`.
198
+ - The exact critical point (`22.064 MPa`, `647.096 K`) is rejected because derivative properties are singular there.
199
+ - `solvePx(p, x)` requires the saturation line: `Pt p Pc`.
200
+ - `solveTx(T, x)` requires the saturation line: `273.15 K T Tc`.
201
+ - `solveTH(T, h)` and `solveTS(T, s)` support Regions 15. Inputs within `0.001 K` of the critical temperature are rejected.
190
202
  - `x` must be in `[0, 1]` for two-phase calculations.
191
- - Properties that are not defined for the requested state are returned as `null`, not `NaN`.
203
+ - Undefined properties are returned as `null`, never `NaN`.
192
204
 
193
- ## Validity notes
205
+ ## Validity Notes
194
206
 
195
- - Thermodynamic core follows IF97 industrial validity ranges up to `100 MPa` and `2273.15 K`, including Region 5.
196
- - Surface tension is only meaningful on the saturation line below the critical point.
207
+ - Thermodynamic properties follow IF97 validity ranges: up to `100 MPa` and `2273.15 K` (including Region 5).
208
+ - Surface tension applies only along the saturation line below the critical point.
197
209
  - Thermal conductivity follows the IAPWS 2011 release.
198
- - Ionization constant uses the latest IAPWS 2024 revised release and is officially recommended for stable fluid states from `273.15 K` to `1273.15 K` and up to `1000 MPa`.
210
+ - Ionization constant follows the IAPWS 2024 revised release, valid for stable fluid states from `273.15 K` to `1273.15 K` and up to `1000 MPa`.
199
211
 
200
212
  ## Verification
201
213
 
202
- The test suite includes:
214
+ The test suite covers:
203
215
 
204
- - Official IF97 verification tables for Regions 1 to 5
205
- - Backward-equation round trips
206
- - Temperature-led backward round trips for `TH` and `TS`
207
- - High-pressure Region 4 regression tests
216
+ - Official IF97 verification tables (Regions 15)
217
+ - Backward-equation round-trip accuracy
218
+ - Temperature-led backward round trips (`TH` and `TS`)
219
+ - High-pressure Region 4 regressions
208
220
  - IAPWS R11-24 ionization-constant verification values
209
- - Coverage thresholds enforced in CI-style local runs
210
- - ASME and GB/T steam-table comparison reports for published standard values
221
+ - Coverage thresholds enforced locally
222
+ - ASME and GB/T steam-table comparisons against published values
211
223
 
212
- Run locally:
224
+ To run locally:
213
225
 
214
226
  ```bash
215
227
  npm run build
@@ -220,8 +232,8 @@ npm run test:standards
220
232
 
221
233
  ### ASME Validation Snapshot
222
234
 
223
- `tests/standards-asme/asme-steam-table-report.test.ts` compares saturation states against ASME International Steam Tables for Industrial Use, 3rd ed., Table S-2 ("Properties of Saturated Water and Steam (Pressure)").
224
- Each pressure case checks 7 published values: saturation temperature, saturated-liquid/saturated-vapor specific volume, enthalpy, and entropy.
235
+ Compares saturation states against *ASME International Steam Tables for Industrial Use*, 3rd ed., Table S-2 ("Properties of Saturated Water and Steam Pressure").
236
+ Each case checks 7 values: saturation temperature, liquid/vapor specific volume, enthalpy, and entropy.
225
237
 
226
238
  | ASME case | Pressure (MPa) | Points checked | Max relative error |
227
239
  | --- | ---: | ---: | ---: |
@@ -237,8 +249,8 @@ The current ASME regression threshold is `maxRelativeError < 5e-4` (less than `0
237
249
 
238
250
  ### GB/T Validation Snapshot
239
251
 
240
- `tests/standards-cn/gbt34060-report.test.ts` compares superheated-steam states against `GB/T 34060-2017`, Table A.3(续), page 55.
241
- Each temperature case checks 4 published values at `10 MPa`: specific volume, enthalpy, entropy, and speed of sound.
252
+ Compares superheated-steam states against *GB/T 34060-2017*, Table A.3(续), page 55.
253
+ Each case checks 4 values at `10 MPa`: specific volume, enthalpy, entropy, and speed of sound.
242
254
 
243
255
  | GB/T case | Pressure (MPa) | Temperature (°C) | Points checked | Max relative error |
244
256
  | --- | ---: | ---: | ---: | ---: |
@@ -254,7 +266,7 @@ The current GB/T regression threshold is `maxRelativeError < 5e-4` (less than `0
254
266
 
255
267
  ## TypeScript
256
268
 
257
- The package ships with bundled declarations and ESM exports.
269
+ The package ships with bundled TypeScript declarations and ESM exports.
258
270
 
259
271
  ```ts
260
272
  import type { SolveInput, SteamState } from 'iapws-if97';
@@ -283,6 +295,4 @@ MIT
283
295
 
284
296
  ## Disclaimer
285
297
 
286
- This software is provided "as is", without warranty of any kind, express or implied, including but not limited to warranties of merchantability, fitness for a particular purpose, and noninfringement.
287
-
288
- In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use of the software.
298
+ This software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability arising from the use of this software.
@@ -0,0 +1,5 @@
1
+ import type { BasicProperties, SteamState } from '../types.js';
2
+ type PublicState = BasicProperties | SteamState;
3
+ export declare function normalizePublicState<T extends PublicState>(state: T): T;
4
+ export {};
5
+ //# sourceMappingURL=public-normalization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-normalization.d.ts","sourceRoot":"","sources":["../../src/core/public-normalization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAM/D,KAAK,WAAW,GAAG,eAAe,GAAG,UAAU,CAAC;AAsBhD,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAYvE"}
@@ -0,0 +1,31 @@
1
+ // Only snap values that are effectively simple decimals plus machine-noise.
2
+ const SIMPLE_DECIMAL_PLACES = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
3
+ const SNAP_ULPS = 8;
4
+ function snapSimpleDecimal(value) {
5
+ if (!Number.isFinite(value)) {
6
+ return value;
7
+ }
8
+ for (const decimals of SIMPLE_DECIMAL_PLACES) {
9
+ const factor = 10 ** decimals;
10
+ const candidate = Math.round(value * factor) / factor;
11
+ // Scale the acceptance window with magnitude so we only absorb
12
+ // binary floating-point residue, not meaningful engineering deltas.
13
+ const tolerance = SNAP_ULPS * Number.EPSILON * Math.max(1, Math.abs(value), Math.abs(candidate));
14
+ if (Math.abs(value - candidate) <= tolerance) {
15
+ return Object.is(candidate, -0) ? 0 : candidate;
16
+ }
17
+ }
18
+ return Object.is(value, -0) ? 0 : value;
19
+ }
20
+ export function normalizePublicState(state) {
21
+ const normalized = { ...state };
22
+ for (const [key, value] of Object.entries(state)) {
23
+ // Preserve enum/null fields exactly; only normalize exposed numeric outputs.
24
+ if (key === 'region' || value === null || typeof value !== 'number') {
25
+ continue;
26
+ }
27
+ normalized[key] = snapSimpleDecimal(value);
28
+ }
29
+ return normalized;
30
+ }
31
+ //# sourceMappingURL=public-normalization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-normalization.js","sourceRoot":"","sources":["../../src/core/public-normalization.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,MAAM,qBAAqB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAU,CAAC;AACtE,MAAM,SAAS,GAAG,CAAC,CAAC;AAIpB,SAAS,iBAAiB,CAAC,KAAa;IACtC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,MAAM,QAAQ,IAAI,qBAAqB,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,EAAE,IAAI,QAAQ,CAAC;QAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;QACtD,+DAA+D;QAC/D,oEAAoE;QACpE,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;QAEjG,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC,IAAI,SAAS,EAAE,CAAC;YAC7C,OAAO,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAClD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAwB,KAAQ;IAClE,MAAM,UAAU,GAAG,EAAE,GAAG,KAAK,EAA8C,CAAC;IAE5E,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,6EAA6E;QAC7E,IAAI,GAAG,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACpE,SAAS;QACX,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,UAA0B,CAAC;AACpC,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { SolveInput } from '../types.js';
2
+ export type CanonicalSolveInput = {
3
+ mode: 'PT';
4
+ p: number;
5
+ T: number;
6
+ } | {
7
+ mode: 'PH';
8
+ p: number;
9
+ h: number;
10
+ } | {
11
+ mode: 'PS';
12
+ p: number;
13
+ s: number;
14
+ } | {
15
+ mode: 'HS';
16
+ h: number;
17
+ s: number;
18
+ } | {
19
+ mode: 'Px';
20
+ p: number;
21
+ x: number;
22
+ } | {
23
+ mode: 'Tx';
24
+ T: number;
25
+ x: number;
26
+ } | {
27
+ mode: 'TH';
28
+ T: number;
29
+ h: number;
30
+ } | {
31
+ mode: 'TS';
32
+ T: number;
33
+ s: number;
34
+ };
35
+ export declare function normalizeSolveInput(input: SolveInput): CanonicalSolveInput;
36
+ //# sourceMappingURL=solve-input-normalization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solve-input-normalization.d.ts","sourceRoot":"","sources":["../../src/core/solve-input-normalization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA6BzC,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,GAAG,mBAAmB,CAuD1E"}
@@ -0,0 +1,71 @@
1
+ import { IF97Error } from '../types.js';
2
+ function pickNumericAlias(input, shortKey, longKey, label) {
3
+ const shortValue = input[shortKey];
4
+ const longValue = input[longKey];
5
+ if (shortValue === undefined && longValue === undefined) {
6
+ throw new IF97Error(`solve input requires '${shortKey}' or '${longKey}' for ${label}`);
7
+ }
8
+ if (shortValue !== undefined &&
9
+ longValue !== undefined &&
10
+ !Object.is(shortValue, longValue)) {
11
+ throw new IF97Error(`solve input received conflicting values for '${shortKey}' and '${longKey}'`);
12
+ }
13
+ return (shortValue ?? longValue);
14
+ }
15
+ // Normalize public solve() aliases to the canonical short-key form used internally.
16
+ export function normalizeSolveInput(input) {
17
+ const raw = input;
18
+ switch (input.mode) {
19
+ case 'PT':
20
+ return {
21
+ mode: 'PT',
22
+ p: pickNumericAlias(raw, 'p', 'pressure', 'pressure'),
23
+ T: pickNumericAlias(raw, 'T', 'temperature', 'temperature'),
24
+ };
25
+ case 'PH':
26
+ return {
27
+ mode: 'PH',
28
+ p: pickNumericAlias(raw, 'p', 'pressure', 'pressure'),
29
+ h: pickNumericAlias(raw, 'h', 'enthalpy', 'enthalpy'),
30
+ };
31
+ case 'PS':
32
+ return {
33
+ mode: 'PS',
34
+ p: pickNumericAlias(raw, 'p', 'pressure', 'pressure'),
35
+ s: pickNumericAlias(raw, 's', 'entropy', 'entropy'),
36
+ };
37
+ case 'HS':
38
+ return {
39
+ mode: 'HS',
40
+ h: pickNumericAlias(raw, 'h', 'enthalpy', 'enthalpy'),
41
+ s: pickNumericAlias(raw, 's', 'entropy', 'entropy'),
42
+ };
43
+ case 'Px':
44
+ return {
45
+ mode: 'Px',
46
+ p: pickNumericAlias(raw, 'p', 'pressure', 'pressure'),
47
+ x: pickNumericAlias(raw, 'x', 'quality', 'quality'),
48
+ };
49
+ case 'Tx':
50
+ return {
51
+ mode: 'Tx',
52
+ T: pickNumericAlias(raw, 'T', 'temperature', 'temperature'),
53
+ x: pickNumericAlias(raw, 'x', 'quality', 'quality'),
54
+ };
55
+ case 'TH':
56
+ return {
57
+ mode: 'TH',
58
+ T: pickNumericAlias(raw, 'T', 'temperature', 'temperature'),
59
+ h: pickNumericAlias(raw, 'h', 'enthalpy', 'enthalpy'),
60
+ };
61
+ case 'TS':
62
+ return {
63
+ mode: 'TS',
64
+ T: pickNumericAlias(raw, 'T', 'temperature', 'temperature'),
65
+ s: pickNumericAlias(raw, 's', 'entropy', 'entropy'),
66
+ };
67
+ default:
68
+ throw new IF97Error(`Unsupported solve mode: ${input.mode ?? 'undefined'}`);
69
+ }
70
+ }
71
+ //# sourceMappingURL=solve-input-normalization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solve-input-normalization.js","sourceRoot":"","sources":["../../src/core/solve-input-normalization.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAYxC,SAAS,gBAAgB,CACvB,KAA8B,EAC9B,QAAgB,EAChB,OAAe,EACf,KAAa;IAEb,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAEjC,IAAI,UAAU,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QACxD,MAAM,IAAI,SAAS,CAAC,yBAAyB,QAAQ,SAAS,OAAO,SAAS,KAAK,EAAE,CAAC,CAAC;IACzF,CAAC;IAED,IACE,UAAU,KAAK,SAAS;QACxB,SAAS,KAAK,SAAS;QACvB,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EACjC,CAAC;QACD,MAAM,IAAI,SAAS,CACjB,gDAAgD,QAAQ,UAAU,OAAO,GAAG,CAC7E,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,UAAU,IAAI,SAAS,CAAW,CAAC;AAC7C,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,mBAAmB,CAAC,KAAiB;IACnD,MAAM,GAAG,GAAG,KAAgC,CAAC;IAE7C,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,IAAI;YACP,OAAO;gBACL,IAAI,EAAE,IAAI;gBACV,CAAC,EAAE,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,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;aACpD,CAAC;QACJ,KAAK,IAAI;YACP,OAAO;gBACL,IAAI,EAAE,IAAI;gBACV,CAAC,EAAE,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,aAAa,EAAE,aAAa,CAAC;gBAC3D,CAAC,EAAE,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,CAAC;aACtD,CAAC;QACJ,KAAK,IAAI;YACP,OAAO;gBACL,IAAI,EAAE,IAAI;gBACV,CAAC,EAAE,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,aAAa,EAAE,aAAa,CAAC;gBAC3D,CAAC,EAAE,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC;aACpD,CAAC;QACJ;YACE,MAAM,IAAI,SAAS,CAAC,2BAA4B,KAA4B,CAAC,IAAI,IAAI,WAAW,EAAE,CAAC,CAAC;IACxG,CAAC;AACH,CAAC"}
@@ -13,7 +13,8 @@ import type { SteamState, SolveInput } from '../types.js';
13
13
  export declare function solvePT(p: number, T: number): SteamState;
14
14
  /**
15
15
  * Unified solver: compute full thermodynamic state from any supported input pair.
16
- * Routes to the correct solver based on input mode, enriches with transport properties.
16
+ * Routes to the correct solver based on input mode, enriches with transport properties,
17
+ * and accepts either shorthand or long-form input field names.
17
18
  */
18
19
  export declare function solve(input: SolveInput): SteamState;
19
20
  //# sourceMappingURL=solver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"solver.d.ts","sourceRoot":"","sources":["../../src/core/solver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAmB,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA2C3E;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU,CAqCxD;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAanD"}
1
+ {"version":3,"file":"solver.d.ts","sourceRoot":"","sources":["../../src/core/solver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAmB,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA4C3E;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU,CAqCxD;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAenD"}
@@ -5,6 +5,7 @@ import { region2 } from '../regions/region2.js';
5
5
  import { region5 } from '../regions/region5.js';
6
6
  import { detectRegionPT } from './region-detector.js';
7
7
  import { solveRegion3PTBasic } from './region3-pt.js';
8
+ import { normalizeSolveInput } from './solve-input-normalization.js';
8
9
  import { viscosity, thermalConductivity, surfaceTension, dielectricConstant, ionizationConstant } from '../transport/properties.js';
9
10
  import { solvePH } from '../backward/ph.js';
10
11
  import { solvePS } from '../backward/ps.js';
@@ -77,18 +78,20 @@ export function solvePT(p, T) {
77
78
  }
78
79
  /**
79
80
  * Unified solver: compute full thermodynamic state from any supported input pair.
80
- * Routes to the correct solver based on input mode, enriches with transport properties.
81
+ * Routes to the correct solver based on input mode, enriches with transport properties,
82
+ * and accepts either shorthand or long-form input field names.
81
83
  */
82
84
  export function solve(input) {
83
- switch (input.mode) {
84
- case 'PT': return solvePT(input.p, input.T);
85
- case 'PH': return enrichState(solvePH(input.p, input.h));
86
- case 'PS': return enrichState(solvePS(input.p, input.s));
87
- case 'HS': return enrichState(solveHS(input.h, input.s));
88
- case 'Px': return enrichState(solvePx(input.p, input.x));
89
- case 'Tx': return enrichState(solveTx(input.T, input.x));
90
- case 'TH': return enrichState(solveTH(input.T, input.h));
91
- case 'TS': return enrichState(solveTS(input.T, input.s));
85
+ const normalized = normalizeSolveInput(input);
86
+ switch (normalized.mode) {
87
+ case 'PT': return solvePT(normalized.p, normalized.T);
88
+ case 'PH': return enrichState(solvePH(normalized.p, normalized.h));
89
+ case 'PS': return enrichState(solvePS(normalized.p, normalized.s));
90
+ case 'HS': return enrichState(solveHS(normalized.h, normalized.s));
91
+ case 'Px': return enrichState(solvePx(normalized.p, normalized.x));
92
+ case 'Tx': return enrichState(solveTx(normalized.T, normalized.x));
93
+ case 'TH': return enrichState(solveTH(normalized.T, normalized.h));
94
+ case 'TS': return enrichState(solveTS(normalized.T, normalized.s));
92
95
  default:
93
96
  throw new IF97Error(`Unsupported solve mode: ${input.mode ?? 'undefined'}`);
94
97
  }
@@ -1 +1 @@
1
- {"version":3,"file":"solver.js","sourceRoot":"","sources":["../../src/core/solver.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,CAAC,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,cAAc,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACpI,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE9D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';
7
- export { solvePH } from './backward/ph.js';
8
- export { solvePS } from './backward/ps.js';
9
- export { solveHS } from './backward/hs.js';
10
- export { solveTH } from './backward/th.js';
11
- export { solveTS } from './backward/ts.js';
12
- export { solvePx, solveTx } from './saturation/two-phase.js';
6
+ import type { BasicProperties, SteamState, SolveInput } from './types.js';
7
+ export declare function solvePT(p: number, T: number): SteamState;
8
+ export declare function solve(input: SolveInput): SteamState;
9
+ export declare function solvePH(p: number, h: number): BasicProperties;
10
+ export declare function solvePS(p: number, s: number): BasicProperties;
11
+ export declare function solveHS(h: number, s: number): BasicProperties;
12
+ export declare function solveTH(T: number, h: number): BasicProperties;
13
+ export declare function solveTS(T: number, s: number): BasicProperties;
14
+ export declare function solvePx(p: number, x: number): BasicProperties;
15
+ export declare function solveTx(T: number, x: number): BasicProperties;
13
16
  export type { SteamState, SolveInput } from './types.js';
14
17
  export { Region, IF97Error, OutOfRangeError, ConvergenceError } from './types.js';
15
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAG7D,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAqB1E,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU,CAExD;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAEnD;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,eAAe,CAE7D;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,eAAe,CAE7D;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,eAAe,CAE7D;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,eAAe,CAE7D;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,eAAe,CAE7D;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,eAAe,CAE7D;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,eAAe,CAE7D;AAGD,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,15 +1,46 @@
1
- /**
2
- * iapws-if97 IAPWS-IF97 Steam/Water Properties Library
3
- *
4
- * Public API exports.
5
- */
1
+ import { solve as solveAny, solvePT as solvePTInternal } from './core/solver.js';
2
+ import { normalizePublicState } from './core/public-normalization.js';
3
+ import { solvePH as solvePHInternal } from './backward/ph.js';
4
+ import { solvePS as solvePSInternal } from './backward/ps.js';
5
+ import { solveHS as solveHSInternal } from './backward/hs.js';
6
+ import { solveTH as solveTHInternal } from './backward/th.js';
7
+ import { solveTS as solveTSInternal } from './backward/ts.js';
8
+ import { solvePx as solvePxInternal, solveTx as solveTxInternal } from './saturation/two-phase.js';
9
+ function normalizeBasicState(state) {
10
+ return normalizePublicState(state);
11
+ }
12
+ function normalizeSteamState(state) {
13
+ return normalizePublicState(state);
14
+ }
6
15
  // Core solvers
7
- export { solvePT, solve } from './core/solver.js';
8
- export { solvePH } from './backward/ph.js';
9
- export { solvePS } from './backward/ps.js';
10
- export { solveHS } from './backward/hs.js';
11
- export { solveTH } from './backward/th.js';
12
- export { solveTS } from './backward/ts.js';
13
- export { solvePx, solveTx } from './saturation/two-phase.js';
16
+ // Normalize only at the public package boundary so internal solver math
17
+ // keeps full raw precision during iteration and region transitions.
18
+ export function solvePT(p, T) {
19
+ return normalizeSteamState(solvePTInternal(p, T));
20
+ }
21
+ export function solve(input) {
22
+ return normalizeSteamState(solveAny(input));
23
+ }
24
+ export function solvePH(p, h) {
25
+ return normalizeBasicState(solvePHInternal(p, h));
26
+ }
27
+ export function solvePS(p, s) {
28
+ return normalizeBasicState(solvePSInternal(p, s));
29
+ }
30
+ export function solveHS(h, s) {
31
+ return normalizeBasicState(solveHSInternal(h, s));
32
+ }
33
+ export function solveTH(T, h) {
34
+ return normalizeBasicState(solveTHInternal(T, h));
35
+ }
36
+ export function solveTS(T, s) {
37
+ return normalizeBasicState(solveTSInternal(T, s));
38
+ }
39
+ export function solvePx(p, x) {
40
+ return normalizeBasicState(solvePxInternal(p, x));
41
+ }
42
+ export function solveTx(T, x) {
43
+ return normalizeBasicState(solveTxInternal(T, x));
44
+ }
14
45
  export { Region, IF97Error, OutOfRangeError, ConvergenceError } from './types.js';
15
46
  //# sourceMappingURL=index.js.map