Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jauslin <ian@jauslin.org>2022-10-17 20:59:01 -0400
committerIan Jauslin <ian@jauslin.org>2022-10-17 20:59:01 -0400
commitbdf817efec1cfdd67cc6176a6664442fd98173ae (patch)
tree93d0abe475c342b2c0cac0dfdb16e2fa018bf4e6 /figs/diamonds.fig/diamonds.py
As presented at RUMA on 2022-10-12HEADv1.0master
Diffstat (limited to 'figs/diamonds.fig/diamonds.py')
-rw-r--r--figs/diamonds.fig/diamonds.py65
1 files changed, 65 insertions, 0 deletions
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}
+''')