# drawing water particles in a water column - tikz

I am trying to generate a figure that shows various water particles in a water column where the particles are moving chaotically driven by the cooling and heating of water. So far I have generated an idealized water column with 3 spheres used to represent the water particles.

\documentclass{article}
\usepackage[margin = 1in]{geometry}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,calc,shapes,shapes.geometric,patterns}
\begin{document}
\begin{tikzpicture}
\shade[bottom color=cyan!60!black, top color=blue!20!white] (0,0) rectangle (4,5);
\foreach \x in {1,1.2,1.4}
\shade[ball color = cyan!20!white] (\x,3) circle (.1);
\end{tikzpicture}
\end{document}


However, this seems really unimaginative and I was hoping if anyone had some advice on how o improve the figure from the description given above.

-
So you want some random particles at random places? There is a great example about random drawings in the manual. See about the function rnd. When, I get off, I will create one for you. :) –  zeroth Mar 8 '13 at 11:48
See also this: tex.stackexchange.com/q/87497/19156 –  Lionel MANSUY Mar 8 '13 at 11:52
And also tex.stackexchange.com/q/98754/18674 might be of interest... –  Benedikt Bauer Mar 8 '13 at 13:17
What do you mean by water particles? Do you mean individually water molecules? The water molecules is what water is. -and they can not in any way be viewed as spheres in a liquid. –  Hans-Peter E. Kristiansen Mar 10 '13 at 16:32
Well I am trying to draw an annotated diagram of convective mixing in a water body where mixing is driven by the cooling of the water particles (where a they cool and become denser the sink and mix the water column). –  KatyB Mar 10 '13 at 18:10

I don't know how much this will get the point, however this is what I imagined the OP had in mind:

Some references for the code:

The idea behind all is to have more particles moving around the hot area, gradually less in the warm area and less in the cold area.

The code:

\documentclass{beamer}
\usepackage{lmodern,tikz}
\usetikzlibrary{shapes.geometric}

\makeatletter
% original code in
% http://tex.stackexchange.com/questions/88040/how-can-we-draw-christmas-animations-with-tikz#88042

rgb(0cm)=(1,1,1);
color(0.35cm)=(tikz@ball!35!white);
color(0.75cm)=(tikz@ball!80!white);
rgb(1cm)=(1,1,1)
}

% original code by Jake:
\def\tikz@falsetext{false}
\tikzset{
\edef\tikz@temp{#1}%
\ifx\tikz@temp\tikz@falsetext%
\else%
\fi
}
}
\makeatother

% original code by Daniel:
% http://tex.stackexchange.com/questions/55806/tikzpicture-in-beamer#55849
\tikzset{
invisible/.style={opacity=0,text opacity=0},
visible on/.style={alt=#1{}{invisible}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
},
}
% original code in
% http://tex.stackexchange.com/questions/84513/highlighting-in-beamer-using-tikz-nodes#84608
\tikzset{
}

\tikzset{water cold particle/.style={
circle,
inner sep=2pt,
},
water warm particle/.style={
circle,
inner sep=2pt,
},
water hot particle/.style={
circle,
inner sep=2pt,
},
}
\begin{document}
\begin{frame}{}
\begin{tikzpicture}
\node[draw,cylinder,
minimum width=4.25cm,
minimum height=5.65cm,
shape border rotate=90,
aspect=1,
bottom color=cyan!60!black,
top color=blue!20!white,
anchor=after bottom]
at (-0.1,-0.1){};

\foreach \hotparticles in {1,...,70}{
\pgfmathrandom{}
\pgfmathsetmacro\xpos{4*\pgfmathresult}
\pgfmathrandom{}
\pgfmathsetmacro\ypos{2*\pgfmathresult}

\pgfmathrandom{1,2}
\let\seqa\pgfmathresult
\pgfmathrandom{3,5}
\let\seqb\pgfmathresult
\pgfmathrandom{4,7}
\let\seqc\pgfmathresult
\pgfmathrandom{7,9}
\let\seqd\pgfmathresult
\node[water hot particle,shade on=<{\seqa,\seqb,\seqc,\seqd}>] at (\xpos,\ypos) {};
}
\foreach \warmparticles in {1,...,45}{
\pgfmathrandom{}
\pgfmathsetmacro\xpos{4*\pgfmathresult}
\pgfmathrandom{}
\pgfmathsetmacro\ypos{2*\pgfmathresult+1.5}
\pgfmathrandom{1,3}
\let\seqa\pgfmathresult
\pgfmathrandom{4,6}
\let\seqb\pgfmathresult
\pgfmathrandom{7,9}
\let\seqc\pgfmathresult
\node[water warm particle,shade on=<{\seqa,\seqb,\seqc}>] at (\xpos,\ypos) {};
}

\foreach \coldparticles in {1,...,25}{
\pgfmathrandom{}
\pgfmathsetmacro\xpos{4*\pgfmathresult}
\pgfmathrandom{}
\pgfmathsetmacro\ypos{2*\pgfmathresult+3}
\pgfmathrandom{1,5}
\let\seqa\pgfmathresult
\pgfmathrandom{4,9}
\let\seqb\pgfmathresult
\node[water cold particle,shade on=<{\seqa,\seqb}>] at (\xpos,\ypos) {};
}

\end{tikzpicture}
\end{frame}
\end{document}


First version without shape

The code:

\documentclass{beamer}
\usepackage{lmodern,tikz}

\makeatletter
% original code in
% http://tex.stackexchange.com/questions/88040/how-can-we-draw-christmas-animations-with-tikz#88042

rgb(0cm)=(1,1,1);
color(0.35cm)=(tikz@ball!35!white);
color(0.75cm)=(tikz@ball!80!white);
rgb(1cm)=(1,1,1)
}

% original code by Jake:
\def\tikz@falsetext{false}
\tikzset{
\edef\tikz@temp{#1}%
\ifx\tikz@temp\tikz@falsetext%
\else%
\fi
}
}
\makeatother

% original code by Daniel:
% http://tex.stackexchange.com/questions/55806/tikzpicture-in-beamer#55849
\tikzset{
invisible/.style={opacity=0,text opacity=0},
visible on/.style={alt=#1{}{invisible}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
},
}
% original code in
% http://tex.stackexchange.com/questions/84513/highlighting-in-beamer-using-tikz-nodes#84608
\tikzset{
}

\tikzset{water cold particle/.style={
circle,
inner sep=2pt,
},
water warm particle/.style={
circle,
inner sep=2pt,
},
water hot particle/.style={
circle,
inner sep=2pt,
},
}
\begin{document}
\begin{frame}{}
\begin{tikzpicture}
\shade[bottom color=cyan!60!black, top color=blue!20!white] (-0.1,-0.1) rectangle (4.1,5.1);

\foreach \hotparticles in {1,...,70}{
\pgfmathrandom{}
\pgfmathsetmacro\xpos{4*\pgfmathresult}
\pgfmathrandom{}
\pgfmathsetmacro\ypos{2*\pgfmathresult}

\pgfmathrandom{1,2}
\let\seqa\pgfmathresult
\pgfmathrandom{3,5}
\let\seqb\pgfmathresult
\pgfmathrandom{4,7}
\let\seqc\pgfmathresult
\pgfmathrandom{7,9}
\let\seqd\pgfmathresult
\node[water hot particle,shade on=<{\seqa,\seqb,\seqc,\seqd}>] at (\xpos,\ypos) {};
}
\foreach \warmparticles in {1,...,45}{
\pgfmathrandom{}
\pgfmathsetmacro\xpos{4*\pgfmathresult}
\pgfmathrandom{}
\pgfmathsetmacro\ypos{2*\pgfmathresult+1.5}
\pgfmathrandom{1,3}
\let\seqa\pgfmathresult
\pgfmathrandom{4,6}
\let\seqb\pgfmathresult
\pgfmathrandom{7,9}
\let\seqc\pgfmathresult
\node[water warm particle,shade on=<{\seqa,\seqb,\seqc}>] at (\xpos,\ypos) {};
}

\foreach \coldparticles in {1,...,25}{
\pgfmathrandom{}
\pgfmathsetmacro\xpos{4*\pgfmathresult}
\pgfmathrandom{}
\pgfmathsetmacro\ypos{2*\pgfmathresult+3}
\pgfmathrandom{1,5}
\let\seqa\pgfmathresult
\pgfmathrandom{4,9}
\let\seqb\pgfmathresult
\node[water cold particle,shade on=<{\seqa,\seqb}>] at (\xpos,\ypos) {};
}
\end{tikzpicture}
\end{frame}
\end{document}

-
By the way, why did you use beamer class rather than standalone class? –  kiss my armpit Mar 10 '13 at 17:10
Oh.. just because I feel more comfortable with the styles visible on and related (shade on in this case). It's doable also with standalone of course :) –  Claudio Fiandrino Mar 10 '13 at 17:23