diff options
author | Ian Jauslin <ian@jauslin.org> | 2022-10-17 20:59:01 -0400 |
---|---|---|
committer | Ian Jauslin <ian@jauslin.org> | 2022-10-17 20:59:01 -0400 |
commit | bdf817efec1cfdd67cc6176a6664442fd98173ae (patch) | |
tree | 93d0abe475c342b2c0cac0dfdb16e2fa018bf4e6 /figs/atoms.fig |
Diffstat (limited to 'figs/atoms.fig')
-rw-r--r-- | figs/atoms.fig/Makefile | 15 | ||||
-rw-r--r-- | figs/atoms.fig/crystal-base.gp | 21 | ||||
-rw-r--r-- | figs/atoms.fig/crystal.py | 24 | ||||
-rw-r--r-- | figs/atoms.fig/gas-base.gp | 21 | ||||
-rw-r--r-- | figs/atoms.fig/gas-rods-base.gp | 21 | ||||
-rw-r--r-- | figs/atoms.fig/gas-rods.py | 88 | ||||
-rw-r--r-- | figs/atoms.fig/gas.py | 39 | ||||
-rw-r--r-- | figs/atoms.fig/liquid-base.gp | 21 | ||||
-rw-r--r-- | figs/atoms.fig/liquid.py | 39 | ||||
-rw-r--r-- | figs/atoms.fig/nematic-base.gp | 21 | ||||
-rw-r--r-- | figs/atoms.fig/nematic.py | 90 | ||||
-rw-r--r-- | figs/atoms.fig/smectic-base.gp | 21 | ||||
-rw-r--r-- | figs/atoms.fig/smectic.py | 92 |
13 files changed, 513 insertions, 0 deletions
diff --git a/figs/atoms.fig/Makefile b/figs/atoms.fig/Makefile new file mode 100644 index 0000000..50559fa --- /dev/null +++ b/figs/atoms.fig/Makefile @@ -0,0 +1,15 @@ +PROJECTNAME=crystal liquid gas nematic smectic gas-rods +PNGS=$(addsuffix .png, $(PROJECTNAME)) + +all: $(PNGS) + +$(PNGS): + cp $(patsubst %.png, %, $@)-base.gp $(patsubst %.png, %, $@).gp + python $(patsubst %.png, %, $@).py >> $(patsubst %.png, %, $@).gp + gnuplot $(patsubst %.png, %, $@).gp > $@ + +clean-aux: + rm -f $(addsuffix .gp, $(PROJECTNAME)) + +clean: clean-aux + rm -f $(PNGS) diff --git a/figs/atoms.fig/crystal-base.gp b/figs/atoms.fig/crystal-base.gp new file mode 100644 index 0000000..4de0ee2 --- /dev/null +++ b/figs/atoms.fig/crystal-base.gp @@ -0,0 +1,21 @@ +set terminal pngcairo size 2048,2048 + +set key off +unset colorbox +unset border +unset xtics +unset ytics +unset ztics + +set parametric + +set view equal xyz + +set isosample 100 + +set pm3d depthorder +set pm3d lighting primary 0.50 specular 0.6 + +set palette defined (0 "#339999", 1 "#339999") + +splot \ diff --git a/figs/atoms.fig/crystal.py b/figs/atoms.fig/crystal.py new file mode 100644 index 0000000..4b1ba3c --- /dev/null +++ b/figs/atoms.fig/crystal.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 + +from math import * +import random +import sys + +# size of lattice +N=5 + +# configuration +config=[] +for i in range(N): + for j in range(N): + for k in range(N): + config.append([2*i+((j+k)%2),sqrt(3)*(j+(k%2)/3),2*sqrt(6)/3*k]) + + +for i in range(len(config)): + print(str(config[i][0])+"+cos(u)*sin(v)", end=",") + print(str(config[i][1])+"+sin(u)*sin(v)", end=",") + print(str(config[i][2])+"+cos(v)", end=" ") + print("with pm3d", end="") + if i<len(config)-1: + print(", \\") diff --git a/figs/atoms.fig/gas-base.gp b/figs/atoms.fig/gas-base.gp new file mode 100644 index 0000000..e95f005 --- /dev/null +++ b/figs/atoms.fig/gas-base.gp @@ -0,0 +1,21 @@ +set terminal pngcairo size 2048,2048 + +set key off +unset colorbox +unset border +unset xtics +unset ytics +unset ztics + +set parametric + +set view equal xyz + +set isosample 100 + +set pm3d depthorder +set pm3d lighting primary 0.5 specular 0.6 + +set palette defined (0 "#339999", 1 "#339999") + +splot \ diff --git a/figs/atoms.fig/gas-rods-base.gp b/figs/atoms.fig/gas-rods-base.gp new file mode 100644 index 0000000..4de0ee2 --- /dev/null +++ b/figs/atoms.fig/gas-rods-base.gp @@ -0,0 +1,21 @@ +set terminal pngcairo size 2048,2048 + +set key off +unset colorbox +unset border +unset xtics +unset ytics +unset ztics + +set parametric + +set view equal xyz + +set isosample 100 + +set pm3d depthorder +set pm3d lighting primary 0.50 specular 0.6 + +set palette defined (0 "#339999", 1 "#339999") + +splot \ diff --git a/figs/atoms.fig/gas-rods.py b/figs/atoms.fig/gas-rods.py new file mode 100644 index 0000000..dc63d24 --- /dev/null +++ b/figs/atoms.fig/gas-rods.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python3 + +from math import * +import random + +# size of space +L=30 +# number of rods +N=15 +# aspect ratio +a=10 + +# check whether two rods overlap +def check_overlap(rod1,rod2): + # relative placement + relative_pos=unrotate(subtract(rod2[0],rod1[0]), rod1[1]) + if(abs(relative_pos[0])<2 and abs(relative_pos[1])<2 and abs(relative_pos[2])<2): + return(True) + # relative angle + relative_ang=cart_to_spherical(unrotate(spherical_to_cart(rod2[1]), rod1[1])) + # exclusion volume + # rotate other rod + relative_pos=unrotate(relative_pos, [0,relative_ang[1]]) + #if(abs(relative_pos[1])<2 and abs(relative_pos[0])-2<abs(sin(relative_ang[0]))*a and abs(relative_pos[2])-a-2<abs(cos(relative_ang[0])*a)): + if(abs(relative_pos[1])<2 and abs(relative_pos[0])-2<abs(sin(relative_ang[0]))*a and abs(sin(relative_ang[0])*relative_pos[2]-cos(relative_ang[0])*relative_pos[0])-2<abs(sin(relative_ang[0])*a)): + return(True) + return(False) + +# def subtract vectors +def subtract(x,y): + return([x[0]-y[0],x[1]-y[1],x[2]-y[2]]) +# rotate vector +def unrotate(x,w): + ret=[x[0],x[1],x[2]] + # rotate phi + tmp=cos(w[1])*ret[0]+sin(w[1])*ret[1] + ret[1]=-sin(w[1])*ret[0]+cos(w[1])*ret[1] + ret[0]=tmp + # rotate theta + tmp=cos(w[0])*ret[0]-sin(w[0])*ret[2] + ret[2]=sin(w[0])*ret[0]+cos(w[0])*ret[2] + ret[0]=tmp + return(ret) + +# convert coordinates +def spherical_to_cart(w): + return([cos(w[1])*sin(w[0]),sin(w[1])*sin(w[0]),cos(w[0])]) +def cart_to_spherical(x): + w=[0,0] + w[0]=acos(x[2]) + if(sin(w[0]==0)): + return([w[0],0]) + c=x[0]/sin(w[0]) + s=x[1]/sin(w[0]) + # to avoid truncation errors + if(abs(c)>1 and abs(c)<1.0001): + if(c>0): + return([w[0],0]) + else: + return([w[0],pi]) + if(s>=0): + return([w[0],acos(c)]) + return([w[0],2*pi-acos(c)]) + +# configuration +config=[] +# add rods +while len(config)<N: + # random position and angles + x=[random.uniform(0,L), random.uniform(0,L), random.uniform(0,L)] + w=[random.uniform(0,pi), random.uniform(0,2*pi)] + # chek it does not interfere with other rods + fine=True + for rod in config: + if(check_overlap(rod,[x,w])): + fine=False + break + if fine: + config.append([x,w]) + +for i in range(len(config)): + rod=config[i] + print(str(rod[0][0])+"+("+str(cos(rod[1][1])*cos(rod[1][0]))+")*cos(u)*sin(v)+("+str(-sin(rod[1][1]))+")*sin(u)*sin(v)+("+str(cos(rod[1][1])*sin(rod[1][0])*a)+")*cos(v)", end=", ") + print(str(rod[0][1])+"+("+str(sin(rod[1][1])*cos(rod[1][0]))+")*cos(u)*sin(v)+("+str(cos(rod[1][1]))+")*sin(u)*sin(v)+("+str(sin(rod[1][1])*sin(rod[1][0])*a)+")*cos(v)", end=", ") + print(str(rod[0][2])+"+("+str(-sin(rod[1][0]))+")*cos(u)*sin(v)+("+str(cos(rod[1][0])*a)+")*cos(v)", end=" ") + print("with pm3d", end="") + if i<len(config)-1: + print(", \\") diff --git a/figs/atoms.fig/gas.py b/figs/atoms.fig/gas.py new file mode 100644 index 0000000..8685999 --- /dev/null +++ b/figs/atoms.fig/gas.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +from math import * +import random + +# size of space +L=15 +# number of particles +N=10 + +# check whether two rods overlap +def check_overlap(sphere1,sphere2): + if(sqrt((sphere2[0]-sphere1[0])**2+(sphere2[1]-sphere1[1])**2+(sphere2[2]-sphere1[2])**2)<2): + return(True) + return(False) + +# configuration +config=[] +# add spheres +while len(config)<N: + # random position + x=[random.uniform(0,L), random.uniform(0,L), random.uniform(0,L)] + # check it does not interfere with other spheres + fine=True + for sphere in config: + if(check_overlap(sphere,x)): + fine=False + break + if fine: + config.append(x) + +for i in range(len(config)): + sphere=config[i] + print(str(sphere[0])+"+cos(u)*sin(v)", end=", ") + print(str(sphere[1])+"+sin(u)*sin(v)", end=", ") + print(str(sphere[2])+"+cos(v)", end=" ") + print("with pm3d", end="") + if i<len(config)-1: + print(", \\") diff --git a/figs/atoms.fig/liquid-base.gp b/figs/atoms.fig/liquid-base.gp new file mode 100644 index 0000000..4de0ee2 --- /dev/null +++ b/figs/atoms.fig/liquid-base.gp @@ -0,0 +1,21 @@ +set terminal pngcairo size 2048,2048 + +set key off +unset colorbox +unset border +unset xtics +unset ytics +unset ztics + +set parametric + +set view equal xyz + +set isosample 100 + +set pm3d depthorder +set pm3d lighting primary 0.50 specular 0.6 + +set palette defined (0 "#339999", 1 "#339999") + +splot \ diff --git a/figs/atoms.fig/liquid.py b/figs/atoms.fig/liquid.py new file mode 100644 index 0000000..99b09ba --- /dev/null +++ b/figs/atoms.fig/liquid.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +from math import * +import random + +# size of space +L=15 +# number of particles +N=100 + +# check whether two rods overlap +def check_overlap(sphere1,sphere2): + if(sqrt((sphere2[0]-sphere1[0])**2+(sphere2[1]-sphere1[1])**2+(sphere2[2]-sphere1[2])**2)<2): + return(True) + return(False) + +# configuration +config=[] +# add spheres +while len(config)<N: + # random position + x=[random.uniform(0,L), random.uniform(0,L), random.uniform(0,L)] + # check it does not interfere with other spheres + fine=True + for sphere in config: + if(check_overlap(sphere,x)): + fine=False + break + if fine: + config.append(x) + +for i in range(len(config)): + sphere=config[i] + print(str(sphere[0])+"+cos(u)*sin(v)", end=", ") + print(str(sphere[1])+"+sin(u)*sin(v)", end=", ") + print(str(sphere[2])+"+cos(v)", end=" ") + print("with pm3d", end="") + if i<len(config)-1: + print(", \\") diff --git a/figs/atoms.fig/nematic-base.gp b/figs/atoms.fig/nematic-base.gp new file mode 100644 index 0000000..4de0ee2 --- /dev/null +++ b/figs/atoms.fig/nematic-base.gp @@ -0,0 +1,21 @@ +set terminal pngcairo size 2048,2048 + +set key off +unset colorbox +unset border +unset xtics +unset ytics +unset ztics + +set parametric + +set view equal xyz + +set isosample 100 + +set pm3d depthorder +set pm3d lighting primary 0.50 specular 0.6 + +set palette defined (0 "#339999", 1 "#339999") + +splot \ diff --git a/figs/atoms.fig/nematic.py b/figs/atoms.fig/nematic.py new file mode 100644 index 0000000..5c779c0 --- /dev/null +++ b/figs/atoms.fig/nematic.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python3 + +from math import * +import random + +# size of space +L=30 +# number of rods +N=75 +# aspect ratio +a=10 +# spread in theta angle +spread=pi/30 + +# check whether two rods overlap +def check_overlap(rod1,rod2): + # relative placement + relative_pos=unrotate(subtract(rod2[0],rod1[0]), rod1[1]) + if(abs(relative_pos[0])<2 and abs(relative_pos[1])<2 and abs(relative_pos[2])<2): + return(True) + # relative angle + relative_ang=cart_to_spherical(unrotate(spherical_to_cart(rod2[1]), rod1[1])) + # exclusion volume + # rotate other rod + relative_pos=unrotate(relative_pos, [0,relative_ang[1]]) + #if(abs(relative_pos[1])<2 and abs(relative_pos[0])-2<abs(sin(relative_ang[0]))*a and abs(relative_pos[2])-a-2<abs(cos(relative_ang[0])*a)): + if(abs(relative_pos[1])<2 and abs(relative_pos[0])-2<abs(sin(relative_ang[0]))*a and abs(sin(relative_ang[0])*relative_pos[2]-cos(relative_ang[0])*relative_pos[0])-2<abs(sin(relative_ang[0])*a)): + return(True) + return(False) + +# def subtract vectors +def subtract(x,y): + return([x[0]-y[0],x[1]-y[1],x[2]-y[2]]) +# rotate vector +def unrotate(x,w): + ret=[x[0],x[1],x[2]] + # rotate phi + tmp=cos(w[1])*ret[0]+sin(w[1])*ret[1] + ret[1]=-sin(w[1])*ret[0]+cos(w[1])*ret[1] + ret[0]=tmp + # rotate theta + tmp=cos(w[0])*ret[0]-sin(w[0])*ret[2] + ret[2]=sin(w[0])*ret[0]+cos(w[0])*ret[2] + ret[0]=tmp + return(ret) + +# convert coordinates +def spherical_to_cart(w): + return([cos(w[1])*sin(w[0]),sin(w[1])*sin(w[0]),cos(w[0])]) +def cart_to_spherical(x): + w=[0,0] + w[0]=acos(x[2]) + if(sin(w[0]==0)): + return([w[0],0]) + c=x[0]/sin(w[0]) + s=x[1]/sin(w[0]) + # to avoid truncation errors + if(abs(c)>1 and abs(c)<1.0001): + if(c>0): + return([w[0],0]) + else: + return([w[0],pi]) + if(s>=0): + return([w[0],acos(c)]) + return([w[0],2*pi-acos(c)]) + +# configuration +config=[] +# add rods +while len(config)<N: + # random position and angles + x=[random.uniform(0,L), random.uniform(0,L), random.uniform(0,L)] + w=[abs(random.gauss(0,spread)), random.uniform(0,2*pi)] + # chek it does not interfere with other rods + fine=True + for rod in config: + if(check_overlap(rod,[x,w])): + fine=False + break + if fine: + config.append([x,w]) + +for i in range(len(config)): + rod=config[i] + print(str(rod[0][0])+"+("+str(cos(rod[1][1])*cos(rod[1][0]))+")*cos(u)*sin(v)+("+str(-sin(rod[1][1]))+")*sin(u)*sin(v)+("+str(cos(rod[1][1])*sin(rod[1][0])*a)+")*cos(v)", end=", ") + print(str(rod[0][1])+"+("+str(sin(rod[1][1])*cos(rod[1][0]))+")*cos(u)*sin(v)+("+str(cos(rod[1][1]))+")*sin(u)*sin(v)+("+str(sin(rod[1][1])*sin(rod[1][0])*a)+")*cos(v)", end=", ") + print(str(rod[0][2])+"+("+str(-sin(rod[1][0]))+")*cos(u)*sin(v)+("+str(cos(rod[1][0])*a)+")*cos(v)", end=" ") + print("with pm3d", end="") + if i<len(config)-1: + print(", \\") diff --git a/figs/atoms.fig/smectic-base.gp b/figs/atoms.fig/smectic-base.gp new file mode 100644 index 0000000..6b2077f --- /dev/null +++ b/figs/atoms.fig/smectic-base.gp @@ -0,0 +1,21 @@ +set terminal pngcairo size 2048,2048 + +set key off +unset colorbox +unset border +unset xtics +unset ytics +unset ztics + +set parametric + +set view 90,0 + +set isosample 100 + +set pm3d depthorder +set pm3d lighting primary 0.50 specular 0.6 + +set palette defined (0 "#339999", 1 "#339999") + +splot \ diff --git a/figs/atoms.fig/smectic.py b/figs/atoms.fig/smectic.py new file mode 100644 index 0000000..c8d4d13 --- /dev/null +++ b/figs/atoms.fig/smectic.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 + +from math import * +import random + +# size of space +L=30 +# number of rods +N=150 +# aspect ratio +a=10 +# spread in theta angle +spread=pi/30 +# spread in height +spread_height=a/5 + +# check whether two rods overlap +def check_overlap(rod1,rod2): + # relative placement + relative_pos=unrotate(subtract(rod2[0],rod1[0]), rod1[1]) + if(abs(relative_pos[0])<2 and abs(relative_pos[1])<2 and abs(relative_pos[2])<2): + return(True) + # relative angle + relative_ang=cart_to_spherical(unrotate(spherical_to_cart(rod2[1]), rod1[1])) + # exclusion volume + # rotate other rod + relative_pos=unrotate(relative_pos, [0,relative_ang[1]]) + #if(abs(relative_pos[1])<2 and abs(relative_pos[0])-2<abs(sin(relative_ang[0]))*a and abs(relative_pos[2])-a-2<abs(cos(relative_ang[0])*a)): + if(abs(relative_pos[1])<2 and abs(relative_pos[0])-2<abs(sin(relative_ang[0]))*a and abs(sin(relative_ang[0])*relative_pos[2]-cos(relative_ang[0])*relative_pos[0])-2<abs(sin(relative_ang[0])*a)): + return(True) + return(False) + +# def subtract vectors +def subtract(x,y): + return([x[0]-y[0],x[1]-y[1],x[2]-y[2]]) +# rotate vector +def unrotate(x,w): + ret=[x[0],x[1],x[2]] + # rotate phi + tmp=cos(w[1])*ret[0]+sin(w[1])*ret[1] + ret[1]=-sin(w[1])*ret[0]+cos(w[1])*ret[1] + ret[0]=tmp + # rotate theta + tmp=cos(w[0])*ret[0]-sin(w[0])*ret[2] + ret[2]=sin(w[0])*ret[0]+cos(w[0])*ret[2] + ret[0]=tmp + return(ret) + +# convert coordinates +def spherical_to_cart(w): + return([cos(w[1])*sin(w[0]),sin(w[1])*sin(w[0]),cos(w[0])]) +def cart_to_spherical(x): + w=[0,0] + w[0]=acos(x[2]) + if(sin(w[0]==0)): + return([w[0],0]) + c=x[0]/sin(w[0]) + s=x[1]/sin(w[0]) + # to avoid truncation errors + if(abs(c)>1 and abs(c)<1.0001): + if(c>0): + return([w[0],0]) + else: + return([w[0],pi]) + if(s>=0): + return([w[0],acos(c)]) + return([w[0],2*pi-acos(c)]) + +# configuration +config=[] +# add rods +while len(config)<N: + # random position and angles + x=[random.uniform(0,L), random.uniform(0,L), 1.6*a*random.randint(0,2)+random.gauss(0,spread_height)] + w=[abs(random.gauss(0,spread)), random.uniform(0,2*pi)] + # chek it does not interfere with other rods + fine=True + for rod in config: + if(check_overlap(rod,[x,w])): + fine=False + break + if fine: + config.append([x,w]) + +for i in range(len(config)): + rod=config[i] + print(str(rod[0][0])+"+("+str(cos(rod[1][1])*cos(rod[1][0]))+")*cos(u)*sin(v)+("+str(-sin(rod[1][1]))+")*sin(u)*sin(v)+("+str(cos(rod[1][1])*sin(rod[1][0])*a)+")*cos(v)", end=", ") + print(str(rod[0][1])+"+("+str(sin(rod[1][1])*cos(rod[1][0]))+")*cos(u)*sin(v)+("+str(cos(rod[1][1]))+")*sin(u)*sin(v)+("+str(sin(rod[1][1])*sin(rod[1][0])*a)+")*cos(v)", end=", ") + print(str(rod[0][2])+"+("+str(-sin(rod[1][0]))+")*cos(u)*sin(v)+("+str(cos(rod[1][0])*a)+")*cos(v)", end=" ") + print("with pm3d", end="") + if i<len(config)-1: + print(", \\") |