# AIBECS.jl for modeling marine biogeochemical tracers

**URL:** https://discourse.julialang.org/t/aibecs-jl-for-modeling-marine-biogeochemical-tracers/27295
**Category:** Package Announcements
**Tags:** package, announcement
**Created:** [August 8, 2019, 5:17am UTC](https://discourse.julialang.org/t/aibecs-jl-for-modeling-marine-biogeochemical-tracers/27295 "2019-08-08T05:17:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![briochemc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/briochemc/32/4209_2.png) [@briochemc](https://discourse.julialang.org/u/briochemc)
#### Post date: [August 8, 2019, 5:17am UTC](https://discourse.julialang.org/t/aibecs-jl-for-modeling-marine-biogeochemical-tracers/27295/1 "2019-08-08T05:17:36Z")

</div>

Dear Julians,

I would like to present [AIBECS.jl](https://github.com/briochemc/AIBECS.jl).

 ![](https://global.discourse-cdn.com/julialang/original/3X/f/2/f262bad1a0f5dccad2ca3d360082275f479953d9.png)

I am making this announcement in the hopes to get people to try the AIBECS. Better would be to get some Julian-expert feedback… And even better would be some direct contributions! (issues and PRs welcome of course!)

In short, the AIBECS (for Algebraic Implicit Biogeochemical Elemental Cycling System) allows you to create and run simulations of marine tracers in a just a few lines of code. An AIBECS user just needs to

1. supply functions to specify the local sources and sinks
2. chose one of the available (steady-state) ocean circulations
3. optionally: define a vertical transport if one of the tracers sinks towards the ocean floor (e.g., particulate organic matter)

The AIBECS is still work in progress but it has usable [documentation](https://briochemc.github.io/AIBECS.jl/latest/) and associated Jupyter notebooks (thanks to [Documenter.jl](https://github.com/JuliaDocs/Documenter.jl) and [Literate.jl](https://github.com/fredrikekre/Literate.jl)), so I encourage you to try those if you feel like you want to run a quick marine tracer simulation, as you do.

The AIBECS uses a number of cool packages, including

- [Unitful.jl](https://github.com/PainterQubits/Unitful.jl) and [UnitfulAstro.jl](https://github.com/JuliaAstro/UnitfulAstro.jl) for, well, units
- [DataDeps.jl](https://github.com/oxinabox/DataDeps.jl) for downloading data dependencies, e.g., the grid and arrays for the available ocean circulations, which are stored using [BSON.jl](https://github.com/MikeInnes/BSON.jl) and  
my [OceanGrids.jl](https://github.com/briochemc/OceanGrids.jl) .
- [DualNumbers.jl](https://github.com/JuliaDiff/DualNumbers.jl) and [HyperdualNumbers.jl](https://github.com/JuliaDiff/HyperDualNumbers.jl), as well as my [DualMatrixTools](https://github.com/briochemc/DualMatrixTools.jl) and [HyperDualMatrixTools](https://github.com/briochemc/HyperDualMatrixTools.jl) packages for solving dual- and hyperdual-valued linear systems (and sparse ones)
- [DataFrames.jl](https://github.com/JuliaData/DataFrames.jl), [Flatten.jl](https://github.com/rafaqz/Flatten.jl) and [FieldMetadata.jl](https://github.com/rafaqz/FieldMetadata.jl) for model parameters
- [DiffEqBase.jl](https://github.com/JuliaDiffEq/DiffEqBase.jl) for the `SteadyStateProblem` type and `solve` function.

The AIBECS uses its own root-finding quasi-Newton iterative solver (basically translated to Julia from C.T.Kelley’s MATLAB `nsold.m` code with a few AIBECS-taylored additions), which maybe could make its way to NLSolvers or DifferentialEquaiton (or something else) at some point.

I’ll stop here for the announcement because I don’t want this to be too long, but I hope it piqued your interest, especially if you’re into oceanography! 🙂

Of course if you are not into oceanography but you have ideas of how to improve things like the API or the performance, that would be amazing, too! So please don’t hesitate to tell me how wrong my code is 😅

Cheers!

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [August 8, 2019, 8:10am UTC](https://discourse.julialang.org/t/aibecs-jl-for-modeling-marine-biogeochemical-tracers/27295/2 "2019-08-08T08:10:04Z")

</div>

> [@briochemc](#):
>
> The AIBECS uses its own root-finding quasi-Newton iterative solver (basically translated to Julia from C.T.Kelley’s MATLAB `nsold.m` code with a few AIBECS-taylored additions), which maybe could make its way to NLSolvers or DifferentialEquaiton (or something else) at some point.

I would definitely like to see that upstreamed for standard SteadyStateProblem usage. We could do a lot more with that package.

---

<div class="post-metadata">

### Author: ![briochemc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/briochemc/32/4209_2.png) [@briochemc](https://discourse.julialang.org/u/briochemc)
#### Post date: [August 14, 2019, 2:46am UTC](https://discourse.julialang.org/t/aibecs-jl-for-modeling-marine-biogeochemical-tracers/27295/3 "2019-08-14T02:46:36Z")

</div>

@ChrisRackauckas Just to be sure I understand correctly, you are suggesting that the `nsold.m` equivalent should go in NLsolve.jl so that then `SteadyStateProblem`s would be able to solved by calling the solver directly from NLsolve?

Other thing I wanted to talk about: I would love to make the AIBECS more of a DSL, maybe using something in the vein of [ModelingToolkit.jl](https://github.com/JuliaDiffEq/ModelingToolkit.jl). I wrote some preliminary notes in [this issue](https://github.com/briochemc/AIBECS.jl/issues/18). Would you care to have a quick look?

I think this might require some work but it would allow for a better interface for users, and it would probably also allow me to optimize some of the code, e.g., the DSL could generate more efficient in-place functions. I would love to chat about all this more with you 🙂

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [August 15, 2019, 3:08am UTC](https://discourse.julialang.org/t/aibecs-jl-for-modeling-marine-biogeochemical-tracers/27295/4 "2019-08-15T03:08:33Z")

</div>

> [@briochemc](#):
>
> @ChrisRackauckas Just to be sure I understand correctly, you are suggesting that the `nsold.m` equivalent should go in NLsolve.jl so that then `SteadyStateProblem` s would be able to solved by calling the solver directly from NLsolve?

Well it looks like you implemented a new algorithm for SteadyStateProblem, It would be cool to have CTKAlg join the club, or at least be sufficiently well-documented as an external solver for other people to use.
