Skip to content

Extend budget diagnostics to salinity and mass - #474

Open
taimoorsohail wants to merge 119 commits into
mainfrom
ts/extend-BudgetComputation-to-salinity-and-mass
Open

Extend budget diagnostics to salinity and mass#474
taimoorsohail wants to merge 119 commits into
mainfrom
ts/extend-BudgetComputation-to-salinity-and-mass

Conversation

@taimoorsohail

@taimoorsohail taimoorsohail commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • extend BudgetComputation from temperature to salinity-content and mass-content budgets
  • expose quantity-specific public term names for heat, salinity, and mass
  • include explicit freshwater volume fluxes in freshwater-content diagnostics
  • use salt-content fluxes for salinity budgets and admitted freshwater mass for mutable-grid mass budgets
  • preserve the fixed-grid virtual-salinity-flux formulation and component consistency
  • add focused fixed-grid and mutable-grid diagnostic coverage

Why

The freshwater-volume coupling was moved into interfaces.net_fluxes.ocean.η, while the freshwater-content diagnostic still inferred freshwater solely from the stored salinity flux. Because the stored salinity flux now contains only salt exchange, the explicit volumetric contribution was omitted. This also made the new salinity and mass budget surface terms use the wrong physical quantities.

User impact

net_ocean_freshwater_flux now reports an outward-positive freshwater-content flux that includes surface volume changes. Salinity budgets use the applied salt-content surface flux, while mass budgets include only mass actually admitted through a mutable surface. Fixed-volume grids retain their virtual-salinity-flux treatment. The quantity-specific BudgetComputation property names remain in place.

Validation

  • git diff --check
  • focused fixed-grid and mutable-grid assertions added to test/test_diagnostics_2.jl
  • local Julia tests were not run, following the repository instruction to use GitHub CI for test execution

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.47059% with 60 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Diagnostics/budget_diagnostic.jl 76.47% 32 Missing ⚠️
src/Diagnostics/interface_fluxes.jl 72.91% 13 Missing ⚠️
src/Diagnostics/meridional_heat_transport.jl 75.00% 12 Missing ⚠️
...lEarthSpeedyWeatherExt/speedy_weather_exchanger.jl 82.35% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@taimoorsohail
taimoorsohail marked this pull request as ready for review July 27, 2026 06:05
Comment on lines +32 to +41
struct BudgetComputation{H, P, T, S, R, A, B}
tracer_name :: Symbol
heat_content :: H
previous_heat_content :: P
tendency :: T
surface_flux :: S
radiative_heat_flux :: R
applied_radiative_heat_flux :: A
residual :: B
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can avoid the getfield overload by defining

Suggested change
struct BudgetComputation{H, P, T, S, R, A, B}
tracer_name :: Symbol
heat_content :: H
previous_heat_content :: P
tendency :: T
surface_flux :: S
radiative_heat_flux :: R
applied_radiative_heat_flux :: A
residual :: B
end
struct BudgetComputation{H, P, T, S, R, A, B}
tracer_name :: Symbol
content :: H
previous_content :: P
tendency :: T
fluxes :: S
residual :: B
end

where for :temperature we allocate

fluxes = (; surface_flux, radiative_flux, applied_radiative_heat_flux)

while for the others

fluxes = (; surface_flux)

Comment on lines +135 to +138
ocean = esm.ocean
model = ocean.model
ρᵒᶜ = reference_density(ocean)
return Field(Integral(0 * model.tracers.T + ρᵒᶜ, dims=3))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ocean = esm.ocean
model = ocean.model
ρᵒᶜ = reference_density(ocean)
return Field(Integral(0 * model.tracers.T + ρᵒᶜ, dims=3))
grid = esm.ocean.grid
ρᵒᶜ = set!(CenterField(grid), reference_density(esm.ocean))
return Field(Integral(ρᵒᶜ, dims=3))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants