I’m trying to draw a process flow diagram using tikz. I'm not an expert, expecially in working with custom nodes.
I saw some other questions about chemical process flow diagrams, but they were general and did not explain how to customize a node to obtain a piece of equipment.
This is what I did so far, using some examples I found:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\tikzset{HeatEx/.style={draw=black,fill=white,thick,circle,minimum width=1cm}}
\tikzset{Tank/.style={draw=black,fill=white,thick,rectangle,rounded corners=20pt,minimum width=1.5cm,minimum height=3cm,text width=1.5cm,align=center}}
\tikzset{3Phase/.style={draw=black,fill=white,thick,rectangle,rounded corners=20pt,minimum width=4cm,minimum height=1.5cm,text width=4cm,align=center}}
\tikzset{Reactor/.style={draw=black,fill=white,ultra thick,rectangle,rounded corners=20pt,minimum width=1.5cm,minimum height=4cm,text width=1.5cm,align=center}}
\def\COOLER#1#2#3{\node[HeatEx,right=#1 of #2](#3){};
\draw[thick,-latex] (#3.south east) to[in=-20,out=160] (#3.north west);
}
\def\HEATER#1#2#3#4{\node[HeatEx,below right=#1 and #2 of #3](#4){};
\draw[thick,-latex] (#4.north east) to[in=20,out=200] (#4.south west);
}
\def\TANK#1#2#3#4{\node[Tank,right=#1 of #2](#3){#4};}
\def\ThreeSEP#1#2#3#4{\node[3Phase,right=#1 of #2](#3){#4};}
\def\REACTOR#1#2#3#4#5{\node[Reactor,below right=#1 and #2 of #3](#4){#5};}
\begin{tikzpicture}
\node (START) {Text};
\TANK{1cm}{START}{F1}{Text}
\node[below right=of F1] (W1) {Text};
\COOLER{1cm}{F1}{C1};
\REACTOR{1cm}{1cm}{C1}{R1}{Text};
\HEATER{1cm}{1cm}{R1}{H1};
\ThreeSEP{1cm}{H1}{S1}{Text};
%Arrows
\draw[thick,-latex] (START.east) to (F1.west);
\draw[thick,-latex] (F1.south) |- (W1);
\draw[thick,-latex] (F1.east) to (C1.west);
\draw[thick,-latex] (C1.east) -| (R1.north);
\draw[thick,-latex] (R1.south) |- (H1.west);
\draw[thick,-latex] (H1.east) to (S1.west);
\end{tikzpicture}
\end{document}
That produces:

I’m not able to get the shapes I want, basically because I don't know how to draw inside a node:
- the curved arrow inside the heat exchangers should go a little outside the circle;
- the three-phase separator (the horizontal vessel -
\ThreeSEP) should be similar to the one in this picture, with the four ports shown:

I managed to draw the arrow inside the circle thanks to (#3.south east) to (#3.north west), but it would be (may be) simpler if I had “relative reference system” inside each node. Or, at least, something like (#3.south east+3mm,#3.south east+3mm) to (#3.north west+3mm,#3.north west+3mm) (if it even makes sense).
Another issue is the positioning of the nodes, that I control using several inputs and is not so easy to use; it would be easier if I could define the shape and then its relative position (at first I tried only with \tikset{} but I couldn't draw inside the node I defined).
For example, I would like to have the first heat exchanger (\COOLER - C1) above right of the first vessel, but I should define a new style only to change below right to above right, or use the former with negative distances.
Finally, if there is a "smarter" way to do it, I am ready to change my code :-) .
Thanks to everyone!


\clip, but I don't know how to set the area that has to be clipped. Thanks again! – MarcoG Jun 16 '15 at 09:47\clip (lower left x, lower left y) rectangle (upper right x, upper right y);where those are the coordinates, as in(-5,-5) rectangle (5,5);, but change them to your needs. Everything after this command will be clipped outside of those coordinates. So if you add this command at the beginning, everything will be clipped. At the end, nothing will be clipped. :) – Alenanno Jun 16 '15 at 10:13\clip ($(#4.west)!.(0.5)!(#4.south west)$) rectangle ($(#4.east)!.(0.5)!(#4.north east)$);in ascopeenvironment. – MarcoG Jun 16 '15 at 10:37