Closed ali-ramadhan closed 1 month ago
Hi @ali-ramadhan, thank you for raising this issue!
I've had a look and am pretty sure this is because the grid is flat, so when Oceananigans calls getbc
the arguments are x, t, DIC, Alk, T, S
, but when I wrote this it would have passed x, 0, t, DIC, Alk, T, S
, so its not computing the pCO2 in the water correctly first. I.e. its using the second method not the first one here:
I tried running your code with y periodic and it appears to be correct.
Currently, I'm doing a lot of work on the gas exchange model because I've discovered a few issues with how I originally implemented it, and following that PR (#186) it will be more sophisticated and better tested. This situation would also cause an issue with the refactored code so I'll work out how to fix it there.
For now, the best thing is probably to only use 3D grids I think.
Thanks for having a look @jagoosw! Tricky dispatch haha. It does work with a 3D grid and I was able to hack in a boundary condition wrapper for 2D grids.
gas_exchange = GasExchange(;
gas = :CO₂,
air_concentration = pCO₂_atmosphere
)
@inline CO₂_flux(x, t, DIC, Alk, T, S, ge) = ge.condition.func(x, 0, t, DIC, Alk, T, S)
DIC_top_bc = FluxBoundaryCondition(CO₂_flux, field_dependencies = (:DIC, :Alk, :T, :S), parameters = gas_exchange)
Out of curiousity, do you know why it works correctly when average_wind_speed = 0.0
?
Just to chime in --- I recommend using the discrete form in packages that build out functionality for Oceananigans. That should avoid the issues that occur when trying to write generic code for Flat
or 3D grids.
Out of curiousity, do you know why it works correctly when
average_wind_speed = 0.0
?
The flux is like $k(u{wind})(pCO{2, \text{air}} - pCO{2, \text{water}})$ and the common form of $k(u{wind})$ is $k0u{wind}^2(660/Sc)^{1/2}$ so it also goes to zero when the wind speed is zero. The new implementation allows the actual wind speed to be put in, as well as having different transfer velocities since a few have a constant factor was well.
Thank you everyone for the super nice package (especially @jagoosw)! I know everything is still in development with lots of changes happening.
I've been playing around with LOBSTER (well, really just the carbonate chemistry component) and the air-sea gas exchange model. I'm just initializing an ocean at equilibrium with constant T, S, DIC, and Alk. I set the atmospheric pCO2 equal to the ocean's pCO2. I expect a surface CO2 flux of zero. I see this but only when
average_wind_speed = 0
.When
average_wind_speed = 10.0
(the default) I believe the flux should still be zero since pCO2 is equal across the air-ocean interface but it's slightly negative after one time step. It's zero at time step 0.Is this behavior expected or am I misunderstanding the gas exchange model?
Thank you!
Here's a minimal working example to showcase what I'm seeing:
Time step 0:
Time step 1:
I'm using Julia 1.10.4 with