diff options
author | Ian Jauslin <jauslin@ias.edu> | 2018-04-04 06:21:21 +0000 |
---|---|---|
committer | Ian Jauslin <jauslin@ias.edu> | 2018-04-04 06:21:21 +0000 |
commit | f950c74e38d120e42637983d504f85843a63e95d (patch) | |
tree | eb2ded33fc156da7adaf096c3816432b4262c8d4 /figs/ising.fig |
Diffstat (limited to 'figs/ising.fig')
-rw-r--r-- | figs/ising.fig/Makefile | 38 | ||||
-rw-r--r-- | figs/ising.fig/ising.py | 56 | ||||
-rw-r--r-- | figs/ising.fig/libs/ising.sty | 9 |
3 files changed, 103 insertions, 0 deletions
diff --git a/figs/ising.fig/Makefile b/figs/ising.fig/Makefile new file mode 100644 index 0000000..eeff491 --- /dev/null +++ b/figs/ising.fig/Makefile @@ -0,0 +1,38 @@ +PROJECTNAME=ising ising_blue ising_red transfer1 transfer2 +LIBS=$(notdir $(wildcard libs/*)) + +PDFS=$(addsuffix .pdf, $(PROJECTNAME)) +SOURCES=$(addsuffix .tikz.tex, $(PROJECTNAME)) + +all: $(PDFS) + +$(PDFS): $(SOURCES) $(LIBS) + echo $(LIBS) + pdflatex -jobname $(basename $@) -file-line-error $(patsubst %.pdf, %.tikz.tex, $@) + +$(SOURCES): + python3 ising.py + +install: $(PDFS) + cp $^ $(INSTALLDIR)/ + +install-sources: $(SOURCES) + cp $^ $(INSTALLDIR)/ + +$(LIBS): + ln -fs libs/$@ ./ + +clean-libs: + rm -f $(LIBS) + +clean-aux: + rm -f $(addsuffix .aux, $(PROJECTNAME)) + rm -f $(addsuffix .log, $(PROJECTNAME)) + +clean-tex: + rm -f $(PDFS) + +clean-sources: + rm -f $(SOURCES) + +clean: clean-libs clean-aux clean-tex clean-sources diff --git a/figs/ising.fig/ising.py b/figs/ising.fig/ising.py new file mode 100644 index 0000000..8dd1447 --- /dev/null +++ b/figs/ising.fig/ising.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 + +import random +from math import * + +# size of the grid +L=8 + +# draw spins, probability of reds: p, only fill up to H +def draw_spins(p, H, file_desc): + for i in range(L): + for j in range(H): + if(random.random()<p): + print("\\fill[color=red]("+str(i)+","+str(j)+")circle(0.2);", file=file_desc); + else: + print("\\fill[color=blue]("+str(i)+","+str(j)+")circle(0.2);", file=file_desc); + print("\\draw("+str(i)+","+str(j)+")circle(0.2);", file=file_desc); + +# init tikz file +def init_tikz(filename): + file_desc=open(filename,"w") + print("\\documentclass{standalone}\n\n\\usepackage{tikz}\n\\usepackage{ising}\n\\usetikzlibrary{decorations.pathmorphing}\n\n\\begin{document}\n\\begin{tikzpicture}\n\n", file=file_desc) + return(file_desc) + +# close tikz file +def close_tikz(file_desc): + print("\\end{tikzpicture}\n\\end{document}", file=file_desc) + file_desc.close() + + +# files + +ising=init_tikz("ising.tikz.tex") +print("\\grid{"+str(L-1)+"}{"+str(L-1)+"}{(0,0)}\n", file=ising) +draw_spins(0.5,L,ising) +close_tikz(ising) + +ising_blue=init_tikz("ising_blue.tikz.tex") +print("\\grid{"+str(L-1)+"}{"+str(L-1)+"}{(0,0)}\n", file=ising_blue) +draw_spins(0.1,L,ising_blue) +close_tikz(ising_blue) + +ising_red=init_tikz("ising_red.tikz.tex") +print("\\grid{"+str(L-1)+"}{"+str(L-1)+"}{(0,0)}\n", file=ising_red) +draw_spins(0.9,L,ising_red) +close_tikz(ising_red) + +transfer1=init_tikz("transfer1.tikz.tex") +print("\\grid{"+str(L-1)+"}{"+str(L-1)+"}{(0,0)}\n", file=transfer1) +draw_spins(0.5,1,transfer1) +close_tikz(transfer1) + +transfer2=init_tikz("transfer2.tikz.tex") +print("\\grid{"+str(L-1)+"}{"+str(L-1)+"}{(0,0)}\n", file=transfer2) +draw_spins(0.5,2,transfer2) +close_tikz(transfer2) diff --git a/figs/ising.fig/libs/ising.sty b/figs/ising.fig/libs/ising.sty new file mode 100644 index 0000000..2f8b2fa --- /dev/null +++ b/figs/ising.fig/libs/ising.sty @@ -0,0 +1,9 @@ +% square lattice (width #1, height #2, origin #3) +\def\grid#1#2#3{ + \foreach\i in {0,...,#2}{ + \draw#3++(0,\i)--++(#1,0); + } + \foreach\i in {0,...,#1}{ + \draw#3++(\i,0)--++(0,#2); + } +} |