2

I've got this diagram visualising the interrelation of various reaction extends Xi on the duties of reactors R101 and R102, consequentially dictating recycle ratio R, purge and makeup flow. After playing around with my first draft for a few hours, I'm still not quite content with the result:

enter image description here

That's my code. Suggestions on improvement are greatly appreciated.

\begin{figure}[!ht]
\centering
\scalebox{1.2}[1.2]{
\begin{tikzpicture}[node distance=2cm,>=stealth',bend angle=45,auto]
\tikzstyle{place}=[circle,thick,draw=blue!75,fill=blue!20,minimum size=6mm]
\tikzstyle{red place}=[place,draw=red!75,fill=red!20]
\tikzstyle{transition}=[rectangle,thick,draw=black!75,
          fill=black!10,minimum size=13mm]

\tikzstyle{every label}=[red]

\begin{scope}[xshift=0cm]

\node[] 
at (-4, -2)   (start) {};
\node[] 
at (4, -2)   (end) {};

\node [red place,tokens=0]
                  (w1')                                                {};
\node [place]     (c1') [below of=w1']                                 {};
\node [red place] (s1') [below of=c1',xshift=-15mm,label=left:$\xi_1$]      {};
\node [red place,tokens=0]
                  (s2') [below of=c1',xshift=15mm,label=right:$\xi_2$] {};


\node [transition] (e1') [left of=c1'] {}
  edge [post,bend left]                  (w1')
  edge [post]                            (s1')
  edge [pre]                             (s2')
  edge [pre]                             (c1')
  edge [pre,dotted]                      (start);


\node [transition] (l1') [right of=c1'] {}
  edge [post]                            (c1')
  edge [pre]                             (s1')
  edge [post]                            (s2')
  edge [pre,bend right] node[swap] {}    (w1')
  edge[post,dotted] (end);

\node[] 
at (-2, -2)   (c)  {R101};
\node[] 
at (2, -2)    (c2) {R102};
\node[red] 
at (0, +0.65) (c2) {$\xi_3$};
\node[blue] 
at (0, -1.35) (c2) {$R$};
\node[black] 
at (-5, -2)   (c2) {make-up};
\node[black] 
at (4.5, -2)  (c2) {purge};

\end{scope}

\end{tikzpicture}
 }
\end{figure}
  • 2
    What don't you like from your result? What do you expect we answer? – Ignasi Mar 5 at 11:41
  • 1
    Welcome to TeX.SX! – Ignasi Mar 5 at 11:42
  • 3
    @FabioEnrico Your diagram is good enough and doesn't need improving. – user156344 Mar 5 at 12:05
  • 3
    @JouleV That's great, thanks a lot! Sorry for the uncleanly formulated question. I'll make sure to be more precise next time. – Fabio Enrico Mar 5 at 12:08
  • 1
    @FabioEnrico No problem. Welcome to TeX.SE! – user156344 Mar 5 at 12:08
3

Just to show that Metapost is also available, here is a version with a different layout. Do you like this better? Does this show what you need?

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{luatex85}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);

    path R, X[], reactor[];

    R  = fullcircle scaled 20 shifted 84 down;
    X1 = fullcircle scaled 20 shifted 42 up;
    X2 = fullcircle scaled 20 shifted 42 down;
    X3 = fullcircle scaled 20 shifted 84 up;

    reactor0 = unitsquare shifted -(1/2, 1/2) scaled 42;
    reactor1 = reactor0 shifted 63 left;
    reactor2 = reactor0 shifted 63 right;

    forsuffixes $=1,2:
        fill reactor$ withcolor 7/8 white;
        draw reactor$;
        label("R10" & decimal $, center reactor$);
    endfor

    fill R withcolor 3/4[blue, white];
    draw R withcolor 1/2 blue;
    label.top("$R$", point 2 of R) withcolor 1/2 blue;

    forsuffixes $=1,2,3:
        fill X$ withcolor 3/4[red, white];
        draw X$ withcolor 1/2 red;
        label.top("$\xi_{" & decimal $ & "}$", point 2 of X$) withcolor 1/2 red;
    endfor

    z1 = point -1/2 of reactor1 shifted 42 left;
    z2 = point  3/2 of reactor2 shifted 42 right;

    label.lft("make up", z1); drawarrow z1 -- point -1/2 of reactor1 dashed withdots scaled 1/2;
    label.rt ("purge", z2); drawarrow point 3/2 of reactor2 -- z2 dashed withdots scaled 1/2;

    forsuffixes $=X1,X3:
        drawarrow center reactor1 {up} .. {right} center $
            cutbefore reactor1 cutafter fullcircle scaled 22 shifted center $;
        drawarrow center $ {right} .. {down} center reactor2
            cutbefore $ cutafter reactor2 shifted 1 up;
    endfor

    forsuffixes $=R, X2:
        drawarrow center reactor2 {down} .. {left} center $
            cutbefore reactor2 cutafter fullcircle scaled 22 shifted center $;
        drawarrow center $ {left} .. {up} center reactor1
            cutbefore $ cutafter reactor1 shifted 1 down;
    endfor

endfig;
\end{mplibcode}
\end{document}

Compile this with lualatex.

  • That looks absolutely brilliant @Thruston, thank you so so much! – Fabio Enrico Mar 6 at 11:47
5

As you request for an improvement of the code, I have some suggestions:

  1. You should use \tikzset instead of \tikzstyle. Read more here.
  2. TikZ already provide you option scale, so using \scalebox is not very TikZ-ish.
  3. Putting a scope where xshift=0cm is unnecessary.
  4. The distance between "make-up" and the arrow is not the same with the difference between "purge" and the arrow. It is minor but we should fix it.
  5. The curved arrow from "R101" look like it is going down a bit before reaching ξ3. The curved arrow to "R102" seems to go up a bit before descending.

By the way, I'd like to show you my code for that figure. I don't use all \nodes, i.e. the commands should be more understandable (\draw means drawing something and \node means there are some nodes to be inserted in). Also, this doesn't use any Cartesian / polar coordinates – which differs TikZ from other graphics tools.

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning,arrows.meta}
\begin{document}
\begin{tikzpicture}[scale=1.2,-stealth]
\tikzset{
    reactor/.style={rectangle,thick,draw=black!75,fill=black!10,minimum size=13mm},
    place/.style={circle,thick,draw=blue!75,fill=blue!20,minimum size=6mm},
    red place/.style={place,draw=red!75,fill=red!20}
}
\node[place] (r) {} node[above=1em,blue!75] {$R$};
\node[reactor,left=1.5 cm of r] (101) {R101};
\node[reactor,right=1.5 cm of r] (102) {R102};
\node[red place,above=2 cm of r] (3) {};
    \draw (3) node[above=1em,red] {$\xi_3$};
\node[red place,below=1.5cm of 101.south east] (1) {};
    \draw (1) node[left=1em,red] {$\xi_1$};
\node[red place,below=1.5cm of 102.south west] (2) {};
    \draw (2) node[right=1em,red] {$\xi_2$};
\node[left=2cm of 101] (start) {make-up};
\node[right=2cm of 102] (end) {purge};
\draw (101)--(1);
\draw (1)--(102);
\draw (102)--(r);
\draw (r)--(101);
\draw (101) to[out=90,in=180] (3);
\draw (3) to[out=0,in=90] (102);
\draw (102)--(2);
\draw (2)--(101);
\draw[dotted] (start)--(101);
\draw[dotted] (102)--(end);
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.