Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jauslin <jauslin@ias.edu>2018-02-06 19:57:42 +0000
committerIan Jauslin <jauslin@ias.edu>2018-02-06 19:57:42 +0000
commitbfed53d2c76cc0449d2d6ef1963863092fb98d03 (patch)
treef9ab1f9e84474684dcdaa37b8a0743c4fa93c1b6 /figs/atoms.fig/liquid.py
As presented at Princeton University on 2018-02-06HEADv1.0master
Diffstat (limited to 'figs/atoms.fig/liquid.py')
-rw-r--r--figs/atoms.fig/liquid.py39
1 files changed, 39 insertions, 0 deletions
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(", \\")