def energy_density_plot(storage): rho=[] ener=[] for minimum in storage.data: ca = CoordsAdapter(nrigid=2, nlattice=6, coords=minimum.coords) ml = lattice.lowerTriangular(ca.lattice) volume = np.dot(ml[:,0],np.cross(ml[:,1], ml[:,2])) rho.append(1./volume) ener.append(minimum.energy) return rho, ener
def draw(self, coords_rigid, index): from OpenGL import GL,GLUT coords=np.zeros([GMIN.getNAtoms(), 3]) GMIN.toAtomistic(coords.reshape(coords.size), coords_rigid) #coords = coords.reshape(GMIN.getNAtoms, 3) com=np.mean(coords, axis=0) if index == 1: color = [[0.65, 0.0, 0.0, 1.], [0.35, 0.0, 0.0, 1.]] else: color = [[0.00, 0.65, 0., 1.], [0.00, 0.35, 0., 1.]] i=0 for xx in coords[:-2]: GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, color[i%2]) i+=1 x = xx-com GL.glPushMatrix() GL.glTranslate(x[0],x[1],x[2]) GLUT.glutSolidSphere(0.5,30,30) GL.glPopMatrix() GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, [0.,0.,1.,1.]) from pygmin.utils import lattice l = lattice.lowerTriangular(coords_rigid[-6:]) mb = l[:,0] + l[:,1] + l[:,2] GL.glPushMatrix() GL.glTranslate(-0.5*mb[0],-0.5*mb[1],-0.5*mb[2]) for i in xrange(3): self.drawCylinder([0.,0.,0.], l[:,i]) for i in xrange(1,3): self.drawCylinder(l[:,0], l[:,0] + l[:,i]) mb = l[:,0] + l[:,1] + l[:,2] for i in xrange(0,3): self.drawCylinder(mb, mb - l[:,i]) for i in xrange(1,3): self.drawCylinder(mb-l[:,0], mb - l[:,i]-l[:,0]) self.drawCylinder(l[:,1], l[:,1] + l[:,0]) self.drawCylinder(l[:,2], l[:,2] + l[:,0]) GL.glPopMatrix()