Skip to content

Commit

Permalink
Merge branch 'main' into glw/density-example
Browse files Browse the repository at this point in the history
  • Loading branch information
glwagner authored Jan 23, 2024
2 parents 5005aed + 55092b6 commit 29b219d
Show file tree
Hide file tree
Showing 38 changed files with 865 additions and 610 deletions.
33 changes: 25 additions & 8 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
agents:
queue: central
slurm_mem: 8G
modules: julia/1.9.3 cuda/12.2
modules: julia/1.10.0 cuda/12.2

env:
JULIA_VERSION: "1.9.3"
JULIA_VERSION: "1.10.0"
OPENBLAS_NUM_THREADS: 1
CUDA_VERSION: "12.2"
OMPI_MCA_opal_warn_on_missing_libcuda: 0
Expand Down Expand Up @@ -58,12 +58,12 @@ steps:
slurm_ntasks: 1
timeout_in_minutes: 60

- label: ":mag::rocket: Constructor flop measurements"
command:
- "julia --project=perf perf/flops.jl"
agents:
slurm_ntasks: 1
timeout_in_minutes: 60
# - label: ":mag::rocket: Constructor flop measurements"
# command:
# - "julia --project=perf perf/flops.jl"
# agents:
# slurm_ntasks: 1
# timeout_in_minutes: 60

- label: ":mag::rocket: JET tests"
command:
Expand All @@ -87,3 +87,20 @@ steps:
slurm_ntasks: 1
slurm_gpus: 1
timeout_in_minutes: 60

- label: "KernelAbstraction GPU kernel benchmarks"
command:
- "julia --project=gpuenv perf/kernel_bm.jl CuArray"
agents:
slurm_ntasks: 1
slurm_gpus: 1
timeout_in_minutes: 60

- label: "KernelAbstraction CPU kernel benchmarks"
command:
- "julia --project=gpuenv perf/kernel_bm.jl"
agents:
slurm_ntasks: 1
slurm_gpus: 1
timeout_in_minutes: 60

6 changes: 3 additions & 3 deletions .github/workflows/CodeCov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2.2.0
- uses: actions/checkout@v4

- name: Set up Julia
uses: julia-actions/setup-julia@latest
with:
version: 1.9
version: '1.10'

- name: Test with coverage
env:
Expand All @@ -36,7 +36,7 @@ jobs:
if: success()

- name: Submit coverage
uses: codecov/codecov-action@v1.0.7
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
if: success()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/DocCleanUp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: gh-pages

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/JuliaFormatter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v2.2.0
- uses: actions/checkout@v4

- uses: dorny/paths-filter@v2.9.1
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
Expand All @@ -30,7 +30,7 @@ jobs:
- uses: julia-actions/setup-julia@latest
if: steps.filter.outputs.julia_file_change == 'true'
with:
version: 1.9
version: '1.10'

- name: Apply JuliaFormatter
if: steps.filter.outputs.julia_file_change == 'true'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- '1.7'
- '1.8'
- '1.9'
- '1.10'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
docbuild:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@latest
with:
version: 1.9
version: '1.10'
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/invalidations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-invalidations@v1
id: invs_pr

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- uses: julia-actions/julia-buildpkg@v1
Expand Down
14 changes: 12 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
name = "Thermodynamics"
uuid = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
authors = ["Climate Modeling Alliance"]
version = "0.11.2"
version = "0.11.4"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
RootSolvers = "7181ea78-2dcb-4de3-ab41-2b8ab5a31e74"
# Required for backwards compatibility with Julia <1.9
CLIMAParameters = "6eacf6c3-8458-43b9-ae03-caf5306d3d53"

[weakdeps]
CLIMAParameters = "6eacf6c3-8458-43b9-ae03-caf5306d3d53"

[extensions]
CreateParametersExt = "CLIMAParameters"

[compat]
DocStringExtensions = "0.8.1, 0.9"
KernelAbstractions = "0.7, 0.8, 0.9"
KernelAbstractions = "0.9"
Random = "1"
RootSolvers = "0.4"
julia = "1.6"
CLIMAParameters = "0.8"
1 change: 0 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
RootSolvers = "7181ea78-2dcb-4de3-ab41-2b8ab5a31e74"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"

[compat]
julia = "1.7"
17 changes: 2 additions & 15 deletions docs/src/Clausius_Clapeyron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,10 @@ import CLIMAParameters as CP
using Thermodynamics.TestedProfiles
import Thermodynamics.Parameters as TP

function get_parameter_set(::Type{FT}) where {FT}
toml_dict = CP.create_toml_dict(FT; dict_type = "alias")
aliases = string.(fieldnames(TP.ThermodynamicsParameters))
param_pairs = CP.get_parameter_values!(toml_dict, aliases, "Thermodynamics")
param_set = TP.ThermodynamicsParameters{FT}(; param_pairs...)
logfilepath = joinpath(@__DIR__, "logfilepath_$FT.toml")
CP.log_parameter_information(toml_dict, logfilepath)
return param_set
end
const param_set_Float64 = get_parameter_set(Float64)
const param_set_Float32 = get_parameter_set(Float32)
parameter_set(::Type{Float64}) = param_set_Float64
parameter_set(::Type{Float32}) = param_set_Float32
ArrayType = Array{Float64}

FT = eltype(ArrayType)
param_set = parameter_set(FT)

param_set = TP.ThermodynamicsParameters(FT)
profiles = TestedProfiles.PhaseEquilProfiles(param_set, ArrayType)
(; T, p, e_int, ρ, θ_liq_ice, phase_type) = profiles
(; q_tot, q_liq, q_ice, q_pt, RH, e_kin, e_pot) = profiles
Expand Down
3 changes: 2 additions & 1 deletion docs/src/Formulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ A virtual potential temperature can be defined analogously:
\end{equation}
```

!!! note
!!! note "Relationship between virtual temperature and 'density temperature'"
Some texts distinguish a "(condensate-ignoring) virtual temperature" and a "density temperature", and an analogous condensate-ignoring virtual potential temperature and density potential temperature.
In those texts, the definition of density temperature incorporates condensate mass but their "condensate-ignoring virtual temperature" does not.
We always take the mass of any condensate into account in the thermodynamics of moist air, so this distinction is irrelevant here.
Expand Down Expand Up @@ -420,6 +420,7 @@ TODO: there was a commented equation here, do we need it?
This expression for temperature as a function of liquid-ice potential temperature is obtained from \eqref{e:TempFromThetaLiGivenP} by substituting for pressure in the Exner function ``\Pi`` from the ideal gas law, ``p=ρ R_m T``, solving for temperature using a second-order Taylor expansion around ``T_u`` for small condensate specific humidities, and using the relation ``1-κ = c_{vm}/c_{pm}``, which follows from ``c_{pm} - R_m = c_{vm}``. The relation for temperature \eqref{e:TempFromThetaLiGivenRho} holds to second order in condensate specific humidities ``q_l`` and ``q_i``. That is, the inversion relation \eqref{e:TempFromThetaLiGivenRho} holds to one higher order of accuracy than the definition of the liquid-ice potential temperature \eqref{e:liquid_ice_pottemp} itself, which is only first-order accurate in the condensate specific humidities ``q_l`` and ``q_i``.

### Speed of Sound

The speed of sound in (moist) unstratified air is
```math
\begin{equation}
Expand Down
21 changes: 6 additions & 15 deletions docs/src/TemperatureProfiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ import Thermodynamics as TD
import Plots
import CLIMAParameters as CP
import Thermodynamics.Parameters as TP
FT = Float64;
toml_dict = CP.create_toml_dict(FT; dict_type = "alias")
aliases = string.(fieldnames(TP.ThermodynamicsParameters))
param_pairs = CP.get_parameter_values!(toml_dict, aliases, "Thermodynamics")
param_set = TP.ThermodynamicsParameters{FT}(; param_pairs...)
FT = Float64
param_set = TP.ThermodynamicsParameters(FT)
z = range(FT(0), stop = FT(2.5e4), length = 50);
isothermal = TD.TemperatureProfiles.IsothermalProfile(param_set, FT);
Expand All @@ -49,11 +46,8 @@ import Thermodynamics as TD
import Plots
import CLIMAParameters as CP
import Thermodynamics.Parameters as TP
FT = Float64;
toml_dict = CP.create_toml_dict(FT; dict_type = "alias")
aliases = string.(fieldnames(TP.ThermodynamicsParameters))
param_pairs = CP.get_parameter_values!(toml_dict, aliases, "Thermodynamics")
param_set = TP.ThermodynamicsParameters{FT}(; param_pairs...)
FT = Float64
param_set = TP.ThermodynamicsParameters(FT)
z = range(FT(0), stop = FT(2.5e4), length = 50);
decaying = TD.TemperatureProfiles.DecayingTemperatureProfile{FT}(param_set);
Expand All @@ -75,11 +69,8 @@ import Thermodynamics as TD
import Plots
import CLIMAParameters as CP
import Thermodynamics.Parameters as TP
FT = Float64;
toml_dict = CP.create_toml_dict(FT; dict_type = "alias")
aliases = string.(fieldnames(TP.ThermodynamicsParameters))
param_pairs = CP.get_parameter_values!(toml_dict, aliases, "Thermodynamics")
param_set = TP.ThermodynamicsParameters{FT}(; param_pairs...)
FT = Float64
param_set = TP.ThermodynamicsParameters(FT)
z = range(FT(0), stop = FT(2.5e4), length = 50);
dry_adiabatic = TD.TemperatureProfiles.DryAdiabaticProfile{FT}(param_set);
Expand Down
14 changes: 4 additions & 10 deletions docs/src/TestedProfiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ import Thermodynamics as TD
import Plots
import CLIMAParameters as CP
import Thermodynamics.Parameters as TP
FT = Float64;
toml_dict = CP.create_toml_dict(FT; dict_type = "alias")
aliases = string.(fieldnames(TP.ThermodynamicsParameters))
param_pairs = CP.get_parameter_values!(toml_dict, aliases, "Thermodynamics")
param_set = TP.ThermodynamicsParameters{FT}(; param_pairs...)
FT = Float64
param_set = TP.ThermodynamicsParameters(FT)
profiles = TD.TestedProfiles.PhaseDryProfiles(param_set, Array{FT});
(;T, ρ, z) = profiles
Expand All @@ -31,11 +28,8 @@ import Thermodynamics as TD
import Plots
import CLIMAParameters as CP
import Thermodynamics.Parameters as TP
FT = Float64;
toml_dict = CP.create_toml_dict(FT; dict_type = "alias")
aliases = string.(fieldnames(TP.ThermodynamicsParameters))
param_pairs = CP.get_parameter_values!(toml_dict, aliases, "Thermodynamics")
param_set = TP.ThermodynamicsParameters{FT}(; param_pairs...)
FT = Float64
param_set = TP.ThermodynamicsParameters(FT)
profiles = TD.TestedProfiles.PhaseEquilProfiles(param_set, Array{FT});
(;T, ρ, q_tot, z) = profiles
Expand Down
14 changes: 5 additions & 9 deletions docs/src/saturation_adjustment.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import RootSolvers
const RS = RootSolvers
import RootSolvers as RS
import Plots

FT = Float64;
import Thermodynamics as TD
const TP = TD.Parameters
import Thermodynamics.Parameters as TP
import CLIMAParameters as CP

TD.print_warning() = false
toml_dict = CP.create_toml_dict(FT; dict_type = "alias")
aliases = string.(fieldnames(TP.ThermodynamicsParameters))
param_pairs = CP.get_parameter_values!(toml_dict, aliases, "Thermodynamics")
const param_set = TP.ThermodynamicsParameters{FT}(; param_pairs...)
FT = Float64

const param_set = TP.ThermodynamicsParameters(FT)

profiles = TD.TestedProfiles.PhaseEquilProfiles(param_set, Array{FT});
(; ρ, q_tot) = profiles
Expand Down
42 changes: 42 additions & 0 deletions ext/CreateParametersExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module CreateParametersExt

import Thermodynamics.Parameters.ThermodynamicsParameters
import CLIMAParameters as CP

ThermodynamicsParameters(::Type{FT}) where {FT <: AbstractFloat} =
ThermodynamicsParameters(CP.create_toml_dict(FT))

function ThermodynamicsParameters(toml_dict::CP.AbstractTOMLDict)
name_map = (;
:temperature_min_at_reference => :T_min_ref,
:entropy_water_vapor => :entropy_water_vapor,
:entropy_dry_air => :entropy_dry_air,
:potential_temperature_reference_pressure => :p_ref_theta,
:entropy_reference_temperature => :entropy_reference_temperature,
:temperature_saturation_adjustment_max => :T_max,
:molar_mass_dry_air => :molmass_dryair,
:pow_icenuc => :pow_icenuc,
:temperature_triple_point => :T_triple,
:adiabatic_exponent_dry_air => :kappa_d,
:pressure_triple_point => :press_triple,
:thermodynamics_temperature_reference => :T_0,
:temperature_water_freeze => :T_freeze,
:isobaric_specific_heat_ice => :cp_i,
:latent_heat_sublimation_at_reference => :LH_s0,
:isobaric_specific_heat_vapor => :cp_v,
:molar_mass_water => :molmass_water,
:mean_sea_level_pressure => :MSLP,
:isobaric_specific_heat_liquid => :cp_l,
:latent_heat_vaporization_at_reference => :LH_v0,
:temperature_saturation_adjustment_min => :T_min,
:gas_constant => :gas_constant,
:temperature_mean_at_reference => :T_surf_ref,
:gravitational_acceleration => :grav,
:temperature_homogenous_nucleation => :T_icenuc,
)
parameters = CP.get_parameter_values(toml_dict, name_map, "Thermodynamics")
FT = CP.float_type(toml_dict)
return ThermodynamicsParameters{FT}(; parameters...)
end

end
12 changes: 5 additions & 7 deletions gpuenv/Project.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CLIMAParameters = "6eacf6c3-8458-43b9-ae03-caf5306d3d53"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
CUDAKernels = "72cfdca4-0801-4ab0-bf6a-d52aa10adc57"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
RootSolvers = "7181ea78-2dcb-4de3-ab41-2b8ab5a31e74"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"

[compat]
CLIMAParameters = "0.6, 0.7"
CUDA = "3.5"
CUDAKernels = "0.3, 0.4"
KernelAbstractions = "0.7, 0.8"
CLIMAParameters = "0.8"
CUDA = "3.5, 4, 5"
KernelAbstractions = "0.9"
RootSolvers = "0.4"
UnPack = "1.0"
julia = "1.7"
Loading

0 comments on commit 29b219d

Please sign in to comment.