MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
gwf-uzf-budget.f90
Go to the documentation of this file.
1!> @brief Build and fill the UZF budget object
2!<
3submodule(uzfmodule) uzfmodulebudget
4contains
5
6 !> @brief Set up the budget object that stores all the uzf flows
7 !!
8 !! The terms listed here must correspond in number and order to the ones
9 !! listed in the uzf_fill_budobj routine
10 !<
11 module procedure uzf_setup_budobj
12 ! -- modules
13 use constantsmodule, only: lenbudtxt
14 ! -- local
15 integer(I4B) :: nbudterm
16 integer(I4B) :: maxlist, naux
17 integer(I4B) :: idx
18 integer(I4B) :: nlen
19 integer(I4B) :: n, n1, n2 !< uzf cell numbers
20 integer(I4B) :: node !< gwf node number
21 integer(I4B) :: ivertflag
22 real(DP) :: q
23 character(len=LENBUDTXT) :: text
24 character(len=LENBUDTXT), dimension(1) :: auxtxt
25 !
26 nlen = 0
27 do n = 1, this%nodes
28 ivertflag = this%uzfobj%cell_below(n)
29 if (ivertflag > 0) then
30 nlen = nlen + 1
31 end if
32 end do
33 !
34 ! -- Determine the number of uzf budget terms. These are fixed for
35 ! the simulation and cannot change. This includes FLOW-JA-FACE
36 ! so they can be written to the binary budget files, but these internal
37 ! flows are not included as part of the budget table.
38 nbudterm = 4
39 if (nlen > 0) nbudterm = nbudterm + 1
40 if (this%ietflag /= 0) nbudterm = nbudterm + 1
41 if (this%imover == 1) nbudterm = nbudterm + 2
42 if (this%naux > 0) nbudterm = nbudterm + 1
43 !
44 ! -- set up budobj
45 call budgetobject_cr(this%budobj, this%packName)
46 call this%budobj%budgetobject_df(this%maxbound, nbudterm, 0, 0, &
47 ibudcsv=this%ibudcsv)
48 idx = 0
49 !
50 ! -- Go through and set up each budget term
51 text = ' FLOW-JA-FACE'
52 if (nlen > 0) then
53 idx = idx + 1
54 maxlist = nlen * 2
55 naux = 1
56 auxtxt(1) = ' FLOW-AREA'
57 call this%budobj%budterm(idx)%initialize(text, &
58 this%name_model, &
59 this%packName, &
60 this%name_model, &
61 this%packName, &
62 maxlist, .false., .false., &
63 naux, auxtxt, ordered_id1=.false.)
64 !
65 ! -- store connectivity
66 call this%budobj%budterm(idx)%reset(nlen * 2)
67 q = dzero
68 do n = 1, this%nodes
69 ivertflag = this%uzfobj%cell_below(n)
70 if (ivertflag > 0) then
71 n1 = n
72 n2 = ivertflag
73 call this%budobj%budterm(idx)%update_term(n1, n2, q)
74 call this%budobj%budterm(idx)%update_term(n2, n1, -q)
75 end if
76 end do
77 end if
78 !
79 ! --
80 text = ' GWF'
81 idx = idx + 1
82 maxlist = this%nodes
83 naux = 1
84 auxtxt(1) = ' FLOW-AREA'
85 call this%budobj%budterm(idx)%initialize(text, &
86 this%name_model, &
87 this%packName, &
88 this%name_model, &
89 this%name_model, &
90 maxlist, .false., .true., &
91 naux, auxtxt)
92 call this%budobj%budterm(idx)%reset(this%nodes)
93 q = dzero
94 do n = 1, this%nodes
95 node = this%igwfnode(n)
96 this%qauxcbc(1) = this%uzfobj%uzfarea(n)
97 call this%budobj%budterm(idx)%update_term(n, node, q, this%qauxcbc)
98 end do
99 !
100 ! --
101 text = ' INFILTRATION'
102 idx = idx + 1
103 maxlist = this%nodes
104 naux = 0
105 call this%budobj%budterm(idx)%initialize(text, &
106 this%name_model, &
107 this%packName, &
108 this%name_model, &
109 this%packName, &
110 maxlist, .false., .false., &
111 naux)
112 !
113 ! --
114 text = ' REJ-INF'
115 idx = idx + 1
116 maxlist = this%nodes
117 naux = 0
118 call this%budobj%budterm(idx)%initialize(text, &
119 this%name_model, &
120 this%packName, &
121 this%name_model, &
122 this%packName, &
123 maxlist, .false., .false., &
124 naux)
125 !
126 ! --
127 text = ' UZET'
128 if (this%ietflag /= 0) then
129 idx = idx + 1
130 maxlist = this%maxbound
131 naux = 0
132 call this%budobj%budterm(idx)%initialize(text, &
133 this%name_model, &
134 this%packName, &
135 this%name_model, &
136 this%packName, &
137 maxlist, .false., .false., &
138 naux)
139 end if
140 !
141 ! --
142 text = ' STORAGE'
143 idx = idx + 1
144 maxlist = this%nodes
145 naux = 1
146 auxtxt(1) = ' VOLUME'
147 call this%budobj%budterm(idx)%initialize(text, &
148 this%name_model, &
149 this%packName, &
150 this%name_model, &
151 this%packName, &
152 maxlist, .false., .false., &
153 naux, auxtxt)
154 !
155 ! --
156 if (this%imover == 1) then
157 !
158 ! --
159 text = ' FROM-MVR'
160 idx = idx + 1
161 maxlist = this%nodes
162 naux = 0
163 call this%budobj%budterm(idx)%initialize(text, &
164 this%name_model, &
165 this%packName, &
166 this%name_model, &
167 this%packName, &
168 maxlist, .false., .false., &
169 naux)
170 !
171 ! --
172 text = ' REJ-INF-TO-MVR'
173 idx = idx + 1
174 maxlist = this%nodes
175 naux = 0
176 call this%budobj%budterm(idx)%initialize(text, &
177 this%name_model, &
178 this%packName, &
179 this%name_model, &
180 this%packName, &
181 maxlist, .false., .false., &
182 naux)
183 end if
184 !
185 ! --
186 naux = this%naux
187 if (naux > 0) then
188 !
189 ! --
190 text = ' AUXILIARY'
191 idx = idx + 1
192 maxlist = this%maxbound
193 call this%budobj%budterm(idx)%initialize(text, &
194 this%name_model, &
195 this%packName, &
196 this%name_model, &
197 this%packName, &
198 maxlist, .false., .false., &
199 naux, this%auxname)
200 end if
201 !
202 ! -- if uzf flow for each reach are written to the listing file
203 if (this%iprflow /= 0) then
204 call this%budobj%flowtable_df(this%iout, cellids='GWF')
205 end if
206 end procedure uzf_setup_budobj
207
208 !> @brief Copy flow terms into this%budobj
209 !<
210 module procedure uzf_fill_budobj
211 ! -- local
212 integer(I4B) :: naux
213 integer(I4B) :: nlen
214 integer(I4B) :: ivertflag
215 integer(I4B) :: n, n1, n2 !< uzf cell numbers
216 integer(I4B) :: node !< gwf node number
217 integer(I4B) :: idx
218 real(DP) :: q
219 real(DP) :: a
220 real(DP) :: top
221 real(DP) :: bot
222 real(DP) :: thick
223 real(DP) :: fm
224 real(DP) :: v
225 !
226 idx = 0
227 !
228 ! -- FLOW JA FACE
229 nlen = 0
230 do n = 1, this%nodes
231 ivertflag = this%uzfobj%cell_below(n)
232 if (ivertflag > 0) then
233 nlen = nlen + 1
234 end if
235 end do
236 if (nlen > 0) then
237 idx = idx + 1
238 call this%budobj%budterm(idx)%reset(nlen * 2)
239 do n = 1, this%nodes
240 ivertflag = this%uzfobj%cell_below(n)
241 if (ivertflag > 0) then
242 a = this%uzfobj%uzfarea(n)
243 q = this%uzfobj%surf_infil_below(n) * a
244 this%qauxcbc(1) = a
245 if (q > dzero) then
246 q = -q
247 end if
248 n1 = n
249 n2 = ivertflag
250 call this%budobj%budterm(idx)%update_term(n1, n2, q, this%qauxcbc)
251 call this%budobj%budterm(idx)%update_term(n2, n1, -q, this%qauxcbc)
252 end if
253 end do
254 end if
255 !
256 ! -- GWF (LEAKAGE)
257 idx = idx + 1
258 call this%budobj%budterm(idx)%reset(this%nodes)
259 do n = 1, this%nodes
260 this%qauxcbc(1) = this%uzfobj%uzfarea(n)
261 node = this%igwfnode(n)
262 q = -this%rch(n)
263 call this%budobj%budterm(idx)%update_term(n, node, q, this%qauxcbc)
264 end do
265 !
266 ! -- INFILTRATION
267 idx = idx + 1
268 call this%budobj%budterm(idx)%reset(this%nodes)
269 do n = 1, this%nodes
270 q = this%appliedinf(n)
271 call this%budobj%budterm(idx)%update_term(n, n, q)
272 end do
273 !
274 ! -- REJECTED INFILTRATION
275 idx = idx + 1
276 call this%budobj%budterm(idx)%reset(this%nodes)
277 do n = 1, this%nodes
278 q = this%rejinf(n)
279 if (q > dzero) then
280 q = -q
281 end if
282 call this%budobj%budterm(idx)%update_term(n, n, q)
283 end do
284 !
285 ! -- UNSATURATED EVT
286 if (this%ietflag /= 0) then
287 idx = idx + 1
288 call this%budobj%budterm(idx)%reset(this%nodes)
289 do n = 1, this%nodes
290 q = this%uzet(n)
291 if (q > dzero) then
292 q = -q
293 end if
294 call this%budobj%budterm(idx)%update_term(n, n, q)
295 end do
296 end if
297 !
298 ! -- STORAGE
299 idx = idx + 1
300 call this%budobj%budterm(idx)%reset(this%nodes)
301 do n = 1, this%nodes
302 q = -this%qsto(n)
303 top = this%uzfobj%celtop(n)
304 bot = this%uzfobj%water_table(n)
305 thick = top - bot
306 if (thick > dzero) then
307 fm = thick * (this%wcnew(n) - this%uzfobj%theta_res(n))
308 v = fm * this%uzfobj%uzfarea(n)
309 else
310 v = dzero
311 end if
312 ! -- save mobile water volume into aux variable
313 this%qauxcbc(1) = v
314 call this%budobj%budterm(idx)%update_term(n, n, q, this%qauxcbc)
315 end do
316 !
317 ! -- MOVER
318 if (this%imover == 1) then
319 !
320 ! -- FROM MOVER
321 idx = idx + 1
322 call this%budobj%budterm(idx)%reset(this%nodes)
323 do n = 1, this%nodes
324 q = this%pakmvrobj%get_qfrommvr(n)
325 call this%budobj%budterm(idx)%update_term(n, n, q)
326 end do
327 !
328 ! -- REJ-INF-TO-MVR
329 idx = idx + 1
330 call this%budobj%budterm(idx)%reset(this%nodes)
331 do n = 1, this%nodes
332 q = this%rejinftomvr(n)
333 if (q > dzero) then
334 q = -q
335 end if
336 call this%budobj%budterm(idx)%update_term(n, n, q)
337 end do
338
339 end if
340 !
341 ! -- AUXILIARY VARIABLES
342 naux = this%naux
343 if (naux > 0) then
344 idx = idx + 1
345 call this%budobj%budterm(idx)%reset(this%nodes)
346 do n = 1, this%nodes
347 q = dzero
348 call this%budobj%budterm(idx)%update_term(n, n, q, this%auxvar(:, n))
349 end do
350 end if
351 !
352 ! --Terms are filled, now accumulate them for this time step
353 call this%budobj%accumulate_terms()
354 end procedure uzf_fill_budobj
355
356end submodule uzfmodulebudget
This module contains simulation constants.
Definition Constants.f90:9
real(dp), parameter dzero
real constant zero
Definition Constants.f90:65
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
Definition Constants.f90:37