Exemplo n.º 1
0
def findTriangleEigs(x,y,h,n):
	mesh = assembleTriangle(x,y,h)
	evals,evecs = FE.findEigs(mesh,n=2*n)
	return evals[n], evecs[:,n], mesh
Exemplo n.º 2
0
def findTriangleEig(x,y,h):
	mesh = assembleTriangle(x,y,h)
	evals,evecs = FE.findEigs(mesh,n=2)
	return evals[1], evecs[:,1], mesh
Exemplo n.º 3
0
mesh1 = triangle.triangulate(domain1, "pqa0.02r")
mesh2 = triangle.triangulate(domain2, "pqa0.02r")

ax1 = plt.subplot(121, aspect="equal")
ax2 = plt.subplot(122, aspect="equal")
plot.plot(ax1, **mesh1)
plot.plot(ax2, **mesh2)
plt.show()

X1 = mesh1["vertices"][:, 0]
Y1 = mesh1["vertices"][:, 1]

X2 = mesh2["vertices"][:, 0]
Y2 = mesh2["vertices"][:, 1]

evals1, evecs1 = FE.findEigs(mesh1, 25)
evals2, evecs2 = FE.findEigs(mesh2, 25)

for j in range(25):
    x1 = evals1[j]
    x2 = evals2[j]
    print x1, x2, np.abs(x2 - x1), np.abs(x2 - x1) / min(x2, x1)

k = 17
v1 = evecs1[:, k]
v2 = evecs2[:, k]

# ax1 = plt.subplot(121,aspect='equal')
# ax1.tricontourf(X1,Y1,v1,0,cmap='copper')
# ax2 = plt.subplot(122,aspect='equal')
# ax2.tricontourf(X2,Y2,v2,0,cmap='copper')
Exemplo n.º 4
0
	def __init__(self,root,canvas_width,canvas_height):
		self.root=root
		self.canvas_width = canvas_width
		self.canvas_height = canvas_height

		self.nodes = False
		self.eiglevel = 1
		self.current_refine = 1

		# set up the domain
		self.dom = {'vertices':np.array([[0.,0.],[1.,0.7],[0.5,0.5]])}
		self.mesh = triangle.triangulate(self.dom,'qa0.001')
		x = self.mesh['vertices'][:,0]
		y = self.mesh['vertices'][:,1]
		
		self.eigvals,self.eigvecs = FE.findEigs(self.mesh,10)
		z = self.eigvecs[:,self.eiglevel]

		# set up the matplotlib nonsense
		self.fig, self.ax = mpl.pyplot.subplots()

		self.ax.clear()
		self.ax.autoscale(enable=False)
		self.ax.axis('off')
		
		triang = tri.Triangulation(x,y)
		self.ax.tricontourf(triang,z,100,cmap=plt.get_cmap('copper'))

		self.canvas = FigureCanvasTkAgg(self.fig,master=root)
		self.canvas.show()
		self.canvas.get_tk_widget().pack()

		#self.canvas.mpl_connect("button_press_event", self.setVertex)
		self.canvas.mpl_connect("key_press_event", self.keyEvent)

		print 'connected key press'

		self.ax.set_xlim([0,1])
		self.ax.set_ylim([0,1])
		self.ax.autoscale(enable=False)

		self.fig.tight_layout()

		self.redraw()

		# build and pack other controls
		self.control_frame = Frame(master=root,width=canvas_width/4,height=canvas_height)
		
		self.control_frame.pack(side=TOP)

		self.b = Button(self.control_frame, text="QUIT", command = self.quit)
		self.b.pack(side=LEFT)

		self.c = Button(self.control_frame, text="Toggle Nodal", command=self.toggle)
		self.c.pack(side=LEFT)
		
		self.s = Button(self.control_frame, text="Energy Up", command=self.energy_up)
		self.s.pack(side=LEFT)

		self.t = Button(self.control_frame, text="Energy Down", command=self.energy_down)
		self.t.pack(side=LEFT)
Exemplo n.º 5
0
[6.4,-11],
[30,-11],
[30,0]]), 
'segments':np.array([[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,0]])}#,
#'segment_markers': np.array([[1],[1],[1],[1],[1],[1],[1],[1]]),
#'vertex_markers':np.array([[1],[1],[1],[1],[1],[1],[1],[1]])}

mesh = triangle.triangulate(point_list,'pqa0.02')

ax1 = plt.subplot(111, aspect='equal')
plot.plot(ax1, **mesh)
plt.show()

print len(mesh['vertices'])

evals, evecs = FE.findEigs(mesh,50)

X = mesh['vertices'][:,0]
Y = mesh['vertices'][:,1]

v = evecs[:,45]

fig = plt.figure()
ax = fig.add_subplot(111,aspect='equal')
ax.tricontourf(X,Y,v,0,cmap='copper')
#ax.triplot(tri.Triangulation(t['vertices'][:,0],d['vertices'][:,1]))
#ax.tricontourf(X,Y,v,levels=[-1e9,0,1e9],cmap='gray')
plt.show()