示例#1
0
    def K(self, new_val):
        """set hydraulic conductivity at link (m/s)"""
        if callable(new_val):
            self._kfunc = True

            if (not isinstance(new_val(self._grid), np.ndarray) and len(
                    new_val(self._grid)) == self._grid.number_of_links):
                raise TypeError(
                    """If a function is provided it must take a ModelGrid and return an array of length number_of_links."""
                )
            else:
                self._func = new_val
                self._K = return_array_at_link(self._grid,
                                               self._func(self._grid))
        else:
            self._kfunc = False
            self._K = return_array_at_link(self._grid, new_val)
示例#2
0
 def K(self):
     """hydraulic conductivity at link (m/s)"""
     if self._kfunc:
         self._K = return_array_at_link(self._grid, self._func(self._grid))
     return self._K
示例#3
0
    def __init__(
        self,
        grid,
        hydraulic_conductivity=0.001,
        porosity=0.2,
        recharge_rate=1.0e-8,
        regularization_f=1e-2,
    ):
        """Initialize the GroundwaterDupuitPercolator.

        Parameters
        ----------
        grid: ModelGrid
            Landlab ModelGrid object
        hydraulic_conductivity: float, field name, or array of float
                saturated hydraulic conductivity, m/s
                Default = 0.001 m/s
        porosity: float, field name or array of float
                the porosity of the aquifer [-]
                Default = 0.2
        recharge_rate: float, field name, or array of float
                Rate of recharge, m/s
                Default = 1.0e-8 m/s
        regularization_f: float
                factor controlling the smoothness of the transition between
                surface and subsurface flow
        """
        # Store grid
        self._grid = grid

        # Shorthand
        self._cores = grid.core_nodes

        # Create fields:
        if "topographic__elevation" in self.grid.at_node:
            self._elev = self.grid.at_node["topographic__elevation"]
        else:
            self._elev = self.grid.add_ones("node", "topographic__elevation")

        if "aquifer_base__elevation" in self.grid.at_node:
            self._base = self.grid.at_node["aquifer_base__elevation"]
        else:
            self._base = self.grid.add_zeros("node", "aquifer_base__elevation")

        if "water_table__elevation" in self.grid.at_node:
            self._wtable = self.grid.at_node["water_table__elevation"]
        else:
            self._wtable = self.grid.add_zeros("node",
                                               "water_table__elevation")
        self._wtable[grid.closed_boundary_nodes] = 0

        if "aquifer__thickness" in self.grid.at_node:
            self._thickness = self.grid.at_node["aquifer__thickness"]
        else:
            self._thickness = self.grid.add_zeros("node", "aquifer__thickness")
            self._thickness[:] = self._wtable - self._base
        self._thickness[grid.closed_boundary_nodes] = 0

        if "hydraulic__gradient" in self.grid.at_link:
            self._hydr_grad = self.grid.at_link["hydraulic__gradient"]
        else:
            self._hydr_grad = self.grid.add_zeros("link",
                                                  "hydraulic__gradient")

        if "aquifer_base__gradient" in self.grid.at_link:
            self._base_grad = self.grid.at_link["aquifer_base__gradient"]
        else:
            self._base_grad = self.grid.add_zeros("link",
                                                  "aquifer_base__gradient")

        if "groundwater__specific_discharge" in self.grid.at_link:
            self._q = self.grid.at_link["groundwater__specific_discharge"]
        else:
            self._q = self.grid.add_zeros("link",
                                          "groundwater__specific_discharge")

        if "groundwater__velocity" in self.grid.at_link:
            self._vel = self.grid.at_link["groundwater__velocity"]
        else:
            self._vel = self.grid.add_zeros("link", "groundwater__velocity")

        if "surface_water__specific_discharge" in self.grid.at_node:
            self._qs = self.grid.at_node["surface_water__specific_discharge"]
        else:
            self._qs = self.grid.add_zeros(
                "node", "surface_water__specific_discharge")

        if "water_table__velocity" in self.grid.at_node:
            self._dhdt = self.grid.at_node["water_table__velocity"]
        else:
            self._dhdt = self.grid.add_zeros("node", "water_table__velocity")

        # Convert parameters to fields if needed, and store a reference
        self._K = return_array_at_link(grid, hydraulic_conductivity)
        self._recharge = return_array_at_node(grid, recharge_rate)
        self._n = return_array_at_node(grid, porosity)
        self._n_link = map_mean_of_link_nodes_to_link(self._grid, self._n)
        self._r = regularization_f
        self._S = abs(grid.calc_grad_at_link(self._elev))
        self._S_node = map_max_of_node_links_to_node(grid, self._S)
示例#4
0
    def __init__(self,
                 grid,
                 hydraulic_conductivity=0.01,
                 recharge_rate=1.0e-8):
        """Initialize the GroundwaterDupuitPercolator.

        Parameters
        ----------
        grid: ModelGrid
            Landlab ModelGrid object
        hydraulic_conductivity: float, field name (link), or array of float
            saturated hydraulic conductivity, m/s
            Default = 0.01 m/s
        recharge_rate: float, field name (node), or array of float
            Rate of recharge, m/s
            Default = 1.0e-8 m/s
        """
        # Store grid
        self._grid = grid

        # Shorthand
        self._cores = grid.core_nodes
        self._inactive_links = np.where(grid.status_at_link != ACTIVE_LINK)[0]

        # Convert parameters to fields if needed, and store a reference
        self._K = return_array_at_link(grid, hydraulic_conductivity)
        self._recharge = return_array_at_node(grid, recharge_rate)

        # Create fields:

        if "topographic__elevation" in self._grid.at_node:
            self._elev = self._grid.at_node["topographic__elevation"]
        else:
            self._elev = self._grid.add_ones("node", "topographic__elevation")

        if "aquifer_base__elevation" in self._grid.at_node:
            self._base = self._grid.at_node["aquifer_base__elevation"]
        else:
            self._base = self._grid.add_zeros("node",
                                              "aquifer_base__elevation")

        if "water_table__elevation" in self._grid.at_node:
            self._wtable = self._grid.at_node["water_table__elevation"]
        else:
            self._wtable = self._grid.add_zeros("node",
                                                "water_table__elevation")

        if "aquifer__thickness" in self._grid.at_node:
            self._thickness = self._grid.at_node["aquifer__thickness"]
        else:
            self._thickness = self._grid.add_zeros("node",
                                                   "aquifer__thickness")
            self._thickness[:] = self._wtable - self._base

        if "hydraulic__gradient" in self._grid.at_link:
            self._hydr_grad = self._grid.at_link["hydraulic__gradient"]
        else:
            self._hydr_grad = self._grid.add_zeros("link",
                                                   "hydraulic__gradient")

        if "groundwater__specific_discharge" in self._grid.at_link:
            self._q = self._grid.at_link["groundwater__specific_discharge"]
        else:
            self._q = self._grid.add_zeros("link",
                                           "groundwater__specific_discharge")

        if "groundwater__velocity" in self._grid.at_link:
            self._vel = self._grid.at_link["groundwater__velocity"]
        else:
            self._vel = self._grid.add_zeros("link", "groundwater__velocity")
示例#5
0
 def K(self, new_val):
     """set hydraulic conductivity at link (m/s)"""
     self._K = return_array_at_link(self._grid, new_val)
示例#6
0
    def __init__(
        self,
        grid,
        hydraulic_conductivity=0.001,
        porosity=0.2,
        recharge_rate=1.0e-8,
        regularization_f=1e-2,
        courant_coefficient=0.01,
    ):
        """
        Parameters
        ----------
        grid: ModelGrid
            Landlab ModelGrid object
        hydraulic_conductivity: float, field name, or array of float
            saturated hydraulic conductivity, m/s
            Default = 0.001 m/s
        porosity: float, field name or array of float
            the porosity of the aquifer [-]
            Default = 0.2
        recharge_rate: float, field name, or array of float
            Rate of recharge, m/s
            Default = 1.0e-8 m/s
        regularization_f: float
            factor controlling the smoothness of the transition between
            surface and subsurface flow
        courant_coefficient: float (-)
            The muliplying factor on the condition that the timestep is
            smaller than the minimum link length over groundwater flow
            velocity. This parameter is only used with
            ``run_with_adaptive_time_step_solver`` and must be greater than
            zero.
        """
        super(GroundwaterDupuitPercolator, self).__init__(grid)

        # Shorthand
        self._cores = grid.core_nodes

        # Create fields:

        self._elev = self._grid.at_node["topographic__elevation"]
        self._base = self._grid.at_node["aquifer_base__elevation"]

        self.initialize_output_fields()

        self._wtable = self._grid.at_node["water_table__elevation"]
        self._wtable[grid.closed_boundary_nodes] = 0

        self._thickness = self._grid.at_node["aquifer__thickness"]
        self._thickness[:] = self._wtable - self._base
        self._thickness[grid.closed_boundary_nodes] = 0

        self._hydr_grad = self._grid.at_link["hydraulic__gradient"]
        self._base_grad = self._grid.at_link["aquifer_base__gradient"]

        self._q = self._grid.at_link["groundwater__specific_discharge"]
        self._qs = self._grid.at_node["surface_water__specific_discharge"]
        self._qsavg = self.grid.at_node[
            "average_surface_water__specific_discharge"]

        self._vel = self._grid.at_link["groundwater__velocity"]

        self._dhdt = self._grid.at_node["water_table__velocity"]

        # Convert parameters to fields if needed, and store a reference
        self._K = return_array_at_link(grid, hydraulic_conductivity)
        self._recharge = return_array_at_node(grid, recharge_rate)
        self._n = return_array_at_node(grid, porosity)
        self._n_link = map_mean_of_link_nodes_to_link(self._grid, self._n)
        self._r = regularization_f

        # save courant_coefficient (and test)
        self._courant_coefficient = courant_coefficient