# creating tanks with tikz

I am trying to create this diagram,

as I am not familiar with tikzpicture, but after going through tutorials, i come up with this:

and the code is:

\usepackage{tikz}
\usepackage{pgf}
\usepackage{pgfplots}
\usetikzlibrary{positioning,shapes,calc, decorations.pathreplacing, arrows, decorations.pathmorphing, backgrounds, fit, shapes.symbols, decorations.text,automata}

\begin{document}
\begin{tikzpicture} %[>=latex,shorten >=2pt,shorten <=2pt,shape
aspect=1] %\node (A) [cylinder, shape border rotate=90, draw,minimum
%height=4cm,minimum width=2cm] %{A};

%\draw (0,0) ellipse (1.25 and 0.5););   \fill [white,opacity=0.5]
(-1.25,0) -- (-1.25,-3.5) arc (180:360:1.25 and 0.5) -- (1.25,0) arc
(0:180:1.25 and -0.5); \draw (-1.25,0) -- (-1.25,-3.5); \draw
(-1.25,-3.5) arc (180:360:1.25 and 0.5); %\draw [dashed] (-1.25,-3.5)
arc (180:360:1.25 and -0.5); \draw (1.25,-3.5) -- (1.25,0);

\draw (-0.3,-4) -- (-0.3,-4.5); \draw (0.3,-4) -- (0.3,-4.5);

\draw[dashed] (-1.2,-1.5) -- (1.2,-1.5) node [midway,
above,fill=white] {$x_1$}; \draw[dashed] (-1.2,-3.3) -- (1.2,-3.3)
node [midway, above,fill=white] {$r_1$};

%[>=latex,shorten >=2pt,shorten <=2pt,shape aspect=1] %\node (A)
[cylinder, shape border rotate=90, draw,minimum %height=4cm,minimum
width=2cm] %{A};

%\draw (0,0) ellipse (1.25 and 0.5); \draw (3.25,0) -- (3.25,-3.5);
\draw (3.25,-3.5) arc (180:360:1.25 and 0.5); %\draw [dashed]
(-1.25,-3.5) arc (180:360:1.25 and -0.5); \draw (5.75,-3.5) --
(5.75,0);   \fill [white,opacity=0.5] (3.25,0) -- (3.25,-3.5) arc
(180:360:1.25 and 0.5) -- (1.25,0) arc (0:180:1.25 and -0.5);

\draw (4.2,-4) -- (4.2,-4.5); \draw (4.8,-4) -- (4.8,-4.5);

\draw[dashed] (2.9,-1.5) -- (5.7,-1.5) node [midway, above,fill=white]
{$x_2$}; \draw[dashed] (2.9,-3.3) -- (5.7,-3.3) node [midway,
above,fill=white] {$r_2$};

\end{tikzpicture}
\end{document}


I am still alot far, but it would be great, if someone can help me creating this diagram. Thank you.

• Welcome to TeX.SX! Can you please expand the code snippets that you have posted to a full minimal working example. It is much easier to help you you if we can start with some compilable code that illustrates your problem. A MWE should compile and be as small as possible to demonstrate your problem. – Andrew Dec 2 '16 at 11:01
• Hi @Andrew, Thank you for your time. I have edited it. Is it enough or still some detail is missing? Please let me know. Thank you. – Waqar Ahmed Dec 2 '16 at 11:36

After a little effort:

\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows.meta}

\begin{document}

\begin{tikzpicture}[thick]

\fill[top color=gray!50!black,bottom color=blue!10,middle color=gray,shading=axis,opacity=0.25] (0,0) circle (2cm and 0.5cm);
\fill[left color=gray!50!black,right color=blue!50!black,middle color=gray!50,shading=axis,opacity=0.25] (2,0) -- (2,4) arc (360:180:2cm and 0.5cm) -- (-2,0) arc (180:360:2cm and 0.5cm);
\fill[top color=blue!90!,bottom color=blue!2,middle color=blue!30,shading=axis,opacity=0.25] (0,4) circle (2cm and 0.5cm);
\draw (-2,4) -- (-2,0) arc (180:360:2cm and 0.5cm) -- (2,4) ++ (-2,0) circle (2cm and 0.5cm);
\draw[] (-2,0) arc (180:0:2cm and 0.5cm) ;
\draw[] (-2,2.6) arc (180:0:2cm and 0.5cm) ;
\draw[] (-2,2.6) node [left] {$X_1$} arc (180:360:2cm and 0.5cm);
\draw[densely dashed] (-2,1.2)node [left] {$\gamma_1$} arc (180:360:2cm and 0.5cm);
\draw[densely dashed] (-2,1) arc (180:0:2cm and 0.5cm);
\draw [bend right] (-2,0) to (-0.5,-2)coordinate (A);
\draw [bend left] (2,0)  to (0.5,-2) coordinate (B);
\draw [] (A) -- (-0.5,-3) coordinate (C);\draw [] (B) -- (0.5,-3)coordinate (D);
\draw[] (C) arc (180:0:0.5cm and 0.2cm) ;
\draw[] (C) arc (180:360:0.5cm and 0.2cm) ;
\draw[double,-latex] (0,-3) -- (0,-4.5)node[left]{$V_1$};
\draw[] (2.25,6)coordinate(A)--(2.25,8);
\draw[] (2.75,6)--(2.75,8);
\draw[] (A) arc (180:0:0.25cm and 0.1cm) ;
\draw[] (A) arc (180:360:0.25cm and 0.1cm) ;
\draw[double,-latex] (2.25,5.75) -- (0,4);
\draw[double,-latex] (2.75,5.75) -- (5,4);
\hspace{5cm}

\fill[top color=gray!50!black,bottom color=blue!10,middle color=gray,shading=axis,opacity=0.25] (0,0) circle (2cm and 0.5cm);
\fill[left color=gray!50!black,right color=blue!50!black,middle color=gray!50,shading=axis,opacity=0.25] (2,0) -- (2,4) arc (360:180:2cm and 0.5cm) -- (-2,0) arc (180:360:2cm and 0.5cm);
\fill[top color=blue!90!,bottom color=blue!2,middle color=blue!30,shading=axis,opacity=0.25] (0,4) circle (2cm and 0.5cm);
\draw (-2,4) -- (-2,0) arc (180:360:2cm and 0.5cm) -- (2,4) ++ (-2,0) circle (2cm and 0.5cm);
\draw[] (-2,0) arc (180:0:2cm and 0.5cm) ;
\draw[] (-2,2.6) arc (180:0:2cm and 0.5cm) ;
\draw[] (-2,2.6) arc (180:360:2cm and 0.5cm)node [right] {$X_2$};
\draw[densely dashed] (-2,1.2) arc (180:360:2cm and 0.5cm)node [right] {$\gamma_2$};
\draw[densely dashed] (-2,1) arc (180:0:2cm and 0.5cm);
\draw [bend right] (-2,0) to (-0.5,-2)coordinate (A);
\draw [bend left] (2,0)  to (0.5,-2) coordinate (B);
\draw [] (A) -- (-0.5,-3) coordinate (C);\draw [] (B) -- (0.5,-3)coordinate (D);
\draw[] (C) arc (180:0:0.5cm and 0.2cm) ;
\draw[] (C) arc (180:360:0.5cm and 0.2cm) ;
\draw[double,-latex] (0,-3) -- (0,-4.5)node[right]{$V_2$};

\end{tikzpicture}
\end{document}


• is there a reason you're not using circle (as for tank's top) for the [densely dashed] part? – ebosi Dec 2 '16 at 12:21
• @ebo, no. I have revised my previous code. – ferahfeza Dec 2 '16 at 12:28
• @ferahfeza Thank you very much for this..:) It is exactly what i was looking for. – Waqar Ahmed Dec 2 '16 at 17:06
• @ferahfeza..one question, can you tell me how to position this picture in centre? I tried "\begin{center}" but it is still somehow on right side. Thank you – Waqar Ahmed Dec 2 '16 at 17:19
• @WaqarAhmed, yourwelcom. For centering, look at: tex.stackexchange.com/a/62494/31034 – ferahfeza Dec 2 '16 at 17:29