Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ PythonCall = "0.9.28"
Reactant = "0.2.235"
Scratch = "1"
SeawaterPolynomials = "0.3.5"
SpeedyWeather = "0.17.4"
SpeedyWeather = "0.19"
StaticArrays = "1"
Statistics = "<0.0.1, 1"
Thermodynamics = "0.15.3"
Expand Down
24 changes: 13 additions & 11 deletions ext/NumericalEarthSpeedyWeatherExt/speedy_atmosphere_simulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ end

# The height of near-surface variables used in the turbulent flux solver
function surface_layer_height(s::SpeedySimulation)
T = s.model.atmosphere.temp_ref
T = s.model.atmosphere.reference_temperature
g = s.model.planet.gravity
Φ = s.model.geopotential.Δp_geopot_full
return Φ[end] * T / g
Expand All @@ -43,14 +43,14 @@ thermodynamics_parameters(atmos::SpeedySimulation) =
NumericalEarth.Atmospheres.AtmosphereThermodynamicsParameters(Float32)

function initialize_atmospheric_state!(simulation::SpeedyWeather.Simulation)
progn, diagn, model = SpeedyWeather.unpack(simulation)
(; time) = progn.clock # current time
vars, model = SpeedyWeather.unpack(simulation)
(; time) = vars.prognostic.clock # current time

# set the tendencies back to zero for accumulation
fill!(diagn.tendencies, 0, typeof(model))
SpeedyWeather.reset_tendencies!(vars)

if model.physics
SpeedyWeather.parameterization_tendencies!(diagn, progn, time, model)
if !model.dynamics_only
SpeedyWeather.parameterization_tendencies!(vars, model)
end

return nothing
Expand All @@ -72,11 +72,13 @@ function atmosphere_simulation(spectral_grid::SpeedyWeather.SpectralGrid; output
surface_heat_flux = SpeedyWeather.SurfaceHeatFlux(ocean=ocean_heat_flux, land=land_heat_flux)

# The atmospheric model
atmosphere_model = SpeedyWeather.PrimitiveWetModel(spectral_grid;
surface_heat_flux,
surface_humidity_flux,
ocean = nothing,
sea_ice = nothing) # This is provided by ClimaSeaIce
atmosphere_model = SpeedyWeather.PrimitiveWetModel(
spectral_grid;
surface_heat_flux,
surface_humidity_flux,
ocean = SpeedyWeather.PrescribedOcean(),
sea_ice = nothing # provided by ClimaSeaIce
)

# Construct the simulation
atmosphere = SpeedyWeather.initialize!(atmosphere_model)
Expand Down
28 changes: 14 additions & 14 deletions ext/NumericalEarthSpeedyWeatherExt/speedy_weather_exchanger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ function interpolate_state!(exchanger, exchange_grid, atmos::SpeedySimulation, c
exchange_state = exchanger.state
surface_layer = atmos.model.spectral_grid.nlayers

ua = RingGrids.field_view(atmos.diagnostic_variables.grid.u_grid, :, surface_layer).data
va = RingGrids.field_view(atmos.diagnostic_variables.grid.v_grid, :, surface_layer).data
Ta = RingGrids.field_view(atmos.diagnostic_variables.grid.temp_grid, :, surface_layer).data
qa = RingGrids.field_view(atmos.diagnostic_variables.grid.humid_grid, :, surface_layer).data
pa = exp.(atmos.diagnostic_variables.grid.pres_grid.data)
ℐꜜˢʷ = atmos.diagnostic_variables.physics.surface_shortwave_down.data
ℐꜜˡʷ = atmos.diagnostic_variables.physics.surface_longwave_down.data
Jᶜ = atmos.diagnostic_variables.physics.total_precipitation_rate.data
ua = RingGrids.field_view(atmos.variables.grid.u, :, surface_layer).data
va = RingGrids.field_view(atmos.variables.grid.v, :, surface_layer).data
Ta = RingGrids.field_view(atmos.variables.grid.temperature, :, surface_layer).data
qa = RingGrids.field_view(atmos.variables.grid.humidity, :, surface_layer).data
pa = exp.(atmos.variables.grid.pressure.data)
ℐꜜˢʷ = atmos.variables.parameterizations.surface_shortwave_down.data
ℐꜜˡʷ = atmos.variables.parameterizations.surface_longwave_down.data
Jᶜ = atmos.variables.parameterizations.rain_rate.data .+ atmos.variables.parameterizations.snow_rate.data

regrid!(exchange_state.u, ua)
regrid!(exchange_state.v, va)
Expand Down Expand Up @@ -111,9 +111,9 @@ function update_net_fluxes!(coupled_model, atmos::SpeedySimulation)
ℵ = interior(sea_ice_concentration(coupled_model.sea_ice))

# All the location of these fluxes will change
𝒬ᵀ_speedy = atmos.prognostic_variables.ocean.sensible_heat_flux.data
Jᵛ_speedy = atmos.prognostic_variables.ocean.surface_humidity_flux.data
sst = atmos.prognostic_variables.ocean.sea_surface_temperature.data
𝒬ᵀ_speedy = atmos.variables.parameterizations.ocean.sensible_heat_flux.data
Jᵛ_speedy = atmos.variables.parameterizations.ocean.surface_humidity_flux.data
sst = atmos.variables.prognostic.ocean.sea_surface_temperature.data
To = coupled_model.interfaces.atmosphere_ocean_interface.temperature
Ti = coupled_model.interfaces.atmosphere_sea_ice_interface.temperature

Expand All @@ -135,9 +135,9 @@ function update_net_fluxes!(coupled_model::SpeedyNoSeaIceEarthSystemModel, atmos
Jᵛᵃᵒ = ao_fluxes.water_vapor

# All the location of these fluxes will change
𝒬ᵀ_speedy = atmos.prognostic_variables.ocean.sensible_heat_flux.data
Jᵛ_speedy = atmos.prognostic_variables.ocean.surface_humidity_flux.data
sst = atmos.prognostic_variables.ocean.sea_surface_temperature.data
𝒬ᵀ_speedy = atmos.variables.parameterizations.ocean.sensible_heat_flux.data
Jᵛ_speedy = atmos.variables.parameterizations.ocean.surface_humidity_flux.data
sst = atmos.variables.prognostic.ocean.sea_surface_temperature.data
To = coupled_model.interfaces.atmosphere_ocean_interface.temperature

# TODO: Figure out how we are going to deal with upwelling radiation
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ PythonCall = "0.9.28"
Reactant = "0.2.235"
Scratch = "1"
SeawaterPolynomials = "0.3.5"
SpeedyWeather = "0.17.4"
SpeedyWeather = "0.19"
Statistics = "<0.0.1, 1"
Test = "<0.0.1, 1"
Thermodynamics = "0.15.3"
Expand Down
4 changes: 2 additions & 2 deletions test/test_speedy_coupling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ atmos = NumericalEarth.atmosphere_simulation(spectral_grid)
radiation = Radiation(ocean_emissivity=0.0, sea_ice_emissivity=0.0)
earth_model = EarthSystemModel(atmos, ocean, default_sea_ice(); radiation)

Qca = atmos.prognostic_variables.ocean.sensible_heat_flux.data
Mva = atmos.prognostic_variables.ocean.surface_humidity_flux.data
Qca = atmos.variables.parameterizations.ocean.sensible_heat_flux.data
Mva = atmos.variables.parameterizations.ocean.surface_humidity_flux.data

@test !(all(Qca .== 0.0))
@test !(all(Mva .== 0.0))
Loading