Extend budget diagnostics to salinity and mass - #474
Open
taimoorsohail wants to merge 119 commits into
Open
Conversation
Co-authored-by: Gregory L. Wagner <wagner.greg@gmail.com>
…ricalEarth.jl into ts-codex/compute-MHT
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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 |
Member
There was a problem hiding this comment.
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)) |
Member
There was a problem hiding this comment.
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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BudgetComputationfrom temperature to salinity-content and mass-content budgetsWhy
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_fluxnow 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-specificBudgetComputationproperty names remain in place.Validation
git diff --checktest/test_diagnostics_2.jl