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
121121The last methods to implement are :code: `_fluxes_function_python ` (pure Python)
122122and :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
146150The 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
182186The only method requiring implementation is the private method used to
183187calculate 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
190194The 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
197201This 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
234238First, 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
243247We then define the method that receives the inputs, and the method that calculates
244248the 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
251255The two methods have the same structure as the ones implemented as part of the earlier
0 commit comments