Skip to content

Commit d08c05e

Browse files
committed
Doc updated
1 parent 9ad9849 commit d08c05e

15 files changed

Lines changed: 422 additions & 120 deletions

doc/build_element.rst

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. TODO
22
.. - review the conde inserted
33
4-
.. note:: Last update 04/05/2021
4+
.. note:: Last update 21/07/2021
55

66
.. .. warning:: This guide is still work in progress. New pages are being written
77
.. and existing ones modified. Once the guide will reach its final
@@ -120,11 +120,11 @@ from the Numba optimization.
120120

121121
The last methods to implement are :code:`_fluxes_function_python` (pure Python)
122122
and :code:`_fluxes_function_numba` (Numba optimized), which calculate the
123-
reservoir fluxes.
123+
reservoir fluxes and their derivatives.
124124

125125
.. literalinclude:: build_element_code.py
126126
:language: python
127-
:lines: 90-124
127+
:lines: 90-132
128128
:linenos:
129129

130130
:code:`_fluxes_function_python` and :code:`_fluxes_function_numba` are both
@@ -142,11 +142,15 @@ The output is a tuple containing three elements:
142142
(e.g. streamflow, :code:`- k * S`);
143143
- lower bound for the search of the state;
144144
- upper bound for the search of the state;
145+
- tuple with the computed values of the derivatives of fluxes w.r.t. the state :code:`S`;
146+
we maintain the convention of positive sign for incoming
147+
fluxes (e.g. derivative of the precipitation, :code:`0`), negative sign for outgoing fluxes
148+
(e.g. derivative of the streamflow, :code:`- k`);
145149

146150
The implementation for the Numba solver differs from the pure Python implementation in two aspects:
147151

148152
- the usage of the Numba decorator that defines the types of input variables
149-
(lines 24-25)
153+
(lines 28-29)
150154
- the method works only for a single time step and not for the vectorized
151155
solution. For the vectorized solution the Python implementation (with Numpy)
152156
is considered sufficient, and hence a Numba implementation is not pursued.
@@ -176,22 +180,22 @@ implement only the methods needed to compute the weight array.
176180

177181
.. literalinclude:: build_element_code.py
178182
:language: python
179-
:lines: 2, 128, 129
183+
:lines: 2, 136, 137
180184
:linenos:
181185

182186
The only method requiring implementation is the private method used to
183187
calculate the :code:`weight` array.
184188

185189
.. literalinclude:: build_element_code.py
186190
:language: python
187-
:lines: 146-160
191+
:lines: 154-168
188192
:linenos:
189193

190194
The method :code:`_build_weight` makes use of a secondary private static method
191195

192196
.. literalinclude:: build_element_code.py
193197
:language: python
194-
:lines: 162-172
198+
:lines: 170-180
195199
:linenos:
196200

197201
This method returns the area :math:`A_i` of the red triangle in the figure,
@@ -228,7 +232,7 @@ the new functionality.
228232

229233
.. literalinclude:: build_element_code.py
230234
:language: python
231-
:lines: 5, 176, 177
235+
:lines: 5, 184, 185
232236
:linenos:
233237

234238
First, we define two private attributes that specify the number of upstream and
@@ -237,15 +241,15 @@ constructing the model structure.
237241

238242
.. literalinclude:: build_element_code.py
239243
:language: python
240-
:lines: 194-195
244+
:lines: 202-203
241245
:linenos:
242246

243247
We then define the method that receives the inputs, and the method that calculates
244248
the outputs.
245249

246250
.. literalinclude:: build_element_code.py
247251
:language: python
248-
:lines: 197, 208-211, 227-233
252+
:lines: 205, 216-219, 235-241
249253
:linenos:
250254

251255
The two methods have the same structure as the ones implemented as part of the earlier

doc/build_element_code.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ def _fluxes_function_python(S, S0, ind, P, k, dt):
106106
- k[ind] * S,
107107
],
108108
0.0,
109-
S0 + P[ind] * dt[ind]
109+
S0 + P[ind] * dt[ind],
110+
[
111+
0.0,
112+
- k[ind]
113+
]
110114
)
111115

112116
@staticmethod
@@ -120,7 +124,11 @@ def _fluxes_function_numba(S, S0, ind, P, k, dt):
120124
- k[ind] * S,
121125
),
122126
0.0,
123-
S0 + P[ind] * dt[ind]
127+
S0 + P[ind] * dt[ind],
128+
(
129+
0.0,
130+
- k[ind]
131+
)
124132
)
125133

126134
# Implement lag function

doc/changelog.rst

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,39 @@
1-
.. note:: Last update 24/05/2021
1+
.. note:: Last update 29/11/2021
22

33
Change log
44
==========
55

6+
Version 1.3.1
7+
-------------
8+
9+
Minor changes
10+
.............
11+
12+
- Added the classifier :code:`Topic :: Scientific/Engineering :: Hydrology`
13+
14+
Version 1.3.0
15+
-------------
16+
17+
Major changes to existing components
18+
....................................
19+
20+
- :code:`ODEsElements` can now return the derivative of the fluxes together with
21+
the fluxes. This enables the usage of numerical solvers that use the
22+
derivatives (e.g., Newton methods).
23+
- Folder structure improved. The numerical approximators and the root finders
24+
have been moved from the folder :code:`implementation/computation` to
25+
:code:`implementation/numerical_approximators` and
26+
:code:`implementation/root_finders`, respectively. Names of the files have
27+
been slightly modified to be coherent with this new folder organization.
28+
29+
New code
30+
........
31+
32+
- Implemented a new numerical approximator implementing Runge Kutta 4
33+
- Implemented a new root finder implementing a Newton-bisection method
34+
- Implemented a new root finder implementing a trivial algorithm to solve
35+
explicit algebraic equations.
36+
637
Version 1.2.1
738
-------------
839

doc/contribute.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. note:: Last update 03/05/2021
1+
.. note:: Last update 22/07/2021
22

33
.. .. warning:: This guide is still work in progress. New pages are being written
44
.. and existing ones modified. Once the guide will reach its final
@@ -42,8 +42,8 @@ GitHub and is published online in
4242
`Read the Docs <https://superflexpy.readthedocs.io/>`_.
4343

4444
Examples are available on GitHub as Jupyter notebooks. These examples can be
45-
visualized statically or run in a sandbox environment (see :ref:`examples` for
46-
further details).
45+
visualized statically or run in a sandbox environment (Binder). Refer to :ref:`examples` for
46+
a list of the available examples.
4747

4848
The scientific publication introducing SuperflexPy has been submitted to
4949
*Geoscientific Model Development* and is currently under review. The draft is

doc/demo_code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
# Import SuperflexPy
88
from superflexpy.implementation.elements.hbv import PowerReservoir
99
from superflexpy.implementation.elements.gr4j import UnitHydrograph1
10-
from superflexpy.implementation.computation.pegasus_root_finding import PegasusPython
11-
from superflexpy.implementation.computation.implicit_euler import ImplicitEulerPython
10+
from superflexpy.implementation.root_finders.pegasus import PegasusPython
11+
from superflexpy.implementation.numerical_approximators.implicit_euler import ImplicitEulerPython
1212
from superflexpy.framework.unit import Unit
1313
from superflexpy.framework.node import Node
1414
from superflexpy.framework.network import Network

doc/interfaces_code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from superflexpy.implementation.computation.implicit_euler import ImplicitEulerPython
2-
from superflexpy.implementation.computation.pegasus_root_finding import PegasusPython
1+
from superflexpy.implementation.numerical_approximators.implicit_euler import ImplicitEulerPython
2+
from superflexpy.implementation.root_finders.pegasus import PegasusPython
33
from superflexpy.implementation.elements.hbv import PowerReservoir
44
from superflexpy.framework.unit import Unit
55
import spotpy

doc/model_thur_hess2020.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from superflexpy.framework.unit import Unit
88
from superflexpy.framework.node import Node
99
from superflexpy.framework.network import Network
10-
from superflexpy.implementation.computation.pegasus_root_finding import PegasusPython
11-
from superflexpy.implementation.computation.implicit_euler import ImplicitEulerPython
10+
from superflexpy.implementation.root_finders.pegasus import PegasusPython
11+
from superflexpy.implementation.numerical_approximators.implicit_euler import ImplicitEulerPython
1212

1313
solver = PegasusPython()
1414
approximator = ImplicitEulerPython(root_finder=solver)

0 commit comments

Comments
 (0)