Species#
module wntr.msx.elements
- class Species[source]#
Bases:
VariableBase
Biological or chemical species.
- Parameters:
name (str) – Species name
species_type – Species type
units – Units of mass for this species, see
units
property.atol (float | None) – Absolute tolerance when solving this species’ equations, by default None
rtol (float | None) – Relative tolerance when solving this species’ equations, by default None
note (str | dict | wntr.epanet.util.ENcomment) – Supplementary information regarding this variable, by default None (see
NoteType
)diffusivity – Diffusivity of the species in water, by default None
_vars – Reaction system this species is a part of, by default None
_vals – Initial quality values for this species, by default None
- Raises:
KeyExistsError – If the name has already been used
TypeError – If atol and rtol are not the same type
ValueError – If atol or rtol ≤ 0
Notes
EPANET-MSX requires that atol and rtol either both be omitted, or both be provided. In order to enforce this, the arguments passed for atol and rtol must both be None or both be positive values.
- __init__(name, species_type, units, atol=None, rtol=None, *, note=None, diffusivity=None, _vars=None, _vals=None)[source]#
Variable ABC init method.
Make sure you call this method from your concrete subclass
__init__
method:super().__init__(name, note=note)
- Parameters:
- Raises:
KeyExistsError – Name is already taken
ValueError – Name is a reserved word
- set_tolerances(atol, rtol)[source]#
Set the absolute and relative tolerance for the solvers.
The user must set both values, or neither value (None). Values must be positive.
- Parameters:
- Raises:
TypeError – If only one of atol or rtol is a float
ValueError – If atol or rtol ≤ 0
- to_dict()[source]#
Dictionary representation of the object
The species dictionary has the following format, as described using a json schema.
{ "title": "Species", "type": "object", "properties": { "name": { "type": "string" }, "species_type": { "enum": ["bulk", "wall"] }, "units": { "type": "string" }, "atol": { "type": "number", "exclusiveMinimum": 0 }, "rtol": { "type": "number", "exclusiveMinimum": 0 }, "note": { "type": "string" }, "diffusivity": { "type": "number", "minimum": 0 } }, "required": ["name", "species_type", "units", "pipe_reaction", "tank_reaction"], "dependentRequired": {"atol": ["rtol"], "rtol":["atol"]} }
- property atol: float#
Absolute tolerance. Must be set using
set_tolerances()
- property initial_quality: InitialQuality#
Initial quality values for the network
- property rtol: float#
Relative tolerance. Must be set using
set_tolerances()
- property species_type: SpeciesType#
- units: str#
Units of mass for this species. For bulk species, concentration is this unit divided by liters, for wall species, concentration is this unit divided by the model’s area-unit (see options).
- property var_type: VariableType#
Type of variable,
SPECIES
.