Skip to content

Generalises gas transfer velocity and allows surface_value to interpolate FieldTimeSeries#370

Open
jagoosw wants to merge 11 commits into
mainfrom
jsw/generalise-gas-transfer
Open

Generalises gas transfer velocity and allows surface_value to interpolate FieldTimeSeries#370
jagoosw wants to merge 11 commits into
mainfrom
jsw/generalise-gas-transfer

Conversation

@jagoosw
Copy link
Copy Markdown
Collaborator

@jagoosw jagoosw commented May 8, 2026

Closes #368 @lgloege

I'm a little concerned about how deep the parameter space is for these boundary conditions and how that might effect peformance.

@jagoosw jagoosw marked this pull request as ready for review May 11, 2026 17:19

This comment was marked as resolved.

@jagoosw
Copy link
Copy Markdown
Collaborator Author

jagoosw commented May 13, 2026

@lgloege As an example of how this could now be generalised, if you wanted a transfer velocity dependant on wind speed, temperature, and significant wave height, $k(u, T, H)$, you could make a struct like:

struct WindWaveTempTransferVelocity{FT, WS, WH}
    a_constant :: FT
    wind_speed :: WS
   wave_height :: WH
end

and define a function:

using OceanBioME.Models.GasExchangeModel: surface_value

@inline function (k::WindWaveTempTransferVelocity)(i, j, grid, clock, model_fields)
    T = @inbounds model_fields.T[i, j, grid.Nz]
    u = surface_value(k.wind_speed, i, j, grid, clock, model_fields)
    H = surface_value(k.wave_height, i, j, grid, clock, model_fields)

    return k.a_constant * u * H
end

Then you can make an instance like:

k0 = WindWaveTempTransferVelocity(0.1, wind_speed, wave_height)

where wind_speed and wave_height are number, arrays (in space not time), fields, or field time series (on the same grid as the model or not). When you actually make the boundary condition you do need to wrap this in the Schmidt number scaling:

k = SchmidtScaledTransferVelocity(
         schmidt_number = CarbonDioxidePolynomialSchmidtNumber(), 
         solubility = MolPerKgPerAtmToMMolPerCubicMPerMicroAtm(carbon_chemistry.solubility, carbon_chemistry.density_function),
         base_transfer_velocity = k0
     )

which goes in the boundary condition constructor:

CarbonDioxideGasExchangeBoundaryCondition(; transfer_velocity = k)

This isn't the best interface but we can work on that.

Perhaps there is a way NumericalEarths atmosphere might carry around the waves (or someone might write a wave model in Julia that could be coupled), but for now it seems most straight forward to directly put the wave info in this way.

@jagoosw jagoosw changed the title Generalises gas transfer velocity Generalises gas transfer velocity and allows surface_value to interpolate FieldTimeSeries May 13, 2026
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.

Generalise gas transfer velocity

1 participant