Tips for life, tips for tech

I wrote this code long time ago and I want to share it since it’s pretty cool and come in handy a lot of times.


\begin{figure}[H]
\begin{tikzpicture}[scale=0.5]
\draw[step=.5cm,lightgray,very thin] (0.1,0.6) grid (7.8,6.8);
\draw[fill=yellow,fill opacity=0.5] (1,3.5) -- (2,5) -- (4,5.5) -- (6,3.6) -- (4,2) -- (2,2) -- (1,3.5);
\draw[fill=cyan,fill opacity=0.5] (1,3.5) circle (0.78cm);
\draw[fill=cyan,fill opacity=0.5] (2,5) circle (1cm);
\draw[fill=cyan,fill opacity=0.5] (4,5.5) circle (1.05cm);
\draw[fill=cyan,fill opacity=0.5] (6,3.72) circle (1.64cm);
\draw[fill=cyan,fill opacity=0.5] (4,2) circle (1cm);
\draw[fill=cyan,fill opacity=0.5] (2,2) circle (1cm);
\fill[black,font=\footnotesize]
(1,3.5) node [above] {$P_1$}
(2,5) node [above] {$P_2$}
(4,5.5) node [above] {$P_3$}
(6,3.6) node [above] {$P_4$}
(4,2) node [above] {$P_5$}
(2,2) node [above] {$P_6$};
\draw[thick,->] (9,3.5) -- (10,3.5);
% draw 2 particles use for pair of contacts
\draw[fill=cyan,fill opacity=0.5] (13,5.5) circle (1.05cm);
\draw[fill=cyan,fill opacity=0.5] (15,3.72) circle (1.64cm);
\fill[black,font=\small]
(13,5.5) node [above] {$P_3$}
(15,3.72) node [above] {$P_4$};
\draw[blue,->,thick] (13,5.5) -- (15,3.72);
\fill[blue,font=\small]
(14,4.5) node [below] {$\vec{l}_{\,3,4}$};
\draw[red,->,thick] (13.784,4.802) -- (15.784,5);
\fill[red,font=\small]
(15.9,5) node [above] {$\vec{f}_{\,3,4}$};
% equation of the stress tensor
\fill[black,font=\small]
(14,2) node [below] {$\sigma_{ij}=\frac{1}{V}\sum \limits_{c} f_{ij}^c\times l_{ij}^c$};
\end{tikzpicture}
\caption{Calculation of meso-stress in a cycle of grains}
\end{figure}

Reply in English

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Tag Cloud

%d bloggers like this: