Skip to content

Commit

Permalink
docs: Update msx-library and string outputs in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dbhart committed Dec 16, 2024
1 parent f53c867 commit d4041bf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
11 changes: 8 additions & 3 deletions documentation/advancedsim.rst
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,15 @@ This method adds the new species to the model and also return a copy of the new
.. doctest::

>>> msx.add_species(name="PB2", species_type='bulk', units="ug", note="dissolved lead (Pb)")
Species(name='PB2', species_type=<SpeciesType.BULK: 1>, units='ug', atol=None, rtol=None, note='dissolved lead (Pb)')
Species(name='PB2', species_type='BULK', units='ug', atol=None, rtol=None, note='dissolved lead (Pb)')


The new species can be accessed by using the item's name and indexing on the model's
:attr:`~wntr.msx.model.MsxModel.reaction_system` attribute.

>>> PB2 = msx.reaction_system['PB2']
>>> PB2
Species(name='PB2', species_type=<SpeciesType.BULK: 1>, units='ug', atol=None, rtol=None, note='dissolved lead (Pb)')
Species(name='PB2', species_type='BULK', units='ug', atol=None, rtol=None, note='dissolved lead (Pb)')

The model also includes two constants and one parameter.

Expand All @@ -345,8 +346,11 @@ methods.
.. doctest::

>>> msx.add_constant("M", value=0.117, note="Desorption rate (ug/m^2/s)", units="ug * m^(-2) * s^(-1)")
Constant(name='M', value=0.117, units='ug * m^(-2) * s^(-1)', note='Desorption rate (ug/m^2/s)')
>>> msx.add_constant("E", value=140.0, note="saturation/plumbosolvency level (ug/L)", units="ug/L")
Constant(name='E', value=140.0, units='ug/L', note='saturation/plumbosolvency level (ug/L)')
>>> msx.add_parameter("F", global_value=0, note="determines which pipes are made of lead")
Parameter(name='F', global_value=0.0, note='determines which pipes are made of lead')

If the value of one of these needs to be modified, then it can be accessed and modified as an object
in the same manner as other WNTR objects.
Expand Down Expand Up @@ -387,13 +391,15 @@ method.
.. doctest::

>>> msx.add_reaction("PB2", "pipe", "RATE", expression="F * Av * M * (E - PB2) / E")
Reaction(species_name='PB2', expression_type='RATE', expression='F * Av * M * (E - PB2) / E')


If the species is saved as an object, as was done above, then it can be passed instead of the species name.

.. doctest::

>>> msx.add_reaction(PB2, "tank", "rate", expression="0")
Reaction(species_name='PB2', expression_type='RATE', expression='0')


Arsenic oxidation and adsorption
Expand Down Expand Up @@ -586,7 +592,6 @@ The model is created in WTNR as shown below.
>>> msx = wntr.msx.MsxModel()
>>> msx.name = "arsenic_chloramine"
>>> msx.title = "Arsenic Oxidation/Adsorption Example"
>>> msx.references.append(wntr.msx.library.cite_msx())

>>> AS3 = msx.add_species(name="AS3", species_type="BULK", units="UG", note="Dissolved arsenite")
>>> AS5 = msx.add_species(name="AS5", species_type="BULK", units="UG", note="Dissolved arsenate")
Expand Down
4 changes: 2 additions & 2 deletions documentation/waterquality.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ In the example below, the strength of the source is changed from 1000 to 1500.

>>> source = wn.get_source('Source')
>>> print(source)
<Source: 'Source', '121', 'SETPOINT', 1000, SourcePattern>
<Source: 'Source', '121', 'SETPOINT', 1000, SourcePattern, None>

>>> source.strength_timeseries.base_value = 1500
>>> print(source)
<Source: 'Source', '121', 'SETPOINT', 1500, SourcePattern>
<Source: 'Source', '121', 'SETPOINT', 1500, SourcePattern, None>

When creating a water network model from an EPANET INP file, the sources that are defined in the [SOURCES] section are added to the water network model.
These sources are given the name 'INP#' where # is an integer representing the number of sources in the INP file.
Expand Down
7 changes: 4 additions & 3 deletions documentation/waterquality_msx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Examples that illustrate how to build MSX models in WNTR are included in :ref:`a
Reaction library
-----------------
WNTR also contains a library of MSX models that are accessed through the
:class:`~wntr.msx.library.ReactionLibrary`.
:class:`~wntr.library.msx.MsxLibrary`.
This includes the following models:

* `Arsenic oxidation/adsorption <https://github.com/USEPA/WNTR/blob/msx/wntr/msx/_library_data/arsenic_chloramine.json>`_ :cite:p:`shang2023`
Expand All @@ -90,11 +90,12 @@ The models are stored in JSON format.
Additional models can be loaded into the library by setting a user specified path.
Additional models could also be added directly to the WNTR Reactions library.

The following example loads the Lead plumbosolvency model (lead_ppm) from the ReactionLibrary.
The following example loads the Lead plumbosolvency model (lead_ppm) from the MsxLibrary.

.. doctest::

>>> reaction_library = wntr.msx.library.ReactionLibrary()
>>> import wntr.library.msx
>>> reaction_library = wntr.library.msx.MsxLibrary()

>>> print(reaction_library.model_name_list())
['arsenic_chloramine', 'batch_chloramine_decay', 'lead_ppm', 'nicotine', 'nicotine_ri']
Expand Down

0 comments on commit d4041bf

Please sign in to comment.