braamvandyk / SteamTables.jl

Julia implementation of steam tables according to IAPWS Industrial Formulation (1997)
Other
12 stars 4 forks source link

SpecificS_Ph failure #23

Closed tkoenig1 closed 6 months ago

tkoenig1 commented 6 months ago

First, thanks for a nice package...

I am having some trouble with SpecificS_Ph, which fails for some valid input data in the supercritical region. Example below.

If this is user error, I don's see what I did wrong. Is there a known fix or workaround for this? I guess using NonlinearSolve would be one method, but I'd like to avoid re-implementing something if it is already available.

              _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.4 (2023-11-14)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using SteamTables

julia> P=30.
30.0

julia> T=650.
650.0

julia> H=SpecificH(P,T)
1808.4778049931917

julia> SpecificS_Ph(P,H)
ERROR: DomainError with (30.0, 1.484696870475923e6):
Pressure/Temperature outside valid ranges.
Stacktrace:
 [1] RegionID_Ph(P::Float64, h::Float64)
   @ SteamTables ~/.julia/packages/SteamTables/eKo68/src/SteamTables.jl:2030
 [2] SpecificS_Ph(P::Float64, h::Float64)
   @ SteamTables ~/.julia/packages/SteamTables/eKo68/src/SteamTables.jl:2951
 [3] top-level scope
   @ REPL[5]:1

(@v1.9) pkg> status SteamTables
Status `~/.julia/environments/v1.9/Project.toml`
  [43dc94dd] SteamTables v1.4.1
longemen3000 commented 6 months ago

the main problem is that there is not a definition of Region3_TPh that calculates the Temperature of the fluid, given p,h inputs in that region. the same problem happens with the region 5, and with P-s inputs

tkoenig1 commented 6 months ago

I tried the version mentioned in the pull request, but unfortunately, it does not appear to work for my case:

$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.2 (2024-03-01)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> include("issue.jl")
ERROR: LoadError: DomainError with (30.0, 1.4846968704759807e6):
Pressure/Temperature outside valid ranges.
Stacktrace:
 [1] RegionID_Ph(P::Float64, h::Float64)
   @ SteamTables ~/.julia/packages/SteamTables/pMvX5/src/SteamTables.jl:2028
 [2] SpecificS_Ph(P::Float64, h::Float64)
   @ SteamTables ~/.julia/packages/SteamTables/pMvX5/src/SteamTables.jl:2949
 [3] top-level scope
   @ ~/Nico/Steam/issue.jl:6
 [4] include(fname::String)
   @ Base.MainInclude ./client.jl:489
 [5] top-level scope
   @ REPL[1]:1
in expression starting at /home/ig25/Nico/Steam/issue.jl:6

(@v1.10) pkg> st SteamTables
Status `~/.julia/environments/v1.10/Project.toml`
  [43dc94dd] SteamTables v1.2.1 `https://github.com/longemen3000/SteamTables.jl.git#master`

where issue.jl is

using SteamTables

P=30.
T=650.
H=SpecificH(P,T)
SpecificS_Ph(P,H)