Code Monkey home page Code Monkey logo

latex-systemdynamics's Introduction

Latex package for System Dynamics

This aims at supporting latex users with some tikz experience to draw system dynamics (SD) diagrams in his/her latex documents.

Usage

  1. Add the following line to your preamble:
    \usepackage{systemdynamics}
    
  2. Compile using pdflatex. Make sure the systemdynamics.sty file is somewhere where your latex distribution will find it.

Commands

The package provides tikz styles and shortcuts.

Drawing Stocks

To draw a stock with the internal name nodename and the label nodelabel use the command:

\node (nodename) [stock] {nodelabel};

To position the node relative to an existing node, you can use the familiar positoning commands inside the [], i.e.

\node (nodename) [stock, below=1em of othernode] {nodelabel};

Drawing Nodes

To add positive or negative flows with the label flowlabel to the node stockname, use the following commands:

\flowIn{stockname}{flowlabel}
\flowOut{stockname}{flowlabel}

This will create nodes with names in_stockname or out_stockname respectively.

Drawing SD Variables

To create a system dynamics variable with name varname and label varlabel, use the command

\node (varname) [sdvariable]  {varlabel};

Drawing Arrows

To indicate relationships, use the \sdarrow command:

\sdarrow{fromNode}{toNode}{bend left=5}

The last argument is optional and contains tikz options that will be passed directly to tikz to control the arrow curvature etc.

You can use the node names of existing stocks, flows and variables to define start and end of the arrow. To avoid arrows that overlap with the node labels, the flows have additional points that can be used as start or endpoints of sdarrows:

  • in_stock_down: A node below the incoming flow label
  • in_stock_down_nolabel: A node below the incoming flows hourglass (useful if the flow has no label)
  • in_stock_up: A node above the incoming flows hourglass
  • out_stock_down: A node below the outcoming flow label
  • out_stock_down_nolabel: A node below the outcoming flows hourglass (useful if the flow has no label)
  • out_stock_up A: node above the outcoming flows hourglass

Example Diagram

The following code draws a simple two-state diagram.

\documentclass{standalone}
\pagestyle{empty}
\usepackage{systemdynamics}

\begin{document}
\begin{tikzpicture} 

% Predator population
\node (predator) [stock] {Predator};
\flowIn{predator}{}
\flowOut{predator}{}
\sdarrow{predator}{out_predator_up}{bend left=70}

% Prey population
\node (prey) [stock, below=7em of predator, xshift=1em] {Prey};
\flowIn{prey}{}
\flowOut{prey}{}
\sdarrow{prey}{in_prey_down_nolabel}{bend left=70}

%Meetings
\node (meetings) [sdvariable, below=3em of predator, xshift=0.5em]  {Meetings};
\sdarrow{prey}{meetings}{bend left=5}
\sdarrow{predator}{meetings}{bend left=10}
\sdarrow{meetings}{in_predator_down_nolabel}{bend left=10}
\sdarrow{meetings}{out_prey_up}{bend left=10}

\end{tikzpicture}
\end{document}

The output will look as follows: Predator Prey model

latex-systemdynamics's People

Contributors

i4h avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

maimaris

latex-systemdynamics's Issues

CTAN

Is it possible to add this to CTAN?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.