summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/sankey/sankey-example-energy.tex
blob: 2e500b10d933c92a810001dc95b04a7ae4eaad62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
\begin{tikzpicture}
  % font choice
  \renewcommand\rmdefault{txr}\rmfamily\footnotesize
  \sisetup{
    round-mode=places,
    round-precision=1,
    add-decimal-zero,
    round-integer-to-decimal,
  }
  \begin{sankeydiagram}
    \colorlet{energy}{blue!30!cyan!80!black}
    \colorlet{lost energy}{red!50!orange!90!black}
    \sankeyset{
      ratio=13em/100,
      minimum radius=1em,
      start style=simple,end style=simple,
      draw/.style={draw=none,line width=0},
      energy/.style={
        fill/.style={
          draw=energy,
          line width=0,
          fill=energy,
        }
      },
      lost energy/.style={
        fill/.style={
          draw=lost energy,
          line width=0,
          fill=lost energy,
        }
      }
    }

    \newcommand\abovelabel[2]{ % valname, label
      \node[anchor=south east,align=center,inner xsep=0] at (#1.left) {#2};
    }

    \newcommand\energylabel[1]{ % valname
      \node[anchor=north east,text=energy,inner xsep=0] at (#1.right)
      {\num{\sankeygetnodeqty{#1}}};
    }

    \newcommand\lostenergylabel[2]{ % valname, label
      \node[anchor=north,text=lost energy] at ([yshift=-2.5mm]#1.center)
      (value)
      {\num{\sankeygetnodeqty{#1}}};
      \node[anchor=north,inner sep=0,align=center] at (value.south) {#2};
    }

    \newcommand\lostenergylabelbottom[2]{ % valname, label
      \draw[draw=lost energy,dashed,thick]
      ([yshift=-3mm]#1.center) coordinate (#1) -- ([yshift=-3mm]#1.center);
      \lostenergylabel{#1}{#2}
    }

    \sankeynode{name=Co,quantity=100.0}
    \path (Co.right) ++(0,-7mm) coordinate (c);

    \newcommand\turnandstop[2]{ % valname, label
      \begingroup
      \sankeyset{lost energy}
      \sankeyturnright{#1}{90}
      \sankeynode{as=#1,name=#1-stop,at={#1 |- c}}
      \sankeyoutin{#1}{#1-stop}
      \sankeynode{as=#1-stop,name=#1}
      \sankeyend{#1}
      \lostenergylabel{#1}{#2}
      \endgroup
    }

    \newcommand\turnandstopbottom[2]{ % valname, label
      \begingroup
      \sankeyset{lost energy}
      \sankeyturnright{#1}{90}
      \sankeynode{as=#1,name=#1-stop,at={#1 |- c}}
      \sankeyoutin{#1}{#1-stop}
      \sankeynode{as=#1-stop,name=#1}
      \sankeyend{#1}
      \lostenergylabelbottom{#1}{#2}
      \endgroup
    }

    \def\hshift{6.25em}

    \sankeyadvance[energy]{Co}{1.2*\hshift}
    \abovelabel{Co}{\textbf{Coal}\\(Primary energy)}
    \energylabel{Co}
    \sankeyfork{Co}{35/El1,65/Pg}
    \turnandstop{Pg}{Power generation}

    \sankeyadvance[energy]{El1}{1.8*\hshift}
    \abovelabel{El1}{\textbf{Electricity}\\(Secondary energy)}
    \energylabel{El1}
    \sankeyfork{El1}{33.5/El2,1.5/Tr}
    \turnandstopbottom{Tr}{Transmission}

    \sankeyadvance[energy]{El2}{.65*\hshift}
    \energylabel{El2}
    \sankeyfork{El2}{31.5/El3,2.0/Di}
    \turnandstop{Di}{Distribution}

    \sankeyadvance[energy]{El3}{.65*\hshift}
    \energylabel{El3}
    \sankeyfork{El3}{31.0/El4,0.5/Wi}
    \turnandstopbottom{Wi}{Wiring}

    \sankeyadvance[energy]{El4}{.65*\hshift}
    \abovelabel{El4}{\textbf{Electricity}\\(Final energy)}
    \energylabel{El4}
    \sankeyfork{El4}{3.0/Lr1,28.0/Lb}
    \turnandstop{Lb}{Lightbulb}

    \sankeyadvance[energy]{Lr1}{1.1*\hshift}
    \abovelabel{Lr1}{\textbf{Light radiation}\\(Useful energy)}
    \energylabel{Lr1}
    \sankeyfork{Lr1}{2.0/Lr2,1.0/Ls}
    \turnandstopbottom{Ls}{Lampshade}

    \sankeyadvance[energy]{Lr2}{.6*\hshift}
    \energylabel{Lr2}
    \sankeyfork{Lr2}{1.0/Il,1.0/Id}
    \turnandstop{Id}{Idle}

    \sankeyadvance[energy]{Il}{.6*\hshift}
    \abovelabel{Il}{\textbf{Illumination}\\(Energy services)}
    \energylabel{Il}
    \sankeyend[energy]{Il}
  \end{sankeydiagram}
\end{tikzpicture}