Commit Graph

5827 Commits

Author SHA1 Message Date
Ian Bell
aa0ae2f46d Ignore the .cache dir (#2752) 2026-04-20 15:57:57 -04:00
Ian Bell
4ad372b0b2 fix(flash): return rhomolar_critical from PT_flash at the critical point (#2738) (#2750)
At the critical point dP/drho -> 0, so solver_rho_Tp is ill-conditioned and
a tight pressure residual does not imply a tight density. PropsSI('Dmass',
'T', Tcrit, 'P', Pcrit, 'CO2') returned 466.207 kg/m^3 instead of the true
467.600 kg/m^3. Add a short-circuit at the top of PT_flash (mirroring the
existing guard in PQ_flash) that detects exact-critical inputs within 1e-10
relative on both T and p and returns the tabulated critical density.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 15:46:50 -04:00
Ian Bell
c075a168fb feat(mixtures): add mixture models from Bell-JCED-2025 and Bell-IJT-2020 (#2748)
Adds 75 new/updated binary mixture interaction parameters:

**Bell-JCED-2025** (doi:10.1021/acs.jced.4c00699):
- 19 Phase II pairs with full 4-parameter models (βT, γT, βv, γv):
  RC318/n-Butane, R125/CF3I, R32/CF3I, IsoButane/R1234ze(Z),
  R1243zf/IsoButane, propane/R1234yf, propane/R1243zf,
  R125/R1234ze(E), R125/R1243zf, R143a/R1234ze(E),
  R1243zf/R152a, R152a/R245fa, R1234ze(E)/R245fa, R124/RC318
- 5 existing pairs updated with improved 4-parameter models:
  CO2/R1234yf, CO2/R1234ze(E), R1234ze(E)/IsoButane,
  propane/R1234ze(E), R152a/R1234ze(E)
- 55 Phase I pairs with γT only (βT=βv=γv=1)

**Bell-IJT-2020** (doi:10.1007/s10765-020-02700-4):
- CO2/CF3I pair from Bell & McLinden 2020

Closes #2726

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 15:03:30 -04:00
Ian Bell
10c7ba2ac1 feat(cubics): add Chebyshev superancillaries for SRK and Peng-Robinson EOS (#2744)
* feat(cubics): add Chebyshev superancillaries for SRK and Peng-Robinson EOS (#2739)

Port piecewise Chebyshev superancillary expansions from teqp for SRK and PR
cubic EOS, providing fast and accurate saturation properties without iterative
flash. Adds `calc_saturation_ancillary`, `update_QT_pure_superanc`, and
`calc_superanc_Tmax` on `AbstractCubicBackend`; vdW data omitted as CoolProp
does not expose a vdW backend.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(cubics): address review feedback on cubic superancillary

- Fix stale comment on calc_superanc_Tmax (no Newton steps; closed-form)
- Move SRK_CODE/PR_CODE/P_CODE/RHOL_CODE/RHOV_CODE constants before
  supercubic() so switch cases use named constants instead of magic ints
- Add T > Tmax guard in calc_saturation_ancillary and update_QT_pure_superanc
  to throw CoolProp ValueError instead of propagating std::invalid_argument
- Add is_pure_or_pseudopure guard in calc_superanc_Tmax
- Near-Tc test now derives pc from the superancillary itself rather than
  AS->p_critical() (which reflects the real fluid, not the cubic model)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs(cubics): document SRK/PR superancillary APIs with timing and citation

Add a Superancillaries for SRK and PR subsection to the Cubic EoS docs
covering update_QT_pure_superanc and saturation_ancillary, their
constraints (pure-only, PR/SRK-only, T-input, T <= Tc, not used by
PropsSI), a %timeit comparison against the full cubic flash, and a
citation to Bell and Deiters, IECR 2021 (added to the bib library).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 15:00:56 -04:00
Ian Bell
c4c2c293d6 test(plot): regenerate isoline test data for exact SRK/PR coefficients (#2749)
PR #2745 replaced the rounded SRK/PR Omega coefficients with their exact
analytical values. Even though the Plot tests use the Helmholtz EOS for
R134a, SRK enters as the initial density guess in
HelmholtzEOSMixtureBackend::solver_rho_Tp(), so the sub-ppm change in the
SRK covolume slightly perturbs the critical-point pressure (~1.5e-3 Pa),
which cascades through p_small, psat_max, and P_max into every isoline
value and exceeds the 1e-10 / 1e-7 WithinAbs tolerances.

Regenerated via dev/scripts/generate_Plot_test_data.py against a build
with the new constants and re-ran clang-format. All 503 assertions in
the three [Plot] test cases now pass.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 14:31:06 -04:00
Jeff Henning
338c83846e Mathematica wrapper web page .rst touchups [skip ci] (#2747) 2026-04-20 05:31:16 -04:00
Ian Bell
df712bfa26 fix(cubics): replace rounded SRK/PR Omega coefficients with exact values (#2745)
Replaces truncated literature values (e.g. 0.42747, 0.07780) with the
full-precision analytical constants from Bell & Deiters, IECR 2021
(https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=931868).

Closes #2742

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 20:12:57 -04:00
Jeff Henning
497c044d5b fix(cmake): Update FindMathematica dependency to latest version (#2741) 2026-04-19 12:05:55 -04:00
Ian Bell
cd69d4b538 Add refrigerant mixture models (Bell-JPCRD-2022/2023) and update R-1234yf EOS (#2725)
* Add refrigerant mixture models (Bell-JPCRD-2022/2023) and update R-1234yf EOS

Pure fluid:
- Replace Richter-JCED-2011 with Lemmon-Akasaka 2022 (Int. J. Thermophys. 43:119)
  as EOS[0] for R-1234yf; retain Richter as EOS[1]
- Ttriple updated from 220.0 K to 121.6 K; pc=3384400 Pa; rhoc=4180 mol/m3
- All 16 Table 7 check values pass to 5+ significant figures
- ASHRAE enthalpy reference state correct: h_L(0C)=200 kJ/kg
- Saturation consistent from 150 K to 360 K (L/V pressure equality)
- SUPERANCILLARY omitted pending fastchebpure fix; CoolProp uses the
  Table 2 ancillary equations (pS, rhoL, rhoV) as initial guesses

Mixture departure functions (8 new, type=Exponential):
- Bell-JPCRD-2022: R1234yf-R134a, R1234yf-R1234ze(E), R134a-R1234ze(E)
- Bell-JPCRD-2023: R32-R1234yf, R32-R1234ze(E), R1234yf-R152a,
                   R125-R1234yf, R1234ze(E)-R227ea

Binary pair parameters (5 updated, 3 new):
- Updated R1234yf/R134a, R32/R1234yf, R32/R1234ze(E),
         R125/R1234yf, R1234yf/R152a (replacing Akasaka-FPE-2013
         and Bell-JCED-2016 interim models with final fits)
- Added R1234yf/R1234ze(E), R134a/R1234ze(E), R1234ze(E)/R227ea

BibTeX entries added: Bell-JPCRD-2022, Bell-JPCRD-2023, Lemmon-IJT-2022

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add C++ check value tests for Lemmon-IJT-2022 and Bell-JPCRD-2022/2023

- Table 7 from Lemmon & Akasaka (2022): 6 state points for R1234yf
  covering ideal-gas, gas, compressed liquid, and near-critical
- Fixed-point constants: Tc, pc, rhoc, Ttriple
- Table XI from Bell (2022): alphar check values for three R1234yf-based
  binary pairs (R1234yf/R1234zeE, R1234yf/R134a, R134a/R1234zeE)
- Table XIII from Bell (2023): alphar check values for five mixture pairs
  (R32/R1234yf, R32/R1234zeE, R125/R1234yf, R1234yf/R152a, R1234zeE/R227ea)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add mixture departure functions and binary pair parameters

Bell-JPCRD-2022 (DOI 10.1063/5.0083545):
- 3 new departure functions: R1234yf-R134a, R1234yf-R1234ze(E), R134a-R1234ze(E)
- 3 new/updated binary pairs

Bell-JPCRD-2023 (DOI 10.1063/5.0124188):
- 5 new departure functions: R32-R1234yf, R32-R1234ze(E), R1234yf-R152a,
  R125-R1234yf, R1234ze(E)-R227ea
- 5 new/updated binary pairs (supersedes Bell-JCED-2016 interim models)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add superancillary equations to R1234yf EOS

Builds Chebyshev superancillary for R1234yf covering the full
saturation curve from Ttriple (121.6 K) to near-critical (66
intervals). Also adds missing 'description' fields to the ANCILLARIES
block (required by the teqp ancillary loader).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(mixtures): correct betaT ordering for R1234zeE pairs; add inverted-order tests

The Bell-JPCRD-2022 JSON entries for R1234yf+R1234zeE and R134a+R1234zeE
had CAS1=R1234zeE (alphabetically first), causing no swap on load.  When
the mixture was constructed with the other component first CoolProp's
MixtureParameters swap logic inverted betaT a second time, yielding the
wrong reducing temperature.

Fix: swap CAS1/CAS2 so that CAS1 is alphabetically later for both pairs,
triggering a swap-on-load that pre-inverts betaT at full double precision.
The swap-on-use then recovers the exact paper value with no rounding error.
The original paper betaT/betaV values are restored in the JSON.

Also enable DmolarT_INPUTS on mixture backends in DHSU_T_flash so the
alphar check-value tests can call update(DmolarT_INPUTS, ...) on a mixture
AbstractState without throwing.

Test updates:
- Bell-JPCRD-2022 Table XI check values for R1234yf-containing pairs
  updated to the final Lemmon-IJT-2022 EOS (pre-pub EOS used in paper
  differs by ~0.4%); tolerance tightened from 1e-6 to 1e-10 throughout.
- Three new inverted-component-order sections check the same tabulated
  alphar values as the forward-order tests, verifying that the GERG
  reducing function symmetry (swap components + reciprocal beta = same
  result) is preserved by the CAS-ordering fix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs(tests): clarify that R1234yf EOS change drives the Table XI value updates

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: bump fastchebpure pin to 2026.04.18 for R1234yf superancillary data

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(tests): specify phase in mixture DmolarT tests; revert FlashRoutines workaround

Mixture tests that call update(DmolarT_INPUTS, ...) must call specify_phase()
first so DHSU_T_flash uses the imposed-phase path rather than hitting the
NotImplementedError. Reverts the iDmolar special-case added to the mixture
else-branch of DHSU_T_flash.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 16:57:35 -04:00
Ian Bell
74e7595def fix(build): default CPM_SOURCE_CACHE to repo-local cache to enable incremental builds (#2735)
Without a stable CPM_SOURCE_CACHE, FetchContent_Populate runs on every cmake
configure (new session), triggering ExternalProject's git fetch/checkout and
touching header timestamps in _deps/<name>-src/. This causes a complete C++
rebuild on every `uv build` even with no source changes.

Defaulting CPM_SOURCE_CACHE to .cpm_cache/ in the repo root ensures CPM skips
FetchContent_Populate for already-downloaded packages, keeping header timestamps
stable. Users can still override via the CPM_SOURCE_CACHE env var.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 14:20:49 -04:00
Ian Bell
3040ebf26e fix(cmake): change CACHE type from LIST to STRING for COOLPROP_APP_SOURCES and COOLPROP_INCLUDE_DIRECTORIES (#2734)
CMake does not have a LIST cache type; it was silently coercing to STRING
and emitting a warning on every configure. Fixes the longstanding CMake
warning reported in PR #2728.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 14:19:48 -04:00
Ian Bell
c189917b36 fix(build): replace CPM.cmake dev snapshot with v0.40.7 release (#2733)
The vendored file was fetched from CPM master rather than the v0.40.7
release tag, causing a CMake warning about an unstable development
version on every configure.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 11:56:58 -04:00
Ian Bell
09a265c907 perf(humid_air): cache virial/alpha0 coefficients to eliminate redundant EOS calls (26× speedup) (#2716)
* perf(humid_air): cache virial coefficients per temperature to eliminate redundant EOS calls

Adds `calc_all_virials()` to `HelmholtzEOSMixtureBackend` which computes B,
dB/dT, C, dC/dT in a single `residual_helmholtz->all()` call instead of four
separate `keyed_output()` calls (each of which invoked `all()` independently).

Adds a T-keyed static cache in `HumidAirProp.cpp` so that Air and Water virials
are computed once per unique temperature across all callers in the same
HAPropsSI evaluation. This eliminates ~12 redundant full EOS evaluations per
T+W→H call (6 Air + 6 Water: B_m and C_m each called twice across
MolarVolume+MolarEnthalpy, plus dB_m_dT and dC_m_dT).

Benchmark results on Apple M-series (ns/call, warm cache):
  T+W→H:    23 µs → 5.2 µs (4.5×)
  T+R→H:    32 µs → 7.6 µs (4.0×)
  T+Twb→W:  3.8 ms → 0.9 ms (4.2×)
  T+V→W:    33 µs → 1.6 µs (21× — dominated by cache warmth)

Adds [virial_cache] Catch2 tests verifying calc_all_virials() matches the
original keyed_output() path for Air and Water across 10 temperatures, and
that the HAPropsSI cache invalidates correctly across temperature changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* perf(humid_air): eliminate all update() calls from ideal-gas enthalpy/entropy functions

Adds two new per-temperature caches to HumidAirProp and two direct EOS methods
to HelmholtzEOSMixtureBackend, removing every backend update() call from the hot
path of HAPropsSI property evaluations.

Changes
-------
HelmholtzEOSMixtureBackend::calc_all_virials (previous commit):
  Single residual_helmholtz->all() call yields B, dB/dT, C, dC/dT at once.

HelmholtzEOSMixtureBackend::calc_alpha0_and_dTau (new):
  Single alpha0.all() call yields f(tau) and dalpha0/dtau at delta=1 without
  any update() call. Pure/pseudopure path (Air, Water) uses tau directly since
  Tc = Tr for these fluids; mixture fallback uses calc_alpha0_deriv_nocache.

HumidAirProp — two independent T-keyed caches:
  s_virial_cache: B, dB/dT, C, dC/dT for Air and Water (filled only when
    FlagUseVirialCorrelations=0, matching the original access pattern).
  s_alpha0_cache: f(tau) and dalpha0/dtau for Air and Water (always filled;
    separated from virial cache so virial EOS calls are not triggered when
    FlagUseVirialCorrelations=1).
  s_ref: one-time reference-state offsets (hoffset, soffset, T_red, rho_red,
    ln_delta_air) computed via update() with specify_phase(iphase_gas) guards.

IdealGasMolarEnthalpy_Water/Air and IdealGasMolarEntropy_Water/Air all rewritten
to use s_alpha0_cache + s_ref — zero update() calls on the hot path.

Benchmark (Apple M-series, warm cache):
  T+W→H:   23 µs → 5.2 µs (virial cache) → 0.88 µs (alpha0 cache)  26×
  T+R→H:   32 µs → 7.6 µs → 3.2 µs                                  10×
  T+R→S:   N/A   →  N/A   → 3.4 µs

Tests
-----
Adds [virial_cache] and [alpha0_cache] Catch2 test cases that verify the new
direct-EOS methods are bit-identical to the original update()+keyed_output()
paths for Air and Water across 10 temperatures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(humid_air): move virial/alpha0 helpers out of HEMB class

Address reviewer comments on PR #2716:

- calc_all_virials and calc_alpha0_and_dTau are removed from
  HelmholtzEOSMixtureBackend.  They are evaluated at delta→0 and
  delta=1 respectively, assumptions that only make sense in the
  humid-air context, so they now live as static free functions in
  HumidAirProp.cpp with clearer names and explicit doc comments
  explaining the delta choice.
- fill_virial_cache and fill_alpha0_cache updated to call the new
  static helpers (calc_all_virials, calc_ideal_gas_alpha0).
- Tests that previously called the class methods directly are replaced
  with end-to-end HAPropsSI checks that exercise the same code paths
  through the public API.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(humid_air): three test failures from alpha0 refactor

- CMakeLists: use local _MY_MAIN_SOURCES so COOLPROP_MY_MAIN doesn't
  pollute APP_SOURCES and override Catch2's main in CatchTestRunner
- HumidAirProp: calc_ideal_gas_alpha0 incorrectly rejected Air
  (pseudo_pure=true); guard now only blocks true multi-component fluids
- CoolProp-Tests: fix Z tolerance (1e-3 → margin 2e-3); fix h-s
  round-trip to use (H,W=0)→T instead of unsupported (H,S)→T

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 11:50:37 -04:00
Ian Bell
f0b988236f build: replace git submodules with CPM.cmake (#2728)
* build: replace git submodules with CPM.cmake

All 11 submodules (Eigen, fmtlib, msgpack-c, rapidjson, IF97,
REFPROP-headers, multicomplex, Catch2, pybind11, ExcelAddinInstaller,
FindMathematica) are now fetched by CPM.cmake at configure time.

Set CPM_SOURCE_CACHE (e.g. ~/.cache/CPM) to share the download cache
across git worktrees and build directories — no more per-worktree
`git submodule update --init --recursive`.

Vendored deps that have no upstream release cycle (miniz, nlohmann-json,
incbin) remain in externals/ as before.

Source-level changes: angle-bracket includes for rapidjson, IF97, and
REFPROP-headers now that their directories are on the include path via
CPM-provided source dirs rather than relative paths from the repo root.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(python): wire up CPM.cmake in Python wrapper, fix include paths

The Python wrapper CMakeLists.txt was still referencing submodule paths
(externals/Eigen, externals/fmtlib, externals/msgpack-c) removed by the
CPM migration. Include CPM.cmake + dependencies.cmake from the root and
use the ${Pkg_SOURCE_DIR} variables instead.  Also adds missing
rapidjson, IF97, and REFPROP_headers include dirs required by CoolProp
sources.

CI workflows drop the now-meaningless `submodules: recursive` checkout
option and add a CPM source-cache step to avoid re-downloading on each
macOS/Windows runner.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: remove git submodule references after CPM.cmake migration

Dependencies are now managed by CPM.cmake (fetched automatically at
CMake configure time), so git submodules no longer exist.

- Drop `--recursive` from all `git clone` commands in Web docs and
  wrapper READMEs (26 .rst/.md files)
- Remove `submodules: recursive` from all CI workflow checkout steps
  (13 workflow files)
- Remove `git submodule foreach/update` calls from release.bsh and
  delete the now-dead pybind11 security-workaround lines
- Drop `--recursive` from build_swigged_matlab.sh and gitMirror.bsh
- Update CONTRIBUTING.md: drop "and its submodules" phrasing

Changelog entries referencing old submodule PRs are left intact as
historical records. The --recursive in buildbot.rst is for the
Dockerfiles repo (unrelated) and is also left unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(ci): remove empty 'with:' blocks after submodule removal, apply clang-format

After removing 'submodules: recursive' from checkout steps, some workflow
files were left with dangling empty 'with:' blocks that GitHub Actions
rejects as workflow file errors. Remove the empty 'with:' in 9 workflows.

Also apply clang-format to fix spacing in REFPROPMixtureBackend.cpp,
HumidAirProp.cpp, and Helmholtz.cpp.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 11:45:10 -04:00
Ian Bell
7a394ac461 fix: repair clang-format CI for fork PRs and push events (#2724) (#2731)
- Use commit SHAs from GitHub context instead of remotes/origin/<branch>
  names, which don't exist for PRs from forks
- Handle push events separately (GITHUB_HEAD/BASE_REF are empty on push)
- Bump actions/checkout v3 -> v6, actions/upload-artifact v4 -> v7
- Remove redundant `git fetch --all`

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 18:03:10 -04:00
Jeff Henning
7da8e74b36 Created HAPropsSI error trapping helper function for Mathcad wrapper. (#2732) 2026-04-17 15:53:08 -04:00
Ian Bell
ee1e541621 feat: add Chlorine (Cl2) fundamental equation of state with superancillaries (#2729)
* feat: add Chlorine (Cl2) fundamental equation of state

Implements the EOS from Thol, Herrig, Span, Lemmon (AIChE J. 67, e17326,
2021, DOI: 10.1002/aic.17326) for chlorine (CAS 7782-50-5).

- 10-term polynomial/exponential residual + 5-term Gaussian bell-shaped
- Ideal gas: diatomic (2.5) + 3 Planck-Einstein terms (800/3000/8200 K)
- NBP reference state (h=0, s=0 at saturated liquid, 101325 Pa)
- Saturation ancillaries: pS, rhoL, rhoV from REFPROP coefficients
- Valid range: 172.17 K to 525 K, up to 20 MPa
- Adds BibTeX entry Thol-AICHE-2021

Closes #2714

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add superancillary equations to Chlorine EOS

Builds Chebyshev superancillary for Cl2 covering the full saturation
curve from Ttriple (172.17 K) to near-critical (416.865 K, 61
intervals). Errors away from the critical region are at machine-
precision level (~1e-13 %).

The fastchebpure builder was also patched to prune near-critical
intervals where the pressure Chebyshev expansion becomes non-monotone
due to ill-conditioned VLE convergence at very small Theta; 3 such
intervals were removed for Chlorine (Theta ~ 2.3e-7).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Bump fastchebpure release to 2026.04.16 to fix docs CI failures

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 12:24:58 -04:00
Ian Bell
6f8b4c95e2 Use requests with retry adapter for PubChem SDF downloads (#2730)
Replaces urllib with requests + HTTPAdapter/Retry to get automatic
retries (up to 3) with exponential backoff on 429/5xx and network
errors; 404 is treated as a definitive miss and skips to 2D without
retrying.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 20:08:58 -04:00
Jeff Henning
54924465d2 Mathcad wrapper additional error trapping for PropsSImulti (#2723) 2026-04-11 11:58:21 -04:00
Jeff Henning
0a4d4e1f26 Mathcad wrapper compliance with CoolProp CLANG-format (#2722) 2026-04-10 22:09:25 -04:00
Jeff Henning
775e1d49a6 Skip REFPROP tests when not available during CI (#2710)
* Try loading REFPROP backend and only warn on failure
* Skip REFPROP related tests when not available using a single helper routine in CoolProp:: namespace
2026-04-09 21:12:20 -04:00
Ian Bell
61351d449c docs: add predefined mixtures table to Mixtures page (#2719)
* docs: add predefined mixtures table to Mixtures documentation

Adds a new section "Predefined mixtures" to Web/fluid_properties/Mixtures.rst
listing all 154 predefined mixtures with their components and mole fractions.
Each mixture is tested at build time; those that fail (missing binary interaction
parameters or not present in the compiled library) are flagged in a Notes column.

Also updates the code examples in the new section to use the required .mix suffix,
and registers the generation script in the doc build task list.

Closes #2711

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: improve predefined mixtures table error messages and auto-count

- Replace CAS numbers with fluid names in binary interaction parameter errors
- Detect and report missing pure fluids by name
- Distinguish 'not registered as predefined mixture' from missing BIP
- Write PredefinedMixturesCount.rst so the mixture count in Mixtures.rst
  is generated automatically rather than hardcoded

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 20:12:33 -04:00
Jeff Henning
44c9526010 Add Predefined Mixture Helper Functions to Mathcad Wrapper (#2709) 2026-04-05 17:53:43 -04:00
Ian Bell
bc8c1bc039 C++17 modernization: remove shims, stdlib idioms, attributes, filesystem (#2688)
* chore: C++17 modernization — remove shims, use stdlib idioms

Phase 1 — Mechanical:
- Replace crossplatform_shared_ptr.h with <memory> in all 20 files; delete shim
- Replace NULL with nullptr (~10 occurrences)
- Replace throw() with noexcept (DataStructures.h)
- Convert 30+ iterator for-loops to range-for with auto/structured bindings
- Replace insert(make_pair/pair<>) with emplace/try_emplace (~40 sites)
- Replace shared_ptr<T>(new T) with make_shared<T> (~5 sites)

Phase 2 — Optional/structured bindings:
- get_alternate() returns std::optional<pair<size_t,size_t>>; remove has_valid_neighbor()
- get_set_of_tables() eliminates bool out-param, returns std::pair
- is_inside() switch refactored to IIFE eliminating nullptr-init pattern

Phase 3 — Attributes:
- Remove DEPRECATED macro; use [[deprecated("...")]] directly (PolyMath.h)
- Add [[nodiscard]] to is_inside, valid, calc_saturated_*_keyed_output,
  get_parameter_information/index, generate_update_pair, has_number

Phase 4 — Architectural:
- CPfilepaths.cpp: use std::filesystem on non-Android/Emscripten/powerpc targets
- DataStructures.h: annotate 5 public enums with explicit underlying type (: int)
- get_parameter_information() takes std::string_view for info param

Build: clean, zero errors. Test suite: 100/110 pass (10 known pre-existing failures).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Remove Unicode replacement character (U+FFFD) from 870.cpp

Addresses PR review comment about non-printing character on line 25.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Remove unnecessary <memory> include from IdealCurves.h

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Always use std::filesystem

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 13:28:11 -04:00
Ian Bell
a3c39a6be5 Fix superancillary performance: store as shared_ptr instead of optional (#2681)
* Fix superancillary performance: store as shared_ptr instead of optional

Every call to AbstractState::factory("HEOS", fluid) was deep-copying the
SuperAncillary_t object (multiple large Chebyshev coefficient vectors) as
part of the CoolPropFluid value copy from the fluid library. Since the
superancillary is immutable once built, switch storage from
std::optional<SuperAncillary_t> to std::shared_ptr<SuperAncillary_t>.

All copies of CoolPropFluid for the same fluid now share a single
SuperAncillary_t in memory; copying the shared_ptr is O(1) (atomic
ref-count increment only).

Also fix a latent bug in get_fluid_parameter_double where optsuperanc.value()
was called before the if(optsuperanc) guard (would have crashed on fluids
without superancillaries when SUPERANC:: parameters were queried).

Changes:
- CoolPropFluid.h: storage type optional -> shared_ptr; rename internal
  accessor get_superanc_optional -> get_superanc
- HelmholtzEOSMixtureBackend.h: update declaration (return shared_ptr)
- HelmholtzEOSMixtureBackend.cpp: update impl + 6 call sites (.value() -> *)
- FlashRoutines.cpp: update 4 call sites (.value() -> *)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* PR review fixes: rename get_superanc, simplify melting line logic, test cleanup

- Rename HelmholtzEOSMixtureBackend::get_superanc_optional() to get_superanc()
  to match EquationOfState::get_superanc() and reflect the shared_ptr return type
- Remove redundant `if (other == iT &&` guard inside case iT: (always true)
- Simplify melting line if/else in subcritical superanc branch: collapse redundant
  has_melting_line()/else branches into a single _phase assignment
- Fix get_fluid_parameter_double: note that .value() before null check was a
  pre-existing bug that the optional->shared_ptr migration implicitly fixed
- Use std::shared_ptr in [2639] test case for consistency
- Add comment explaining [2608] CO2 temperature change (218.048->218.050)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 11:46:03 -04:00
Ian Bell
b8e0bf7835 Add some more predefined mixtures from ASHRAE 34 (#2713)
* Add some more predefined mixtures from ASHRAE 34

* document origin of MM
2026-04-04 11:20:49 -04:00
Ian Bell
c649586e8c feat(docs): add interactive 3D molecule viewers to fluid pages (#2707)
* feat(docs): add interactive 3D molecule viewers to fluid pages

Use py3Dmol + PubChem SDF data to embed a rotate-and-drag 3D (or 2D
fallback) molecule viewer on each pure fluid documentation page.

- fetch_pubchem_sdf(): downloads 3D conformer SDF from PubChem REST API
  (falls back to 2D), caching results in molecule_sdf/ to avoid repeated
  network calls on doc rebuilds
- generate_3dmol_rst(): inlines the SDF as a JS template literal inside a
  .. raw:: html block — no extra static files needed at Sphinx build time
- FluidGenerator.write(): validates InChIKey with regex before fetching;
  pseudo-pure fluids (Air, R404A, etc.) without InChIKeys are silently skipped
- conf.py: loads 3Dmol.js from CDN via html_js_files
- .gitignore: excludes the generated molecule_sdf/ cache directory

Restores molecule visualisation that was removed in April 2025 (the old
approach tried to embed an image directive inside a CSV table, which is
invalid RST; this implementation places the viewer in the RST template).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(docs): serve 3Dmol.js locally to eliminate CORS errors

Download 3Dmol-min.js to _static/ at Sphinx build time (same pattern
as MathJax) instead of loading it from the CDN via html_js_files.
Serving the script same-origin removes the cross-origin restriction
that caused CORS errors when docs were opened from file:// or a local
dev server.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(docs): correct 3Dmol viewer positioning and initialization timing

3Dmol.js sets its canvas to position:absolute;top:0;left:0 and only
auto-sets the container to position:relative when the container's
inline style.position === "static". An unstyled div has style.position
=== "" so the check fails, and the canvas escapes the container and
anchors to the nearest positioned ancestor in the Sphinx page layout.

Fix: add position:relative explicitly to the viewer container div.

Also defer viewer init via DOMContentLoaded so layout is finalized
before createViewer reads the container dimensions, and call v.resize()
before v.render() to sync the WebGL canvas to the container size.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(docs): disable MathJax SRE to prevent CORS errors on file:// URLs

MathJax 4.0's Speech Rule Engine fetches sre/mathmaps/base.json at
runtime via fetch(). Chrome blocks this when docs are opened from a
local file:// URL (null origin). Disabling enableExplorer and
enableAssistiveMml prevents SRE from initialising entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(docs): load 3Dmol before require.js to fix AMD conflict

sphinx.ext.mathjax injects require.js at priority 500. When 3Dmol
loads after it, AMD detection fires and calls define([], factory)
instead of setting window.$3Dmol directly. Since nothing ever calls
require(['3Dmol-min']), the factory never runs and the viewer silently
fails (infinite setTimeout retry, no console errors).

Setting priority 450 ensures 3Dmol loads before require.js.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(docs): add retry logic to downloads in conf.py using requests

Replace urllib.request.urlretrieve with a requests-based _download()
helper that retries up to 5 times (exponential backoff, factor=2) on
transient HTTP errors and timeouts. Fixes CI build failures when
the MathJax or 3Dmol.js downloads time out.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 10:41:10 -04:00
Ian Bell
636fba7093 fix(docs): resolve all 162 doxygen warnings (#2708)
- Remove 13 obsolete Doxyfile tags (TCL_SUBST, CLANG_ASSISTED_PARSING,
  CLANG_OPTIONS, COLS_IN_ALPHA_INDEX, HTML_TIMESTAMP, FORMULA_TRANSPARENT,
  LATEX_SOURCE_CODE, PERL_PATH, CLASS_DIAGRAMS, MSCGEN_PATH, DOT_FONTNAME,
  DOT_FONTSIZE, DOT_TRANSPARENT)
- Fix unclosed \f$ inline math blocks in TransportRoutines.h and VLERoutines.h
- Fix spurious \f] inside display math block in TransportRoutines.h
- Fix @param name mismatches (matrix→mat, mole_fractions→mf, x0→x, etc.)
- Add missing @param docs to FlashRoutines, MixtureDerivatives,
  PhaseEnvelopeRoutines, ODEIntegrators, BicubicBackend, CoolProp.h
- Remove @return on void function in MixtureParameters.h
- Remove unresolvable \ref tags in ReducingFunctions.h and CoolPropLib.h
- Fix UNIFAC.h @param on no-arg function
- Remove ~25 duplicate /// @param blocks from PolyMath.cpp definitions
- Remove duplicate @param from IncompressibleBackend.cpp
- Clean up commented-out @param block leaking into calc_rhomass

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 10:34:15 -04:00
Ian Bell
d5eecbb4da test(humid_air): add comprehensive validation test suite (#2705)
Covers ASHRAE RP-1485 scenarios from HAValidation.py as C++ Catch2
tests so they run in CI instead of only during Python doc builds:

- [ashrae_a61]: saturated air T=-60..0°C (ice regime, R=1)
- [ashrae_a62]: saturated air T=0..90°C (liquid regime, R=1)
- [ashrae_a8/a9]: hot humid air T=200/320°C across multiple pressures
- [humid_air_physics]: T_dp <= T_wb <= T_db ordering, W/R invariants
- [humid_air_roundtrip]: W, H, T_dp, T_wb round-trips
- [humid_air_aux]: f_factor, p_ws, beta_H, kT, vbar_ws, virial checks

Also documents two current behaviors as known baselines:
- W_sat > 1 kg/kg is physically correct above ~60 degC (not a bug)
- beta_H returns inf below 273.16 K (no liquid water)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-29 15:35:03 -04:00
Ian Bell
f060795b2a Revert "Fix HAPropsSI T_db from T_wb + low RelHum failing for narrow pressure band (issue #2690) (#2697)" (#2704)
This reverts commit 3b23cb5409.
2026-03-29 10:49:30 -04:00
Ian Bell
fa7455043a chore(deps): update miniz 3.0.2 → 3.1.1 (#2700)
* chore(deps): update miniz from 3.0.2 to 3.1.1

Adds the miniz-3.1.1 source directory and updates all CMakeLists.txt
references. Notable fixes in 3.1.0/3.1.1: integer promotion warnings,
tinfl_decompress bug that broke mem-to-heap decompression, MinGW Unicode
path support, and inline static wrappers to silence warnings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore(deps): remove old miniz-3.0.2 source tree

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-29 10:16:10 -04:00
Jeff Henning
6d7d5eccbd Add \$\$ to equations on Ideal Gas web page [skip ci] (#2702) 2026-03-27 13:29:45 -04:00
Ian Bell
3b23cb5409 Fix HAPropsSI T_db from T_wb + low RelHum failing for narrow pressure band (issue #2690) (#2697)
Three fixes to src/HumidAirProp.cpp:

1. WetbulbTemperature inner Brent upper bound: changed Brent(WBS, Tmax+1, 100)
   to Brent(WBS, Tmax, 100). The old Tmax+1 evaluated WBS at T_sat(P) where
   P_s == P, causing division-by-zero (W_s_wb infinite) and an exception that
   cascaded into the outer solver returning _HUGE for certain pressures.

2. _HAPropsSI_inputs T_max extension for T_wb / enthalpy secondary inputs: when
   MainInput is RelHum (>= 1e-10) and the secondary input is T_wb or enthalpy,
   use T_max = 640 K instead of T_sat(P) - 1. For very dry air at sub-atmospheric
   pressures the solution T_db can legitimately exceed T_sat(P); WetbulbTemperature
   already handles T_db > T_sat correctly via its fallback solver.

3. Replace CoolProp::PropsSI("T","P",p,"Q",0,"Water") with the already-instantiated
   Water singleton (Water->update(PQ_INPUTS,...); T_max = Water->T() - 1), consistent
   with the rest of HumidAirProp.cpp.

Also added a Catch regression test [humid_air][2690] covering 10 pressures
(including the previously-failing 90190–91160 Pa band) with round-trip
verification to < 1e-6 K.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-22 11:17:47 -04:00
Ian Bell
6cb4dc12f6 Remove unused heavy headers to improve compile times (#2689)
* Remove unused heavy headers to improve compile times

- Exceptions.h: replace unused <iostream> with <string> (needed for std::string)
- CPnumerics.h: add explicit <iostream> (was relying on transitive include via Exceptions.h for std::cerr)
- superancillary/superancillary.h: replace <iostream> with <cstdio>; use fprintf for debug output
- TabularBackends.h: remove unused <sstream>

<iostream> is one of the heaviest stdlib headers; removing it from widely-included
headers (Exceptions.h: ~32 dependents, superancillary.h: pulled in by AbstractState.h,
CoolPropFluid.h, Configuration.h) reduces cold build times.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add missing <iostream> to ODEIntegrators.cpp

ODEIntegrators.cpp uses std::cout but was relying on transitive inclusion
via Exceptions.h. After removing <iostream> from Exceptions.h, this broke
compilation. Add the include directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-22 11:14:53 -04:00
Tobias Loew
3fa5c20e9b make _binary arrays constexpr and use string_view instead of string (#2692)
* make _binary arrays constexpr and use string_view instead of string

By making _binary arrays constexpr and using string_view instead of string, startup speed of the library is improved.

* fixed interfaces for string_view
added /bigobj /MP to MSVC CXX-flags

* empty commit to trigger CI

* empty commit to force CI build

---------

Co-authored-by: Löw, Tobias <Tobias.Loew@iqony.energy>
2026-03-22 11:10:51 -04:00
Ian Bell
0dea224e89 fix(ci): skip REFPROP build for fork PRs where secrets are unavailable (#2699)
GitHub does not pass repository secrets to workflows triggered by PRs
from forks, causing the gpg decrypt step to fail. Add a condition so
the Build REFPROP step is skipped for fork PRs; the rest of the build
and non-REFPROP tests still run.

Fixes #2694

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-22 11:10:19 -04:00
Jeff Henning
1d338cb8c4 Split Mathcad installation of helper and README files in CMake [skip ci]
See if this fixes getting the Mathcad Prime README.md file on SourceForge
2026-03-21 17:58:03 -04:00
Jeff Henning
ccb0ccb543 Add issue template configuration [skip ci] 2026-03-21 17:39:37 -04:00
Jeff Henning
9ba982c9c5 Update general issue report template [skip-ci]
Added a template for general issue reporting with sections for questions, support, and issue details.
2026-03-21 16:12:09 -04:00
Jeff Henning
644036b142 Move ISSUE_TEMPLATE.md to .github/ISSUE_TEMPLATE/
Move ISSUE_TEMPLATE.md to .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md per GitHub guidance.

Closes #2696
2026-03-21 15:14:50 -04:00
henningjp
1864c03c07 Implement PropsSImulti in the Mathcad wrapper 2026-03-21 14:30:47 -04:00
henningjp
ccc0668eff Add PhaseSI function to Mathcad wrapper 2026-03-21 14:30:47 -04:00
Jeff Henning
8fa873a46f Install updated README.md to SourceForge with Mathcad binaries [skip ci] (#2687)
Puts installation instructions on SourceForge with binaries.
2026-03-13 18:07:35 -04:00
Jeff Henning
8a13203c66 Update mixture tables for R1234ze [skip ci] (#2683) 2026-03-07 09:59:23 -05:00
Jeff Henning
d4ebdf1ef1 Some Refactoring of the Mathcad Wrapper for simplification and readability (#2682)
Only the REFPROP checks not passing because of permissions but ran fine locally.  All regression testing passed and limited to the single Mathcad wrapper file.
2026-03-01 12:18:23 -05:00
Ian Bell
4c44353628 Fix HAPropsSI with T_dp+R or W+R inputs when T is unknown (issue #2670) (#2679)
Both combinations uniquely determine dry-bulb temperature: T_dp and W
each fix psi_w independently of T, while relative humidity R provides
the T-dependent equation R = psi_w*P / (f(T,P)*p_ws(T)) to solve.

Changes:
- Reorder priority chain to prefer T_dp over R as main key when both
  are present (T_dp gives psi_w directly, yielding correct T_min bound)
- Relax the two-water-content guard to allow T_dp+R and W+R combinations
  while still rejecting W+T_dp (both fix psi_w; T remains unconstrained)
- Add Catch2 test covering all three cases, including the W+T_dp invalid
  case which correctly returns _HUGE

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 07:36:09 -05:00
Jeff Henning
e52d1ebc9f VB .Net README Update [skip ci] (#2677) 2026-02-21 12:23:16 -05:00
Ian Bell
a3c7430265 Add checks for melting line with PT inputs (#2648) 2025-11-10 18:00:56 -05:00
Matthis Thorade
e03848f1ab Revert "remove bountysource from readme (#2645)"
This reverts commit 3b3b5f92c4.
2025-11-10 10:53:41 +01:00
Matthis Thorade
3b3b5f92c4 remove bountysource from readme (#2645)
because the service went bankrupt and does not exist anymore
2025-11-09 10:29:43 -05:00