Skip to content

Adjust sea ice model constants to align with ClimaSeaIce.jl#main#224

Closed
taimoorsohail wants to merge 8 commits into
mainfrom
ts/align-constants-with-ClimaSeaIce.jl
Closed

Adjust sea ice model constants to align with ClimaSeaIce.jl#main#224
taimoorsohail wants to merge 8 commits into
mainfrom
ts/align-constants-with-ClimaSeaIce.jl

Conversation

@taimoorsohail
Copy link
Copy Markdown
Collaborator

Currently, NumericalEarth.jl#main and ClimaSeaIce.jl#main cannot be run together due to a mismatch in constant naming and function definitions in src/EarthSystemModels/InterfaceComputations.

I have attempted to change the relevant files so that OceanSeaIceModel() again works with the #main branches of both projects. This was the minimal fix I could find to ensure the code ran -- not necessarily an exhaustive fix for existing bugs in the #main branches of either repo.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 0% with 21 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/SeaIces/sea_ice_simulation.jl 0.00% 20 Missing ⚠️
src/EarthSystemModels/earth_system_model.jl 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@simone-silvestri
Copy link
Copy Markdown
Member

This should be fixed in PR #164, can you review that one? Should be rather easy a part the change to the temperature interface computation which is reformulated a bit, the rest should be trivial (split freshwater fluxes in rain and snow and accumulate snow in the sea ice fluxes).

@taimoorsohail
Copy link
Copy Markdown
Collaborator Author

taimoorsohail commented May 12, 2026

Thanks @simone-silvestri -- I had a look and it looks good. However, I think there are some specific changes here that are not in #164 :

  1. Swap OceanSeaIceModel() input order so it is (ocean, sea_ice; kwargs...) as before
  2. Adjust the ThreeEquationState default in ComponentInterfaces to be sea_ice_ocean_heat_flux = ThreeEquationHeatFlux(eltype(exchange_grid)),
  3. Add a guard so that ocean.model is not accidentally passed to sea_ice specific components:
sea_ice_model(sea_ice::Simulation) = sea_ice_model(sea_ice.model)
sea_ice_model(model::SeaIceModel) = model

sea_ice_model(model) =
    throw(ArgumentError("Expected a ClimaSeaIce.SeaIceModel or sea-ice Simulation, got $(typeof(model))"))

(3) is more descriptive in case users accidentally swap the order of ocean and sea_ice in OceanSeaIceModel

@simone-silvestri
Copy link
Copy Markdown
Member

Ok, I ll merge that one then we can also add what implemented in this PR

atmosphere_ocean_fluxes = SimilarityTheoryFluxes(eltype(exchange_grid)),
atmosphere_sea_ice_fluxes = atmosphere_sea_ice_similarity_theory(eltype(exchange_grid)),
sea_ice_ocean_heat_flux = ThreeEquationHeatFlux(sea_ice),
sea_ice_ocean_heat_flux = ThreeEquationHeatFlux(eltype(exchange_grid)),
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.

are you sure about this change? ThreeEquationHeatFlux is specialized for a ClimaSeaIce simulation to include the internal heat flux in the balance of fluxes required by the interfacial temperature. If we use eltype(exchange_grid) we loose the internal conductive flux

Comment thread src/SeaIces/sea_ice_simulation.jl Outdated
Comment on lines +154 to +155
heat_capacity(sea_ice) = sea_ice_model(sea_ice).phase_transitions.heat_capacity
reference_density(sea_ice) = sea_ice_model(sea_ice).phase_transitions.density
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 instead of having a sea_ice_model guard we can specialize these functions for

heat_capacity(sea_ice::Simulation{<:SeaIceModel})

which is the more "julia" way


conductive_flux = sea_ice.model.ice_thermodynamics.internal_heat_flux
ice_temperature = sea_ice.model.ice_thermodynamics.top_surface_temperature
model = sea_ice_model(sea_ice)
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.

same as above, we probably should just specialize ThreeEquationHeatFlux to dispatch on

ThreeEquationHeatFlux(sea_ice::Simulation{<:SeaIceModel}, ....)

@taimoorsohail
Copy link
Copy Markdown
Collaborator Author

Thanks @simone-silvestri -- I think you are right about the ThreeEquation fix here. I will make the changes now.

@taimoorsohail
Copy link
Copy Markdown
Collaborator Author

Actually @simone-silvestri I am closing this PR now. I think the only meaningful addition was the more verbose sea ice model error, and that can be added upstream to warn the user that the input order in OceanSeaIceModel is wrong. It doesn't need to happen in the InterfaceComputations. The choice of doing OceanSeaIceModel(sea_ice, ocean; kwargs...) vs OceanSeaIceModel(ocean, sea_ice; kwargs...) is probably better discussed in an issue anyway.

@taimoorsohail
Copy link
Copy Markdown
Collaborator Author

Closed in favour of #230

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.

2 participants