MsxModel#
module wntr.msx.model
- class MsxModel[source]#
Bases:
QualityModelBase
Multi-species water quality model
- Parameters:
msx_file_name (str, optional) – MSX file to to load into the MsxModel object, by default None
- __init__(msx_file_name=None)[source]#
QualityModel ABC init method.
Make sure you call this method from your concrete subclass
__init__
method:super().__init__(filename=filename)
- Parameters:
filename (str, optional) – File to use to populate the initial data
- add_constant(name, value, units=None, note=None)[source]#
Add a constant coefficient to the model
- Parameters:
- Raises:
KeyExistsError – Variable with this name already exists
- Returns:
New constant coefficient
- Return type:
- add_parameter(name, global_value, units=None, note=None)[source]#
Add a parameterized coefficient to the model
- Parameters:
name (str) – Name of the parameter
global_value (float) – Global value of the coefficient (can be overridden for specific pipes/tanks)
units (str, optional) – Units for the coefficient, by default None
note (NoteType, optional keyword) – Supplementary information regarding this variable, by default None (see also
ENcomment
).
- Raises:
KeyExistsError – If a variable with this name already exists
- Returns:
New parameterized coefficient
- Return type:
- add_reaction(species_name, reaction_type, expression_type, expression, note=None)[source]#
Add a reaction to a species in the model
Note that all species need to have both a pipe and tank reaction defined unless all species are bulk species and the tank reactions are identical to the pipe reactions. However, it is not recommended that users take this approach.
Once added, access the reactions from the species’ object.
- Parameters:
species_name (Species or str) – Species (or name of species) the reaction is being defined for
reaction_type (ReactionType) – Reaction type (location), from {PIPE, TANK}
expression_type (ExpressionType) – Expression type (left-hand-side) of the equation, from {RATE, EQUIL, FORMULA}
expression (str) – Expression defining the reaction
note (NoteType, optional keyword) – Supplementary information regarding this reaction, by default None (see also
ENcomment
)
- Raises:
TypeError – If a variable that is not species is passed
- Returns:
New reaction object
- Return type:
- add_species(name, species_type, units, atol=None, rtol=None, note=None, diffusivity=None)[source]#
Add a species to the model
- Parameters:
name (str) – Species name
species_type (SpeciesType) – Type of species, either BULK or WALL
units (str) – Mass units for this species
atol (float, optional unless rtol is not None) – Absolute solver tolerance for this species, by default None
rtol (float, optional unless atol is not None) – Relative solver tolerance for this species, by default None
note (NoteType, optional keyword) – Supplementary information regarding this variable, by default None (see also
ENcomment
)diffusivity (float, optional) – Diffusivity of this species in water
- Raises:
KeyExistsError – If a variable with this name already exists
ValueError – If atol or rtol ≤ 0
- Returns:
New species
- Return type:
- add_term(name, expression, note=None)[source]#
Add a named expression (term) to the model
- Parameters:
- Raises:
KeyExistsError – if a variable with this name already exists
- Returns:
New term
- Return type:
- classmethod from_dict(data)[source]#
Create a new multi-species water quality model from a dictionary
- Parameters:
data (dict) – Model data
- remove_reaction(species_name, reaction_type)[source]#
Remove a reaction at a specified location from a species
- Parameters:
species (Species or str) – Species (or name of the species) of the reaction to remove
reaction_type (ReactionType) – Reaction type (location) of the reaction to remove
- remove_species(variable_or_name)[source]#
Remove a species from the model
Removes from both the reaction_system and the network_data.
- description: str#
Longer description; note that multi-line descriptions may not be represented well in dictionary form
- property network_data: MsxNetworkData#
Network-specific values added to this model
- property options: MsxSolverOptions#
MSX model options
- property reaction_system: MsxReactionSystem#
Reaction variables defined for this model