Skip to content

Automates DIC boundary condition setup for multiple #375

Open
jagoosw wants to merge 1 commit into
mainfrom
jsw/automate-dic-bc-setup
Open

Automates DIC boundary condition setup for multiple #375
jagoosw wants to merge 1 commit into
mainfrom
jsw/automate-dic-bc-setup

Conversation

@jagoosw
Copy link
Copy Markdown
Collaborator

@jagoosw jagoosw commented May 18, 2026

This PR adds a possible way to streamline DIC boundary condition setup when there are multiple realisations of the carbon chemistry, e.g. the example changes:

CO₂_flux1 = 
    CarbonDioxideGasExchangeBoundaryCondition(; 
        wind_speed,
        water_concentration = CarbonDioxideConcentration(; DIC = :DIC1,
                                                           Alk = :Alk1)
    )
CO₂_flux2 = 
    CarbonDioxideGasExchangeBoundaryCondition(; 
        wind_speed,
        water_concentration = CarbonDioxideConcentration(; DIC = :DIC2,
                                                           Alk = :Alk2)
    )

wind = FluxBoundaryCondition(-ρₐ/ρₒ * Cᴰ * wind_speed^2)

boundary_conditions = (; DIC1 = FieldBoundaryConditions(top = CO₂_flux1),
                         DIC2 = FieldBoundaryConditions(top = CO₂_flux2),
                         u    = FieldBoundaryConditions(top = wind))

to

CO₂_fluxes = CarbonDioxideGasExchangeBoundaryConditions(2; wind_speed)

wind = FluxBoundaryCondition(-ρₐ/ρₒ * Cᴰ * wind_speed^2)

boundary_conditions = (; DIC1 = FieldBoundaryConditions(top = CO₂_fluxes.DIC1),
                         DIC2 = FieldBoundaryConditions(top = CO₂_fluxes.DIC2),
                         u    = FieldBoundaryConditions(top = wind))

This is still a bit cumbersome and it would be nice to just do:

CO₂_flux = CarbonDioxideGasExchangeBoundaryCondition(; wind_speed)

wind = FluxBoundaryCondition(-ρₐ/ρₒ * Cᴰ * wind_speed^2)

boundary_conditions = (; DIC1 = FieldBoundaryConditions(top = CO₂_flux),
                         DIC2 = FieldBoundaryConditions(top = CO₂_flux),
                         u    = FieldBoundaryConditions(top = wind))

but currently regularize_boundary_condition(condition...) does not get the field name. I'll keep on thinking of a solution, or if that would be the preferred interface propose the change in Oceananigans.

@johnryantaylor

@jagoosw
Copy link
Copy Markdown
Collaborator Author

jagoosw commented May 18, 2026

This also retains the current interface CarbonDioxideGasExchangeBoundaryCondition(args...; kwargs...) which falls back to CarbonDioxideGasExchangeBoundaryCondition(1, args...; kwargs...) and uses DIC and Alk

@jagoosw jagoosw marked this pull request as ready for review May 20, 2026 12:07
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.

1 participant