Commit aa6235ca authored by Gilliam van Oudenaren's avatar Gilliam van Oudenaren
Browse files

numbered beads, added visualization for options next bead, created a (not...

numbered beads, added visualization for options next bead, created a (not completely working) function that detectes line intersection
parent 95bb3d51
......@@ -24,4 +24,31 @@ def MCweight(Ej):
else:
randnum = W*np.random.rand()
j = next(x[0] for x in enumerate(np.cumsum(wj)) if x[1] > randnum)
return j
\ No newline at end of file
return j
def radiussqrt2(xy, roptions):
xy=xy[:-1] #remove this later
xydis = xy[:-1]-xy[-1]
xy2 = np.sum(xydis**2, axis = 1)
close = [j for j in range(len(xydis)) if xy2[j] < 2]
close.remove((len(xy)-2))
print("Points sqrt(2) within point %d are: " % (len(xy)-1) + str(close))
for i in close:
for j in range(len(roptions)):
print(i,j)
A1 = 0.5*np.linalg.det(np.array([np.concatenate((xy[-1], [1])),
np.concatenate((xy[i], [1])),
np.concatenate((xy[i-1], [1]))]))
A2 = 0.5*np.linalg.det(np.array([np.concatenate((xy[-1], [1])),
np.concatenate((xy[i], [1])),
np.concatenate((roptions[1], [1]))]))
A3 = 0.5*np.linalg.det(np.array([np.concatenate((xy[-1], [1])),
np.concatenate((xy[i], [1])),
np.concatenate((xy[i+1], [1]))]))
if abs(A1+A2) <= max(abs(A1), abs(A2)):
print("Option %d intersects point %d and %d" % (j, (i-1), i))
if abs(A2+A3) <= max(abs(A2), abs(A3)):
print("Option %d intersects point %d and %d" % (j, i, (i+1)))
\ No newline at end of file
......@@ -3,7 +3,6 @@ import matplotlib.pyplot as plt
import functions
from parameters import N, theta
plt.close("all")
xy = np.zeros((N, 2))
xy[0] = [0, 0]
......@@ -21,8 +20,19 @@ while i < len(xy):
else:
xy[i] = xy[i-1] + np.transpose(np.array([np.sin(theta[j]+theta0), np.cos(theta[j]+theta0)]))
i += 1
txtstr = [str(i) for i in range(len(xy))]
plt.close("all")
plt.figure()
plt.plot(xy[:, 0], xy[:, 1])
plt.scatter(xy[:, 0], xy[:, 1],color = 'k')
plt.show()
for i in range(len(xy)-1):
plt.text(xy[i, 0], xy[i, 1],txtstr[i])
txtstr = [str(i) for i in range(len(xy))]
for i in range(len(roptions)):
plt.plot([xy[-2,0], roptions[i, 0]], [xy[-2,1], roptions[i, 1]], c = 'r')
plt.scatter(roptions[i, 0], roptions[i, 1], c = 'k')
plt.text(roptions[i, 0], roptions[i, 1], s= "option " + str(i))
plt.show()
\ No newline at end of file
import numpy as np
#Physical constants
kbT = 1e+3
kbT = 1e+1
epsilon = 0.25
sigma = 0.8
......@@ -9,4 +9,4 @@ n = 6
theta = 2*np.pi/n*np.arange(n)
#Chain length
N = 200
N = 30
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment