Skip to content

Commit

Permalink
update Thermodynamics
Browse files Browse the repository at this point in the history
  • Loading branch information
trontrytel authored and szy21 committed Sep 23, 2024
1 parent 3395e5a commit fca6ca3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ SciMLBase = "2.12"
StaticArrays = "1.7"
Statistics = "1"
SurfaceFluxes = "0.11, 0.12"
Thermodynamics = "0.12.4"
Thermodynamics = "0.12.8"
UnrolledUtilities = "0.1.5"
YAML = "0.4"
julia = "1.9"
62 changes: 31 additions & 31 deletions examples/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.10.5"
julia_version = "1.10.4"
manifest_format = "2.0"
project_hash = "f170b98e0622d3f170fe6045d8258f49ebd31345"

[[deps.ADTypes]]
git-tree-sha1 = "99a6f5d0ce1c7c6afdb759daa30226f71c54f6b0"
git-tree-sha1 = "5a5eafb8344b81b8c2237f8a6f6b3602b3f6180e"
uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
version = "1.7.1"
version = "1.8.1"
weakdeps = ["ChainRulesCore", "EnzymeCore"]

[deps.ADTypes.extensions]
Expand Down Expand Up @@ -248,9 +248,9 @@ version = "1.0.1+0"

[[deps.CUDA]]
deps = ["AbstractFFTs", "Adapt", "BFloat16s", "CEnum", "CUDA_Driver_jll", "CUDA_Runtime_Discovery", "CUDA_Runtime_jll", "Crayons", "DataFrames", "ExprTools", "GPUArrays", "GPUCompiler", "KernelAbstractions", "LLVM", "LLVMLoopInfo", "LazyArtifacts", "Libdl", "LinearAlgebra", "Logging", "NVTX", "Preferences", "PrettyTables", "Printf", "Random", "Random123", "RandomNumbers", "Reexport", "Requires", "SparseArrays", "StaticArrays", "Statistics"]
git-tree-sha1 = "fdd9dfb67dfefd548f51000cc400bb51003de247"
git-tree-sha1 = "cdbdca28f19c2c7fcf34ffb48bfdaca404dcd18a"
uuid = "052768ef-5323-5732-b1bb-66c8b64840ba"
version = "5.4.3"
version = "5.5.0"
weakdeps = ["ChainRulesCore", "EnzymeCore", "SpecialFunctions"]

[deps.CUDA.extensions]
Expand All @@ -260,9 +260,9 @@ weakdeps = ["ChainRulesCore", "EnzymeCore", "SpecialFunctions"]

[[deps.CUDA_Driver_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "325058b426c2b421e3d2df3d5fa646d72d2e3e7e"
git-tree-sha1 = "e2d9695d60b647e8803f1b5771412a7bf980e971"
uuid = "4ee394cb-3365-5eb0-8335-949819d2adfc"
version = "0.9.2+0"
version = "0.10.2+0"

[[deps.CUDA_Runtime_Discovery]]
deps = ["Libdl"]
Expand All @@ -272,9 +272,9 @@ version = "0.3.5"

[[deps.CUDA_Runtime_jll]]
deps = ["Artifacts", "CUDA_Driver_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"]
git-tree-sha1 = "afea94249b821dc754a8ca6695d3daed851e1f5a"
git-tree-sha1 = "1dce783060fb871658a6a4852c853293126eef8c"
uuid = "76a88914-d11a-5bdc-97e0-2f5a05c973a2"
version = "0.14.1+0"
version = "0.15.2+0"

[[deps.Cairo]]
deps = ["Cairo_jll", "Colors", "Glib_jll", "Graphics", "Libdl", "Pango_jll"]
Expand All @@ -296,9 +296,9 @@ version = "1.18.0+2"

[[deps.ChainRulesCore]]
deps = ["Compat", "LinearAlgebra"]
git-tree-sha1 = "71acdbf594aab5bbb2cec89b208c41b4c411e49f"
git-tree-sha1 = "3e4b134270b372f2ed4d4d0e936aabaefc1802bc"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "1.24.0"
version = "1.25.0"
weakdeps = ["SparseArrays"]

[deps.ChainRulesCore.extensions]
Expand Down Expand Up @@ -903,10 +903,10 @@ uuid = "46192b85-c4d5-4398-a991-12ede77f4527"
version = "0.1.6"

[[deps.GPUCompiler]]
deps = ["ExprTools", "InteractiveUtils", "LLVM", "Libdl", "Logging", "Preferences", "Scratch", "Serialization", "TOML", "TimerOutputs", "UUIDs"]
git-tree-sha1 = "ab29216184312f99ff957b32cd63c2fe9c928b91"
deps = ["ExprTools", "InteractiveUtils", "LLVM", "Libdl", "Logging", "PrecompileTools", "Preferences", "Scratch", "Serialization", "TOML", "TimerOutputs", "UUIDs"]
git-tree-sha1 = "fd8e483d0921ab300fd7c5a144f08332a8fbb745"
uuid = "61eb1bfa-7361-4325-ad38-22787b887f55"
version = "0.26.7"
version = "0.27.7"

[[deps.GaussQuadrature]]
deps = ["SpecialFunctions"]
Expand Down Expand Up @@ -1187,9 +1187,9 @@ version = "0.9.9"

[[deps.JLD2]]
deps = ["FileIO", "MacroTools", "Mmap", "OrderedCollections", "PrecompileTools", "Requires", "TranscodingStreams"]
git-tree-sha1 = "1dbe274ad1c199490b19a153b60a9e46c5386f8d"
git-tree-sha1 = "cafcd62f46d534f20361b30f8ab7eb1ae2473700"
uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
version = "0.5.1"
version = "0.5.2"

[[deps.JLLWrappers]]
deps = ["Artifacts", "Preferences"]
Expand Down Expand Up @@ -1229,9 +1229,9 @@ version = "0.2.1+0"

[[deps.KernelAbstractions]]
deps = ["Adapt", "Atomix", "InteractiveUtils", "MacroTools", "PrecompileTools", "Requires", "StaticArrays", "UUIDs", "UnsafeAtomics", "UnsafeAtomicsLLVM"]
git-tree-sha1 = "cb1cff88ef2f3a157cbad75bbe6b229e1975e498"
git-tree-sha1 = "045d41a364a81e357757c566b5a69fd4a2a2c445"
uuid = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
version = "0.9.25"
version = "0.9.26"
weakdeps = ["EnzymeCore", "LinearAlgebra", "SparseArrays"]

[deps.KernelAbstractions.extensions]
Expand Down Expand Up @@ -1275,19 +1275,19 @@ version = "3.0.0+1"

[[deps.LLVM]]
deps = ["CEnum", "LLVMExtra_jll", "Libdl", "Preferences", "Printf", "Requires", "Unicode"]
git-tree-sha1 = "2470e69781ddd70b8878491233cd09bc1bd7fc96"
git-tree-sha1 = "4ad43cb0a4bb5e5b1506e1d1f48646d7e0c80363"
uuid = "929cbde3-209d-540e-8aea-75f648917ca0"
version = "8.1.0"
version = "9.1.2"
weakdeps = ["BFloat16s"]

[deps.LLVM.extensions]
BFloat16sExt = "BFloat16s"

[[deps.LLVMExtra_jll]]
deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"]
git-tree-sha1 = "597d1c758c9ae5d985ba4202386a607c675ee700"
git-tree-sha1 = "05a8bd5a42309a9ec82f700876903abce1017dd3"
uuid = "dad2f222-ce93-54a1-a47d-0025e8a3acab"
version = "0.0.31+0"
version = "0.0.34+0"

[[deps.LLVMLoopInfo]]
git-tree-sha1 = "2e5c102cfc41f48ae4740c7eca7743cc7e7b75ea"
Expand Down Expand Up @@ -1913,9 +1913,9 @@ version = "1.0.0"

[[deps.QuadGK]]
deps = ["DataStructures", "LinearAlgebra"]
git-tree-sha1 = "1d587203cf851a51bf1ea31ad7ff89eff8d625ea"
git-tree-sha1 = "cda3b045cf9ef07a08ad46731f5a3165e56cf3da"
uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
version = "2.11.0"
version = "2.11.1"

[deps.QuadGK.extensions]
QuadGKEnzymeExt = "Enzyme"
Expand Down Expand Up @@ -2053,9 +2053,9 @@ version = "0.7.0"

[[deps.SIMD]]
deps = ["PrecompileTools"]
git-tree-sha1 = "2803cab51702db743f3fda07dd1745aadfbf43bd"
git-tree-sha1 = "98ca7c29edd6fc79cd74c61accb7010a4e7aee33"
uuid = "fdea26ae-647d-5447-a871-4b548cad5224"
version = "3.5.0"
version = "3.6.0"

[[deps.SIMDTypes]]
git-tree-sha1 = "330289636fb8107c5f32088d2741e9fd7a061a5c"
Expand Down Expand Up @@ -2367,9 +2367,9 @@ version = "1.0.2"

[[deps.Thermodynamics]]
deps = ["DocStringExtensions", "KernelAbstractions", "Random", "RootSolvers"]
git-tree-sha1 = "80b13ddc5ae7b8605ef5a055e7f23c5b5f4775cf"
git-tree-sha1 = "8c2afc6dbb2bdac698a5b05816b7521630dea034"
uuid = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
version = "0.12.7"
version = "0.12.8"
weakdeps = ["ClimaParams"]

[deps.Thermodynamics.extensions]
Expand Down Expand Up @@ -2477,9 +2477,9 @@ version = "1.0.0"

[[deps.WriteVTK]]
deps = ["Base64", "CodecZlib", "FillArrays", "LightXML", "TranscodingStreams", "VTKBase"]
git-tree-sha1 = "46664bb833f24e4fe561192e3753c9168c3b71b2"
git-tree-sha1 = "93fd3a6bbeb33c18929b7d8b4f4dbd2024395f70"
uuid = "64499a7a-5c06-52f2-abe2-ccb03c286192"
version = "1.19.2"
version = "1.20.0"

[[deps.XML2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Zlib_jll"]
Expand Down Expand Up @@ -2591,7 +2591,7 @@ version = "0.15.2+0"
[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.11.0+0"
version = "5.8.0+1"

[[deps.libfdk_aac_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
Expand Down
24 changes: 13 additions & 11 deletions src/prognostic_equations/implicit/implicit_solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use_derivative(::IgnoreDerivative) = false

"""
ImplicitEquationJacobian(
Y, atmos;
Y, atmos;
approximate_solve_iters, diffusion_flag, topography_flag, sgs_advection_flag, transform_flag
)
Expand Down Expand Up @@ -487,8 +487,10 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ)

cv_d = FT(CAP.cv_d(params))
Δcv_v = FT(CAP.cv_v(params)) - cv_d
T_tri = FT(CAP.T_triple(params))
e_int_v0 = T_tri * Δcv_v - FT(CAP.e_int_v0(params))
T_0 = FT(CAP.T_0(params))
R_d = FT(CAP.R_d(params))
cp_d = FT(CAP.cp_d(params))
∂e_int_∂q_tot = T_0 * (Δcv_v - R_d) - FT(CAP.e_int_v0(params))
thermo_params = CAP.thermodynamics_params(params)

ᶜρ = Y.c.ρ
Expand Down Expand Up @@ -550,15 +552,15 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ)
@. ∂ᶠu₃_err_∂ᶜρ =
dtγ * (
ᶠp_grad_matrix
DiagonalMatrixRow(ᶜkappa_m * (T_tri * cv_d - ᶜK - ᶜΦ)) +
DiagonalMatrixRow(ᶜkappa_m * (T_0 * cp_d - ᶜK - ᶜΦ)) +
DiagonalMatrixRow(ᶠgradᵥ(ᶜp) / abs2(ᶠinterp(ᶜρ)))
ᶠinterp_matrix()
)
@. ∂ᶠu₃_err_∂ᶜρe_tot = dtγ * ᶠp_grad_matrix DiagonalMatrixRow(ᶜkappa_m)
if MatrixFields.has_field(Y, @name(c.ρq_tot))
∂ᶠu₃_err_∂ᶜρq_tot = matrix[@name(f.u₃), @name(c.ρq_tot)]
@. ∂ᶠu₃_err_∂ᶜρq_tot =
dtγ * ᶠp_grad_matrix DiagonalMatrixRow(ᶜkappa_m * e_int_v0)
dtγ * ᶠp_grad_matrix DiagonalMatrixRow(ᶜkappa_m * ∂e_int_∂q_tot)
end

∂ᶠu₃_err_∂ᶜuₕ = matrix[@name(f.u₃), @name(c.uₕ)]
Expand Down Expand Up @@ -599,7 +601,7 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ)
dtγ * ᶜdiffusion_h_matrix DiagonalMatrixRow(
(
-(1 + ᶜkappa_m) * ᶜspecific.e_tot -
ᶜkappa_m * e_int_v0 * ᶜspecific.q_tot
ᶜkappa_m * ∂e_int_∂q_tot * ᶜspecific.q_tot
) / ᶜρ,
)
@. ∂ᶜρe_tot_err_∂ᶜρe_tot =
Expand All @@ -609,7 +611,7 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ)
∂ᶜρe_tot_err_∂ᶜρq_tot = matrix[@name(c.ρe_tot), @name(c.ρq_tot)]
@. ∂ᶜρe_tot_err_∂ᶜρq_tot =
dtγ * ᶜdiffusion_h_matrix
DiagonalMatrixRow(ᶜkappa_m * e_int_v0 / ᶜρ)
DiagonalMatrixRow(ᶜkappa_m * ∂e_int_∂q_tot / ᶜρ)
end

tracer_info = (
Expand Down Expand Up @@ -727,7 +729,7 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ)
adjoint(ᶜinterp(ᶠu³ʲs.:(1))) *
ᶜgradᵥ_ᶠΦ *
Y.c.ρ *
ᶜkappa_mʲ / ((ᶜkappa_mʲ + 1) * ᶜp) * e_int_v0,
ᶜkappa_mʲ / ((ᶜkappa_mʲ + 1) * ᶜp) * ∂e_int_∂q_tot,
)
)
∂ᶜmseʲ_err_∂ᶜρ = matrix[@name(c.sgsʲs.:(1).mse), @name(c.ρ)]
Expand Down Expand Up @@ -764,14 +766,14 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ)
),
) ᶠwinterp_matrix(ᶜJ) DiagonalMatrixRow(
ᶜkappa_mʲ * (ᶜρʲs.:(1))^2 / ((ᶜkappa_mʲ + 1) * ᶜp) *
e_int_v0,
∂e_int_∂q_tot,
)
@. ᶠbidiagonal_matrix_ct3_2 =
DiagonalMatrixRow(ᶠwinterp(ᶜJ, ᶜρʲs.:(1)))
ᶠset_upwind_matrix_bcs(ᶠupwind_matrix(ᶠu³ʲs.:(1)))
DiagonalMatrixRow(
Y.c.sgsʲs.:(1).ρa * ᶜkappa_mʲ / ((ᶜkappa_mʲ + 1) * ᶜp) *
e_int_v0,
∂e_int_∂q_tot,
)

@. ∂ᶜρaʲ_err_∂ᶜq_totʲ =
Expand Down Expand Up @@ -820,7 +822,7 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ)
ᶠgradᵥ_ᶜΦ * ᶠinterp(Y.c.ρ) / (ᶠinterp(ᶜρʲs.:(1)))^2,
) ᶠinterp_matrix() DiagonalMatrixRow(
ᶜkappa_mʲ * (ᶜρʲs.:(1))^2 / ((ᶜkappa_mʲ + 1) * ᶜp) *
e_int_v0,
∂e_int_∂q_tot,
)
∂ᶠu₃ʲ_err_∂ᶜmseʲ =
matrix[@name(f.sgsʲs.:(1).u₃), @name(c.sgsʲs.:(1).mse)]
Expand Down

0 comments on commit fca6ca3

Please sign in to comment.