Coverage for C:\src\imod-python\imod\wq\dsp.py: 39%
23 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-08 10:26 +0200
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-08 10:26 +0200
1import jinja2
3from imod.wq.pkgbase import Package
6class Dispersion(Package):
7 """
8 Solves the concentration change due to dispersion explicitly or formulates
9 the coefficient matrix of the dispersion term for the matrix solver.
11 Parameters
12 ----------
13 longitudinal: float
14 is the longitudinal dispersivity (AL), for every cell of the model grid
15 (unit: L).
16 Default value is 1.0 m. Nota bene: this is for regional applications.
17 ratio_horizontal: float
18 is a 1D real array defining the ratio of the horizontal transverse
19 dispersivity (TRPT), to the longitudinal dispersivity. Each value in the
20 array corresponds to one model layer. Some recent field studies suggest
21 that ratio_horizontal is generally not greater than 0.1.
22 ratio_vertical: float
23 (TRPV) is the ratio of the vertical transverse dispersivity to the
24 longitudinal dispersivity. Each value in the array corresponds to one
25 model layer.
26 Some recent field studies suggest that ratio_vertical is generally not
27 greater than 0.01.
28 Set ratio_vertical equal to ratio_horizontal to use the standard
29 isotropic dispersion model. Otherwise, the modified isotropic dispersion
30 model is used.
31 diffusion_coefficient: float
32 is the effective molecular diffusion coefficient (unit: L2T-1). Set
33 diffusion_coefficient = 0 if the effect of molecular diffusion is
34 considered unimportant. Each value in the array corresponds to one model
35 layer.
37 iMOD-wq always uses meters and days.
38 """
40 _pkg_id = "dsp"
42 _mapping = (
43 ("al", "longitudinal"),
44 ("trpt", "ratio_horizontal"),
45 ("trpv", "ratio_vertical"),
46 ("dmcoef", "diffusion_coefficient"),
47 )
49 _template = jinja2.Template(
50 "[dsp]\n"
51 " {%- for name, dictname in mapping -%}\n"
52 " {%- for layer, value in dicts[dictname].items() %}\n"
53 " {{name}}_l{{layer}} = {{value}}\n"
54 " {%- endfor -%}\n"
55 " {%- endfor -%}\n"
56 )
58 def __init__(
59 self,
60 longitudinal=1.0,
61 ratio_horizontal=0.1,
62 ratio_vertical=0.1,
63 diffusion_coefficient=8.64e-5,
64 ):
65 super().__init__()
66 self["longitudinal"] = longitudinal
67 self["ratio_horizontal"] = ratio_horizontal
68 self["ratio_vertical"] = ratio_vertical
69 self["diffusion_coefficient"] = diffusion_coefficient
71 def _render(self, directory, nlayer, *args, **kwargs):
72 d = {"mapping": self._mapping}
73 dicts = {}
75 for varname in self.dataset.data_vars.keys():
76 dicts[varname] = self._compose_values_layer(
77 varname, directory, nlayer=nlayer
78 )
79 d["dicts"] = dicts
81 return self._template.render(d)
83 def _pkgcheck(self, ibound=None):
84 to_check = [
85 "longitudinal",
86 "ratio_horizontal",
87 "ratio_vertical",
88 "diffusion_coefficient",
89 ]
90 self._check_positive(to_check)
91 self._check_location_consistent(to_check)