[Tex/LaTex] tikz package for drawing thermodynamic cycles

tikz-pgf

Is there a extension of tikz library that allows one to draw thermodynamic cycles easily? For example the picture you see in the link: http://en.wikipedia.org/wiki/Carnot_heat_engine#mediaviewer/File:Carnot_heat_engine_2.svg

If there is no library can someone suggest a easy way to go about this? Maybe provide an example? I have used LaTeX for a little over a year now but am just starting to draw in LaTeX with tikz.

Best Answer

This is one possibility where pic with 3 arguments, known as nodea, nodeb and nodec are designed here -- #1=color, #2=label and #3=internal node label.

enter image description here

Code

\documentclass[border=10pt]{standalone}%{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\tikzset{%
pics/.cd,
nodea/.style args={#1#2#3}{
  code={\node[minimum height=2cm] (#3) {\color{#1}#2};
       \draw[thick] (#3.south west) -| (#3.north east)--(#3.north west);
  }
},
%pics/.cd,
nodeb/.style args={#1#2#3}{
  code={\node[minimum height=2cm] (#3) {\color{#1}#2};
       \draw[thick] (#3.south east) -| (#3.north west)--(#3.north east);
  }
},
%pics/.cd,
nodec/.style args={#1#2#3}{
  code={\node[draw,thick,shape=circle,inner sep=1cm] (#3) {\color{#1}#2};
  }
},
}
\begin{document}
  \begin{tikzpicture}[scale=2]
    \pic at (0,0) {nodea={red}{$T_H$}{L}};
    \pic at (2,0) {nodec={black}{}{C}};
    \pic at (4,0) {nodeb={blue}{$T_C$}{R}};
 \draw[->,>=latex](L)--node[midway,above]{$\mathbf{Q_H}$}(C); 
 \draw[->,>=latex](C)--node[midway,above]{$\mathbf{Q_C}$} (R);
 \draw[->,>=latex](C)--node[midway,left]{$\mathbf{W}$} ++(0,-2cm);
  \end{tikzpicture}
\end{document}
Related Question