1790 Commits

Author SHA1 Message Date
Jorrit Wronski
f8db5bb217 Use CoolProp's secant solver for humid air calculations. should solve #2190 2022-12-07 11:51:47 +01:00
msaitta-mpr
15720ab6cc Prevent crashes near critical density due to saturation calc (#2173)
* Add extrapolating secant solver

Sometimes, the backwards ancillary solver fails near the critical
point. This can happen if the ancillary function at its limit
(i.e., critical temperature) does not reach the desired seek value
(e.g., density). Because we are only usually using these to get a
guess value, we can extrapolate them without issue to avoid a crash
near the critical point.

This helps to resolve #2154.

* Stabilize saturation curve solution

Solving for the saturation curve near the critical point can be
unstable. This commit fixes that in a few ways.

1) Prevent the solver from overshooting and prevent a negative
temperature or density.

2) If it does fail, try again with a smaller omega value.

If the solver fails after all of this, we will still throw to allow
something downstream to handle it.

This helps to address issue #2154.

* Move saturation_D_pure max iterations to options
2022-10-28 18:08:13 -04:00
Friederike Boehm
38a6ea61e1 Add fluid_param_string and get_JSONstring to cubic (#2134)
Implementation comparable to HelmholtzEOSMixturebackend
See PR #1371 (4014f85c4c)

Minor changes to CubicBackend.cpp
If phase is imposed, it is returned
instead of always returning gas phase for mixtures
TODO is not properly fixed though
2022-09-07 20:36:59 -04:00
Zach Baird
e52c26c8e8 improve PC-SAFT flash (#2161)
* improve PC-SAFT flash

* fix error in PC-SAFT JSON file

* change C type to string
2022-08-27 18:59:31 -04:00
Yaykhel
dc668009d2 Corrected rho_ice route by replacing g_ice with dg_dp_Ice in Ice.cpp (#2143) 2022-07-13 10:06:32 -04:00
Ian Bell
a2a4040912 Round kb and N_AV for PCSAFT to exact CODATA values 2022-06-29 09:13:49 -04:00
Ian Bell
66d43a96e9 More PC-SAFT unrounding 2022-06-28 18:50:01 -04:00
Ian Bell
a1f4d88a0b Unround the PC-SAFT coefficients for ai and bi 2022-06-28 17:25:46 -04:00
Friederike Boehm
c4cf52b671 AbstractState functions for CoolPropLib (#2135)
* Add AbstractState functions to CoolPropLib
AbstractState_get_mole_fractions_satState
AbstractState_keyed_output_satState
AbstractState_backend_name
add_fluids_as_JSON

* Overloaded AbstractState_get_phase_envelope_data and appended checkedMemory to function name
2022-06-07 08:26:10 -04:00
Friederike Boehm
44325d9e6a Add Props1SImulti and PropsSImulti to CoolPropLib (#2133)
Props1SImulti new function in CoolProp
2022-05-17 20:13:57 -04:00
Friederike Boehm
4ef119f102 Add bound-check to setter and getter functions (#2107) 2022-04-01 07:40:14 -04:00
Julien Marrec
6913fc41dc Format macros, they keep getting picked incrementally by clang format + Strip trailing whitespaces
```
find . -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx|py)$' | xargs -I@ sed -i 's/[ \t]*$//' "@"
```
2022-04-01 07:39:35 -04:00
Julien Marrec
c1ed08617e Bump Catch 1 to Catch v3.0.0-preview4 (#2105)
* Bump Catch2 to latest v3.0.0-preview4

Bump Catch2 to latest 2.x: 2.13.8

Rename submodule Catch to Catch2

Add catch2 to ctest

Fix missing ";" in catch tests

Use ctest for catch2: run once with little output, then 2nd time with verbose output for failed tests

Run through CatchTestRunner: TEMP: PICK A STYLE

Update Catch to v3.0.0-preview4

Try to migrate to catch2 v3

Ok it builds and runs, but I'm missing tests

Get all files that have inline tests, now I get same behavior as with catch1

Put back app sources

* Remove the link to coolprop lib since I am now using APP_SOURCES instead of just the specific files with tests
2022-03-31 18:47:00 -04:00
Julien Marrec
05c8cf503b Lint: use automated tooling to reformat C++ and CMakeLists files (#2103)
* Add initial clang tidy / clang format config files

* Clang format the entire codebase

```
find ./src -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx)$' | xargs clang-format-12 -style=file -i -fallback-style=none
find ./include -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx)$' | xargs clang-format-12 -style=file -i -fallback-style=none
find ./Web -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx)$' | xargs clang-format-12 -style=file -i -fallback-style=none
find ./dev -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx)$' | xargs clang-format-12 -style=file -i -fallback-style=none
find ./wrappers -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx)$' | xargs clang-format-12 -style=file -i -fallback-style=none
```

* Add a .cmake-format file and reformat CmakeLists.txt with it

https://github.com/cheshirekow/cmake_format

* Add a clang-format workflow


only runs on PRs, only on touched files
2022-03-31 10:51:48 -04:00
Julien Marrec
149a40d88b Add github action to build python wheels (including python 3.9 and 3.10) (#2097)
* Fix build error: `src/Backends/IF97/IF97Backend.h:54:34: error: call of overloaded ‘abs(double)’ is ambiguous`

Found with the manylinux_2_24_x86_64

gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516

* Register MSVC 2019 and 2022 in setup.py

* setup.py: when calling cmake, build in parallel

* Enable using Env variables instead of passing them as args to setup.py

* Github actions for linux: try 1

* use actions/checkout@v3 for submodules

* mod setup.py:; typo

* Random shot for cibuildwheel for all platforms

* I thought package_dir was a flag, but it's positional

* typo in cmake_compiler

* add cython to setup_requires

* try a pryproject.toml to install cython

* try more requirements?

* pywin32 only found on win32 I guess

* Try with CIBW_BEFORE_BUILD instead

* try to enable msvc via vcvarsall on windows, and pass MACOSX_DEPLOYMENT_TARGET

* more tweaks for windoze

* disable tests for now (fails on windows)

* tweak mac again: it seems mac doesn't understand a C++ lambda, so like it's using pre C++11

* tweak

* try 10.15 for mac...

* try to  force C++11 since mac picks up the path where lambdas are used...

* Move back down to 10.9 now that C++11 is enabled and it works on mac, it should be enough

* Try to debug win32

* Enable part of the upload step (minus the upload) to list the wheels

* try to allow win32 to fail for now (instead of plain disabling)

* Disable the python_linux.yml workflow, so cibuildwheels works fine.

* Adjust the upload step to point to the right folder

* make LGTM python happy
2022-03-31 09:26:31 -04:00
friederikeboehm
072f828e3e Fix Rcomponent in calc_alpha0_deriv_nocache (#2101) 2022-03-24 17:58:35 -04:00
friederikeboehm
5b8496f9da Add functions to CoolPropLib (#2084)
Add functions to CoolPropLib: AbstractState_get_mole_fractions and AbstractState_fluid_names
2022-02-02 19:04:51 -05:00
Ian Bell
77f3bdec7a Fix PHI0 delta derivatives for REFPROP backend. Closes #2073 2022-01-08 18:29:20 -05:00
Jeff Henning
9500f4d314 Merge pull request #2058 from henningjp/IF97-QPatch
IF97 Backend Q and Phase Patch
2021-11-03 14:34:45 -04:00
Qi-Chu-woodside
2d52842caf Fix typo in iQ description (#2056) 2021-11-02 19:21:26 -04:00
henningjp
dd42740c7f Include iphase_critical_point check when returning _phase from IF97 Backend 2021-10-28 22:13:41 -04:00
henningjp
31903f8a5e IF97 patch to set _Q and _phase 2021-10-28 07:49:11 -04:00
Ian Bell
64e27b95de Add function set_interaction_parameters 2021-07-27 14:50:09 -04:00
Ian Bell
7e4eecee3b Yet another _HUGE
Last one I think
2020-12-13 09:15:55 -05:00
Ian Bell
9cda7adc57 Allow for a prefactor multiplying alpha0
To deal with the ratio of gas constants from Jaeschke and Schley in GERG-2008
2020-12-07 08:45:20 -05:00
Ian Bell
c0b3fea245 Skip the Cosh and Sinh terms when not present 2020-12-04 16:16:07 -05:00
Ian Bell
d1fa02f9ac Allow possibility to add a single file in add_fluid_as_JSON 2020-12-04 15:04:43 -05:00
Ian Bell
25e1db17cc Fix some higher order derivatives 2020-12-04 14:33:31 -05:00
Ian Bell
8ab810a560 Allow for the Cosh and Sinh terms of GERG-2004 in alpha0 2020-12-04 13:38:56 -05:00
Ian Bell
f7dffbc04b Lay groundwork for cp0 to agree exactly with REFPROP and TREND
See #1982
2020-11-25 18:18:48 -05:00
ian
54ddec6aa7 Fix ideal-gas Helmholtz energy derivatives
Add ratio of gas constants, as in GERG approach
2020-11-17 18:51:25 -05:00
Ian Bell
f9fee35dac Negative pressures are acceptable
Negative pressures should be allowed because they can be physical
2020-05-23 16:55:41 -04:00
Ian Bell
7b0ce8b934 One more potentially uninitialized variable 2020-05-22 19:42:03 -04:00
Ian Bell
035ab39135 Initialize two variables
Does this help with #1937
2020-05-22 19:05:20 -04:00
Ian Bell
cc0617818c Also clear the residual properties
Otherwise they are impossible to calculate more than once, they never reset
2020-05-14 21:45:15 -04:00
Ian Bell
9e5b4dab55 Find either FLUIDS or fluids (case-sensitivity fix, finally) 2020-05-08 11:07:57 -04:00
Ian Bell
500357b871 More python 2.7 compat 2020-05-07 08:29:21 -04:00
ian
16a2523551 Add residual entropy back for REFPROP backend 2020-05-04 09:11:38 -04:00
Ian Bell
f809f9ab8c Fix case of alias handling in cubic backend 2020-05-02 16:42:16 -04:00
ian
d4d913361b Fix std::isfinite call 2020-04-30 19:39:32 -04:00
Tobias Loew
5d15e725f2 Fixed crash in PTflash_twophase::build_arrays (#1881)
* Fixed crash in PTflash_twophase::build_arrays

Fixed crash in SaturationSolvers::PTflash_twophase::build_arrays for mixtures with 3 or more components.

* set HEOS._Q = -1 when phase-envelope built
2020-04-27 22:24:03 -04:00
Zach Baird
feec37f2d8 Fix pcsaft flash (#1913)
* fixing PC-SAFT flashes

* minor fixes from review

* corrections requested in review
2020-04-09 12:14:15 -04:00
ian
4076e91cf8 Fix bracket 2020-03-26 14:36:20 -04:00
ian
816497fc63 Fix guessing for Maxwell when guessed p is negative 2020-03-26 14:15:05 -04:00
Alexandr Vasilyev
783fb66b7b Fix uppercase-only fluid naming (#1891) 2020-01-26 17:36:25 -07:00
ian
a1abe128ef Fix calculation of residual entropy 2019-12-16 00:20:41 -07:00
ian
0f0f1cad78 Back to old-school ValidNumber 2019-12-13 21:56:21 -07:00
ian
0808924906 full conversion 2019-12-13 21:28:40 -07:00
ian
9d4c3a4758 Move to std namespace 2019-12-13 21:20:58 -07:00
ian
4a53a9e38c Add cmath 2019-12-13 20:38:13 -07:00