diff options
Diffstat (limited to 'figs/diamonds.fig')
-rw-r--r-- | figs/diamonds.fig/Makefile | 20 | ||||
-rw-r--r-- | figs/diamonds.fig/diamonds.py | 65 | ||||
l--------- | figs/diamonds.fig/shapes.sty | 1 |
3 files changed, 86 insertions, 0 deletions
diff --git a/figs/diamonds.fig/Makefile b/figs/diamonds.fig/Makefile new file mode 100644 index 0000000..42b4031 --- /dev/null +++ b/figs/diamonds.fig/Makefile @@ -0,0 +1,20 @@ +all: diamonds + +diamonds: + python diamonds.py > diamonds.tikz.tex + cat diamonds.tikz.tex | sed 's/%1%/red/g;s/%2%/blue/g' > diamonds_color.tikz.tex + sed -i 's/%1%/teal/g;s/%2%/teal/g' diamonds.tikz.tex + pdflatex -jobname diamonds diamonds.tikz.tex + pdflatex -jobname diamonds_color diamonds_color.tikz.tex + +clean-aux: + rm -f diamonds.tikz.tex + rm -f diamonds.log + rm -f diamonds.aux + rm -f diamonds_color.tikz.tex + rm -f diamonds_color.log + rm -f diamonds_color.aux + +clean: clean-aux + rm -f diamonds.pdf + rm -f diamonds_color.pdf diff --git a/figs/diamonds.fig/diamonds.py b/figs/diamonds.fig/diamonds.py new file mode 100644 index 0000000..2bc4d9c --- /dev/null +++ b/figs/diamonds.fig/diamonds.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +from math import * +import random + +# size of space (must be int) +L=30 +# number of particles +N=int(L*L/2*0.97) + +# check whether two diamonds overlap +def check_overlap(x1,x2): + if(sqrt((x1[0]-x2[0])**2+(x1[1]-x2[1])**2)<=1): + return(True) + return(False) + +# configuration +config=[] + +# put particles on odd lattice manually +for i in range(4): + for j in range(4): + if (i!=2 or j!=1): + config.append([2*int(L/2/2)+1+i+j,2*int(L/2/2)+i-j]) + +# add particles +while len(config)<N: + # random position + # even sublattice + if(random.random()<0.5): + x=[2*random.randint(0,int(L/2)), 2*random.randint(0,int(L/2))] + else: + x=[2*random.randint(0,int(L/2))+1, 2*random.randint(0,int(L/2))+1] + # check it does not interfere with other particles + fine=True + for part in config: + if(check_overlap(part,x)): + fine=False + break + if fine: + config.append(x) + +print(r'''\documentclass{standalone} +\usepackage{tikz} +\usepackage{shapes} + +\begin{document} +\begin{tikzpicture} +\grid{'''+str(L+3)+'}{'+str(L+3)+'''}{(-1,-1)} +''') + +for i in range(len(config)): + part=config[i] + # different colors for even and odd + if i<15: + # replace %1% later + print(r'\diamond{%1%}{('+str(part[0])+','+str(part[1])+')}') + else: + # replace %2% later + print(r'\diamond{%2%}{('+str(part[0])+','+str(part[1])+')}') + +print(r''' +\end{tikzpicture} +\end{document} +''') diff --git a/figs/diamonds.fig/shapes.sty b/figs/diamonds.fig/shapes.sty new file mode 120000 index 0000000..2607bef --- /dev/null +++ b/figs/diamonds.fig/shapes.sty @@ -0,0 +1 @@ +../libs/shapes.sty
\ No newline at end of file |