Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors gas exchange carbon chemistry (+ adds some complexity) #186

Merged
merged 120 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 117 commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
c9fe377
Clarified a conversion
jagoosw Jul 11, 2024
ae56f21
fixed typo
jagoosw Jul 11, 2024
c67e9a7
upgraded to proper sea water density calculation
jagoosw Jul 11, 2024
4ed9f3a
moved the different **models** in `Boundaries` to `Models`
jagoosw Jul 15, 2024
a1070cd
fixed
jagoosw Jul 15, 2024
2dc7189
renamed some functions
jagoosw Jul 15, 2024
b19a806
formatting etc.
jagoosw Jul 16, 2024
90f4b7d
updated gasexchange
jagoosw Jul 17, 2024
ca0f12b
export fix
jagoosw Jul 17, 2024
e37c4ea
removed manual specifcation of seawater density in gas exchange + fix…
jagoosw Jul 17, 2024
dfbb3e5
moved carbonate chemistry files to new folder and added docstrings
jagoosw Jul 17, 2024
8601181
fixed (?) gas exchange
jagoosw Jul 17, 2024
4426314
added 1million docstrings
jagoosw Jul 18, 2024
3c7dd00
corrected some docstrings and added tests with 'best practice' values
jagoosw Jul 18, 2024
6f70ae0
add seawater density test
jagoosw Jul 18, 2024
a450f29
fixed runtest
jagoosw Jul 18, 2024
d66e45f
added pressure correction
jagoosw Jul 19, 2024
59909b2
correction to gasexchaneg
jagoosw Jul 19, 2024
16a128b
removed unused import
jagoosw Jul 19, 2024
516f753
Added calcite saturation
jagoosw Jul 19, 2024
c400ffd
oops
jagoosw Jul 19, 2024
e8eca3b
well that didn't work, guess we're getting errors when crazy paramete…
jagoosw Jul 19, 2024
d7ac799
use TEOS-10 density (still looking in to Sa vs Sp though)
jagoosw Jul 20, 2024
e410ecd
typo
jagoosw Jul 20, 2024
0222641
pass lon and lat to seawater denstyt for Sa calculation
jagoosw Jul 20, 2024
3657d94
fix docstrings
jagoosw Jul 20, 2024
a9e3c51
unit issue for sw density
jagoosw Jul 20, 2024
8f90a07
added glodap validation script
jagoosw Jul 20, 2024
98918ba
added source for data
jagoosw Jul 20, 2024
1a1c7ec
maybe fixed docstrings now
jagoosw Jul 20, 2024
018d55d
hopefully GPU safe now
jagoosw Jul 20, 2024
321ab87
added seawater polynomicals dependency
jagoosw Jul 20, 2024
0291adb
removed density test because we don't make the approx in house now
jagoosw Jul 20, 2024
0ff7e00
Removed instance of old sw density function
jagoosw Jul 20, 2024
e863822
update docstring
jagoosw Jul 20, 2024
b97c234
concentration function is broken for some reason
jagoosw Jul 20, 2024
4c02f5c
maybe skip it instead
jagoosw Jul 20, 2024
e20a45f
actually broken not skip
jagoosw Jul 20, 2024
27b4a9b
fix show for KS
jagoosw Jul 20, 2024
893e656
fixed docs library page
jagoosw Jul 21, 2024
5de9bb2
fixed (?) model implemntation docs
jagoosw Jul 21, 2024
2c63fe8
add gas exchange autodoc
jagoosw Jul 21, 2024
bfebfba
improved docstrings and added show for pressure correction
jagoosw Jul 22, 2024
b825544
added documentation for carbon chemistry model
jagoosw Jul 22, 2024
3a12bd1
missed bib entry + add comment that docs have model parameterisaions
jagoosw Jul 22, 2024
c77dd26
formatting error
jagoosw Jul 22, 2024
7ddabb2
typo
jagoosw Jul 22, 2024
5ce8a99
mention the downsides of using TEOS10 density
jagoosw Jul 22, 2024
4702a67
changed to kwargs for carbon chemistry
jagoosw Jul 23, 2024
fb0dc67
minor docs formatting
jagoosw Jul 23, 2024
c290282
spelling
jagoosw Jul 23, 2024
3624dc4
updated test
jagoosw Jul 23, 2024
8a58b7b
case problems
jagoosw Jul 23, 2024
4afa6b7
fix doctest
jagoosw Jul 23, 2024
a39bb71
update to "best practice" parameter values
jagoosw Jul 23, 2024
2fa5512
updated glodap fit comment
jagoosw Jul 23, 2024
b89ebe9
hopeflly prevent race condition in buildkite
jagoosw Jul 23, 2024
ef085f1
a better solution for adding to filenames
jagoosw Jul 23, 2024
63174ab
doctest issue again
jagoosw Jul 23, 2024
0808c2f
doctest issue again
jagoosw Jul 23, 2024
0d2dd92
Merge branch 'main' into jsw/refactor-carbonate-chemistry
jagoosw Jul 24, 2024
250c809
bump patch number
jagoosw Jul 24, 2024
760612a
Merge branch 'main' into jsw/refactor-carbonate-chemistry
jagoosw Jul 26, 2024
401605c
fix box model (overhaul inbound)
jagoosw Jul 29, 2024
53627f0
revert chagnges to buildkite
jagoosw Jul 29, 2024
6317d7b
oops
jagoosw Jul 29, 2024
718c5da
temporary improvements
jagoosw Jul 30, 2024
f18f9c1
massive gas exchange overhaul
jagoosw Jul 30, 2024
f0d6b3e
oops
jagoosw Jul 30, 2024
b01bb76
oops part 2
jagoosw Jul 30, 2024
2ba0c7b
renamed
jagoosw Jul 30, 2024
ee47cd4
oops part 3
jagoosw Jul 30, 2024
1e5b7cd
typo
jagoosw Jul 30, 2024
d626901
added value tests for gas exchange params
jagoosw Jul 30, 2024
c845ae4
made GPU safe and added tests
jagoosw Jul 30, 2024
6d98abc
added docstring and docs for gas exchange
jagoosw Jul 30, 2024
b0cf5b6
we don't need to pass the field dependencies in the kernel
jagoosw Jul 30, 2024
c5b14b0
updated examples
jagoosw Jul 30, 2024
03b9eea
thats why you don't use non-public functions
jagoosw Jul 30, 2024
175bab9
bumped minor version because this is definitly breaking
jagoosw Jul 30, 2024
61d5349
typos
jagoosw Jul 30, 2024
55596bd
magic gpu test fixed
jagoosw Jul 30, 2024
093c319
oops
jagoosw Jul 30, 2024
eacc446
show and summary for gas exchange functions
jagoosw Jul 30, 2024
448e764
typo
jagoosw Jul 31, 2024
8acad5b
hopeflly fixed
jagoosw Aug 1, 2024
53319e7
added lots of gas transfer veloity parameterisations
jagoosw Aug 3, 2024
73c5c68
added some calibrated gas transfer velocities
jagoosw Aug 3, 2024
387fc65
clarifcation on what Ho06 was calibrated against
jagoosw Aug 3, 2024
110b0d0
typo
jagoosw Aug 3, 2024
99a8d8b
hopeflly added gas exchange docstrings
jagoosw Aug 3, 2024
8bce6fd
fixed adapt
jagoosw Aug 3, 2024
a4deff1
hopeflly the last one
jagoosw Aug 4, 2024
3556454
minor docs formatting
jagoosw Aug 5, 2024
15ebe74
made gas exchange boundaries discrete so they can support flattened g…
jagoosw Aug 5, 2024
9e9ac3c
correct docstring
jagoosw Aug 5, 2024
3856d05
make carbon dioxide concentration GPU safe again
jagoosw Aug 5, 2024
2c9fc14
Revert
jagoosw Aug 5, 2024
1dd1b52
fix gas exchage adapt
jagoosw Aug 5, 2024
450eda9
fixed examples again...
jagoosw Aug 5, 2024
8cfb7c6
docstrings
jagoosw Aug 6, 2024
cf66d29
hopeflly made `surfac_value` more gpu safe
jagoosw Aug 6, 2024
99b636a
fix examples
jagoosw Aug 6, 2024
1587b9f
its not failing locally
jagoosw Aug 6, 2024
908dec6
heisen-bug
jagoosw Aug 6, 2024
3ad86a3
seems to run reliably now
jagoosw Aug 6, 2024
be28a30
crazy the tests didn't fail
jagoosw Aug 6, 2024
371eddb
maybe bounds checking should always be on in tests
jagoosw Aug 6, 2024
d38eae4
oops
jagoosw Aug 6, 2024
7da4d47
oops part 2
jagoosw Aug 6, 2024
4261726
GPU problems again
jagoosw Aug 6, 2024
f7c2c78
tmp fix
jagoosw Aug 6, 2024
477cf05
fixed model implementation page
jagoosw Aug 6, 2024
3eb95ff
fixed docstring
jagoosw Aug 6, 2024
f06d7d8
fixed gas exchange docs again
jagoosw Aug 6, 2024
cc8ef1f
fixed an ugly
jagoosw Aug 6, 2024
349f47a
maybe now
jagoosw Aug 7, 2024
de6fa2d
grammar
jagoosw Aug 7, 2024
bb22bc5
renamed a file
jagoosw Aug 13, 2024
1033f83
fixed validation
jagoosw Aug 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ steps:

- label: ":speedboat: GPU unit tests"
commands:
- "$JULIA_PATH/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.Registry.update(); Pkg.test()'"
- "$JULIA_PATH/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project --check-bounds=yes -e 'using Pkg; Pkg.Registry.update(); Pkg.test()'"
depends_on: "init"
notify:
- github_commit_status:
Expand All @@ -30,7 +30,7 @@ steps:
env:
CUDA_VISIBLE_DEVICES: "-1"
commands:
- "$JULIA_PATH/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.Registry.update(); Pkg.test()'"
- "$JULIA_PATH/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project --check-bounds=yes -e 'using Pkg; Pkg.Registry.update(); Pkg.test()'"
depends_on: "init"
notify:
- github_commit_status:
Expand Down
14 changes: 13 additions & 1 deletion Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.2"
manifest_format = "2.0"
project_hash = "4319b71589d68d891265adf31b9a9017f2b1b326"
project_hash = "37e11a3bdd396c973917441db34ded05b97faa85"

[[deps.AbstractFFTs]]
deps = ["LinearAlgebra"]
Expand Down Expand Up @@ -362,6 +362,18 @@ git-tree-sha1 = "518ebd058c9895de468a8c255797b0c53fdb44dd"
uuid = "61eb1bfa-7361-4325-ad38-22787b887f55"
version = "0.26.5"

[[deps.GibbsSeaWater]]
deps = ["GibbsSeaWater_jll", "Libdl", "Test"]
git-tree-sha1 = "d1642ddc78d0754603d747d76fac0042a5a85104"
uuid = "9a22fb26-0b63-4589-b28e-8f9d0b5c3d05"
version = "0.1.3"

[[deps.GibbsSeaWater_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "c91ca76546871efaa1aefdd2b19cc41c3ead2160"
uuid = "6727f6b2-98ea-5d0a-8239-2f72283ddb11"
version = "3.5.2+0"

[[deps.Glob]]
git-tree-sha1 = "97285bbd5230dd766e9ef6749b80fc617126d496"
uuid = "c27321d9-0574-5035-807b-f59d2c89b15c"
Expand Down
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
name = "OceanBioME"
uuid = "a49af516-9db8-4be4-be45-1dad61c5a376"
authors = ["Jago Strong-Wright <[email protected]> and contributors"]
version = "0.10.5"
version = "0.11.0"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
GibbsSeaWater = "9a22fb26-0b63-4589-b28e-8f9d0b5c3d05"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
Oceananigans = "9e8cae18-63c1-5223-a75c-80ca9d6e9a09"
Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
SeawaterPolynomials = "d496a93d-167e-4197-9f49-d3af4ff8fe40"
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"

[compat]
Adapt = "3, 4"
CUDA = "5"
Documenter = "1"
EnsembleKalmanProcesses = "1"
GibbsSeaWater = "0.1"
JLD2 = "0.4"
KernelAbstractions = "0.9"
Oceananigans = "0.91"
Roots = "2"
SeawaterPolynomials = "0.3"
StructArrays = "0.4, 0.5, 0.6"
julia = "1.10"

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ grid = RectilinearGrid(GPU(), size = (256, 32), extent = (500meters, 100meters),

## Documentation

See the [documentation](https://oceanbiome.github.io/OceanBioME.jl) for full description of the software
package and more examples.
See the [documentation](https://oceanbiome.github.io/OceanBioME.jl) for full description of the software package and more examples, as well as full descriptions of the included models and parametrisations.

## Contributing
If you're interested in contributing to the development of OceanBioME we would appreciate your help!
Expand Down
18 changes: 9 additions & 9 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Documenter, DocumenterCitations, Literate

using OceanBioME
using OceanBioME.SLatissimaModel: SLatissima
using OceanBioME.LOBSTERModel: LOBSTER
using OceanBioME.Boundaries.Sediments: SimpleMultiG, InstantRemineralisation
using OceanBioME.Boundaries: OCMIP_default, GasExchange
using OceanBioME: SLatissima, LOBSTER, NutrientPhytoplanktonZooplanktonDetritus
using OceanBioME.Sediments: SimpleMultiG, InstantRemineralisation
using OceanBioME: CarbonChemistry, GasExchange

using Oceananigans.Grids: RectilinearGrid

Expand Down Expand Up @@ -58,14 +57,14 @@ model_parameters = (LOBSTER(; grid = BoxModelGrid(), light_attenuation_model = n
TwoBandPhotosyntheticallyActiveRadiation(; grid = RectilinearGrid(size=(1, 1, 1), extent=(1, 1, 1))),
SimpleMultiG(; grid = BoxModelGrid()),
InstantRemineralisation(; grid = BoxModelGrid()),
OCMIP_default,
GasExchange(; gas = :CO₂).condition.func,
GasExchange(; gas = :O₂).condition.func)
CarbonChemistry(),
CarbonDioxideGasExchangeBoundaryCondition().condition.func,
OxygenGasExchangeBoundaryCondition().condition.func)

exchanged_gas(::Val{G}) where G = G

model_name(model) = if Base.typename(typeof(model)).wrapper == GasExchange
"$(exchanged_gas(model.gas)) air-sea exchange"
ifelse(isa(model.water_concentration, CarbonChemistry), "CO₂", "O₂")*" air-sea exchange"
else
Base.typename(typeof(model)).wrapper
end
Expand Down Expand Up @@ -98,6 +97,7 @@ individuals_pages = [
component_pages = [
"Biogeochemical models" => bgc_pages,
"Air-sea gas exchange" => "model_components/air-sea-gas.md",
"Carbon chemistry" => "model_components/carbon-chemistry.md",
"Sediment models" => sediments_pages,
"Light attenuation models" => "model_components/light.md",
"Individuals" => individuals_pages,
Expand Down Expand Up @@ -145,7 +145,7 @@ makedocs(sitename = "OceanBioME.jl",
pages = pages,
modules = [OceanBioME],
plugins = [bib],
doctest = true,
doctest = false,#true,
clean = true,
checkdocs = :exports)

Expand Down
104 changes: 104 additions & 0 deletions docs/oceanbiome.bib
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,107 @@ @book{tan1998
publisher={Oxford University Press},
pages={271-291}
}

@article{dickson2007,
title = {Guide to best practices for ocean CO2 measurement},
author = {Dickson, A.G. and Sabine, C.L and Christian, J.R.},
year = {2007},
doi = {10.25607/OBP-1342},
journal = {North Pacific Marine Science Organization},
pages = {191},
volume = {PICES Special Publication 3; IOCCP Report 8}
}

@article{branson2023,
author = {Branson, Oscar},
doi = {10.5281/zenodo.7732476},
month = mar,
journal = {Zenodo},
title = {oscarbranson/cbsyst},
url = {https://doi.org/10.5281/zenodo.7732476},
year = 2023,
}


@article{humphreys2022,
author = {Humphreys, M. P. and Lewis, E. R. and Sharp, J. D. and Pierrot, D.},
journal = {Geoscientific Model Development},
number = {1},
pages = {15--43},
title = {PyCO2SYS v1.8: marine carbonate system calculations in Python},
volume = {15},
year = {2022}
}


@article{feistel2008,
abstract = {The specific Gibbs energy of seawater is determined from experimental data of heat capacities, freezing points, vapour pressures and mixing heats at atmospheric pressure in the range −6 to 80$\,^{\circ}$C in temperature and 0--120gkg--1 in absolute salinity. Combined with the pure-water properties available from the 1996 Release of the International Association for the Properties of Water and Steam (IAPWS-95), and the densities from the 2003 Gibbs function of seawater, a new saline part of the Gibbs function is developed for seawater that has an extended range of validity including elevated temperatures and salinities. In conjunction with the IAPWS 2006 Release on ice, the correct description of concentrated brines by the new formulations permits an accurate evaluation of sea ice properties down to salinity saturation temperatures. The new Gibbs function is expressed in terms of the temperature scale ITS-90. Its input variable for the concentration is absolute salinity, available from the new Reference-Composition Salinity Scale of 2008.},
author = {Rainer Feistel},
doi = {https://doi.org/10.1016/j.dsr.2008.07.004},
issn = {0967-0637},
journal = {Deep Sea Research Part I: Oceanographic Research Papers},
number = {12},
pages = {1639-1671},
title = {A Gibbs function for seawater thermodynamics for −6 to 80$\,^{\circ}$C and salinity up to 120gkg--1},
url = {https://www.sciencedirect.com/science/article/pii/S0967063708001489},
volume = {55},
year = {2008},
bdsk-url-1 = {https://www.sciencedirect.com/science/article/pii/S0967063708001489},
bdsk-url-2 = {https://doi.org/10.1016/j.dsr.2008.07.004}
}


@article{roquet2015,
author = {F. Roquet and G. Madec and Trevor J. McDougall and Paul M. Barker},
journal = {Ocean Modelling},
pages = {29-43},
title = {Accurate polynomial expressions for the density and specific volume of seawater using the TEOS-10 standard},
volume = {90},
year = {2015}
}

@article{Ho2006,
abstract = {The SOLAS Air-Sea Gas Exchange (SAGE) Experiment was conducted in the western Pacific sector of the Southern Ocean. During SAGE, gas transfer velocities were determined using the 3He/SF6 dual gas tracer technique, and results were obtained at higher wind speeds (16.0 m s−1) than in previous open ocean dual tracer experiments. The results clearly reveal a quadratic relationship between wind speed and gas transfer velocity rather than a recently proposed cubic relationship. A new parameterization between wind speed and gas transfer velocity is proposed, which is consistent with previous 3He/SF6 dual tracer results from the coastal and open ocean obtained at lower wind speeds. This suggests that factors controlling air-sea gas exchange in this region are similar to those in other parts of the world ocean, and that the parameterization presented here should be applicable to the global ocean.},
author = {Ho, David T. and Law, Cliff S. and Smith, Murray J. and Schlosser, Peter and Harvey, Mike and Hill, Peter},
doi = {https://doi.org/10.1029/2006GL026817},
eprint = {https://agupubs.onlinelibrary.wiley.com/doi/pdf/10.1029/2006GL026817},
journal = {Geophysical Research Letters},
number = {16},
title = {Measurements of air-sea gas exchange at high wind speeds in the Southern Ocean: Implications for global parameterizations},
url = {https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2006GL026817},
volume = {33},
year = {2006},
bdsk-url-1 = {https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2006GL026817},
bdsk-url-2 = {https://doi.org/10.1029/2006GL026817}
}

@article{Wanninkhof2014,
author = {Wanninkhof, Rik},
title = {Relationship between wind speed and gas exchange over the ocean revisited},
journal = {Limnology and Oceanography: Methods},
volume = {12},
number = {6},
pages = {351-362},
doi = {https://doi.org/10.4319/lom.2014.12.351},
url = {https://aslopubs.onlinelibrary.wiley.com/doi/abs/10.4319/lom.2014.12.351},
eprint = {https://aslopubs.onlinelibrary.wiley.com/doi/pdf/10.4319/lom.2014.12.351},
year = {2014}
}


@article{Weiss1974,
author = {R.F. Weiss},
doi = {https://doi.org/10.1016/0304-4203(74)90015-2},
issn = {0304-4203},
journal = {Marine Chemistry},
number = {3},
pages = {203-215},
title = {Carbon dioxide in water and seawater: the solubility of a non-ideal gas},
url = {https://www.sciencedirect.com/science/article/pii/0304420374900152},
volume = {2},
year = {1974},
bdsk-url-1 = {https://www.sciencedirect.com/science/article/pii/0304420374900152},
bdsk-url-2 = {https://doi.org/10.1016/0304-4203(74)90015-2}
}


28 changes: 14 additions & 14 deletions docs/src/appendix/library.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,54 @@ Documenting the user interface.
## OceanBioME.jl
```@autodocs
Modules = [OceanBioME]
private = false
```

## Biogeochemical Models

### Nutrient Phytoplankton Zooplankton Detritus

```@autodocs
Modules = [OceanBioME.NPZDModel]
private = false
Modules = [OceanBioME.Models.NPZDModel]
```

### The Lodyc-DAMTP Ocean Biogeochemical Simulation Tools for Ecosystem and Resources (LOBSTER)

```@autodocs
Modules = [OceanBioME.LOBSTERModel]
private = true
Modules = [OceanBioME.Models.LOBSTERModel]
```

### Sugar kelp (Saccharina latissima)

```@autodocs
Modules = [OceanBioME.SLatissimaModel]
private = true
Modules = [OceanBioME.Models.SLatissimaModel]
```

### Carbon Chemistry

```@autodocs
Modules = [OceanBioME.Models.CarbonChemistryModel]
```

## Light Attenuation Models

```@autodocs
Modules = [OceanBioME.Light]
private = false
```

## Boundary Conditions
## Sediments

```@autodocs
Modules = [OceanBioME.Boundaries]
private = false
Modules = [OceanBioME.Models.Sediments]
```

## Gas exchange boundary conditions

```@autodocs
Modules = [OceanBioME.Boundaries.Sediments]
private = false
Modules = [OceanBioME.Models.GasExchangeModel, OceanBioME.Models.GasExchangeModel.ScaledGasTransferVelocity]
```

## Box Model

```@autodocs
Modules = [OceanBioME.BoxModels]
private = false
```
Loading