Skip to content

Commit e855954

Browse files
committed
update conduit filters
1 parent 46c4327 commit e855954

1 file changed

Lines changed: 18 additions & 35 deletions

File tree

‎docs/describing_models.rst‎

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ Different components of a coupled simulation typically run at their own pace: a
139139
detailed micro model may take many small steps for every single step of the macro model
140140
driving it, and a meso model may sit somewhere in between the two. yMMSL captures this
141141
idea of "running at a different pace" as a *timeline*. Wiring a component's ``o_i``/``s``
142-
ports (the ports it uses to run a loop) to another component's ``f_init``/``o_f`` ports
143-
puts that other component, and anything it in turn drives, on a timeline nested inside the
144-
first. yMMSL works this out automatically from how components are wired together with
145-
conduits, so in most models you never have to declare a timeline explicitly.
142+
ports to another component's ``f_init``/``o_f`` ports puts that other component, and anything
143+
it in turn drives, on a timeline nested inside the first. yMMSL works this out automatically
144+
from how components are wired together with conduits, so in most models you never have
145+
to declare a timeline explicitly.
146146
147147
A component that nobody calls sits on the outermost, root timeline, written ``:``. Every
148148
level of nesting adds one more name, giving each timeline in the model an addressable
@@ -250,9 +250,14 @@ sender:
250250
Conduit filters
251251
^^^^^^^^^^^^^^^
252252
253-
As explained in :ref:`Timelines` above, a conduit that connects a port on one timeline
254-
to a port on another must bridge the difference in how often either side sends or
255-
receives, using a filter:
253+
A conduit filter lets a conduit skip past an in-between timeline(s): a component can send
254+
directly to (or receive directly from) another one further down or up the nesting,
255+
without the message being relayed through whatever sits between them. Because the
256+
deeper side of such a conduit still gets called multiple times for every step the
257+
shallower side takes, skipping down needs a filter that produces enough messages to
258+
match (``repeat``/``pad``), and skipping back up needs one that picks a single message
259+
out of the many produced (``last``). A conduit between directly connected timelines (a
260+
component and its own caller) doesn't skip anything, so it can't take a filter at all.
256261
257262
- ``repeat`` and ``pad`` cross from an outer timeline into a nested one: a single
258263
message sent on the outer timeline (e.g. an initial state) is repeated, or followed
@@ -269,12 +274,11 @@ Filters are written in front of the receiver and may be combined:
269274
macro.init_out: repeat micro.init_in
270275
micro.state_out: last macro.final_in
271276
272-
A filter is only needed where a conduit *skips* a level of nesting. Extending the
273-
macro-meso-micro example from :ref:`Timelines`: ``macro`` lives on the root timeline
274-
``:``, ``meso`` on ``:macro``, and ``micro`` on ``:macro:meso``. The conduits that call
275-
``meso`` and that call ``micro`` from ``meso`` don't need a filter, since each one only
276-
crosses a single level of nesting that it also establishes. A conduit that goes directly
277-
from ``macro`` to ``micro``, bypassing ``meso``, skips a level, and does need one:
277+
Extending the macro-meso-micro example from :ref:`Timelines`: ``macro`` lives on the
278+
root timeline ``:``, ``meso`` on ``:macro``, and ``micro`` on ``:macro:meso``. The
279+
conduits that call ``meso`` and that call ``micro`` from ``meso`` are each a direct
280+
connection, so neither needs a filter. A conduit that goes directly from ``macro`` to
281+
``micro``, bypassing ``meso``, does:
278282
279283
.. literalinclude:: conduit_filters_bypass.ymmsl
280284
:caption: ``docs/conduit_filters_bypass.ymmsl``
@@ -285,28 +289,7 @@ from ``macro`` to ``micro``, bypassing ``meso``, skips a level, and does need on
285289
bypassing meso, labeled "repeat" and "last".
286290
287291
The same model, visualized with `ymmsl2svg
288-
<https://github.com/multiscale/ymmsl2svg>`_. Besides the normal call/release
289-
conduits, ``macro`` sends directly into ``micro``'s timeline with ``repeat`` (since
290-
``macro`` only sends once per ``meso`` step, but ``micro`` runs several times per
291-
``meso`` step), and ``micro`` reports back to ``macro`` with ``last`` (since only
292-
the final value of several ``micro`` runs is meaningful once you're back up at
293-
``macro``'s level).
294-
295-
This is represented in Python by the ``filters`` attribute of
296-
:class:`.ymmsl.v0_2.Conduit`, a list of :class:`.ymmsl.v0_2.ConduitFilter` values:
297-
298-
.. code-block:: python
299-
:caption: Conduit filters in python code
300-
301-
from pathlib import Path
302-
import ymmsl
303-
304-
config = ymmsl.load(Path('conduit_filters_bypass.ymmsl'))
305-
model = config.models['macro_meso_micro_filtered']
306-
307-
conduits = model.conduits
308-
print(conduits[1]) # output: Conduit(macro.bypass_out -> repeat -> micro.bypass_in)
309-
print(conduits[1].filters) # output: [<ConduitFilter.REPEAT: 'repeat'>]
292+
<https://github.com/multiscale/ymmsl2svg>`_.
310293
311294
312295
Nesting models

0 commit comments

Comments
 (0)