Meadows – a small language for stock-and-flow diagrams that run

(lorezzed.github.io)

28 points | by jjsalamon 4 hours ago ago

3 comments

  • jamessb 2 hours ago

    The "Behaviour over time" graphs don't seem to render for the hunger/chicken & egg/burnout/predator & prey examples.

    • jjsalamon 2 hours ago

      There's no units attached to those first examples so in effect there's nothing to render in the behavior over time graph. The system can still be rendered however.

      In the later examples they start introducing numbers to the stock/flow nodes which then populates both graphs.

      Maybe that can be made clearer somehow

  • jjsalamon 4 hours ago

    I was reading Donella Meadows' "Thinking in Systems" and wanted to play with its diagrams instead of just looking at them, so I wrote a small language for them. You type a model:

      | =>inflow [water in tub: 50] =>outflow: 5 |
    
    and get the stock-and-flow diagram, a chart of each stock over time, and an animation of the run on the diagram itself: stocks, and feedback loops pulse.

    Each example has notes in its source explaining what it shows. You can also build by clicking.

    It runs entirely in the browser, with no account and no backend. The whole model lives in the URL, so any diagram can be shared as a link.

    The compiler is PureScript (lexer, parser evaluator) and emits a graph as JSON; the front end is TypeScript and d3, with a force layout and a fixed-step Euler simulator. It's deliberately small: numbers are plain numbers with no units, and the simulator takes simple fixed steps. It's for learning and sketching, not a replacement for Vensim or Stella.

    Source (MIT): https://github.com/lorezzed/meadows

    I'd welcome feedback on the language itself