Coverage for C:\src\imod-python\imod\wq\ghb.py: 100%
24 statements
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-08 14:15 +0200
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-08 14:15 +0200
1from imod.wq.pkgbase import BoundaryCondition
3# class GeneralHeadBoundaryGroup(object):
4# Does a groupby over packages of the same kind when writing
5# Collects total data of all same kind packages
6# adds a system number
7# This one is actually in charge of generating the output from
8# the dictionaries provided by the ._compose_values methods
9# Every system is treated independently
12class GeneralHeadBoundary(BoundaryCondition):
13 """
14 The General-Head Boundary package is used to simulate head-dependent flux
15 boundaries. In the General-Head Boundary package the flux is always
16 proportional to the difference in head.
18 Parameters
19 ----------
20 head: float or xr.DataArray of floats
21 head value for the GHB (BHEAD).
22 conductance: float or xr.DataArray of floats
23 the conductance of the GHB (COND).
24 density: float or xr.DataArray of floats
25 is the density used to convert the point head to the freshwater head
26 (GHBSSMDENS).
27 concentration: "None" or xr.DataArray of floats, optional
28 concentration of the GHB (CGHB), get automatically inserted into the SSM
29 package.
30 Default is "None".
31 save_budget: bool, optional
32 is a flag indicating if the budget should be saved (IGHBCB).
33 Default is False.
34 """
36 _pkg_id = "ghb"
37 _mapping = (("bhead", "head"), ("cond", "conductance"), ("ghbssmdens", "density"))
39 def __init__(
40 self, head, conductance, density, concentration=None, save_budget=False
41 ):
42 super().__init__()
43 self["head"] = head
44 self["conductance"] = conductance
45 self["density"] = density
46 if concentration is not None:
47 self["concentration"] = concentration
48 self["save_budget"] = save_budget
50 def _pkgcheck(self, ibound=None):
51 to_check = ["conductance", "density"]
52 if "concentration" in self.dataset.data_vars:
53 to_check.append("concentration")
54 self._check_positive(to_check)
56 to_check.append("head")
57 self._check_location_consistent(to_check)
59 def repeat_stress(
60 self,
61 head=None,
62 conductance=None,
63 density=None,
64 concentration=None,
65 use_cftime=False,
66 ):
67 varnames = ["head", "conductance", "density", "concentration"]
68 values = [head, conductance, density, concentration]
69 for varname, value in zip(varnames, values):
70 self._repeat_stress(varname, value, use_cftime)