geometry.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:dft 作者: rosenbrockc 项目源码 文件源码
def _latvec_plot(self, R=True, withpts=False, legend=False):
        """Plots the lattice vectors (for real or reciprocal space).
        """
        import matplotlib.pyplot as plt
        from mpl_toolkits.mplot3d import Axes3D
        fig = plt.figure()
        ax = fig.gca(projection='3d')

        vecs = self.R if R else self.K
        for i in range(3):
            steps = np.linspace(0, 1, np.floor(10*np.linalg.norm(vecs[:,i])))
            Ri = vecs[:,i]
            Ri.shape = (1, 3)
            steps.shape = (len(steps), 1)
            line = np.dot(steps, Ri)
            ax.plot(line[:,0], line[:,1], line[:,2], label="R{0:d}".format(i+1))

        if withpts:
            pts = self.r if R else self.G
            ax.scatter(pts[:,0], pts[:,1], pts[:,2], color='k')

        if legend:
            ax.legend()

        return (fig, ax)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号