MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
gwf-csub.f90
Go to the documentation of this file.
1!> @brief This module contains the CSUB package methods
2!!
3!! This module contains the methods used to add the effects of elastic
4!! skeletal storage, compaction, and subsidence on the groundwater flow
5!! equation. The contribution of elastic skelatal, inelastic and elastic
6!! interbed storage and water compressibility can be represented.
7!!
8!! This file holds the type, the interfaces, the create, allocate and read,
9!! read and prepare, advance, and fill routines, and the shared helpers. The
10!! other procedures are in submodules/gwf-csub-*.f90:
11!!
12!! - memory: allocation and deallocation
13!! - input: options, dimensions, griddata, and packagedata
14!! - stress: initial states and coarse-grained stresses
15!! - coarse: coarse-grained storage
16!! - nodelay: no-delay interbed storage
17!! - delay: delay interbeds
18!! - budget: convergence check, flows, and budget
19!! - output: final processing and dependent variable output
20!! - obs: observations
21!!
22!<
24 use kindmodule, only: i4b, dp, lgp
34 use mathutilmodule, only: is_close
41 use observemodule, only: observetype
42 use obsmodule, only: obstype, obs_cr
43 use geomutilmodule, only: get_node
45 use basedismodule, only: disbasetype
49 use sortmodule, only: selectn
50 !
52 use budgetmodule, only: budgettype
56 !
58 !
59 implicit none
60 !
61 private
62 public :: csub_cr
63 public :: gwfcsubtype
64 !
65 ! -- local parameter
66 real(dp), parameter :: dlog10es = 0.4342942_dp !< derivative of the log of effective stress
67 real(dp), parameter :: stressfloor = dem3 !< effective-stress regularization floor (fraction of geostatic stress)
68
69 !> @brief Interbed storage state
70 !<
71 enum, bind(C)
72 enumerator :: storage_unset = -1 !< no state recorded
73 enumerator :: storage_elastic = 0 !< effective stress not above preconsolidation stress
74 enumerator :: storage_inelastic = 1 !< effective stress above preconsolidation stress
75 end enum
76
77 !> @brief Interbed type
78 !<
79 enum, bind(C)
80 enumerator :: interbed_elastic_inelastic = 0 !< elastic and inelastic storage
81 enumerator :: interbed_elastic = 1 !< elastic storage only
82 end enum
83
84 !> @brief Interbed storage input
85 !<
86 enum, bind(C)
87 enumerator :: storage_input_compression_index = 0 !< compression indices
88 enumerator :: storage_input_specific_storage = 1 !< specific storage coefficients
89 end enum
90 !
91 ! CSUB type
93 ! -- characters scalars
94 character(len=LENLISTLABEL), pointer :: listlabel => null() !< title of table written for RP
95 character(len=LENMEMPATH), pointer :: stomempath => null() !< memory path of storage package
96 ! -- character arrays
97 character(len=LENBOUNDNAME), dimension(:), &
98 pointer, contiguous :: boundname => null() !< vector of boundnames
99 character(len=LENAUXNAME), dimension(:), &
100 pointer, contiguous :: auxname => null() !< vector of auxname
101 ! -- logical scalars
102 logical(LGP), pointer :: lhead_based => null() !< logical variable indicating if head-based solution
103 ! -- integer scalars
104 integer(I4B), pointer :: istounit => null() !< unit number of storage package
105 integer(I4B), pointer :: istrict_stress => null() !< 1 terminates on negative effective stress, 0 regularizes (default)
106 integer(I4B), pointer :: nreg_ts => null() !< count of time steps with effective-stress regularization
107 integer(I4B), pointer :: istrainib => null() !< unit number of interbed strain output
108 integer(I4B), pointer :: istrainsk => null() !< unit number of coarse-grained strain output
109 integer(I4B), pointer :: ioutcomp => null() !< unit number for cell-by-cell compaction output
110 integer(I4B), pointer :: ioutcompi => null() !< unit number for cell-by-cell inelastic compaction output
111 integer(I4B), pointer :: ioutcompe => null() !< unit number for cell-by-cell elastic compaction output
112 integer(I4B), pointer :: ioutcompib => null() !< unit number for cell-by-cell interbed compaction output
113 integer(I4B), pointer :: ioutcomps => null() !< unit number for cell-by-cell coarse-grained compaction output
114 integer(I4B), pointer :: ioutzdisp => null() !< unit number for z-displacement output
115 integer(I4B), pointer :: ipakcsv => null() !< unit number for csv output
116 integer(I4B), pointer :: iupdatematprop => null() !< flag indicating if material properties will be updated
117 integer(I4B), pointer :: istoragec => null() !< interbed storage input (STORAGE_INPUT_*)
118 integer(I4B), pointer :: icellf => null() !< flag indicating cell fractions will be specified
119 integer(I4B), pointer :: ispecified_pcs => null() !< flag indicating preconsolidation state is specified (not relative)
120 integer(I4B), pointer :: ispecified_dbh => null() !< flag indicating delay bed head is specified (not relative)
121 integer(I4B), pointer :: inamedbound => null() !< flag to read boundnames
122 integer(I4B), pointer :: iconvchk => null() !< flag indicating if a final convergence check will be made
123 integer(I4B), pointer :: naux => null() !< number of auxiliary variables
124 integer(I4B), pointer :: ninterbeds => null() !< number of interbeds
125 integer(I4B), pointer :: maxsig0 => null() !< maximum number of cells with specified sig0 values
126 integer(I4B), pointer :: nbound => null() !< number of boundaries for current stress period
127 integer(I4B), pointer :: iscloc => null() !< bound column to scale with SFAC
128 integer(I4B), pointer :: iauxmultcol => null() !< column to use as multiplier for column iscloc
129 integer(I4B), pointer :: ndelaycells => null() !< number of cells in delay interbeds
130 integer(I4B), pointer :: ndelaybeds => null() !< number of delay interbeds
131 integer(I4B), pointer :: initialized => null() !< flag indicating if the initial stresses have been initialized
132 integer(I4B), pointer :: ieslag => null() !< flag indicating if the effective stress is lagged
133 integer(I4B), pointer :: ipch => null() !< flag indicating if initial precosolidation value is a head
134 integer(I4B), pointer :: iupdatestress => null() !< flag indicating if the geostatic stress is active
135 ! -- real scalars
136 real(dp), pointer :: epsilon => null() !< epsilon for stress smoothing
137 real(dp), pointer :: cc_crit => null() !< convergence criteria for csub-gwf convergence check
138 real(dp), pointer :: gammaw => null() !< product of fluid density, and gravity
139 real(dp), pointer :: beta => null() !< water compressibility
140 real(dp), pointer :: brg => null() !< product of gammaw and water compressibility
141 real(dp), pointer :: satomega => null() !< newton-raphson saturation omega
142 real(dp), pointer :: pcsomega => null() !< elastic<->inelastic switch smoothing window (fraction of pcs; 0 = hard switch)
143 ! -- integer pointer to storage package variables
144 integer(I4B), pointer :: gwfiss => null() !< pointer to model iss flag
145 integer(I4B), pointer :: gwfiss0 => null() !< iss flag for last stress period
146 ! -- integer arrays
147 integer(I4B), dimension(:), pointer, contiguous :: ibound => null() !< pointer to model ibound
148 integer(I4B), dimension(:), pointer, contiguous :: stoiconv => null() !< pointer to iconvert in storage
149 ! -- real arrays
150 real(dp), dimension(:), pointer, contiguous :: stoss => null() !< pointer to ss in storage
151 real(dp), dimension(:), pointer, contiguous :: buff => null() !< buff array
152 real(dp), dimension(:), pointer, contiguous :: buffusr => null() !< buffusr array
153 integer, dimension(:), pointer, contiguous :: nodelist => null() !< reduced node that the interbed is attached to
154 integer, dimension(:), pointer, contiguous :: unodelist => null() !< user node that the interbed is attached to
155 !
156 ! -- coarse-grained storage variables
157 real(dp), dimension(:), pointer, contiguous :: sgm => null() !< specific gravity moist sediments
158 real(dp), dimension(:), pointer, contiguous :: sgs => null() !< specific gravity saturated sediments
159 real(dp), dimension(:), pointer, contiguous :: cg_ske_cr => null() !< coarse-grained specified storage
160 real(dp), dimension(:), pointer, contiguous :: cg_gs => null() !< geostatic stress for a cell
161 real(dp), dimension(:), pointer, contiguous :: cg_es => null() !< coarse-grained (aquifer) effective stress
162 real(dp), dimension(:), pointer, contiguous :: cg_es0 => null() !< coarse-grained (aquifer) effective stress for the previous time step
163 real(dp), dimension(:), pointer, contiguous :: cg_pcs => null() !< coarse-grained (aquifer) preconsolidation stress
164 real(dp), dimension(:), pointer, contiguous :: cg_comp => null() !< coarse-grained (aquifer) incremental compaction
165 real(dp), dimension(:), pointer, contiguous :: cg_tcomp => null() !< coarse-grained (aquifer) total compaction
166 real(dp), dimension(:), pointer, contiguous :: cg_stor => null() !< coarse-grained (aquifer) storage
167 real(dp), dimension(:), pointer, contiguous :: cg_ske => null() !< coarse-grained (aquifer) elastic storage coefficient
168 real(dp), dimension(:), pointer, contiguous :: cg_sk => null() !< coarse-grained (aquifer) first storage coefficient
169 real(dp), dimension(:), pointer, contiguous :: cg_thickini => null() !< initial coarse-grained (aquifer) thickness
170 real(dp), dimension(:), pointer, contiguous :: cg_thetaini => null() !< initial coarse-grained (aquifer) porosity
171 real(dp), dimension(:), pointer, contiguous :: cg_thick => null() !< current coarse-grained (aquifer) thickness
172 real(dp), dimension(:), pointer, contiguous :: cg_thick0 => null() !< previous coarse-grained (aquifer) thickness
173 real(dp), dimension(:), pointer, contiguous :: cg_theta => null() !< current coarse-grained (aquifer) porosity
174 real(dp), dimension(:), pointer, contiguous :: cg_theta0 => null() !< previous coarse-grained (aquifer) porosity
175 !
176 ! -- cell storage variables
177 real(dp), dimension(:), pointer, contiguous :: cell_wcstor => null() !< cell water compressibility storage
178 real(dp), dimension(:), pointer, contiguous :: cell_thick => null() !< cell compressible material thickness
179 !
180 ! -- interbed variables
181 integer(I4B), dimension(:), pointer, contiguous :: idelay => null() !< delay interbed flag - 0 = nodelay, > 0 = delay
182 integer(I4B), dimension(:), pointer, contiguous :: ielastic => null() !< interbed type (INTERBED_*)
183 integer(I4B), dimension(:), pointer, contiguous :: iconvert => null() !< no-delay interbed storage state (STORAGE_*)
184 integer(I4B), dimension(:), pointer, contiguous :: iconvert_nr => null() !< iconvert at the last Newton-Raphson term (STORAGE_*)
185 real(dp), dimension(:), pointer, contiguous :: ci => null() !< compression index
186 real(dp), dimension(:), pointer, contiguous :: rci => null() !< recompression index
187 real(dp), dimension(:), pointer, contiguous :: pcs => null() !< preconsolidation stress
188 real(dp), dimension(:), pointer, contiguous :: rnb => null() !< interbed system material factor
189 real(dp), dimension(:), pointer, contiguous :: kv => null() !< vertical hydraulic conductivity of interbed
190 real(dp), dimension(:), pointer, contiguous :: h0 => null() !< initial head in interbed
191 real(dp), dimension(:), pointer, contiguous :: comp => null() !< interbed incremental compaction
192 real(dp), dimension(:), pointer, contiguous :: tcomp => null() !< total interbed compaction
193 real(dp), dimension(:), pointer, contiguous :: tcompi => null() !< total inelastic interbed compaction
194 real(dp), dimension(:), pointer, contiguous :: tcompe => null() !< total elastic interbed compaction
195 real(dp), dimension(:), pointer, contiguous :: storagee => null() !< elastic storage
196 real(dp), dimension(:), pointer, contiguous :: storagei => null() !< inelastic storage
197 real(dp), dimension(:), pointer, contiguous :: ske => null() !< elastic storage coefficient
198 real(dp), dimension(:), pointer, contiguous :: sk => null() !< first storage coefficient
199 real(dp), dimension(:), pointer, contiguous :: thickini => null() !< initial interbed thickness
200 real(dp), dimension(:), pointer, contiguous :: thetaini => null() !< initial interbed theta
201 real(dp), dimension(:), pointer, contiguous :: thick => null() !< current interbed thickness
202 real(dp), dimension(:), pointer, contiguous :: thick0 => null() !< previous interbed thickness
203 real(dp), dimension(:), pointer, contiguous :: theta => null() !< current interbed porosity
204 real(dp), dimension(:), pointer, contiguous :: theta0 => null() !< previous interbed porosity
205 real(dp), dimension(:, :), pointer, contiguous :: auxvar => null() !< auxiliary variable array
206 !
207 ! -- delay interbed
208 integer(I4B), dimension(:), pointer, contiguous :: idb_nconv_count => null() !< non-convertible count of interbeds with heads below delay cell top
209 integer(I4B), dimension(:, :), pointer, contiguous :: idbconvert => null() !< delay cell storage state (STORAGE_*)
210 real(dp), dimension(:), pointer, contiguous :: dbdhmax => null() !< delay bed maximum head change
211 real(dp), dimension(:, :), pointer, contiguous :: dbz => null() !< delay bed cell z
212 real(dp), dimension(:, :), pointer, contiguous :: dbrelz => null() !< delay bed cell z relative to znode
213 real(dp), dimension(:, :), pointer, contiguous :: dbh => null() !< delay bed cell h
214 real(dp), dimension(:, :), pointer, contiguous :: dbh0 => null() !< delay bed cell previous h
215 real(dp), dimension(:, :), pointer, contiguous :: dbgeo => null() !< delay bed cell geostatic stress
216 real(dp), dimension(:, :), pointer, contiguous :: dbes => null() !< delay bed cell effective stress
217 real(dp), dimension(:, :), pointer, contiguous :: dbes0 => null() !< delay bed cell previous effective stress
218 real(dp), dimension(:, :), pointer, contiguous :: dbpcs => null() !< delay bed cell preconsolidation stress
219 real(dp), dimension(:), pointer, contiguous :: dbflowtop => null() !< delay bed flow through interbed top
220 real(dp), dimension(:), pointer, contiguous :: dbflowbot => null() !< delay bed flow through interbed bottom
221 real(dp), dimension(:, :), pointer, contiguous :: dbdzini => null() !< initial delay bed cell thickness
222 real(dp), dimension(:, :), pointer, contiguous :: dbthetaini => null() !< initial delay bed cell porosity
223 real(dp), dimension(:, :), pointer, contiguous :: dbdz => null() !< delay bed dz
224 real(dp), dimension(:, :), pointer, contiguous :: dbdz0 => null() !< delay bed previous dz
225 real(dp), dimension(:, :), pointer, contiguous :: dbtheta => null() !< delay bed cell porosity
226 real(dp), dimension(:, :), pointer, contiguous :: dbtheta0 => null() !< delay bed cell previous porosity
227 real(dp), dimension(:, :), pointer, contiguous :: dbcomp => null() !< delay bed incremental compaction
228 real(dp), dimension(:, :), pointer, contiguous :: dbtcomp => null() !< delay bed total interbed compaction
229 !
230 ! -- delay interbed solution arrays
231 real(dp), dimension(:), pointer, contiguous :: dbal => null() !< delay bed lower diagonal
232 real(dp), dimension(:), pointer, contiguous :: dbad => null() !< delay bed diagonal
233 real(dp), dimension(:), pointer, contiguous :: dbau => null() !< delay bed upper diagonal
234 real(dp), dimension(:), pointer, contiguous :: dbrhs => null() !< delay bed right hand side
235 real(dp), dimension(:), pointer, contiguous :: dbdh => null() !< delay bed dh
236 real(dp), dimension(:), pointer, contiguous :: dbaw => null() !< delay bed work vector
237 !
238 ! -- period data
239 integer(I4B), dimension(:), pointer, contiguous :: nodelistsig0 => null() !< vector of reduced node numbers
240 real(dp), dimension(:), pointer, contiguous :: sig0 => null() !< array of package specific boundary numbers
241 !
242 ! -- observation data
243 integer(I4B), pointer :: inobspkg => null() !< unit number for obs package
244 type(obstype), pointer :: obs => null() !< observation package
245 !
246 ! -- table objects
247 type(tabletype), pointer :: inputtab => null() !< table for input variables
248 type(tabletype), pointer :: outputtab => null() !< table for output variables
249 type(tabletype), pointer :: pakcsvtab => null() !< table for csv output
250
251 contains
252 !> @brief Define the list label for the package
253 !!
254 !! Method defined the list label for the CSUB package. The list label is
255 !! the heading that is written to iout when PRINT_INPUT option is used.
256 !!
257 !<
258 procedure :: define_listlabel
259 !> @brief Source options for package
260 !!
261 !! Source options for CSUB package.
262 !!
263 !<
264 procedure :: source_options
265 !> @brief log options for package
266 !!
267 !! log options block for CSUB package.
268 !!
269 !<
270 procedure :: log_options
271 procedure :: csub_ar
272 !> @brief Deallocate package memory
273 !!
274 !! Deallocate CSUB package scalars and arrays.
275 !!
276 !<
277 procedure :: csub_da
278 procedure :: csub_rp
279 procedure :: csub_ad
280 procedure :: csub_fc
281 procedure :: csub_fn
282 !> @brief Final convergence check
283 !!
284 !! Final convergence check for the CSUB package. The final convergence
285 !! check is only required when the simulation includes delay interbeds.
286 !! The final convergence check compares the sum of water contributed
287 !! by storage and water compressibility in the delay bed to the fluid
288 !! exchange between the delay interbed and the gwf cell.
289 !<
290 procedure :: csub_cc
291 !> @brief Calculate flows for package
292 !!
293 !! Flow calculation for the CSUB package components. Components include
294 !! coarse-grained storage, delay and no-delay interbeds, and water
295 !! compressibility.
296 !!
297 !<
298 procedure :: csub_cq
299 !> @brief Model budget calculation for package
300 !!
301 !! Budget calculation for the CSUB package components. Components include
302 !! coarse-grained storage, delay and no-delay interbeds, and water
303 !! compressibility.
304 !<
305 procedure :: csub_bd
306 !> @brief Save model flows for package
307 !!
308 !! Save cell-by-cell budget terms for the CSUB package.
309 !!
310 !<
311 procedure :: csub_save_model_flows
312 !> @brief Save and print dependent values for package
313 !!
314 !! Method saves cell-by-cell compaction and z-displacement terms. The method
315 !! also calls the method to process observation output.
316 !!
317 !<
318 procedure :: csub_ot_dv
319 !> @brief Final processing for package
320 !!
321 !! Final processing for the CSUB package. This method generates the final
322 !! strain tables that are output so that the user can evaluate if calculated
323 !! strain rates in coarse-grained sediments and interbeds exceed 1 percent.
324 !!
325 !<
326 procedure :: csub_fp
327 !> @brief Source dimensions for package
328 !!
329 !! Read the number of interbeds and maximum number of cells with a specified
330 !! overlying geostatic stress.
331 !!
332 !<
333 procedure :: source_dimensions => csub_source_dimensions
334 !> @brief Allocate scalars
335 !!
336 !! Allocate and initialize scalars for the CSUB package. The base model
337 !! allocate scalars method is also called.
338 !!
339 !<
340 procedure, private :: csub_allocate_scalars
341 !> @brief Allocate package arrays
342 !!
343 !! Allocate and initialize CSUB package arrays.
344 !!
345 !<
346 procedure, private :: csub_allocate_arrays
347 !> @brief Source griddata for package
348 !<
349 procedure, private :: csub_source_griddata
350 !> @brief source packagedata for package
351 !!
352 !! Read delay and no-delay interbed input data for the CSUB package. Method
353 !! also validates interbed input data.
354 !!
355 !<
356 procedure, private :: csub_source_packagedata
357 !> @brief Print packagedata
358 !<
359 procedure, private :: csub_print_packagedata
360 !
361 ! -- helper methods
362 procedure, private :: csub_calc_znode
363 procedure, private :: csub_calc_sat
364 procedure, private :: csub_calc_sat_derivative
365 procedure, private :: csub_calc_sfacts
366 procedure, private :: csub_calc_interbed_thickness
367 !> @brief Calculate the flow from delay interbed top or bottom
368 !!
369 !! Function to calculate the flow from across the top or bottom of
370 !! a delay interbed.
371 !!
372 !! @return q flow across the top or bottom of a delay interbed
373 !<
374 procedure, private :: csub_calc_delay_flow
375 !
376 ! -- stress methods
377 !> @brief Calculate the stress for model cells
378 !!
379 !! Method calculates the geostatic stress, pressure head, and effective
380 !! stress at the bottom of each cell. The method also applies the overlying
381 !! geostatic stress (sig0) not represented in the model.
382 !!
383 !<
384 procedure, private :: csub_cg_calc_stress
385 !> @brief Check effective stress values
386 !!
387 !! Method checks calculated effective stress values to ensure that
388 !! effective stress values are positive. An error condition and message
389 !! are issued if calculated effective stress values are less than a small
390 !! positive value (DEM6).
391 !!
392 !<
393 procedure, private :: csub_cg_chk_stress
394 !
395 ! -- initial states
396 !> @brief Set initial states for the package
397 !!
398 !! Method sets the initial states for coarse-grained materials and fine-
399 !! grained sediments in the interbeds.
400 !!
401 !<
402 procedure, private :: csub_set_initial_state
403 !
404 ! -- coarse-grained coarse-grained methods
405 !> @brief Update coarse-grained material properties
406 !!
407 !! Method updates coarse-grained material properties in a cell.
408 !!
409 !<
410 procedure, private :: csub_cg_update
411 !> @brief Calculate coarse-grained compaction in a cell
412 !!
413 !! Method calculates coarse-grained compaction in a cell.
414 !<
415 procedure, private :: csub_cg_calc_comp
416 !> @brief Calculate Sske for a cell
417 !!
418 !! Method calculates Sske for coarse-grained materials in a cell.
419 !<
420 procedure, private :: csub_cg_calc_sske
421 !> @brief Formulate the coefficients for coarse-grained materials
422 !!
423 !! Method formulates the coefficient matrix and right-hand side terms
424 !! for coarse grained materials in a cell.
425 !<
426 procedure, private :: csub_cg_fc
427 !> @brief Formulate coarse-grained Newton-Raphson terms
428 !!
429 !! Method formulates the coefficient matrix and right-hand side terms
430 !! for coarse grained materials in a cell when using the Newton-Raphson
431 !! formulation.
432 !<
433 procedure, private :: csub_cg_fn
434 !> @brief Formulate coarse-grained water compressibility coefficients
435 !!
436 !! Method formulates the standard formulation coefficient matrix and
437 !! right-hand side terms for water compressibility in coarse-grained
438 !! sediments.
439 !<
440 procedure, private :: csub_cg_wcomp_fc
441 !> @brief Formulate coarse-grained water compressibility coefficients
442 !!
443 !! Method formulates the Newton-Raphson formulation coefficient matrix and
444 !! right-hand side terms for water compressibility in coarse-grained
445 !! sediments.
446 !<
447 procedure, private :: csub_cg_wcomp_fn
448 !
449 ! -- interbed methods
450 !> @brief Formulate the coefficients for a interbed
451 !!
452 !! Method formulates the coefficient matrix and right-hand side terms
453 !! for a interbed in a cell.
454 !<
455 procedure, private :: csub_interbed_fc
456 !> @brief Formulate the coefficients for a interbed
457 !!
458 !! Method formulates the Newton-Raphson formulation coefficient matrix and
459 !! right-hand side terms for a interbed in a cell.
460 !<
461 procedure, private :: csub_interbed_fn
462 !
463 ! -- no-delay interbed methods
464 !> @brief Update no-delay material properties
465 !!
466 !! Method updates no-delay material properties based on the current
467 !! compaction value.
468 !!
469 !<
470 procedure, private :: csub_nodelay_update
471 !> @brief Calculate no-delay interbed storage coefficients
472 !!
473 !! Method calculates the skeletal storage coefficients for a no-delay
474 !! interbed. The method also calculates the contribution of the
475 !! no-delay interbed to the right-hand side of the groundwater flow
476 !! equation for the cell.
477 !<
478 procedure, private :: csub_nodelay_fc
479 !> @brief Formulate no-delay interbed water compressibility coefficients
480 !!
481 !! Method formulates the standard formulation coefficient matrix and
482 !! right-hand side terms for water compressibility in no-delay
483 !! interbeds.
484 !<
485 procedure, private :: csub_nodelay_wcomp_fc
486 !> @brief Formulate no-delay interbed water compressibility coefficients
487 !!
488 !! Method formulates the Newton-Raphson formulation coefficient matrix and
489 !! right-hand side terms for water compressibility in no-delay
490 !! interbeds.
491 !<
492 procedure, private :: csub_nodelay_wcomp_fn
493 !> @brief Calculate no-delay interbed compaction
494 !!
495 !! Method calculates the compaction for a no-delay interbed. The method
496 !! also calculates the storage coefficients for the no-delay interbed.
497 !<
498 procedure, private :: csub_nodelay_calc_comp
499 !
500 ! -- delay interbed methods
501 !> @brief Calculate delay interbed saturation
502 !!
503 !! Method to calculate the saturation in a delay interbed cell.
504 !<
505 procedure, private :: csub_delay_calc_sat
506 !> @brief Calculate the delay interbed cell saturation derivative
507 !!
508 !! Function to calculate the derivative of the saturation with
509 !! respect to the current head in delay interbed cell n.
510 !!
511 !! @return satderv derivative of saturation
512 !<
513 procedure, private :: csub_delay_calc_sat_derivative
514 !> @brief Calculate delay interbed znode and z relative to interbed center
515 !!
516 !! Method to calculate the initial center of each delay interbed cell,
517 !! assuming the delay bed head is equal to the top of the delay interbed.
518 !! The method also calculates the distance of the center of each delay
519 !! bed cell from the center of the delay interbed (z_offset) that is used
520 !! to calculate average skeletal specific storage values for a delay interbed
521 !! centered on the center of the saturated thickness for a cell.
522 !!
523 !<
524 procedure, private :: csub_delay_init_zcell
525 !> @brief Calculate delay interbed stress values
526 !!
527 !! Method to calculate the geostatic and effective stress in delay interbed
528 !! cells using the passed the current head value in a cell.
529 !!
530 !<
531 procedure, private :: csub_delay_calc_stress
532 !> @brief Calculate delay interbed cell storage coefficients
533 !<
534 procedure, private :: csub_delay_calc_ssksske
535 !> @brief Calculate delay interbed compaction
536 !!
537 !! Method to calculate the compaction in a delay interbed.
538 !<
539 procedure, private :: csub_delay_calc_comp
540 !> @brief Update delay interbed material properties
541 !!
542 !! Method to update the thickness and porosity of each delay interbed cell.
543 !!
544 !<
545 procedure, private :: csub_delay_update
546 !> @brief Calculate delay interbed storage change
547 !!
548 !! Method to calculate the storage change in a delay interbed.
549 !<
550 procedure, private :: csub_delay_calc_dstor
551 !> @brief Calculate delay interbed water compressibility
552 !!
553 !! Method to calculate the change in water compressibility in a delay
554 !! interbed.
555 !<
556 procedure, private :: csub_delay_calc_wcomp
557 !> @brief Calculate delay interbed contribution to the cell
558 !!
559 !! Method to calculate the coefficients to calculate the delay interbed
560 !! contribution to a cell. The product of hcof* h - rhs equals the
561 !! delay contribution to the cell
562 !<
563 procedure, private :: csub_delay_fc
564 !> @brief Solve delay interbed continuity equation
565 !!
566 !! Method to calculate solve the delay interbed continuity equation for a
567 !! delay interbed. The method encapsulates the non-linear loop and calls the
568 !! linear solution.
569 !!
570 !<
571 procedure, private :: csub_delay_sln
572 !> @brief Assemble delay interbed coefficients
573 !!
574 !! Method to assemble matrix and right-hand side coefficients for a delay
575 !! interbed. The method calls the appropriate standard or Newton-Raphson
576 !! assembly routines and fills all of the entries for a delay interbed.
577 !!
578 !<
579 procedure, private :: csub_delay_assemble
580 !> @brief Assemble delay interbed standard formulation coefficients
581 !!
582 !! Method to assemble standard formulation matrix and right-hand side
583 !! coefficients for a delay interbed.
584 !!
585 !<
586 procedure, private :: csub_delay_assemble_fc
587 !> @brief Assemble delay interbed Newton-Raphson formulation coefficients
588 !!
589 !! Method to assemble Newton-Raphson formulation matrix and right-hand side
590 !! coefficients for a delay interbed.
591 !!
592 !<
593 procedure, private :: csub_delay_assemble_fn
594 !> @brief Check delay interbed head
595 !!
596 !! Method to determine if the delay interbed head in any delay cell
597 !! in a non-convertible gwf cell is less than the top of each delay
598 !! interbed cell.
599 !!
600 !<
601 procedure, private :: csub_delay_head_check
602
603 ! methods for tables
604 !> @brief Initialize optional tables
605 !!
606 !! Subroutine to initialize optional tables. Tables include:
607 !! o delay interbeds convergence tables
608 !!
609 !<
610 procedure, private :: csub_initialize_tables
611 !
612 ! -- methods for observations
613 !> @brief Determine if observations are supported.
614 !!
615 !! Function to determine if observations are supported by the CSUB package.
616 !! Observations are supported by the CSUB package.
617 !!
618 !<
619 procedure, public :: csub_obs_supported
620 !> @brief Define the observation types available in the package
621 !!
622 !! Method to define the observation types available in the CSUB package.
623 !!
624 !<
625 procedure, public :: csub_df_obs
626 !> @brief Read and prepare the observations
627 !!
628 !! Method to read and prepare the observations for the CSUB package.
629 !!
630 !<
631 procedure, private :: csub_rp_obs
632 !> @brief Set the observations for this time step
633 !!
634 !! Method to set the CSUB package observations for this time step.
635 !!
636 !<
637 procedure, public :: csub_bd_obs
638 end type gwfcsubtype
639
640 interface
641
642 ! -- memory allocation and deallocation (submodules/gwf-csub-memory.f90)
643
644 module subroutine csub_allocate_scalars(this)
645 class(gwfcsubtype), intent(inout) :: this
646 end subroutine csub_allocate_scalars
647
648 module subroutine csub_allocate_arrays(this)
649 class(gwfcsubtype), intent(inout) :: this
650 end subroutine csub_allocate_arrays
651
652 module subroutine csub_da(this)
653 class(gwfcsubtype) :: this
654 end subroutine csub_da
655
656 ! -- input processing (submodules/gwf-csub-input.f90)
657
658 module subroutine source_options(this)
659 class(gwfcsubtype), intent(inout) :: this
660 end subroutine source_options
661
662 module subroutine log_options(this, warn_estress_lag)
663 class(gwfcsubtype), intent(inout) :: this
664 logical(LGP), intent(in) :: warn_estress_lag
665 end subroutine log_options
666
667 module subroutine csub_source_dimensions(this)
668 class(gwfcsubtype), intent(inout) :: this
669 end subroutine csub_source_dimensions
670
671 module subroutine csub_source_griddata(this)
672 class(gwfcsubtype), intent(inout) :: this
673 end subroutine csub_source_griddata
674
675 module subroutine csub_source_packagedata(this)
676 class(gwfcsubtype), intent(inout) :: this
677 end subroutine csub_source_packagedata
678
679 module subroutine csub_print_packagedata(this)
680 class(gwfcsubtype) :: this
681 end subroutine csub_print_packagedata
682
683 module subroutine csub_initialize_tables(this)
684 class(gwfcsubtype) :: this
685 end subroutine csub_initialize_tables
686
687 module subroutine define_listlabel(this)
688 class(gwfcsubtype), intent(inout) :: this
689 end subroutine define_listlabel
690
691 ! -- initial states and stresses (submodules/gwf-csub-stress.f90)
692
693 module subroutine csub_cg_calc_stress(this, nodes, hnew)
694 class(gwfcsubtype) :: this
695 integer(I4B), intent(in) :: nodes !< number of active model nodes
696 real(dp), dimension(nodes), intent(in) :: hnew !< current head
697 end subroutine csub_cg_calc_stress
698
699 module subroutine csub_set_initial_state(this, nodes, hnew)
700 class(gwfcsubtype) :: this
701 integer(I4B), intent(in) :: nodes !< number of active model nodes
702 real(dp), dimension(nodes), intent(in) :: hnew !< current heads
703 end subroutine csub_set_initial_state
704
705 ! -- coarse-grained storage (submodules/gwf-csub-coarse.f90)
706
707 module subroutine csub_cg_fc(this, node, tled, area, hcell, hcellold, hcof, &
708 rhs)
709 class(gwfcsubtype) :: this
710 integer(I4B), intent(in) :: node !< cell node number
711 real(dp), intent(in) :: tled !< recripicol of the time step length
712 real(dp), intent(in) :: area !< horizontal cell area
713 real(dp), intent(in) :: hcell !< current head
714 real(dp), intent(in) :: hcellold !< previous head
715 real(dp), intent(inout) :: hcof !< coarse-grained A matrix entry
716 real(dp), intent(inout) :: rhs !< coarse-grained right-hand side entry
717 end subroutine csub_cg_fc
718
719 module subroutine csub_cg_fn(this, node, tled, area, hcell, hcof, rhs)
720 class(gwfcsubtype) :: this
721 integer(I4B), intent(in) :: node !< node number
722 real(dp), intent(in) :: tled !< reciprocal of the time step length
723 real(dp), intent(in) :: area !< horizontal cell area
724 real(dp), intent(in) :: hcell !< current head in cell
725 real(dp), intent(inout) :: hcof !< coarse-grained A matrix entry
726 real(dp), intent(inout) :: rhs !< coarse-grained right-hand side entry
727 end subroutine csub_cg_fn
728
729 module subroutine csub_cg_calc_sske(this, n, sske, hcell)
730 class(gwfcsubtype), intent(inout) :: this
731 integer(I4B), intent(in) :: n !< cell node number
732 real(dp), intent(inout) :: sske !< coarse grained Sske
733 real(dp), intent(in) :: hcell !< current head in cell
734 end subroutine csub_cg_calc_sske
735
736 module subroutine csub_cg_calc_comp(this, node, hcell, hcellold, comp)
737 class(gwfcsubtype) :: this
738 integer(I4B), intent(in) :: node !< cell node number
739 real(dp), intent(in) :: hcell !< current head in cell
740 real(dp), intent(in) :: hcellold !< previous head in cell
741 real(dp), intent(inout) :: comp !< coarse-grained compaction
742 end subroutine csub_cg_calc_comp
743
744 module subroutine csub_cg_update(this, node)
745 class(gwfcsubtype), intent(inout) :: this
746 integer(I4B), intent(in) :: node !< cell node number
747 end subroutine csub_cg_update
748
749 module subroutine csub_cg_wcomp_fc(this, node, tled, area, hcell, hcellold, &
750 hcof, rhs)
751 class(gwfcsubtype), intent(inout) :: this
752 integer(I4B), intent(in) :: node !< cell node number
753 real(dp), intent(in) :: tled !< reciprocal of the time step length
754 real(dp), intent(in) :: area !< horizontal cell area
755 real(dp), intent(in) :: hcell !< current head in cell
756 real(dp), intent(in) :: hcellold !< previous head in cell
757 real(dp), intent(inout) :: hcof !< coarse-grained A matrix entry
758 real(dp), intent(inout) :: rhs !< coarse-grained right-hand side entry
759 end subroutine csub_cg_wcomp_fc
760
761 module subroutine csub_cg_wcomp_fn(this, node, tled, area, hcell, hcellold, &
762 hcof, rhs)
763 class(gwfcsubtype), intent(inout) :: this
764 integer(I4B), intent(in) :: node !< cell node number
765 real(dp), intent(in) :: tled !< reciprocal of the time step length
766 real(dp), intent(in) :: area !< horizontal cell area
767 real(dp), intent(in) :: hcell !< current head in cell
768 real(dp), intent(in) :: hcellold !< previous head in cell
769 real(dp), intent(inout) :: hcof !< coarse-grained A matrix entry
770 real(dp), intent(inout) :: rhs !< coarse-grained right-hand side entry
771 end subroutine csub_cg_wcomp_fn
772
773 ! -- no-delay interbed storage (submodules/gwf-csub-nodelay.f90)
774
775 module subroutine csub_nodelay_update(this, i)
776 class(gwfcsubtype), intent(inout) :: this
777 integer(I4B), intent(in) :: i
778 end subroutine csub_nodelay_update
779
780 module subroutine csub_nodelay_fc(this, ib, hcell, hcellold, rho1, rho2, &
781 rhs, argtled)
782 class(gwfcsubtype) :: this
783 integer(I4B), intent(in) :: ib !< interbed number
784 real(dp), intent(in) :: hcell !< current head in the cell
785 real(dp), intent(in) :: hcellold !< previous head in the cell
786 real(dp), intent(inout) :: rho1 !< current storage coefficient value using Sske
787 real(dp), intent(inout) :: rho2 !< current storage coefficient value based on Ssk
788 real(dp), intent(inout) :: rhs !< no-delay interbed contribution to the right-hand side
789 real(dp), intent(in), optional :: argtled !< optional reciprocal of the time step length
790 end subroutine csub_nodelay_fc
791
792 module subroutine csub_nodelay_calc_comp(this, ib, hcell, hcellold, comp, &
793 rho1, rho2)
794 class(gwfcsubtype) :: this
795 integer(I4B), intent(in) :: ib !< interbed number
796 real(dp), intent(in) :: hcell !< current head for the cell
797 real(dp), intent(in) :: hcellold !< previous head for the cell
798 real(dp), intent(inout) :: comp !< no-delay interbed compaction
799 real(dp), intent(inout) :: rho1 !< current storage coefficient based on Sske
800 real(dp), intent(inout) :: rho2 !< current storage coefficient based on Ssk
801 end subroutine csub_nodelay_calc_comp
802
803 module subroutine csub_interbed_fc(this, ib, node, area, hcell, hcellold, &
804 hcof, rhs)
805 class(gwfcsubtype) :: this
806 integer(I4B), intent(in) :: ib !< interbed number
807 integer(I4B), intent(in) :: node !< cell node number
808 real(dp), intent(in) :: area !< horizontal cell area
809 real(dp), intent(in) :: hcell !< current head in cell
810 real(dp), intent(in) :: hcellold !< previous head in cell
811 real(dp), intent(inout) :: hcof !< interbed A matrix entry
812 real(dp), intent(inout) :: rhs !< interbed right-hand side
813 end subroutine csub_interbed_fc
814
815 module subroutine csub_interbed_fn(this, ib, node, area, hcell, hcellold, &
816 hcof, rhs)
817 class(gwfcsubtype) :: this
818 integer(I4B), intent(in) :: ib !< interbed number
819 integer(I4B), intent(in) :: node !< cell node number
820 real(dp), intent(in) :: area !< horizontal cell area
821 real(dp), intent(in) :: hcell !< current head in a cell
822 real(dp), intent(in) :: hcellold !< previous head in a cell
823 real(dp), intent(inout) :: hcof !< interbed A matrix entry
824 real(dp), intent(inout) :: rhs !< interbed right-hand side entry
825 end subroutine csub_interbed_fn
826
827 module subroutine csub_nodelay_wcomp_fc(this, ib, node, tled, area, hcell, &
828 hcellold, hcof, rhs)
829 class(gwfcsubtype), intent(inout) :: this
830 integer(I4B), intent(in) :: ib !< interbed number
831 integer(I4B), intent(in) :: node !< cell node number
832 real(dp), intent(in) :: tled !< reciprocal of time step length
833 real(dp), intent(in) :: area !< horizontal cell area
834 real(dp), intent(in) :: hcell !< current head in cell
835 real(dp), intent(in) :: hcellold !< previous head in cell
836 real(dp), intent(inout) :: hcof !< no-delay A matrix entry
837 real(dp), intent(inout) :: rhs !< no-delay right-hand side entry
838 end subroutine csub_nodelay_wcomp_fc
839
840 module subroutine csub_nodelay_wcomp_fn(this, ib, node, tled, area, hcell, &
841 hcellold, hcof, rhs)
842 class(gwfcsubtype), intent(inout) :: this
843 integer(I4B), intent(in) :: ib !< interbed number
844 integer(I4B), intent(in) :: node !< cell node number
845 real(dp), intent(in) :: tled !< reciprocal of time step length
846 real(dp), intent(in) :: area !< horizontal cell area
847 real(dp), intent(in) :: hcell !< current head in cell
848 real(dp), intent(in) :: hcellold !< previous head in cell
849 real(dp), intent(inout) :: hcof !< no-delay A matrix entry
850 real(dp), intent(inout) :: rhs !< no-delay right-hand side entry
851 end subroutine csub_nodelay_wcomp_fn
852
853 ! -- delay interbeds (submodules/gwf-csub-delay.f90)
854
855 module subroutine csub_delay_head_check(this, ib)
856 class(gwfcsubtype), intent(inout) :: this
857 integer(I4B), intent(in) :: ib !< interbed number
858 end subroutine csub_delay_head_check
859
860 module subroutine csub_delay_sln(this, ib, hcell, update)
861 class(gwfcsubtype), intent(inout) :: this
862 integer(I4B), intent(in) :: ib !< interbed number
863 real(dp), intent(in) :: hcell !< current head in a cell
864 logical(LGP), intent(in), optional :: update !< optional logical variable indicating
865 end subroutine csub_delay_sln
866
867 module subroutine csub_delay_init_zcell(this, ib)
868 class(gwfcsubtype), intent(inout) :: this
869 integer(I4B), intent(in) :: ib !< interbed number
870 end subroutine csub_delay_init_zcell
871
872 module subroutine csub_delay_calc_stress(this, ib, hcell)
873 class(gwfcsubtype), intent(inout) :: this
874 integer(I4B), intent(in) :: ib !< interbed number
875 real(dp), intent(in) :: hcell !< current head in a cell
876 end subroutine csub_delay_calc_stress
877
878 module subroutine csub_delay_calc_ssksske(this, ib, n, hcell, ssk, sske, &
879 dsskde, wfac)
880 class(gwfcsubtype), intent(inout) :: this
881 integer(I4B), intent(in) :: ib !< interbed number
882 integer(I4B), intent(in) :: n !< delay interbed cell number
883 real(dp), intent(in) :: hcell !< current head in a cell
884 real(dp), intent(inout) :: ssk !< delay interbed skeletal specific storage
885 real(dp), intent(inout) :: sske !< delay interbed elastic skeletal specific storage
886 real(dp), intent(out), optional :: dsskde !< d(ssk)/d(effective stress)
887 real(dp), intent(out), optional :: wfac !< inelastic weight (0 elastic, 1 inelastic) for the budget split
888 end subroutine csub_delay_calc_ssksske
889
890 module subroutine csub_delay_assemble(this, ib, hcell)
891 class(gwfcsubtype), intent(inout) :: this
892 integer(I4B), intent(in) :: ib !< interbed number
893 real(dp), intent(in) :: hcell !< current head in a cell
894 end subroutine csub_delay_assemble
895
896 module subroutine csub_delay_assemble_fc(this, ib, n, hcell, aii, au, al, r)
897 class(gwfcsubtype), intent(inout) :: this
898 integer(I4B), intent(in) :: ib !< interbed number
899 integer(I4B), intent(in) :: n !< delay interbed cell number
900 real(dp), intent(in) :: hcell !< current head in a cell
901 real(dp), intent(inout) :: aii !< diagonal in the A matrix
902 real(dp), intent(inout) :: au !< upper term in the A matrix
903 real(dp), intent(inout) :: al !< lower term in the A matrix
904 real(dp), intent(inout) :: r !< right-hand side term
905 end subroutine csub_delay_assemble_fc
906
907 module subroutine csub_delay_assemble_fn(this, ib, n, hcell, aii, au, al, r)
908 class(gwfcsubtype), intent(inout) :: this
909 integer(I4B), intent(in) :: ib !< interbed number
910 integer(I4B), intent(in) :: n !< delay interbed cell number
911 real(dp), intent(in) :: hcell !< current head in a cell
912 real(dp), intent(inout) :: aii !< diagonal in the A matrix
913 real(dp), intent(inout) :: au !< upper term in the A matrix
914 real(dp), intent(inout) :: al !< lower term in the A matrix
915 real(dp), intent(inout) :: r !< right-hand side term
916 end subroutine csub_delay_assemble_fn
917
918 module subroutine csub_delay_calc_sat(this, node, idelay, n, hcell, &
919 hcellold, snnew, snold)
920 class(gwfcsubtype), intent(inout) :: this
921 integer(I4B), intent(in) :: node !< cell node number
922 integer(I4B), intent(in) :: idelay !< delay interbed number
923 integer(I4B), intent(in) :: n !< delay interbed cell number
924 real(dp), intent(in) :: hcell !< current head in delay interbed cell n
925 real(dp), intent(in) :: hcellold !< previous head in delay interbed cell n
926 real(dp), intent(inout) :: snnew !< current saturation in delay interbed cell n
927 real(dp), intent(inout) :: snold !< previous saturation in delay interbed cell n
928 end subroutine csub_delay_calc_sat
929
930 module function csub_delay_calc_sat_derivative(this, node, idelay, n, &
931 hcell) result(satderv)
932 class(gwfcsubtype), intent(inout) :: this
933 integer(I4B), intent(in) :: node !< cell node number
934 integer(I4B), intent(in) :: idelay !< delay interbed number
935 integer(I4B), intent(in) :: n !< delay interbed cell number
936 real(dp), intent(in) :: hcell !< current head in delay interbed cell n
937 real(dp) :: satderv
938 end function csub_delay_calc_sat_derivative
939
940 module subroutine csub_delay_calc_dstor(this, ib, hcell, stoe, stoi)
941 class(gwfcsubtype), intent(inout) :: this
942 integer(I4B), intent(in) :: ib !< interbed number
943 real(dp), intent(in) :: hcell !< current head in cell
944 real(dp), intent(inout) :: stoe !< current elastic storage change in delay interbed
945 real(dp), intent(inout) :: stoi !< current inelastic storage change in delay interbed
946 end subroutine csub_delay_calc_dstor
947
948 module subroutine csub_delay_calc_wcomp(this, ib, dwc)
949 class(gwfcsubtype), intent(inout) :: this
950 integer(I4B), intent(in) :: ib !< interbed number
951 real(dp), intent(inout) :: dwc !< current water compressibility change in delay interbed
952 end subroutine csub_delay_calc_wcomp
953
954 module subroutine csub_delay_calc_comp(this, ib, hcell, hcellold, comp, &
955 compi, compe)
956 class(gwfcsubtype), intent(inout) :: this
957 integer(I4B), intent(in) :: ib !< interbed number
958 real(dp), intent(in) :: hcell !< current head in cell
959 real(dp), intent(in) :: hcellold !< previous head in cell
960 real(dp), intent(inout) :: comp !< compaction in delay interbed
961 real(dp), intent(inout) :: compi !< inelastic compaction in delay interbed
962 real(dp), intent(inout) :: compe !< elastic compaction in delay interbed
963 end subroutine csub_delay_calc_comp
964
965 module subroutine csub_delay_update(this, ib)
966 class(gwfcsubtype), intent(inout) :: this
967 integer(I4B), intent(in) :: ib !< interbed number
968 end subroutine csub_delay_update
969
970 module subroutine csub_delay_fc(this, ib, hcof, rhs)
971 class(gwfcsubtype), intent(inout) :: this
972 integer(I4B), intent(in) :: ib !< interbed number
973 real(dp), intent(inout) :: hcof !< head dependent coefficient
974 real(dp), intent(inout) :: rhs !< right-hand side
975 end subroutine csub_delay_fc
976
977 module function csub_calc_delay_flow(this, ib, n, hcell) result(q)
978 class(gwfcsubtype), intent(inout) :: this
979 integer(I4B), intent(in) :: ib !< interbed number
980 integer(I4B), intent(in) :: n !< delay interbed cell
981 real(dp), intent(in) :: hcell !< current head in cell
982 real(dp) :: q
983 end function csub_calc_delay_flow
984
985 ! -- convergence check and budget (submodules/gwf-csub-budget.f90)
986
987 module subroutine csub_cc(this, innertot, kiter, iend, icnvgmod, nodes, &
988 hnew, hold, cpak, ipak, dpak)
989 class(gwfcsubtype) :: this
990 integer(I4B), intent(in) :: innertot !< total number of inner iterations
991 integer(I4B), intent(in) :: kiter !< outer iteration number
992 integer(I4B), intent(in) :: iend !< flag indicating if it is the last iteration
993 integer(I4B), intent(in) :: icnvgmod !< flag indicating if the solution is considered converged
994 integer(I4B), intent(in) :: nodes !< number of active nodes
995 real(dp), dimension(nodes), intent(in) :: hnew !< current gwf head
996 real(dp), dimension(nodes), intent(in) :: hold !< gwf for previous time step
997 character(len=LENPAKLOC), intent(inout) :: cpak !< string location of the maximum change in csub package
998 integer(I4B), intent(inout) :: ipak !< node with the maximum change in csub package
999 real(dp), intent(inout) :: dpak !< maximum change in csub package
1000 end subroutine csub_cc
1001
1002 module subroutine csub_cq(this, nodes, hnew, hold, isuppress_output, flowja)
1003 class(gwfcsubtype) :: this
1004 integer(I4B), intent(in) :: nodes !< number of active model nodes
1005 real(dp), intent(in), dimension(nodes) :: hnew !< current head
1006 real(dp), intent(in), dimension(nodes) :: hold !< head for the previous time step
1007 integer(I4B), intent(in) :: isuppress_output !< flag indicating if budget output should be suppressed
1008 real(dp), dimension(:), contiguous, intent(inout) :: flowja
1009 end subroutine csub_cq
1010
1011 module subroutine csub_bd(this, isuppress_output, model_budget)
1012 class(gwfcsubtype) :: this
1013 integer(I4B), intent(in) :: isuppress_output
1014 type(budgettype), intent(inout) :: model_budget !< model budget object
1015 end subroutine csub_bd
1016
1017 module subroutine csub_save_model_flows(this, icbcfl, icbcun)
1018 class(gwfcsubtype) :: this
1019 integer(I4B), intent(in) :: icbcfl !< flag to output budget data
1020 integer(I4B), intent(in) :: icbcun !< unit number for cell-by-cell file
1021 end subroutine csub_save_model_flows
1022
1023 ! -- output (submodules/gwf-csub-output.f90)
1024
1025 module subroutine csub_fp(this)
1026 class(gwfcsubtype) :: this
1027 end subroutine csub_fp
1028
1029 module subroutine csub_ot_dv(this, idvfl, idvprint)
1030 class(gwfcsubtype) :: this
1031 integer(I4B), intent(in) :: idvfl !< flag to save dependent variable data
1032 integer(I4B), intent(in) :: idvprint !< flag to print dependent variable data
1033 end subroutine csub_ot_dv
1034
1035 module subroutine csub_cg_chk_stress(this)
1036 class(gwfcsubtype) :: this
1037 end subroutine csub_cg_chk_stress
1038
1039 ! -- observations (submodules/gwf-csub-obs.f90)
1040
1041 module logical function csub_obs_supported(this)
1042 class(gwfcsubtype) :: this
1043 end function csub_obs_supported
1044
1045 module subroutine csub_df_obs(this)
1046 class(gwfcsubtype) :: this
1047 end subroutine csub_df_obs
1048
1049 module subroutine csub_bd_obs(this)
1050 class(gwfcsubtype), intent(inout) :: this
1051 end subroutine csub_bd_obs
1052
1053 module subroutine csub_rp_obs(this)
1054 class(gwfcsubtype), intent(inout) :: this
1055 end subroutine csub_rp_obs
1056
1057 module subroutine csub_process_obsid(obsrv, dis, inunitobs, iout)
1058 type(observetype), intent(inout) :: obsrv !< observation type
1059 class(disbasetype), intent(in) :: dis !< pointer to the model discretization
1060 integer(I4B), intent(in) :: inunitobs !< unit number of the observation file
1061 integer(I4B), intent(in) :: iout !< unit number to the model listing file
1062 end subroutine csub_process_obsid
1063
1064 end interface
1065
1066contains
1067
1068 !> @brief Create a new package object
1069 !!
1070 !! Create a new CSUB object
1071 !!
1072 !<
1073 subroutine csub_cr(csubobj, name_model, mempath, istounit, stoPckName, inunit, &
1074 iout)
1075 ! -- dummy variables
1076 type(gwfcsubtype), pointer :: csubobj !< pointer to default package type
1077 character(len=*), intent(in) :: name_model !< model name
1078 character(len=*), intent(in) :: mempath !< input context mem path
1079 integer(I4B), intent(in) :: inunit !< unit number of csub input file
1080 integer(I4B), intent(in) :: istounit !< unit number of storage package
1081 character(len=*), intent(in) :: stopckname !< name of the storage package
1082 integer(I4B), intent(in) :: iout !< unit number of lst output file
1083 ! -- local variables
1084 !
1085 ! -- allocate the object and assign values to object variables
1086 allocate (csubobj)
1087
1088 ! -- create name and memory path
1089 call csubobj%set_names(1, name_model, 'CSUB', 'CSUB', mempath)
1090 !
1091 ! -- Allocate scalars
1092 call csubobj%csub_allocate_scalars()
1093 !
1094 ! -- Create memory path to variables from STO package
1095 csubobj%stoMemPath = create_mem_path(name_model, stopckname)
1096 !
1097 ! -- Set variables
1098 csubobj%istounit = istounit
1099 csubobj%inunit = inunit
1100 csubobj%iout = iout
1101 end subroutine csub_cr
1102
1103 !> @brief Allocate and read method for package
1104 !!
1105 !! Method to allocate and read static data for the CSUB package.
1106 !!
1107 !<
1108 subroutine csub_ar(this, dis, ibound)
1109 ! -- modules
1111 use constantsmodule, only: linelength
1112 use kindmodule, only: i4b
1113 ! -- dummy variables
1114 class(gwfcsubtype), intent(inout) :: this
1115 class(disbasetype), pointer, intent(in) :: dis !< model discretization
1116 integer(I4B), dimension(:), pointer, contiguous :: ibound !< model ibound array
1117 ! -- local variables
1118 character(len=20) :: cellid
1119 integer(I4B) :: idelay
1120 integer(I4B) :: ib
1121 integer(I4B) :: node
1122 integer(I4B) :: n
1123 integer(I4B) :: istoerr
1124 real(DP) :: top
1125 real(DP) :: bot
1126 real(DP) :: thick
1127 real(DP) :: cg_ske_cr
1128 real(DP) :: theta
1129 real(DP) :: v
1130 real(DP) :: vtot
1131 real(DP) :: cell_thickness
1132 real(DP) :: overshoot
1133 real(DP) :: f
1134 real(DP) :: rval
1135 ! -- format
1136 character(len=*), parameter :: fmtcsub = &
1137 "(1x,/1x,'CSUB -- COMPACTION PACKAGE, VERSION 1.15, 7/27/2026', &
1138 &' INPUT READ FROM MEMPATH: ', A, /)"
1139 !
1140 ! --print a message identifying the csub package.
1141 write (this%iout, fmtcsub) this%input_mempath
1142 !
1143 ! -- store pointers to arguments that were passed in
1144 this%dis => dis
1145 this%ibound => ibound
1146 !
1147 ! -- create obs package
1148 call obs_cr(this%obs, this%inobspkg)
1149 !
1150 ! -- source csub options
1151 call this%source_options()
1152 !
1153 ! -- source the csub dimensions
1154 call this%source_dimensions()
1155 !
1156 ! - observation data
1157 call this%obs%obs_ar()
1158 !
1159 ! -- terminate if errors dimensions block data
1160 if (count_errors() > 0) then
1161 call store_error_filename(this%input_fname)
1162 end if
1163
1164 ! -- Allocate arrays in
1165 call this%csub_allocate_arrays()
1166 !
1167 ! -- source griddata
1168 call this%csub_source_griddata()
1169 !
1170 ! -- evaluate the coarse-grained material properties and if
1171 ! non-zero specific storage values are specified in the
1172 ! STO package
1173 istoerr = 0
1174 do node = 1, this%dis%nodes
1175 call this%dis%noder_to_string(node, cellid)
1176 cg_ske_cr = this%cg_ske_cr(node)
1177 theta = this%cg_thetaini(node)
1178 !
1179 ! -- coarse-grained storage error condition
1180 if (cg_ske_cr < dzero) then
1181 write (errmsg, '(a,g0,a,1x,a,1x,a,a)') &
1182 'Coarse-grained material CG_SKE_CR (', cg_ske_cr, ') is less', &
1183 'than zero in cell', trim(adjustl(cellid)), '.'
1184 end if
1185 !
1186 ! -- storage (STO) package error condition
1187 if (this%stoss(node) /= dzero) then
1188 istoerr = 1
1189 end if
1190 !
1191 ! -- porosity error condition
1192 if (theta > done .or. theta < dzero) then
1193 write (errmsg, '(a,g0,a,1x,a,1x,a,a)') &
1194 'Coarse-grained material THETA (', theta, ') is less', &
1195 'than zero or greater than 1 in cell', trim(adjustl(cellid)), '.'
1196 end if
1197 end do
1198 !
1199 ! -- write single message if storage (STO) package has non-zero specific
1200 ! storage values
1201 if (istoerr /= 0) then
1202 write (errmsg, '(a,3(1x,a))') &
1203 'Specific storage values in the storage (STO) package must', &
1204 'be zero in all active cells when using the', &
1205 trim(adjustl(this%packName)), &
1206 'package.'
1207 call store_error(errmsg)
1208 end if
1209 !
1210 ! -- source interbed data
1211 if (this%ninterbeds > 0) then
1212 call this%csub_source_packagedata()
1213 end if
1214 !
1215 ! setup package convergence tables
1216 call this%csub_initialize_tables()
1217 !
1218 ! -- calculate the coarse-grained material thickness without the interbeds
1219 do node = 1, this%dis%nodes
1220 top = this%dis%top(node)
1221 bot = this%dis%bot(node)
1222 this%cg_thickini(node) = top - bot
1223 this%cell_thick(node) = top - bot
1224 end do
1225 !
1226 ! -- subtract the interbed thickness from aquifer thickness
1227 do ib = 1, this%ninterbeds
1228 node = this%nodelist(ib)
1229 idelay = this%idelay(ib)
1230 if (idelay == 0) then
1231 v = this%thickini(ib)
1232 else
1233 v = this%rnb(ib) * this%thickini(ib)
1234 end if
1235 this%cg_thickini(node) = this%cg_thickini(node) - v
1236 end do
1237 !
1238 ! -- evaluate if the interbed thicknesses in a cell exceed the cell
1239 ! thickness (cg_thickini < 0). A small excess (numerical roundoff in the
1240 ! summed interbed thicknesses) is resolved by proportionally scaling the
1241 ! cell's interbed thicknesses to fit; a larger excess is a genuine
1242 ! over-specification and is an error
1243 do node = 1, this%dis%nodes
1244 thick = this%cg_thickini(node)
1245 if (thick >= dzero) cycle
1246 cell_thickness = this%cell_thick(node)
1247 overshoot = -thick
1248 if (overshoot <= dem5 * cell_thickness) then
1249 ! -- roundoff: scale the cell's interbed thicknesses so they fill the
1250 ! cell exactly (cell_thickness - thick is the summed interbed
1251 ! thickness, which exceeds cell_thickness by overshoot)
1252 f = cell_thickness / (cell_thickness - thick)
1253 do ib = 1, this%ninterbeds
1254 if (node /= this%nodelist(ib)) cycle
1255 this%thickini(ib) = this%thickini(ib) * f
1256 if (this%iupdatematprop /= 0) then
1257 this%thick(ib) = this%thick(ib) * f
1258 end if
1259 idelay = this%idelay(ib)
1260 if (idelay /= 0) then
1261 rval = this%thickini(ib) / real(this%ndelaycells, dp)
1262 do n = 1, this%ndelaycells
1263 this%dbdzini(n, idelay) = rval
1264 this%dbdz(n, idelay) = rval
1265 this%dbdz0(n, idelay) = rval
1266 end do
1267 ! -- recompute delay-bed cell elevations from the scaled thickness
1268 call this%csub_delay_init_zcell(ib)
1269 end if
1270 end do
1271 this%cg_thickini(node) = dzero
1272 else
1273 call this%dis%noder_to_string(node, cellid)
1274 write (errmsg, '(a,g0,a,1x,a,a)') &
1275 'Coarse grained material thickness is less than zero (', &
1276 thick, ') in cell', trim(adjustl(cellid)), '. Interbed thicknesses:'
1277
1278 vtot = dzero
1279 do ib = 1, this%ninterbeds
1280 if (node /= this%nodelist(ib)) then
1281 cycle
1282 end if
1283 idelay = this%idelay(ib)
1284 v = this%thickini(ib)
1285 if (idelay /= 0) then
1286 v = v * this%rnb(ib)
1287 end if
1288 vtot = vtot + v
1289 write (errmsg, '(a,1x,a,i0,a,g0)') &
1290 trim(adjustl(errmsg)), &
1291 'icbno(', ib, ')=', v
1292 end do
1293 write (errmsg, '(a,a,g0,a)') &
1294 trim(adjustl(errmsg)), &
1295 '. Total interbed thickness=', vtot, '.'
1296 call store_error(errmsg)
1297 end if
1298 end do
1299 !
1300 ! -- terminate if errors griddata, packagedata blocks, TDIS, or STO data
1301 if (count_errors() > 0) then
1302 call store_error_filename(this%input_fname)
1303 end if
1304 !
1305 ! -- set current coarse-grained thickness (cg_thick) and
1306 ! current coarse-grained porosity (cg_theta). Only needed
1307 ! if updating material properties
1308 if (this%iupdatematprop /= 0) then
1309 do node = 1, this%dis%nodes
1310 this%cg_thick(node) = this%cg_thickini(node)
1311 this%cg_theta(node) = this%cg_thetaini(node)
1312 end do
1313 end if
1314 end subroutine csub_ar
1315
1316 !> @brief Read and prepare stress period data for package
1317 !!
1318 !! Method reads and prepares stress period data for the CSUB package.
1319 !! The overlying geostatic stress (sig0) is the only stress period data
1320 !! read by the CSUB package.
1321 !!
1322 !<
1323 subroutine csub_rp(this)
1324 ! -- modules
1325 use tdismodule, only: kper
1326 use constantsmodule, only: linelength
1329 ! -- dummy variables
1330 class(gwfcsubtype), intent(inout) :: this
1331 ! -- local variables
1332 integer(I4B), dimension(:, :), pointer, contiguous :: cellids
1333 integer(I4B), dimension(:), pointer, contiguous :: cellid
1334 integer(I4B), pointer :: iper
1335 integer(I4B) :: n, nodeu, noder
1336 character(len=LINELENGTH) :: title, text
1337 character(len=20) :: cellstr
1338 logical(LGP) :: found
1339 ! -- formats
1340 character(len=*), parameter :: fmtlsp = &
1341 &"(1X,/1X,'REUSING ',a,'S FROM LAST STRESS PERIOD')"
1342
1343 call mem_setptr(iper, 'IPER', this%input_mempath)
1344 if (iper /= kper) then
1345 write (this%iout, fmtlsp) trim(this%filtyp)
1346 call this%csub_rp_obs()
1347 return
1348 end if
1349
1350 call mem_setptr(cellids, 'CELLID', this%input_mempath)
1351 call mem_set_value(this%nbound, 'NBOUND', this%input_mempath, &
1352 found, release=.false.)
1353
1354 ! -- setup table for period data
1355 if (this%iprpak /= 0) then
1356 ! -- reset the input table object
1357 title = 'CSUB'//' PACKAGE ('// &
1358 trim(adjustl(this%packName))//') DATA FOR PERIOD'
1359 write (title, '(a,1x,i6)') trim(adjustl(title)), kper
1360 call table_cr(this%inputtab, this%packName, title)
1361 call this%inputtab%table_df(1, 2, this%iout, finalize=.false.)
1362 text = 'CELLID'
1363 call this%inputtab%initialize_column(text, 20)
1364 text = 'SIG0'
1365 call this%inputtab%initialize_column(text, 15, alignment=tableft)
1366 end if
1367
1368 ! -- update nodelist
1369 do n = 1, this%nbound
1370
1371 ! -- set cellid
1372 cellid => cellids(:, n)
1373
1374 ! -- set user node number
1375 if (this%dis%ndim == 1) then
1376 nodeu = cellid(1)
1377 elseif (this%dis%ndim == 2) then
1378 nodeu = get_node(cellid(1), 1, cellid(2), &
1379 this%dis%mshape(1), 1, &
1380 this%dis%mshape(2))
1381 else
1382 nodeu = get_node(cellid(1), cellid(2), cellid(3), &
1383 this%dis%mshape(1), &
1384 this%dis%mshape(2), &
1385 this%dis%mshape(3))
1386 end if
1387
1388 ! -- set noder
1389 noder = this%dis%get_nodenumber(nodeu, 1)
1390 if (noder <= 0) then
1391 cycle
1392 end if
1393
1394 this%nodelistsig0(n) = noder
1395
1396 ! -- write line to table
1397 if (this%iprpak /= 0) then
1398 call this%dis%noder_to_string(noder, cellstr)
1399 call this%inputtab%add_term(cellstr)
1400 call this%inputtab%add_term(this%sig0(n))
1401 end if
1402 end do
1403 !
1404 ! -- terminate if errors encountered
1405 if (count_errors() > 0) then
1406 call store_error_filename(this%input_fname)
1407 end if
1408 !
1409 ! -- finalize the table
1410 if (this%iprpak /= 0) then
1411 call this%inputtab%finalize_table()
1412 end if
1413 !
1414 ! -- read observations
1415 call this%csub_rp_obs()
1416 end subroutine csub_rp
1417
1418 !> @brief Advance the package
1419 !!
1420 !! Advance data in the CSUB package. The method sets data for the previous
1421 !! time step to the current value for the data (e.g., HOLD = HNEW). The
1422 !! method also calls the method to initialize the initial stress conditions
1423 !! if this is the first transient stress period.
1424 !!
1425 !<
1426 subroutine csub_ad(this, nodes, hnew)
1427 ! -- modules
1428 use tdismodule, only: nper, kper
1429 ! -- dummy variables
1430 class(gwfcsubtype) :: this
1431 integer(I4B), intent(in) :: nodes !< number of active model nodes
1432 real(DP), dimension(nodes), intent(in) :: hnew !< current head
1433 ! -- local variables
1434 integer(I4B) :: ib
1435 integer(I4B) :: n
1436 integer(I4B) :: idelay
1437 integer(I4B) :: node
1438 real(DP) :: h
1439 real(DP) :: es
1440 real(DP) :: pcs
1441 !
1442 ! -- evaluate if steady-state stress periods are specified for more
1443 ! than the first and last stress period if interbeds are simulated
1444 if (this%ninterbeds > 0) then
1445 if (kper > 1 .and. kper < nper) then
1446 if (this%gwfiss /= 0) then
1447 write (errmsg, '(a,i0,a,1x,a,1x,a,1x,i0,1x,a)') &
1448 'Only the first and last (', nper, ')', &
1449 'stress period can be steady if interbeds are simulated.', &
1450 'Stress period', kper, 'has been defined to be steady state.'
1451 call store_error(errmsg, terminate=.true.)
1452 end if
1453 end if
1454 end if
1455 !
1456 ! -- set initial states
1457 if (this%initialized == 0) then
1458 if (this%gwfiss == 0) then
1459 call this%csub_set_initial_state(nodes, hnew)
1460 end if
1461 end if
1462 !
1463 ! -- update state variables
1464 !
1465 ! -- coarse-grained materials
1466 do node = 1, nodes
1467 this%cg_comp(node) = dzero
1468 this%cg_es0(node) = this%cg_es(node)
1469 if (this%iupdatematprop /= 0) then
1470 this%cg_thick0(node) = this%cg_thick(node)
1471 this%cg_theta0(node) = this%cg_theta(node)
1472 end if
1473 end do
1474 !
1475 ! -- interbeds
1476 do ib = 1, this%ninterbeds
1477 idelay = this%idelay(ib)
1478 !
1479 ! -- update common terms for no-delay and delay interbeds
1480 this%comp(ib) = dzero
1481 node = this%nodelist(ib)
1482 if (this%initialized /= 0) then
1483 es = this%cg_es(node)
1484 pcs = this%pcs(ib)
1485 if (es > pcs) then
1486 this%pcs(ib) = es
1487 end if
1488 end if
1489 if (this%iupdatematprop /= 0) then
1490 this%thick0(ib) = this%thick(ib)
1491 this%theta0(ib) = this%theta(ib)
1492 end if
1493 !
1494 ! -- update delay interbed terms
1495 if (idelay /= 0) then
1496 !
1497 ! -- update state if previous period was steady state
1498 if (kper > 1) then
1499 if (this%gwfiss0 /= 0) then
1500 node = this%nodelist(ib)
1501 h = hnew(node)
1502 do n = 1, this%ndelaycells
1503 this%dbh(n, idelay) = h
1504 end do
1505 end if
1506 end if
1507 !
1508 ! -- update preconsolidation stress, stresses, head, dbdz0, and theta0
1509 do n = 1, this%ndelaycells
1510 ! update preconsolidation stress
1511 if (this%initialized /= 0) then
1512 if (this%dbes(n, idelay) > this%dbpcs(n, idelay)) then
1513 this%dbpcs(n, idelay) = this%dbes(n, idelay)
1514 end if
1515 end if
1516 this%dbh0(n, idelay) = this%dbh(n, idelay)
1517 this%dbes0(n, idelay) = this%dbes(n, idelay)
1518 if (this%iupdatematprop /= 0) then
1519 this%dbdz0(n, idelay) = this%dbdz(n, idelay)
1520 this%dbtheta0(n, idelay) = this%dbtheta(n, idelay)
1521 end if
1522 end do
1523 end if
1524 end do
1525 !
1526 ! -- set gwfiss0
1527 this%gwfiss0 = this%gwfiss
1528 !
1529 ! -- For each observation, push simulated value and corresponding
1530 ! simulation time from "current" to "preceding" and reset
1531 ! "current" value.
1532 call this%obs%obs_ad()
1533 end subroutine csub_ad
1534
1535 !> @brief Fill A and r for the package
1536 !!
1537 !! Fill the coefficient matrix and right-hand side with the CSUB package terms.
1538 !!
1539 !<
1540 subroutine csub_fc(this, kiter, hold, hnew, matrix_sln, idxglo, rhs)
1541 ! -- modules
1542 use tdismodule, only: delt
1543 ! -- dummy variables
1544 class(gwfcsubtype) :: this
1545 integer(I4B), intent(in) :: kiter !< outer iteration numbed
1546 real(DP), intent(in), dimension(:) :: hold !< previous heads
1547 real(DP), intent(in), dimension(:) :: hnew !< current heads
1548 class(matrixbasetype), pointer :: matrix_sln !< A matrix
1549 integer(I4B), intent(in), dimension(:) :: idxglo !< global index model to solution
1550 real(DP), intent(inout), dimension(:) :: rhs !< right-hand side
1551 ! -- local variables
1552 integer(I4B) :: ib
1553 integer(I4B) :: node
1554 integer(I4B) :: idiag
1555 integer(I4B) :: idelay
1556 real(DP) :: tled
1557 real(DP) :: area
1558 real(DP) :: hcof
1559 real(DP) :: rhsterm
1560 real(DP) :: comp
1561 !
1562 ! -- update geostatic load calculation
1563 call this%csub_cg_calc_stress(this%dis%nodes, hnew)
1564 !
1565 ! -- formulate csub terms
1566 if (this%gwfiss == 0) then
1567 !
1568 ! -- initialize tled
1569 tled = done / delt
1570 !
1571 ! -- coarse-grained storage
1572 do node = 1, this%dis%nodes
1573 idiag = this%dis%con%ia(node)
1574 area = this%dis%get_area(node)
1575 !
1576 ! -- skip inactive cells
1577 if (this%ibound(node) < 1) cycle
1578 !
1579 ! -- update coarse-grained material properties
1580 if (this%iupdatematprop /= 0) then
1581 if (this%ieslag == 0) then
1582 !
1583 ! -- calculate compaction
1584 call this%csub_cg_calc_comp(node, hnew(node), hold(node), comp)
1585 this%cg_comp(node) = comp
1586 !
1587 ! -- update coarse-grained thickness and void ratio
1588 call this%csub_cg_update(node)
1589 end if
1590 end if
1591 !
1592 ! -- calculate coarse-grained storage terms
1593 call this%csub_cg_fc(node, tled, area, hnew(node), hold(node), &
1594 hcof, rhsterm)
1595 !
1596 ! -- add coarse-grained storage terms to amat and rhs for coarse-grained storage
1597 call matrix_sln%add_value_pos(idxglo(idiag), hcof)
1598 rhs(node) = rhs(node) + rhsterm
1599 !
1600 ! -- calculate coarse-grained water compressibility
1601 ! storage terms
1602 if (this%brg /= dzero) then
1603 call this%csub_cg_wcomp_fc(node, tled, area, hnew(node), hold(node), &
1604 hcof, rhsterm)
1605 !
1606 ! -- add water compression storage terms to amat and rhs for
1607 ! coarse-grained storage
1608 call matrix_sln%add_value_pos(idxglo(idiag), hcof)
1609 rhs(node) = rhs(node) + rhsterm
1610 end if
1611 end do
1612 !
1613 ! -- interbed storage
1614 if (this%ninterbeds /= 0) then
1615 !
1616 ! -- calculate the contribution of interbeds to the
1617 ! groundwater flow equation
1618 do ib = 1, this%ninterbeds
1619 node = this%nodelist(ib)
1620 idelay = this%idelay(ib)
1621 idiag = this%dis%con%ia(node)
1622 area = this%dis%get_area(node)
1623 call this%csub_interbed_fc(ib, node, area, hnew(node), hold(node), &
1624 hcof, rhsterm)
1625 call matrix_sln%add_value_pos(idxglo(idiag), hcof)
1626 rhs(node) = rhs(node) + rhsterm
1627 !
1628 ! -- calculate interbed water compressibility terms
1629 if (.not. is_close(this%brg, dzero) .and. idelay == 0) then
1630 call this%csub_nodelay_wcomp_fc(ib, node, tled, area, &
1631 hnew(node), hold(node), &
1632 hcof, rhsterm)
1633 !
1634 ! -- add water compression storage terms to amat and rhs for interbed
1635 call matrix_sln%add_value_pos(idxglo(idiag), hcof)
1636 rhs(node) = rhs(node) + rhsterm
1637 end if
1638 end do
1639 end if
1640 end if
1641 !
1642 ! -- terminate if errors encountered when updating material properties
1643 if (count_errors() > 0) then
1644 call store_error_filename(this%input_fname)
1645 end if
1646 end subroutine csub_fc
1647
1648 !> @brief Fill Newton-Raphson terms in A and r for the package
1649 !!
1650 !! Fill the coefficient matrix and right-hand side with CSUB package
1651 !! with Newton-Raphson terms.
1652 !<
1653 subroutine csub_fn(this, kiter, hold, hnew, matrix_sln, idxglo, rhs)
1654 ! -- modules
1655 use tdismodule, only: delt
1656 ! -- dummy variables
1657 class(gwfcsubtype) :: this
1658 integer(I4B), intent(in) :: kiter !< outer iteration number
1659 real(DP), intent(in), dimension(:) :: hold !< previous heads
1660 real(DP), intent(in), dimension(:) :: hnew !< current heads
1661 class(matrixbasetype), pointer :: matrix_sln !< A matrix
1662 integer(I4B), intent(in), dimension(:) :: idxglo !< global index model to solution
1663 real(DP), intent(inout), dimension(:) :: rhs !< right-hand side
1664 ! -- local variables
1665 integer(I4B) :: idelay
1666 integer(I4B) :: node
1667 integer(I4B) :: idiag
1668 integer(I4B) :: ib
1669 real(DP) :: tled
1670 real(DP) :: area
1671 real(DP) :: hcof
1672 real(DP) :: rhsterm
1673 !
1674 ! -- formulate csub terms
1675 if (this%gwfiss == 0) then
1676 tled = done / delt
1677 !
1678 ! -- coarse-grained storage
1679 do node = 1, this%dis%nodes
1680 idiag = this%dis%con%ia(node)
1681 area = this%dis%get_area(node)
1682 !
1683 ! -- skip inactive cells
1684 if (this%ibound(node) < 1) cycle
1685 !
1686 ! -- calculate coarse-grained storage newton terms
1687 call this%csub_cg_fn(node, tled, area, &
1688 hnew(node), hcof, rhsterm)
1689 !
1690 ! -- add coarse-grained storage newton terms to amat and rhs for
1691 ! coarse-grained storage
1692 call matrix_sln%add_value_pos(idxglo(idiag), hcof)
1693 rhs(node) = rhs(node) + rhsterm
1694 !
1695 ! -- calculate coarse-grained water compressibility storage
1696 ! newton terms
1697 if (this%brg /= dzero) then
1698 call this%csub_cg_wcomp_fn(node, tled, area, hnew(node), hold(node), &
1699 hcof, rhsterm)
1700 !
1701 ! -- add water compression storage newton terms to amat and rhs for
1702 ! coarse-grained storage
1703 call matrix_sln%add_value_pos(idxglo(idiag), hcof)
1704 rhs(node) = rhs(node) + rhsterm
1705 end if
1706 end do
1707 !
1708 ! -- interbed storage
1709 if (this%ninterbeds /= 0) then
1710 !
1711 ! -- calculate the interbed newton terms for the
1712 ! groundwater flow equation
1713 do ib = 1, this%ninterbeds
1714 idelay = this%idelay(ib)
1715 node = this%nodelist(ib)
1716 !
1717 ! -- skip inactive cells
1718 if (this%ibound(node) < 1) cycle
1719 !
1720 ! -- calculate interbed newton terms
1721 idiag = this%dis%con%ia(node)
1722 area = this%dis%get_area(node)
1723 call this%csub_interbed_fn(ib, node, area, hnew(node), hold(node), &
1724 hcof, rhsterm)
1725 !
1726 ! -- add interbed newton terms to amat and rhs
1727 call matrix_sln%add_value_pos(idxglo(idiag), hcof)
1728 rhs(node) = rhs(node) + rhsterm
1729 !
1730 ! -- calculate interbed water compressibility terms
1731 if (this%brg /= dzero .and. idelay == 0) then
1732 call this%csub_nodelay_wcomp_fn(ib, node, tled, area, &
1733 hnew(node), hold(node), &
1734 hcof, rhsterm)
1735 !
1736 ! -- add interbed water compression newton terms to amat and rhs
1737 call matrix_sln%add_value_pos(idxglo(idiag), hcof)
1738 rhs(node) = rhs(node) + rhsterm
1739 end if
1740 end do
1741 end if
1742 end if
1743 end subroutine csub_fn
1744
1745 !> @brief Calculate the interbed thickness
1746 !!
1747 !! Function to calculate the interbed thickness.
1748 !!
1749 !! @return thick interbed thickness
1750 !<
1751 function csub_calc_interbed_thickness(this, ib) result(thick)
1752 ! -- dummy variables
1753 class(gwfcsubtype), intent(inout) :: this
1754 integer(I4B), intent(in) :: ib !< interbed number
1755 ! -- local variables
1756 integer(I4B) :: idelay
1757 real(dp) :: thick
1758 !
1759 ! -- calculate interbed thickness
1760 idelay = this%idelay(ib)
1761 thick = this%thick(ib)
1762 if (idelay /= 0) then
1763 thick = thick * this%rnb(ib)
1764 end if
1765 end function csub_calc_interbed_thickness
1766
1767 !> @brief Calculate the cell node
1768 !!
1769 !! Function to calculate elevation of the node between the specified corrected
1770 !! elevation zbar and the bottom elevation. If zbar is greater than the top
1771 !! elevation, the node elevation is halfway between the top and bottom
1772 !! elevations. The corrected elevation (zbar) is always greater than or
1773 !! equal to bottom.
1774 !!
1775 !! @return znode node elevation
1776 !<
1777 function csub_calc_znode(this, top, bottom, zbar) result(znode)
1778 ! -- dummy variables
1779 class(gwfcsubtype), intent(inout) :: this
1780 real(dp), intent(in) :: top !< top of cell
1781 real(dp), intent(in) :: bottom !< bottom of cell
1782 real(dp), intent(in) :: zbar !< corrected elevation
1783 ! -- local variables
1784 real(dp) :: znode
1785 real(dp) :: v
1786 !
1787 ! -- calculate the node elevation
1788 if (zbar > top) then
1789 v = top
1790 else
1791 v = zbar
1792 end if
1793 znode = dhalf * (v + bottom)
1794 end function csub_calc_znode
1795
1796 !> @brief Calculate cell saturation
1797 !!
1798 !! Method to calculate the cell saturation for the current and
1799 !! previous time step.
1800 !<
1801 subroutine csub_calc_sat(this, node, hcell, hcellold, snnew, snold)
1802 ! -- dummy variables
1803 class(gwfcsubtype), intent(inout) :: this
1804 integer(I4B), intent(in) :: node !< cell node number
1805 real(DP), intent(in) :: hcell !< current head
1806 real(DP), intent(in) :: hcellold !< previous head
1807 real(DP), intent(inout) :: snnew !< current saturation
1808 real(DP), intent(inout) :: snold !< previous saturation
1809 ! -- local variables
1810 real(DP) :: top
1811 real(DP) :: bot
1812 !
1813 ! -- calculate cell saturation
1814 if (this%stoiconv(node) /= 0) then
1815 top = this%dis%top(node)
1816 bot = this%dis%bot(node)
1817 snnew = squadraticsaturation(top, bot, hcell, this%satomega)
1818 snold = squadraticsaturation(top, bot, hcellold, this%satomega)
1819 else
1820 snnew = done
1821 snold = done
1822 end if
1823 if (this%ieslag /= 0) then
1824 snold = snnew
1825 end if
1826 end subroutine csub_calc_sat
1827
1828 !> @brief Calculate the saturation derivative
1829 !!
1830 !! Function to calculate the derivative of the saturation with
1831 !! respect to the current head.
1832 !!
1833 !! @return satderv derivative of saturation
1834 !<
1835 function csub_calc_sat_derivative(this, node, hcell) result(satderv)
1836 ! -- dummy variables
1837 class(gwfcsubtype), intent(inout) :: this
1838 integer(I4B), intent(in) :: node !< cell node number
1839 real(dp), intent(in) :: hcell !< current head
1840 ! -- local variables
1841 real(dp) :: satderv
1842 real(dp) :: top
1843 real(dp) :: bot
1844
1845 if (this%stoiconv(node) /= 0) then
1846 top = this%dis%top(node)
1847 bot = this%dis%bot(node)
1848 satderv = squadraticsaturationderivative(top, bot, hcell, this%satomega)
1849 else
1850 satderv = dzero
1851 end if
1852 end function csub_calc_sat_derivative
1853
1854 !> @brief Calculate specific storage coefficient factor
1855 !!
1856 !! Method to calculate the factor that is used to calculate skeletal
1857 !! specific storage coefficients. Can be used for coarse-grained
1858 !! materials and interbeds.
1859 !<
1860 subroutine csub_calc_sfacts(this, node, bot, znode, theta, es, es0, geo, fact)
1861 ! -- dummy variables
1862 class(gwfcsubtype), intent(inout) :: this
1863 integer(I4B), intent(in) :: node !< cell node number
1864 real(DP), intent(in) :: bot !
1865 real(DP), intent(in) :: znode
1866 real(DP), intent(in) :: theta !< porosity
1867 real(DP), intent(in) :: es !< current effective stress
1868 real(DP), intent(in) :: es0 !< previous effective stress
1869 real(DP), intent(in) :: geo !< geostatic stress (regularization reference)
1870 real(DP), intent(inout) :: fact !< skeletal storage coefficient factor (1/((1+void_ratio)*bar(es)))
1871 ! -- local variables
1872 real(DP) :: esv
1873 real(DP) :: adjes
1874 real(DP) :: esfloor
1875 !
1876 ! -- initialize variables
1877 fact = dzero
1878 if (this%ieslag /= 0) then
1879 esv = es0
1880 else
1881 esv = es
1882 end if
1883 !
1884 ! -- effective stress adjusted to the vertical node position
1885 adjes = adjust_eff_stress(esv, bot, znode, this%sgs(node))
1886 !
1887 ! -- smoothly floor the adjusted effective stress at stressfloor * geo so the
1888 ! storage factor (1/es) stays bounded and positive as es approaches zero;
1889 ! unchanged above the floor, disabled by STRICT_EFFECTIVE_STRESS
1890 if (this%istrict_stress == 0 .and. geo > dzero) then
1891 esfloor = stressfloor * geo
1892 adjes = squadratic0sp(adjes, esfloor, esfloor)
1893 end if
1894 !
1895 ! -- calculate storage factors for the effective stress case
1896 fact = storage_factor(adjes, theta)
1897 end subroutine csub_calc_sfacts
1898
1899end module gwfcsubmodule
subroutine source_options(this, iout)
Source options.
subroutine source_dimensions(this, iout)
Source dimension from input context.
This module contains the BudgetModule.
Definition Budget.f90:20
Relations for compacting porous materials.
pure real(dp) function, public wcomp_newton_term(wc, wc0, h, h0, satderv, lagged)
Calculate the Newton-Raphson term for water compressibility.
pure real(dp) function, public porosity_to_void_ratio(theta)
Calculate the void ratio from the porosity.
pure subroutine, public compact_layer(comp, thick, theta)
Update the thickness and porosity of a layer after compaction.
pure real(dp) function, public storage_newton_term(rho, rho0, sn, satderv, hbarderv, es, es0, pcs, lagged)
Calculate the Newton-Raphson term for skeletal storage.
pure real(dp) function, public adjust_eff_stress(es0, z0, z, sgs)
Calculate the effective stress at elevation z from its value at z0.
pure real(dp) function, public storage_factor(es, theta)
Calculate the skeletal storage factor, 1 / ((1 + void ratio) es).
This module contains simulation constants.
Definition Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition Constants.f90:45
@ tabcenter
centered table column
@ tabright
right justified table column
@ tableft
left justified table column
real(dp), parameter dem20
real constant 1e-20
@ tabucstring
upper case string table data
@ tabstring
string table data
@ tabreal
real table data
@ tabinteger
integer table data
integer(i4b), parameter lenpackagename
maximum length of the package name
Definition Constants.f90:23
real(dp), parameter dp9
real constant 9/10
Definition Constants.f90:72
real(dp), parameter dem10
real constant 1e-10
real(dp), parameter dem7
real constant 1e-7
real(dp), parameter dem8
real constant 1e-8
integer(i4b), parameter namedboundflag
named bound flag
Definition Constants.f90:49
real(dp), parameter dnodata
real no data constant
Definition Constants.f90:95
real(dp), parameter dhnoflo
real no flow constant
Definition Constants.f90:93
integer(i4b), parameter lenlistlabel
maximum length of a llist label
Definition Constants.f90:46
real(dp), parameter dhundred
real constant 100
Definition Constants.f90:86
integer(i4b), parameter lenpakloc
maximum length of a package location
Definition Constants.f90:50
@ dis
DIS6 discretization.
real(dp), parameter dem1
real constant 1e-1
real(dp), parameter dhalf
real constant 1/2
Definition Constants.f90:68
integer(i4b), parameter lenftype
maximum length of a package type (DIS, WEL, OC, etc.)
Definition Constants.f90:39
real(dp), parameter dgravity
real constant gravitational acceleration (m/(s s))
integer(i4b), parameter lenauxname
maximum length of a aux variable
Definition Constants.f90:35
real(dp), parameter dem3
real constant 1e-3
integer(i4b), parameter lenboundname
maximum length of a bound name
Definition Constants.f90:36
real(dp), parameter dem4
real constant 1e-4
real(dp), parameter dem6
real constant 1e-6
real(dp), parameter dzero
real constant zero
Definition Constants.f90:65
real(dp), parameter dem5
real constant 1e-5
real(dp), parameter dten
real constant 10
Definition Constants.f90:84
real(dp), parameter dprec
real constant machine precision
real(dp), parameter dem15
real constant 1e-15
real(dp), parameter dtwo
real constant 2
Definition Constants.f90:79
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
Definition Constants.f90:37
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition Constants.f90:27
real(dp), parameter dthree
real constant 3
Definition Constants.f90:80
real(dp), parameter done
real constant 1
Definition Constants.f90:76
integer(i4b) function, public get_node(ilay, irow, icol, nlay, nrow, ncol)
Get node number, given layer, row, and column indices for a structured grid. If any argument is inval...
Definition GeomUtil.f90:92
real(dp) function, public area(xv, yv, cw)
Calculate polygon area, with vertices given in CW or CCW order.
Definition GeomUtil.f90:364
This module contains the CSUB package methods.
Definition gwf-csub.f90:23
subroutine csub_ar(this, dis, ibound)
Allocate and read method for package.
real(dp) function csub_calc_sat_derivative(this, node, hcell)
Calculate the saturation derivative.
subroutine, public csub_cr(csubobj, name_model, mempath, istounit, stopckname, inunit, iout)
Create a new package object.
@ storage_elastic
effective stress not above preconsolidation stress
Definition gwf-csub.f90:73
@ storage_unset
no state recorded
Definition gwf-csub.f90:72
@ storage_inelastic
effective stress above preconsolidation stress
Definition gwf-csub.f90:74
subroutine csub_fc(this, kiter, hold, hnew, matrix_sln, idxglo, rhs)
Fill A and r for the package.
subroutine csub_calc_sat(this, node, hcell, hcellold, snnew, snold)
Calculate cell saturation.
real(dp) function csub_calc_znode(this, top, bottom, zbar)
Calculate the cell node.
real(dp) function csub_calc_interbed_thickness(this, ib)
Calculate the interbed thickness.
real(dp), parameter dlog10es
derivative of the log of effective stress
Definition gwf-csub.f90:66
subroutine csub_rp(this)
Read and prepare stress period data for package.
subroutine csub_ad(this, nodes, hnew)
Advance the package.
@ storage_input_specific_storage
specific storage coefficients
Definition gwf-csub.f90:88
@ storage_input_compression_index
compression indices
Definition gwf-csub.f90:87
@ interbed_elastic
elastic storage only
Definition gwf-csub.f90:81
@ interbed_elastic_inelastic
elastic and inelastic storage
Definition gwf-csub.f90:80
subroutine csub_calc_sfacts(this, node, bot, znode, theta, es, es0, geo, fact)
Calculate specific storage coefficient factor.
subroutine csub_fn(this, kiter, hold, hnew, matrix_sln, idxglo, rhs)
Fill Newton-Raphson terms in A and r for the package.
real(dp), parameter stressfloor
effective-stress regularization floor (fraction of geostatic stress)
Definition gwf-csub.f90:67
subroutine, public extract_idnum_or_bndname(line, icol, istart, istop, idnum, bndname)
Starting at position icol, define string as line(istart:istop).
This module defines variable data types.
Definition kind.f90:8
pure logical function, public is_close(a, b, rtol, atol, symmetric)
Check if a real value is approximately equal to another.
Definition MathUtil.f90:46
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
Store and issue logging messages to output units.
Definition Message.f90:2
subroutine, public write_message(text, iunit, fmt, skipbefore, skipafter, advance)
Write a message to an output unit.
Definition Message.f90:212
This module contains the base numerical package type.
This module contains the derived types ObserveType and ObsDataType.
Definition Observe.f90:15
This module contains the derived type ObsType.
Definition Obs.f90:127
subroutine, public obs_cr(obs, inobs)
Create a new ObsType object.
Definition Obs.f90:225
This module contains simulation methods.
Definition Sim.f90:10
subroutine, public store_warning(msg, substring)
Store warning message.
Definition Sim.f90:241
subroutine, public store_error(msg, terminate)
Store an error message.
Definition Sim.f90:94
integer(i4b) function, public count_errors()
Return number of errors.
Definition Sim.f90:60
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition Sim.f90:208
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
character(len=maxcharlen) warnmsg
warning message string
integer(i4b) iout
file unit number for simulation output
real(dp) function squadraticsaturation(top, bot, x, eps)
sQuadraticSaturation
real(dp) function squadraticsaturationderivative(top, bot, x, eps)
Derivative of the quadratic saturation function.
real(dp) function squadratic0spderivative(x, xi, tomega)
sQuadratic0spDerivative
real(dp) function squadratic0sp(x, xi, tomega)
sQuadratic0sp
subroutine, public selectn(indx, v, reverse)
Definition sort.f90:384
subroutine finalize(this)
Definition Table.f90:407
subroutine, public table_cr(this, name, title)
Definition Table.f90:87
integer(i4b), pointer, public kper
current stress period number
Definition tdis.f90:26
real(dp), pointer, public delt
length of the current time step
Definition tdis.f90:32
integer(i4b), pointer, public nper
number of stress period
Definition tdis.f90:24
Derived type for the Budget object.
Definition Budget.f90:40
subroutine log_options(this, found)
Write user options to list file.
Definition swf-dfw.f90:385