model.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:WNTR 作者: USEPA 项目源码 文件源码
def add_tank(self, name, elevation=0.0, init_level=3.048,
                 min_level=0.0, max_level=6.096, diameter=15.24,
                 min_vol=None, vol_curve=None, coordinates=None):
        """
        Adds a tank to the water network model.

        Parameters
        -------------------
        name : string
            Name of the tank.
        elevation : float
            Elevation at the Tank.
        init_level : float
            Initial tank level.
        min_level : float
            Minimum tank level.
        max_level : float
            Maximum tank level.
        diameter : float
            Tank diameter.
        min_vol : float
            Minimum tank volume.
        vol_curve : Curve object
            Curve object
        coordinates : tuple of floats
            X-Y coordinates of the node location.

        Raises
        ------
        ValueError
            If `init_level` greater than `max_level` or less than `min_level`

        """
        elevation = float(elevation)
        init_level = float(init_level)
        min_level = float(min_level)
        max_level = float(max_level)
        diameter = float(diameter)
        if min_vol is not None:
            min_vol = float(min_vol)
        if init_level < min_level:
            raise ValueError("Initial tank level must be greater than or equal to the tank minimum level.")
        if init_level > max_level:
            raise ValueError("Initial tank level must be less than or equal to the tank maximum level.")
        if vol_curve and isinstance(vol_curve, six.string_types):
            vol_curve = self.get_curve(vol_curve)
        tank = Tank(name, elevation, init_level, min_level, max_level, diameter, min_vol, vol_curve)
        self._nodes[name] = tank
        self._tanks[name] = tank
        self._graph.add_node(name)
        if coordinates is not None:
            self.set_node_coordinates(name, coordinates)
        nx.set_node_attributes(self._graph, name='type', values={name: 'tank'})
        self._num_tanks += 1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号