Skip to content

test thermodynamics branch #3907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .buildkite/Manifest-v1.11.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.11.5"
julia_version = "1.11.3"
manifest_format = "2.0"
project_hash = "04945e2a7116cfacb2d57340f477dbe23e208227"
project_hash = "a25db2ac38461b28c1b3a6176008dee03780354b"

[[deps.ADTypes]]
git-tree-sha1 = "be7ae030256b8ef14a441726c4c37766b90b93a3"
Expand Down Expand Up @@ -1818,7 +1818,7 @@ version = "2.5.4+0"
[[deps.OpenLibm_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
version = "0.8.5+0"
version = "0.8.1+2"

[[deps.OpenMPI_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML", "Zlib_jll"]
Expand Down Expand Up @@ -2539,8 +2539,10 @@ uuid = "b718987f-49a8-5099-9789-dcd902bef87d"
version = "1.0.2"

[[deps.Thermodynamics]]
deps = ["DocStringExtensions", "KernelAbstractions", "Random", "RootSolvers"]
git-tree-sha1 = "bff801ad0a9bbb5c1bf38ffe89a83907a1b145cd"
deps = ["DocStringExtensions", "ForwardDiff", "KernelAbstractions", "Random", "RootSolvers"]
git-tree-sha1 = "1c6b10882d535f28b5c79be9d8d782a12f5592f9"
repo-rev = "zs/test_autodiff"
repo-url = "https://github.com/CliMA/Thermodynamics.jl.git"
uuid = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
version = "0.12.15"
weakdeps = ["ClimaParams"]
Expand Down
1 change: 1 addition & 0 deletions .buildkite/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ SnoopCompileCore = "e2b509da-e806-4183-be48-004708413034"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"

[compat]
Expand Down
23 changes: 23 additions & 0 deletions src/prognostic_equations/implicit/autodiff_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,29 @@ end
return ForwardDiff.dual_definition_retval(tag, val, deriv, partials)
end

# Set the derivative of max(x, y) to handle cases where x == y. When x == y,
# the derivative is set to the derivative of x (the first argument) to ensure
# continuity and avoid numerical issues. This is a common approach in automatic
# differentiation for max functions.

@inline function Base.max(d::ForwardDiff.Dual{Jacobian}, r::Integer)
tag = Val(Jacobian)
x = ForwardDiff.value(d)
partials = ForwardDiff.partials(d)
val = max(x, r)
deriv = 1
return ForwardDiff.dual_definition_retval(tag, val, deriv, partials)
end

# @inline function Base.clamp(d::ForwardDiff.Dual{Jacobian}, r1::FT, r2::FT) where {FT}
# tag = Val(Jacobian)
# x = ForwardDiff.value(d)
# partials = ForwardDiff.partials(d)
# val = clamp(x, r1, r2)
# deriv = 1
# return ForwardDiff.dual_definition_retval(tag, val, deriv, partials)
# end

# Ignore all derivative information when comparing Duals to other Numbers. This
# ensures that conditional statements are always equivalent for Duals and Reals.
for func in (:iszero,)
Expand Down
Loading