Skip to content

Commit

Permalink
Merge #125
Browse files Browse the repository at this point in the history
125: Try replacing pow with exp log r=charleskawczynski a=charleskawczynski

I may try to add Float32 perf tests, just to see / verify from here that this is problematic.

Co-authored-by: Charles Kawczynski <[email protected]>
  • Loading branch information
bors[bot] and charleskawczynski authored Aug 17, 2022
2 parents e39a650 + caea43f commit 2a8aa23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Thermodynamics"
uuid = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
authors = ["Climate Modeling Alliance"]
version = "0.9.3"
version = "0.9.4"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand Down
7 changes: 6 additions & 1 deletion src/relations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,10 @@ function saturation_vapor_pressure(
return saturation_vapor_pressure(param_set, T, LH_0, Δcp)
end

# we may be hitting a slow path:
# https://stackoverflow.com/questions/14687665/very-slow-stdpow-for-bases-very-close-to-1
pow_hack(x, y) = exp(y * log(x))

function saturation_vapor_pressure(
param_set::APS,
T::FT,
Expand All @@ -935,7 +939,8 @@ function saturation_vapor_pressure(
T_0::FT = TP.T_0(param_set)

return press_triple *
(T / T_triple)^(Δcp / R_v) *
# (T / T_triple)^(Δcp / R_v) *
pow_hack(T / T_triple, Δcp / R_v) *
exp((LH_0 - Δcp * T_0) / R_v * (1 / T_triple - 1 / T))

end
Expand Down

2 comments on commit 2a8aa23

@charleskawczynski
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/66394

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.9.4 -m "<description of version>" 2a8aa233c9710c002a5f7ca80ba67c0a242df903
git push origin v0.9.4

Please sign in to comment.