anuga.Rate_operator
- class anuga.Rate_operator(domain, rate=0.0, factor=1.0, region=None, indices=None, polygon=None, center=None, radius=None, default_rate=0.0, description=None, label=None, logging=False, verbose=False, monitor=False)[source]
Bases:
Operator- __init__(domain, rate=0.0, factor=1.0, region=None, indices=None, polygon=None, center=None, radius=None, default_rate=0.0, description=None, label=None, logging=False, verbose=False, monitor=False)[source]
Create a Rate_operator that adds water over a region at a specified rate.
The applied rate is
rate * factorin m/s (depth per second). For common use-cases prefer the factory constructors:Rate_operator.rainfall(domain, rate_mm_hr)— rainfall in mm/hrRate_operator.inflow(domain, rate_m3_s)— inflow in m³/s
- Parameters:
domain (anuga.Domain) – The simulation domain.
rate (scalar, callable, Quantity, or ndarray) – Rate in m/s (after multiplication by factor). May be a scalar, a function of
t,(x, y), or(x, y, t), a Quantity, a numpy array of shape(n_triangles,), or an xarray DataArray.factor (scalar or callable(t)) – Multiplier applied to rate before adding to stage. Use to convert units (e.g.
1/(1000*3600)for mm/hr → m/s).region (Region, optional) – Pre-built Region. Cannot be combined with polygon, center, radius, or indices.
indices (list, optional) – Triangle indices where the rate is applied.
polygon (list of [x, y], optional) – Polygon bounding the application area.
center ([x, y], optional) – Centre of a circular application area.
radius (float, optional) – Radius of the circular application area.
default_rate (scalar or callable(t), optional) – Rate to use outside the time interval of the rate function/xarray.
description – Passed to the base
Operator.label – Passed to the base
Operator.logging – Passed to the base
Operator.verbose – Passed to the base
Operator.monitor – Passed to the base
Operator.
Methods
__init__(domain[, rate, factor, region, ...])Create a Rate_operator that adds water over a region at a specified rate.
activate_logging()get_Q([full_only])Calculate current overall discharge
get_factor([t])Provide a factor to calculate added volume
get_non_spatial_rate([t])Provide a rate to calculate added volume
get_spatial_rate([x, y, t])Provide a rate to calculate added volume only call if self.rate_spatial = True
get_time()get_timestep()inflow(domain, rate[, polygon, region, ...])Create a Rate_operator for a volumetric inflow.
log_timestepping_statistics()Operator is applied independently on each cell and so is parallel safe.
print_statistics()print_timestepping_statistics()rainfall(domain, rate[, polygon, region, ...])Create a Rate_operator for rainfall.
set_areas()set_default_rate(default_rate)Check and store default_rate
set_factor(factor)Set factor.
set_full_indices()set_label([label])set_logging([flag])set_rate(rate)Set rate.
statistics()timestepping_statistics()Attributes
counter- get_spatial_rate(x=None, y=None, t=None)[source]
Provide a rate to calculate added volume only call if self.rate_spatial = True
- classmethod inflow(domain, rate, polygon=None, region=None, center=None, radius=None, indices=None, default_rate=0.0, label=None, description=None, logging=False, verbose=False, monitor=False)[source]
Create a Rate_operator for a volumetric inflow.
- Parameters:
domain (anuga.Domain)
rate (scalar or callable(t)) – Volumetric flow rate in m³/s. The operator divides by the total region area so that the net inflow equals rate m³/s.
- Return type:
- Raises:
ValueError – If the specified region has zero area.
Examples
>>> op = Rate_operator.inflow(domain, rate=0.5, polygon=poly) >>> op = Rate_operator.inflow(domain, rate=lambda t: 0.1*t)
- classmethod rainfall(domain, rate, polygon=None, region=None, center=None, radius=None, indices=None, default_rate=0.0, label=None, description=None, logging=False, verbose=False, monitor=False)[source]
Create a Rate_operator for rainfall.
- Parameters:
domain (anuga.Domain)
rate (scalar, callable(t), or array) – Rainfall intensity in mm/hr. All other rate forms accepted by
Rate_operator(callables, arrays) are also supported and are interpreted as mm/hr.polygon – Location arguments — same as
Rate_operator.__init__.region – Location arguments — same as
Rate_operator.__init__.center – Location arguments — same as
Rate_operator.__init__.radius – Location arguments — same as
Rate_operator.__init__.indices – Location arguments — same as
Rate_operator.__init__.
- Returns:
Operator with
factor = 1 / (1000 * 3600)so that mm/hr is converted to m/s automatically.- Return type:
Examples
>>> rain = Rate_operator.rainfall(domain, rate=10.0) # 10 mm/hr >>> rain = Rate_operator.rainfall(domain, rate=lambda t: 5.0) # time-varying