esbmtk 0.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. esbmtk-0.0.0/.gitattributes +1 -0
  2. esbmtk-0.0.0/.gitignore +69 -0
  3. esbmtk-0.0.0/CODE_OF_CONDUCT.md +76 -0
  4. esbmtk-0.0.0/Documentation/ESBMTK-Tutorial.org +227 -0
  5. esbmtk-0.0.0/Documentation/ESBMTK-Tutorial.pdf +0 -0
  6. esbmtk-0.0.0/Documentation/ltximg/org-ltximg_90283c65ec1ef8e75e917e41a14d78bfa1796652.png +0 -0
  7. esbmtk-0.0.0/Documentation/ltximg/org-ltximg_98938d40f30c69013acd798599585db91f6da0cc.png +0 -0
  8. esbmtk-0.0.0/Documentation/mpc.png +0 -0
  9. esbmtk-0.0.0/Documentation/po4_1.py +94 -0
  10. esbmtk-0.0.0/LICENSE.md +157 -0
  11. esbmtk-0.0.0/LICENSE.txt +165 -0
  12. esbmtk-0.0.0/MANIFEST.in +1 -0
  13. esbmtk-0.0.0/PKG-INFO +23 -0
  14. esbmtk-0.0.0/README.md +105 -0
  15. esbmtk-0.0.0/README.org +137 -0
  16. esbmtk-0.0.0/Release_History.md +98 -0
  17. esbmtk-0.0.0/Release_History.org +252 -0
  18. esbmtk-0.0.0/docs/.directory +5 -0
  19. esbmtk-0.0.0/esbmtk/Hypsometric_Curve_05m.csv +1801 -0
  20. esbmtk-0.0.0/esbmtk/TAGS +352 -0
  21. esbmtk-0.0.0/esbmtk/__init__.py +28 -0
  22. esbmtk-0.0.0/esbmtk/carbonate_chemistry.py +669 -0
  23. esbmtk-0.0.0/esbmtk/connections.py +1509 -0
  24. esbmtk-0.0.0/esbmtk/esbmtk.py +2299 -0
  25. esbmtk-0.0.0/esbmtk/esbmtk_base.py +380 -0
  26. esbmtk-0.0.0/esbmtk/experimental_reactions/__init__.py +3 -0
  27. esbmtk-0.0.0/esbmtk/experimental_reactions/add_functions.py +285 -0
  28. esbmtk-0.0.0/esbmtk/experimental_reactions/bio_geochemical_reactions.py +509 -0
  29. esbmtk-0.0.0/esbmtk/experimental_reactions/init_functions.py +330 -0
  30. esbmtk-0.0.0/esbmtk/extended_classes.py +2326 -0
  31. esbmtk-0.0.0/esbmtk/obipy-resources/5e3c2614852594e60bd3dc4782f5b5acd8f5b93b/d2c8c40b6f4f738a784ee3dba7798761d7f2bdd7.png +0 -0
  32. esbmtk-0.0.0/esbmtk/ode_backend.py +977 -0
  33. esbmtk-0.0.0/esbmtk/ode_backend_2.py +221 -0
  34. esbmtk-0.0.0/esbmtk/post_processing.py +108 -0
  35. esbmtk-0.0.0/esbmtk/processes.py +1329 -0
  36. esbmtk-0.0.0/esbmtk/reactions/__init__.py +3 -0
  37. esbmtk-0.0.0/esbmtk/reactions/add_functions.py +285 -0
  38. esbmtk-0.0.0/esbmtk/reactions/bio_geochemical_reactions.py +509 -0
  39. esbmtk-0.0.0/esbmtk/reactions/init_functions.py +331 -0
  40. esbmtk-0.0.0/esbmtk/sealevel.py +313 -0
  41. esbmtk-0.0.0/esbmtk/seawater.py +593 -0
  42. esbmtk-0.0.0/esbmtk/solver.py +245 -0
  43. esbmtk-0.0.0/esbmtk/species_definitions.py +234 -0
  44. esbmtk-0.0.0/esbmtk/utility_functions.py +1306 -0
  45. esbmtk-0.0.0/esbmtk.egg-info/PKG-INFO +23 -0
  46. esbmtk-0.0.0/esbmtk.egg-info/SOURCES.txt +51 -0
  47. esbmtk-0.0.0/esbmtk.egg-info/dependency_links.txt +1 -0
  48. esbmtk-0.0.0/esbmtk.egg-info/requires.txt +5 -0
  49. esbmtk-0.0.0/esbmtk.egg-info/top_level.txt +1 -0
  50. esbmtk-0.0.0/pyproject.toml +10 -0
  51. esbmtk-0.0.0/requirements.txt +8 -0
  52. esbmtk-0.0.0/setup.cfg +39 -0
@@ -0,0 +1 @@
1
+ ./esbmtk/_version.py export-subst
@@ -0,0 +1,69 @@
1
+ # gitignore file for ESS345 Computational Geology.
2
+
3
+ # The goal is to only push files which make sense to the students
4
+ # so we exclude everything but the Jupyter Notebooks files
5
+ # and image files
6
+
7
+ # exclude everything
8
+
9
+ # but add these 2 files
10
+ # none at the moment
11
+
12
+ # but allow the following directories
13
+
14
+ # within this directory, allow for the following file types
15
+ !LICENSE
16
+ !README.md
17
+ !*.png
18
+ !*.jpg
19
+ !*.ipynb
20
+ !*.py
21
+ !*.xlsx
22
+ !*.csv
23
+ !*.txt
24
+ !*.md
25
+ !*.org
26
+ !*.pdf
27
+ !*.html
28
+ !*
29
+
30
+ # last but not least, make sure the above rules are applied
31
+ # to all subdirs as well
32
+ !*/
33
+ /build/
34
+ /.directory
35
+ /.mypy_cache/
36
+ /Documentation/.directory
37
+ /Documentation/*.tex
38
+ *.log
39
+ *.tex
40
+ /esbmtk/*.py#
41
+ ./directory
42
+ /esbmtk/__pycache__/
43
+ /auto/
44
+ /dist/
45
+ /tests/__pycache__/
46
+ examples/
47
+ tests/
48
+ /package.sh
49
+ /esbmtk/.directory
50
+ /esbmtk.egg-info/PKG-INFO
51
+ /tests/.coverage
52
+ /tests/TAGS
53
+ /tests/foo.py
54
+ /tests/.coverage
55
+ /esbmtk/.esbmtk.py.~undo-tree~
56
+ *.~undo-tree~
57
+ Notes.org
58
+ /docs/ltximg/
59
+ docs/_minted-*
60
+
61
+ /notes.org
62
+
63
+ /.sourcery.yaml
64
+ /Documentation/_minted-*
65
+ /#%2Aediff-merge%2A#a5u92t#
66
+ /#Release_History.org#
67
+ /#README.org#
68
+ /esbmtk/esbmtk.egg-info/
69
+ __pycache__
@@ -0,0 +1,76 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at uli.wortmann@utoronto.ca. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ [homepage]: https://www.contributor-covenant.org
74
+
75
+ For answers to common questions about this code of conduct, see
76
+ https://www.contributor-covenant.org/faq
@@ -0,0 +1,227 @@
1
+ #+TITLE: ESBMTK Tutorial
2
+ #+AUTHOR:Ulrich G Wortmann
3
+ #+OX-IPYNB-LANGUAGE: ipython
4
+ #+BIND: org-export-use-babel nil
5
+ #+STARTUP: showall
6
+ #+STARTUP: latexpreview
7
+ #+OPTIONS: todo:nil tasks:nil tags:nil toc:nil
8
+ #+PROPERTY: header-args :eval never-export
9
+ #+EXCLUDE_TAGS: noexport
10
+ #+LATEX_HEADER: \usepackage{breakurl}
11
+ #+LATEX_HEADER: \usepackage{newuli}
12
+ #+LATEX_HEADER: \usepackage{uli-german-paragraphs}
13
+ \maketitle
14
+
15
+ #+TOC: headlines
16
+
17
+ * A simple example
18
+
19
+ A simple model of the marine P-cycle would consider the delivery of P from weathering, the burial of P in the sediments, the thermohaline transport of dissolved PO_4 as well as the export of P in form of sinking organic matter (POP). The concentration in the respective surface an deep water boxes is then sum of the respective fluxes (see Fig.\space{}ref:pcycle). The model parameters are taken from Glover 2011, Modeling Methods in the Marine Sciences.
20
+ #+attr_org: :width 300
21
+ #+attr_latex: :width 0.5\textwidth
22
+ #+name: pcycle
23
+ #+caption: A two-box model of the marine P-cycle. F_w = weathering
24
+ #+caption: F_u = upwelling, F_d = downwelling, F_{POP} = particulate
25
+ #+caption: organic phosphor, F_b = burial.
26
+ [[/home/uliw/user/python-scripts/esbmtk/Documentation/mpc.png]]
27
+
28
+ If we define equations that control the export of particulate P (F_{POP}) as a fraction of the upwelling P (F_u), and the burial of P (F_b) as fraction of (F_{POP}), we express this model as coupled ordinary differential equations (ODE, or initial value problem):
29
+
30
+ \begin{equation}\label{}
31
+ \frac{d[PO_{4}]_{S}}{dt} = \frac{F_w + F_u - F_d - F_{POP}}{V_S}
32
+ \end{equation}
33
+
34
+ and for the deep ocean,
35
+
36
+ \begin{equation}\label{}
37
+ \frac{d[PO_{4}]_{D}}{dt}= \frac{F_{POP} + F_d - F_u - F_b}{V_D}
38
+ \end{equation}
39
+
40
+
41
+ which is easily encoded as a python function
42
+ #+BEGIN_SRC ipython
43
+ def dCdt(t, C_0, V, F_w, thx):
44
+ """Calculate the change in concentration as
45
+ a function of time. After Glover 2011, Modeling
46
+ Methods for Marine Science.
47
+
48
+ :param C: list of initial concentrations mol/m*3
49
+ :param time: array of time points
50
+ :params V: lits of surface and deep ocean volume [m^3]
51
+ :param F_w: River (weathering) flux of PO4 mol/s
52
+ :param thx: thermohaline circulation in m*3/s
53
+ :returns dCdt: list of concentration changes mol/s
54
+ """
55
+
56
+ C_S = C_0[0] # surface
57
+ C_D = C_0[1] # deep
58
+ F_d = C_S * thx # downwelling
59
+ F_u = C_D * thx # upwelling
60
+ tau = 100 # residence time of P in surface waters [yrs]
61
+ F_POP = C_S * V[0] / tau # export production
62
+ F_b = F_POP / 100 # burial
63
+
64
+ dCdt[0] = (F_w + F_u - F_d - F_POP) / V[0]
65
+ dCdt[1] = (F_d + F_POP - F_u - F_b) / V[1]
66
+
67
+ return dCdt
68
+ #+END_SRC
69
+
70
+ ** Implementing the P-cycle with ESBMTK
71
+ While ESBMTK provides abstractions to efficiently define complex models, the following section will use the basic ESBMTK classes to define the above model. While quite verbose, it demonstrates the design philosophy behind ESBMTK. More complex approaches are described further down.
72
+
73
+ Currently ESBMTK is only available via pip install as
74
+ #+BEGIN_SRC ipython
75
+ import sys
76
+ !{sys.executable} -m pip install esbmtk
77
+ #+END_SRC
78
+
79
+
80
+
81
+ *** Defining the model geometry and initial conditions
82
+ In a first step one needs to define a model object that describes fundamental model parameters. The following code first loads the various esbmtk classes that will help with model construction, and then defines the model object. Note that units are automatically translated into model units. While convenient, there are some import caveats:
83
+ Internally, the model uses 'year' as the time unit, mol as the mass unit, and liter as the volume unit. You can change this by setting these values to e.g., 'mol' and 'kg', however, some functions assume that their input values are in 'mol/l' rather than mol/m**3 or 'kg/s'. Ideally this would be caught by ESBMTK, but at present, this not guaranteed. So your mileage may vary, if you fiddle with these settings. Note: Using mol/kg e.g., for seawater, will be discussed below.
84
+ #+BEGIN_SRC ipython :tangle po4_1.py
85
+ # import classes from the esbmtk library
86
+ from esbmtk import (
87
+ Model, # the model class
88
+ Reservoir, # the reservoir class
89
+ Connection, # the connection class
90
+ Source, # the source class
91
+ Sink, # sink class
92
+ Q_, # Quantity operator
93
+ )
94
+
95
+ # define the basic model parameters
96
+ M = Model(
97
+ name="M", # model name
98
+ stop="3 Myr", # end time of model
99
+ timestep="1 kyr", # upper limit of time step
100
+ element=["Phosphor"], # list of element definitions
101
+ )
102
+ #+END_SRC
103
+
104
+ Next, we need to declare some boundary conditions. Most ESBMTK classes will be able to accept input in the form of strings that also contain units (e.g., ="30 Gmol/a"= ). Internally these strings are parsed and converted into the model base units. This works most of the time, but not always. In the below example, we the residence time \tau. This variable is then used as input to calculate the scale for the primary production as =M.sb.volume / tau= which must fail since =M.sb.volume= is a numeric value and =tau= is a string.
105
+ #+BEGIN_SRC ipython
106
+ # try the following
107
+ tau = "100 years"
108
+ tau * 12
109
+ #+END_SRC
110
+
111
+ To avoid this we have to manually parse the string into a quantity. This is done with the quantity operator =Q_= Note that =Q_= is not part of ESBMTk but imported from the =pint= library.
112
+ #+BEGIN_SRC ipython
113
+ # now try this
114
+ from esbmtk import Q_
115
+ tau = Q_("100 years")
116
+ tau * 12
117
+ #+END_SRC
118
+
119
+ Most ESBMTK classes accept quantities, strings that represent quantities as well as numerical values. Weathering and burial fluxes are often defined in =mol/year=, whereas ocean models use =kg/year=. ESBMTK provides a method (=set_flux()= ) that will automatically convert the input into the correct units. In this example it is not necessary since the flux and the model both use =mol= . It is however good practice to to relay on the automatic conversion. Note that it makes a difference for the mole to kilogram conversion whether ones uses =M.P= or =M.PO4= as the reference species!
120
+ #+BEGIN_SRC ipython :tangle po4_1.py
121
+ # boundary conditions
122
+ F_w = M.set_flux("45 Gmol", "year", M.P) # P @280 ppm (Filipelli 2002)
123
+ tau = Q_("100 year") # PO4 residence time in surface box
124
+ F_b = 0.01 # About 1% of the exported P is buried in the deep ocean
125
+ thc = "20*Sv" # Thermohaline circulation in Sverdrup
126
+ #+END_SRC
127
+
128
+ To set up the model geometry, we first use the =Source= and =Reservoir= classes to create a source for the weathering flux, a sink for the burial flux, and instances of the surface and deep oceans boxes. Since we loaded the element definitions for phosphor in the model definition above, we can directly refer to the "PO4" species in the reservoir definition.
129
+ #+BEGIN_SRC ipython :tangle po4_1.py
130
+ # Source definitions
131
+ Source(
132
+ name="weathering",
133
+ species=M.PO4,
134
+ register=M, # i.e., the instance will be available as M.weathering
135
+ )
136
+ Sink(
137
+ name="burial",
138
+ species=M.PO4,
139
+ register=M, #
140
+ )
141
+
142
+ # reservoir definitions
143
+ Reservoir(
144
+ name="sb", # box name
145
+ species=M.PO4, # species in box
146
+ register=M, # this box will be available as M.sb
147
+ volume="3E16 m**3", # surface box volume
148
+ concentration="0 umol/l", # initial concentration
149
+ )
150
+ Reservoir(
151
+ name="db", # box name
152
+ species=M.PO4, # species in box
153
+ register=M, # this box will be available M.db
154
+ volume="100E16 m**3", # deeb box volume
155
+ concentration="0 umol/l", # initial concentration
156
+ )
157
+ #+END_SRC
158
+
159
+
160
+
161
+ *** Model processes
162
+ For many models, processes can mapped as the transfer of mass from one box to the next. Within the ESBMTK framework this is accomplished through the =Connection= class. To connect the a weathering flux from the source object (M.w) to the surface ocean (M.sb) we declare a connection instance describing this relationship as follows:
163
+ #+BEGIN_SRC ipython :tangle po4_1.py
164
+ Connection(
165
+ source=M.weathering, # source of flux
166
+ sink=M.sb, # target of flux
167
+ rate=F_w, # rate of flux
168
+ id="river", # connection id
169
+ )
170
+ #+END_SRC
171
+ Unless the=register= keyword is given, connections will be automatically registered withe the parent of the source, i.e., the model =M=. Unless explicitly given through the =name= keyword, connection names will be automatically constructed from the names of the source and sink instances. However, it is a good habit to provide the =id= keyword to keep connections separate in cases where two reservoir instances share more than one connection. The list of all connection instances can be obtained from the model object (see below).
172
+
173
+ To map the process of thermohaline circulation, we connect the surface and deep ocean boxes using a connection type that scales the mass transfer as a function of the concentration in a given reservoir (=ctype ="scale_with_concentration"= ) . The concentration data is taken from the reference reservoir which defaults to the source reservoir. As such, in most cases the =ref_reservoirs= keyword can be omitted. The =scale= keyword can be a string, or a numerical value. If its provided as a string ESBMTK will map the value into model units. Note that the connection class does not require the =name= keyword. Rather the name is derived from the source and sink reservoir instances. Since reservoir instances can have more than one connection (i.e., surface to deep via downwelling, and surface to deep via primary production), it is required to set the =id= keyword.
174
+ #+BEGIN_SRC ipython :tangle po4_1.py
175
+ Connection( # thermohaline downwelling
176
+ source=M.sb, # source of flux
177
+ sink=M.db, # target of flux
178
+ ctype="scale_with_concentration",
179
+ scale=thc,
180
+ id="downwelling_PO4",
181
+ # ref_reservoirs=M.sb, defaults to the source instance
182
+ )
183
+ Connection( # thermohaline upwelling
184
+ source=M.db, # source of flux
185
+ sink=M.sb, # target of flux
186
+ ctype="scale_with_concentration",
187
+ scale=thc,
188
+ id="upwelling_PO4",
189
+ )
190
+ #+END_SRC
191
+
192
+ There are several ways to define the biological export production, e.g., as function of the upwelling PO_4, or as function of the residence time of PO_4 in surface ocean. Here we follow Glover (2011), and use the residence time \tau = 100 years.
193
+ #+BEGIN_SRC ipython :tangle po4_1.py
194
+ Connection( #
195
+ source=M.sb, # source of flux
196
+ sink=M.db, # target of flux
197
+ ctype="scale_with_concentration",
198
+ scale=M.sb.volume / tau,
199
+ id="primary_production",
200
+ )
201
+ #+END_SRC
202
+
203
+ We require one more connection to describe the burial of P in the sediment. We describe this flux as a fraction of the primary export productivity. To create the connection we can either recalculate the export productivity, or use the previously calculated flux. We can query the export productivity using the =id_string= of the above connection with the =flux_summary()= method of the model instance:
204
+ #+BEGIN_SRC ipython
205
+ M.flux_summary(filter_by="primary_production", return_list=True)[0]
206
+ #+END_SRC
207
+ The =flux_summary()= method will return a list of matching fluxes but since there is only one match, we can simply use the first result, and use it to define the phosphor burial as a consequence of export production in the following way:
208
+ #+BEGIN_SRC ipython :tangle po4_1.py
209
+ Connection( #
210
+ source=M.db, # source of flux
211
+ sink=M.burial, # target of flux
212
+ ctype="scale_with_flux",
213
+ ref_flux=M.flux_summary(filter_by="primary_production", return_list=True)[0],
214
+ scale=F_b,
215
+ id="burial",
216
+ )
217
+ #+END_SRC
218
+
219
+
220
+ ** Running the model, visualizing and saving the results
221
+
222
+ #+BEGIN_SRC ipython :tangle po4_1.py
223
+ M.run()
224
+ M.plot([M.sb, M.db])
225
+ #+END_SRC
226
+
227
+
Binary file
@@ -0,0 +1,94 @@
1
+ # import classes from the esbmtk library
2
+ from esbmtk import (
3
+ Model, # the model class
4
+ Reservoir, # the reservoir class
5
+ Connection, # the connection class
6
+ Source, # the source class
7
+ Sink, # sink class
8
+ Q_, # Quantity operator
9
+ )
10
+
11
+ # define the basic model parameters
12
+ M = Model(
13
+ name="M", # model name
14
+ stop="3 Myr", # end time of model
15
+ timestep="1 kyr", # upper limit of time step
16
+ element=["Phosphor"], # list of element definitions
17
+ )
18
+
19
+ # boundary conditions
20
+ F_w = M.set_flux("45 Gmol", "year", M.P) # P @280 ppm (Filipelli 2002)
21
+ tau = Q_("100 year") # PO4 residence time in surface box
22
+ F_b = 0.01 # About 1% of the exported P is buried in the deep ocean
23
+ thc = "20*Sv" # Thermohaline circulation in Sverdrup
24
+
25
+ # Source definitions
26
+ Source(
27
+ name="weathering",
28
+ species=M.PO4,
29
+ register=M, # i.e., the instance will be available as M.weathering
30
+ )
31
+ Sink(
32
+ name="burial",
33
+ species=M.PO4,
34
+ register=M, #
35
+ )
36
+
37
+ # reservoir definitions
38
+ Reservoir(
39
+ name="sb", # box name
40
+ species=M.PO4, # species in box
41
+ register=M, # this box will be available as M.sb
42
+ volume="3E16 m**3", # surface box volume
43
+ concentration="0 umol/l", # initial concentration
44
+ )
45
+ Reservoir(
46
+ name="db", # box name
47
+ species=M.PO4, # species in box
48
+ register=M, # this box will be available M.db
49
+ volume="100E16 m**3", # deeb box volume
50
+ concentration="0 umol/l", # initial concentration
51
+ )
52
+
53
+ Connection(
54
+ source=M.weathering, # source of flux
55
+ sink=M.sb, # target of flux
56
+ rate=F_w, # rate of flux
57
+ id="river", # connection id
58
+ )
59
+
60
+ Connection( # thermohaline downwelling
61
+ source=M.sb, # source of flux
62
+ sink=M.db, # target of flux
63
+ ctype="scale_with_concentration",
64
+ scale=thc,
65
+ id="downwelling_PO4",
66
+ # ref_reservoirs=M.sb, defaults to the source instance
67
+ )
68
+ Connection( # thermohaline upwelling
69
+ source=M.db, # source of flux
70
+ sink=M.sb, # target of flux
71
+ ctype="scale_with_concentration",
72
+ scale=thc,
73
+ id="upwelling_PO4",
74
+ )
75
+
76
+ Connection( #
77
+ source=M.sb, # source of flux
78
+ sink=M.db, # target of flux
79
+ ctype="scale_with_concentration",
80
+ scale=M.sb.volume / tau,
81
+ id="primary_production",
82
+ )
83
+
84
+ Connection( #
85
+ source=M.db, # source of flux
86
+ sink=M.burial, # target of flux
87
+ ctype="scale_with_flux",
88
+ ref_flux=M.flux_summary(filter_by="primary_production", return_list=True)[0],
89
+ scale=F_b,
90
+ id="burial",
91
+ )
92
+
93
+ M.run()
94
+ M.plot([M.sb, M.db])
@@ -0,0 +1,157 @@
1
+ # GNU LESSER GENERAL PUBLIC LICENSE
2
+
3
+ Version 3, 29 June 2007
4
+
5
+ Copyright (C) 2007 Free Software Foundation, Inc.
6
+ <https://fsf.org/>
7
+
8
+ Everyone is permitted to copy and distribute verbatim copies of this
9
+ license document, but changing it is not allowed.
10
+
11
+ This version of the GNU Lesser General Public License incorporates the
12
+ terms and conditions of version 3 of the GNU General Public License,
13
+ supplemented by the additional permissions listed below.
14
+
15
+ ## 0. Additional Definitions.
16
+
17
+ As used herein, "this License" refers to version 3 of the GNU Lesser
18
+ General Public License, and the "GNU GPL" refers to version 3 of the
19
+ GNU General Public License.
20
+
21
+ "The Library" refers to a covered work governed by this License, other
22
+ than an Application or a Combined Work as defined below.
23
+
24
+ An "Application" is any work that makes use of an interface provided
25
+ by the Library, but which is not otherwise based on the Library.
26
+ Defining a subclass of a class defined by the Library is deemed a mode
27
+ of using an interface provided by the Library.
28
+
29
+ A "Combined Work" is a work produced by combining or linking an
30
+ Application with the Library. The particular version of the Library
31
+ with which the Combined Work was made is also called the "Linked
32
+ Version".
33
+
34
+ The "Minimal Corresponding Source" for a Combined Work means the
35
+ Corresponding Source for the Combined Work, excluding any source code
36
+ for portions of the Combined Work that, considered in isolation, are
37
+ based on the Application, and not on the Linked Version.
38
+
39
+ The "Corresponding Application Code" for a Combined Work means the
40
+ object code and/or source code for the Application, including any data
41
+ and utility programs needed for reproducing the Combined Work from the
42
+ Application, but excluding the System Libraries of the Combined Work.
43
+
44
+ ## 1. Exception to Section 3 of the GNU GPL.
45
+
46
+ You may convey a covered work under sections 3 and 4 of this License
47
+ without being bound by section 3 of the GNU GPL.
48
+
49
+ ## 2. Conveying Modified Versions.
50
+
51
+ If you modify a copy of the Library, and, in your modifications, a
52
+ facility refers to a function or data to be supplied by an Application
53
+ that uses the facility (other than as an argument passed when the
54
+ facility is invoked), then you may convey a copy of the modified
55
+ version:
56
+
57
+ - a) under this License, provided that you make a good faith effort
58
+ to ensure that, in the event an Application does not supply the
59
+ function or data, the facility still operates, and performs
60
+ whatever part of its purpose remains meaningful, or
61
+ - b) under the GNU GPL, with none of the additional permissions of
62
+ this License applicable to that copy.
63
+
64
+ ## 3. Object Code Incorporating Material from Library Header Files.
65
+
66
+ The object code form of an Application may incorporate material from a
67
+ header file that is part of the Library. You may convey such object
68
+ code under terms of your choice, provided that, if the incorporated
69
+ material is not limited to numerical parameters, data structure
70
+ layouts and accessors, or small macros, inline functions and templates
71
+ (ten or fewer lines in length), you do both of the following:
72
+
73
+ - a) Give prominent notice with each copy of the object code that
74
+ the Library is used in it and that the Library and its use are
75
+ covered by this License.
76
+ - b) Accompany the object code with a copy of the GNU GPL and this
77
+ license document.
78
+
79
+ ## 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that, taken
82
+ together, effectively do not restrict modification of the portions of
83
+ the Library contained in the Combined Work and reverse engineering for
84
+ debugging such modifications, if you also do each of the following:
85
+
86
+ - a) Give prominent notice with each copy of the Combined Work that
87
+ the Library is used in it and that the Library and its use are
88
+ covered by this License.
89
+ - b) Accompany the Combined Work with a copy of the GNU GPL and this
90
+ license document.
91
+ - c) For a Combined Work that displays copyright notices during
92
+ execution, include the copyright notice for the Library among
93
+ these notices, as well as a reference directing the user to the
94
+ copies of the GNU GPL and this license document.
95
+ - d) Do one of the following:
96
+ - 0) Convey the Minimal Corresponding Source under the terms of
97
+ this License, and the Corresponding Application Code in a form
98
+ suitable for, and under terms that permit, the user to
99
+ recombine or relink the Application with a modified version of
100
+ the Linked Version to produce a modified Combined Work, in the
101
+ manner specified by section 6 of the GNU GPL for conveying
102
+ Corresponding Source.
103
+ - 1) Use a suitable shared library mechanism for linking with
104
+ the Library. A suitable mechanism is one that (a) uses at run
105
+ time a copy of the Library already present on the user's
106
+ computer system, and (b) will operate properly with a modified
107
+ version of the Library that is interface-compatible with the
108
+ Linked Version.
109
+ - e) Provide Installation Information, but only if you would
110
+ otherwise be required to provide such information under section 6
111
+ of the GNU GPL, and only to the extent that such information is
112
+ necessary to install and execute a modified version of the
113
+ Combined Work produced by recombining or relinking the Application
114
+ with a modified version of the Linked Version. (If you use option
115
+ 4d0, the Installation Information must accompany the Minimal
116
+ Corresponding Source and Corresponding Application Code. If you
117
+ use option 4d1, you must provide the Installation Information in
118
+ the manner specified by section 6 of the GNU GPL for conveying
119
+ Corresponding Source.)
120
+
121
+ ## 5. Combined Libraries.
122
+
123
+ You may place library facilities that are a work based on the Library
124
+ side by side in a single library together with other library
125
+ facilities that are not Applications and are not covered by this
126
+ License, and convey such a combined library under terms of your
127
+ choice, if you do both of the following:
128
+
129
+ - a) Accompany the combined library with a copy of the same work
130
+ based on the Library, uncombined with any other library
131
+ facilities, conveyed under the terms of this License.
132
+ - b) Give prominent notice with the combined library that part of it
133
+ is a work based on the Library, and explaining where to find the
134
+ accompanying uncombined form of the same work.
135
+
136
+ ## 6. Revised Versions of the GNU Lesser General Public License.
137
+
138
+ The Free Software Foundation may publish revised and/or new versions
139
+ of the GNU Lesser General Public License from time to time. Such new
140
+ versions will be similar in spirit to the present version, but may
141
+ differ in detail to address new problems or concerns.
142
+
143
+ Each version is given a distinguishing version number. If the Library
144
+ as you received it specifies that a certain numbered version of the
145
+ GNU Lesser General Public License "or any later version" applies to
146
+ it, you have the option of following the terms and conditions either
147
+ of that published version or of any later version published by the
148
+ Free Software Foundation. If the Library as you received it does not
149
+ specify a version number of the GNU Lesser General Public License, you
150
+ may choose any version of the GNU Lesser General Public License ever
151
+ published by the Free Software Foundation.
152
+
153
+ If the Library as you received it specifies that a proxy can decide
154
+ whether future versions of the GNU Lesser General Public License shall
155
+ apply, that proxy's public statement of acceptance of any version is
156
+ permanent authorization for you to choose that version for the
157
+ Library.