Skip to content

Commit

Permalink
rm UnPack dep
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasloan25 committed Nov 22, 2023
1 parent 61af0de commit cbd85a0
Show file tree
Hide file tree
Showing 28 changed files with 100 additions and 115 deletions.
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
SurfaceFluxes = "49b00bb7-8bd4-4f2b-b78c-51cd0450215f"
TempestRemap_jll = "8573a8c5-1df0-515e-a024-abad257ee284"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"

[compat]
CLIMAParameters = "0.4, 0.5, 0.6, 0.7"
Expand All @@ -43,5 +42,4 @@ Statistics = "1"
SurfaceFluxes = "0.8"
TempestRemap_jll = "2"
Thermodynamics = "0.11"
UnPack = "1"
julia = "1.8"
2 changes: 1 addition & 1 deletion experiments/AMIP/modular/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.9.4"
manifest_format = "2.0"
project_hash = "f9930640d41fb661fa56427b6e532a1097e825cd"
project_hash = "51945627ab4a5bce03b6e1cc416e4ae07bac2bff"

[[deps.ADTypes]]
git-tree-sha1 = "332e5d7baeff8497b923b730b994fa480601efc7"
Expand Down
1 change: 0 additions & 1 deletion experiments/AMIP/modular/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ TempestRemap_jll = "8573a8c5-1df0-515e-a024-abad257ee284"
TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"

[compat]
Expand Down
5 changes: 2 additions & 3 deletions experiments/AMIP/modular/coupler_driver_modular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ using OrdinaryDiffEq: ODEProblem, solve, SSPRK33, savevalues!, Euler
using LinearAlgebra
import Test: @test
using Dates
using UnPack
using Plots
using Statistics: mean
import ClimaAtmos as CA
Expand Down Expand Up @@ -583,8 +582,8 @@ update_model_sims!(cs.model_sims, cs.fields, turbulent_fluxes)
function solve_coupler!(cs)
@info "Starting coupling loop"

@unpack model_sims, Δt_cpl, tspan = cs
@unpack atmos_sim, land_sim, ocean_sim, ice_sim = model_sims
(; model_sims, Δt_cpl, tspan) = cs
(; atmos_sim, land_sim, ocean_sim, ice_sim) = model_sims

## step in time
walltime = @elapsed for t in ((tspan[1] + Δt_cpl):Δt_cpl:tspan[end])
Expand Down
2 changes: 0 additions & 2 deletions experiments/ClimaCore/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"

[compat]
IntervalSets = "0.6"
OrdinaryDiffEq = "6.15"
SciMLBase = "1.40"
TerminalLoggers = "0.1"
UnPack = "1.0"
1 change: 1 addition & 0 deletions experiments/ClimaCore/bc-wave-slab/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

julia_version = "1.7.1"
manifest_format = "2.0"
project_hash = "76ed02fff745b8d35c713258782ec9ac17ca37a0"

[[deps.AbstractFFTs]]
deps = ["ChainRulesCore", "LinearAlgebra"]
Expand Down
1 change: 0 additions & 1 deletion experiments/ClimaCore/bc-wave-slab/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"

[extras]
CPUSummary = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9"
5 changes: 2 additions & 3 deletions experiments/ClimaCore/bc-wave-slab/atmos.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# from ClimaAtmos:test/test_cases/run_3d_baroclinic_wave.jl, removing `step!`
# from ClimaAtmos:test/test_cases/run_3d_baroclinic_wave.jl, removing `step!`

using OrdinaryDiffEq: SSPRK33
using ClimaCorePlots, Plots
using UnPack

import ClimaCore
import ClimaCore: Fields, Geometry, Operators
Expand Down Expand Up @@ -66,7 +65,7 @@ function atmos_init(::Type{FT}, tspan; stepper = SSPRK33(), nelements = (6, 10),
simulation = Simulation(model, stepper, dt = dt, tspan = tspan)

# test set function
@unpack ρ, uh, w, ρe_tot = init_3d_baroclinic_wave(FT, params)
(; ρ, uh, w, ρe_tot) = init_3d_baroclinic_wave(FT, params)
set!(simulation, :base, ρ = ρ, uh = uh, w = w)
set!(simulation, :thermodynamics, ρe_tot = ρe_tot)

Expand Down
2 changes: 1 addition & 1 deletion experiments/ClimaCore/sea_breeze/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.9.3"
manifest_format = "2.0"
project_hash = "611b5e1a4a3d0a56deb02707202cae2cba6c4b50"
project_hash = "d8266eea50eeaba5c2a0feab114ac07a15343ef5"

[[deps.ADTypes]]
git-tree-sha1 = "5d2e21d7b0d8c22f67483ef95ebdc39c0e6b6003"
Expand Down
1 change: 0 additions & 1 deletion experiments/ClimaCore/sea_breeze/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"

[compat]
PrettyTables = "2"
Expand Down
2 changes: 1 addition & 1 deletion experiments/ClimaCore/sea_breeze/atmos_rhs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ and for vertical-momentum, as:
push!(LOAD_PATH, joinpath(@__DIR__, "..", "..", ".."))

using Test
using StaticArrays, IntervalSets, LinearAlgebra, UnPack
using StaticArrays, IntervalSets, LinearAlgebra

import ClimaCore: ClimaCore, slab, Spaces, Domains, Meshes, Geometry, Topologies, Spaces, Fields, Operators
using ClimaCore.Geometry
Expand Down
4 changes: 2 additions & 2 deletions experiments/ClimaCore/sea_breeze/land_rhs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ function lnd_rhs!(du, u, (parameters, F_accumulated), t)
where
F_accumulated = F_integrated / Δt_coupler
"""
@unpack lnd_h, lnd_ρ, lnd_c = parameters
@unpack T_sfc = du
(; lnd_h, lnd_ρ, lnd_c) = parameters
(; T_sfc = du)

@. T_sfc = (-F_accumulated) / (lnd_h * lnd_ρ * lnd_c)
end
Expand Down
4 changes: 2 additions & 2 deletions experiments/ClimaCore/sea_breeze/ocean_rhs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ function ocn_rhs!(du, u, (parameters, F_accumulated), t)
where
F_accumulated = F_integrated / Δt_coupler
"""
@unpack ocn_h, ocn_ρ, ocn_c = parameters
@unpack T_sfc = du
(; ocn_h, ocn_ρ, ocn_c) = parameters
(; T_sfc) = du

@. T_sfc = (-F_accumulated) / (ocn_h * ocn_ρ * ocn_c)
end
Expand Down
2 changes: 1 addition & 1 deletion experiments/ClimaCore/sea_breeze/run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ where $F_{integ}$ has units of $J m^{-2}$.
=#
function cpl_run(simulation::AOLCoupledSim)
@info "Run model"
@unpack atmos, ocean, land, coupler = simulation
(; atmos, ocean, land, coupler) = simulation
Δt_coupled = coupler.Δt_coupled
## coupler stepping
for t in ((t_start + Δt_coupled):Δt_coupled:t_end)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
2 changes: 1 addition & 1 deletion experiments/ClimaCore/tc1_heat-diffusion-with-slab/run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
## import Pkg; Pkg.add(url="https://github.com/CliMA/ClimaCore.jl",rev="main")

# - load external packages:
import LinearAlgebra, UnPack
import LinearAlgebra
import ClimaCore: Fields, Domains, Topologies, Meshes, DataLayouts, Operators, Geometry, Spaces

using Base: show_supertypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,40 @@

#=
Ekman column:
∂_t ρ = ∇ (μ ∇ ρ - w ρ)
∂_t ρ = ∇ (μ ∇ ρ - w ρ)
∂_t ρθ = ∇ (μ ∇ ρθ - w ρθ)
∂_t u = ∇ (μ ∇ u - w u) + (v - v_g)
∂_t v = ∇ (μ ∇ v - w v) - (u - u_g)
∂_t w = ∇ (μ ∇ w - w w) - g - c_p θ ∂_z Π
∂_t v = ∇ (μ ∇ v - w v) - (u - u_g)
∂_t w = ∇ (μ ∇ w - w w) - g - c_p θ ∂_z Π
where
where
Π = (p/p_0)^{R/c_p}
top BCs are insulating and impenetrable:
∂_t T = 0
u = u_g
v = v_g
w = 0.0
∂_t ρ = 0
∂_t T = 0
u = u_g
v = v_g
w = 0.0
∂_t ρ = 0
and bottom BCs use bulk formulae for surface fluxes of heat and momentum:
∂_t ρθ = F₃ = -Ch ρ ||u|| (T_sfc - ρθ / ρ)
∂_t u = F₁ = -Cd u ||u||
∂_t v = F₂ = -Cd v ||u||
w = 0.0
∂_t ρ = 0
∂_t ρθ = F₃ = -Ch ρ ||u|| (T_sfc - ρθ / ρ)
∂_t u = F₁ = -Cd u ||u||
∂_t v = F₂ = -Cd v ||u||
w = 0.0
∂_t ρ = 0
We also use this model to accumulate fluxes it calculates
∂_t F_accum = -(F₁, F₂, F₃)
=#
function ∑tendencies_atm!(dY, Y, (parameters, T_sfc), t)

UnPack.@unpack Cd, f, ν, ug, vg, C_p, MSLP, R_d, R_m, C_v, grav = parameters
(; Cd, f, ν, ug, vg, C_p, MSLP, R_d, R_m, C_v, grav) = parameters

(Yc, Yf, _) = Y.x
(dYc, dYf, dF_sfc) = dY.x
UnPack.@unpack ρ, u, v, ρθ = Yc
UnPack.@unpack w = Yf
(; ρ, u, v, ρθ) = Yc
(; w) = Yf
= dYc.ρ
du = dYc.u
dv = dYc.v
Expand All @@ -50,7 +50,7 @@ function ∑tendencies_atm!(dY, Y, (parameters, T_sfc), t)
θ_1 = parent(If(ρθ))[1] / parent(If(ρ))[1]
u_wind = sqrt(u_1^2 + v_1^2)

# surface flux calculations
# surface flux calculations
F_sfc = -calculate_sfc_fluxes_energy(DryBulkFormulaWithRadiation(), parameters, T_sfc[1], θ_1, u_1, v_1, ρ_1, t) # W / m2
dY.x[3] .= -F_sfc[1]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

function ∑tendencies_atm!(dY, Y, (parameters, T_sfc), t)
# Heat diffusion:
# ∂_t ρ = ∇ (μ ∇ ρ - w ρ)
# ∂_t ρθ = ∇ (μ ∇ ρθ - w ρθ)
# ∂_t w = ∇ (μ ∇ w - w w)
# ∂_t ρ = ∇ (μ ∇ ρ - w ρ)
# ∂_t ρθ = ∇ (μ ∇ ρθ - w ρθ)
# ∂_t w = ∇ (μ ∇ w - w w)

# where
# ∂_t T = n \cdot F at z = zmin_atm
Expand All @@ -27,12 +27,12 @@ function ∑tendencies_atm!(dY, Y, (parameters, T_sfc), t)
# @. du.x[1] = gradf2c( μ * gradc2f(T))
# du.x[2] .= - F_sfc[1]

UnPack.@unpack Cd, f, ν, ug, vg, C_p, MSLP, R_d, R_m, C_v, grav = parameters
(; Cd, f, ν, ug, vg, C_p, MSLP, R_d, R_m, C_v, grav) = parameters

(Yc, Yf, F_sfc) = Y.x
(dYc, dYf, dF_sfc) = dY.x
UnPack.@unpack ρ, u, v, ρθ = Yc
UnPack.@unpack w = Yf
(; ρ, u, v, ρθ) = Yc
(; w) = Yf
= dYc.ρ
du = dYc.u
dv = dYc.v
Expand Down
4 changes: 2 additions & 2 deletions experiments/ClimaCore/tc2_ekman-column-with-slab/run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Base: show_supertypes
# add https://github.com/CliMA/ClimaAtmos.jl/#main

# import required modules
import ClimaCore.Geometry, LinearAlgebra, UnPack
import ClimaCore.Geometry, LinearAlgebra
import ClimaCore: Fields, Domains, Topologies, Meshes, DataLayouts, Operators, Geometry, Spaces

using ClimaAtmos
Expand Down Expand Up @@ -105,7 +105,7 @@ face_space_atm = Spaces.FaceFiniteDifferenceSpace(center_space_atm)
# Set up inital conditions
########
function init_centers(zc, parameters)
UnPack.@unpack T_surf, T_min_ref, grav, C_p, MSLP, R_d = parameters
(; T_surf, T_min_ref, grav, C_p, MSLP, R_d) = parameters

# temperature
Γ = grav / C_p
Expand Down
48 changes: 24 additions & 24 deletions experiments/ClimaCore/tc3_atm-ocn-lnd/atmos_rhs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@

#=
Ekman column:
∂_t ρ = ∇ (μ ∇ ρ - w ρ)
∂_t ρ = ∇ (μ ∇ ρ - w ρ)
∂_t ρθ = ∇ (μ ∇ ρθ - w ρθ)
∂_t u = ∇ (μ ∇ u - w u) + (v - v_g)
∂_t v = ∇ (μ ∇ v - w v) - (u - u_g)
∂_t w = ∇ (μ ∇ w - w w) - g - c_p θ ∂_z Π
∂_t v = ∇ (μ ∇ v - w v) - (u - u_g)
∂_t w = ∇ (μ ∇ w - w w) - g - c_p θ ∂_z Π
where
where
Π = (p/p_0)^{R/c_p}
top BCs are insulating and impenetrable:
∂_t T = 0
u = u_g
v = v_g
w = 0.0
∂_t ρ = 0
∂_t T = 0
u = u_g
v = v_g
w = 0.0
∂_t ρ = 0
and bottom BCs use bulk formulae for surface fluxes of heat and momentum:
∂_t ρθ = F₃ = -Ch ρ ||u|| (T_sfc - ρθ / ρ)
∂_t u = F₁ = -Cd u ||u||
∂_t v = F₂ = -Cd v ||u||
w = 0.0
∂_t ρ = 0
∂_t ρθ = F₃ = -Ch ρ ||u|| (T_sfc - ρθ / ρ)
∂_t u = F₁ = -Cd u ||u||
∂_t v = F₂ = -Cd v ||u||
w = 0.0
∂_t ρ = 0
We also use this model to accumulate fluxes it calculates
∂_t F_accum = -(F₁, F₂, F₃)
=#

function ∑tendencies_atm!(dY, Y, (parameters, T_sfc), t)

UnPack.@unpack Ch, Cd, f, ν, ug, vg, C_p, MSLP, R_d, R_m, C_v, grav = parameters
(; Ch, Cd, f, ν, ug, vg, C_p, MSLP, R_d, R_m, C_v, grav) = parameters

#@show(t, Y.x[3])
#@show(t, Y.x[3])
(Yc, Yf, F_sfc) = Y.x
(dYc, dYf, dF_sfc) = dY.x

UnPack.@unpack ρ, u, v, ρθ = Yc
UnPack.@unpack w = Yf
(; ρ, u, v, ρθ) = Yc
(; w) = Yf
= dYc.ρ
du = dYc.u
dv = dYc.v
Expand All @@ -52,7 +52,7 @@ function ∑tendencies_atm!(dY, Y, (parameters, T_sfc), t)
ρθ_1 = parent(ρθ)[1]
u_wind = sqrt(u_1^2 + v_1^2)

# surface flux calculations
# surface flux calculations
surface_flux_ρθ =
-calculate_sfc_fluxes_energy(
DryBulkFormulaWithRadiation(),
Expand All @@ -69,15 +69,15 @@ function ∑tendencies_atm!(dY, Y, (parameters, T_sfc), t)

# accumulate in the required right units
@inbounds begin
dY.x[3][1] = -ρ_1 * surface_flux_u #
dY.x[3][2] = -ρ_1 * surface_flux_v #
dY.x[3][1] = -ρ_1 * surface_flux_u #
dY.x[3][2] = -ρ_1 * surface_flux_v #
dY.x[3][3] = -C_p * surface_flux_ρθ # W / m^2
end

# @inbounds begin
# dY.x[3][1] = - 10.0
# dY.x[3][2] = - 1.0
# dY.x[3][3] = - 1.0
# dY.x[3][1] = - 10.0
# dY.x[3][2] = - 1.0
# dY.x[3][3] = - 1.0
# end

# Density tendency (located at cell centers)
Expand Down
5 changes: 2 additions & 3 deletions experiments/ClimaCore/tc3_atm-ocn-lnd/atmos_simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ using ClimaAtmos.Interface: PeriodicRectangle, BarotropicFluidModel
using ClimaCore: Fields, Domains, Topologies, Meshes, Spaces

using IntervalSets
using UnPack
using OrdinaryDiffEq: SSPRK33
using OrdinaryDiffEq: ODEProblem, solve, SSPRK33
using Logging: global_logger
Expand Down Expand Up @@ -55,7 +54,7 @@ parameters = (
τ_d = 10, # idealized daily cycle period [s]

# surface fluxes
λ = FT(0.01),#FT(1e-5) # coupling transfer coefficient for LinearRelaxation() SurfaceFluxType
λ = FT(0.01),#FT(1e-5) # coupling transfer coefficient for LinearRelaxation() SurfaceFluxType
)

function atmos_simulation(
Expand All @@ -82,7 +81,7 @@ function atmos_simulation(

""" Initialize fields located at cell centers in the vertical. """
function init_centers(zc, parameters)
UnPack.@unpack grav, C_p, MSLP, R_d = parameters
(; grav, C_p, MSLP, R_d) = parameters

# temperature
Γ = grav / C_p
Expand Down
Loading

0 comments on commit cbd85a0

Please sign in to comment.