예제 #1
0
파일: hist.py 프로젝트: gmatteo/abipy
    def mvplot_trajectories(self, colormap="hot", sampling=1, figure=None, show=True,
                            with_forces=True, **kwargs):  # pragma: no cover
        """
        Call mayavi_ to plot atomic trajectories and the variation of the unit cell.
        """
        from abipy.display import mvtk
        figure, mlab = mvtk.get_fig_mlab(figure=figure)
        style = "labels"
        line_width = 100
        mvtk.plot_structure(self.initial_structure, style=style, unit_cell_color=(1, 0, 0), figure=figure)
        mvtk.plot_structure(self.final_structure, style=style, unit_cell_color=(0, 0, 0), figure=figure)

        steps = np.arange(start=0, stop=self.num_steps, step=sampling)
        xcart_list = self.reader.read_value("xcart") * units.bohr_to_ang
        for iatom in range(self.reader.natom):
            x, y, z = xcart_list[::sampling, iatom, :].T
            #for i in zip(x, y, z): print(i)
            trajectory = mlab.plot3d(x, y, z, steps, colormap=colormap, tube_radius=None,
                                    line_width=line_width, figure=figure)
            mlab.colorbar(trajectory, title='Iteration', orientation='vertical')

        if with_forces:
            fcart_list = self.reader.read_cart_forces(unit="eV ang^-1")
            for iatom in range(self.reader.natom):
                x, y, z = xcart_list[::sampling, iatom, :].T
                u, v, w = fcart_list[::sampling, iatom, :].T
                q = mlab.quiver3d(x, y, z, u, v, w, figure=figure, colormap=colormap,
                                  line_width=line_width, scale_factor=10)
                #mlab.colorbar(q, title='Forces [eV/Ang]', orientation='vertical')

        if show: mlab.show()
        return figure
예제 #2
0
    def mvplot_trajectories(self,
                            colormap="hot",
                            sampling=1,
                            figure=None,
                            show=True,
                            with_forces=True,
                            **kwargs):  # pragma: no cover
        """
        Call mayavi_ to plot atomic trajectories and the variation of the unit cell.
        """
        from abipy.display import mvtk
        figure, mlab = mvtk.get_fig_mlab(figure=figure)
        style = "labels"
        line_width = 100
        mvtk.plot_structure(self.initial_structure,
                            style=style,
                            unit_cell_color=(1, 0, 0),
                            figure=figure)
        mvtk.plot_structure(self.final_structure,
                            style=style,
                            unit_cell_color=(0, 0, 0),
                            figure=figure)

        steps = np.arange(start=0, stop=self.num_steps, step=sampling)
        xcart_list = self.reader.read_value("xcart") * units.bohr_to_ang
        for iatom in range(self.reader.natom):
            x, y, z = xcart_list[::sampling, iatom, :].T
            #for i in zip(x, y, z): print(i)
            trajectory = mlab.plot3d(x,
                                     y,
                                     z,
                                     steps,
                                     colormap=colormap,
                                     tube_radius=None,
                                     line_width=line_width,
                                     figure=figure)
            mlab.colorbar(trajectory,
                          title='Iteration',
                          orientation='vertical')

        if with_forces:
            fcart_list = self.reader.read_cart_forces(unit="eV ang^-1")
            for iatom in range(self.reader.natom):
                x, y, z = xcart_list[::sampling, iatom, :].T
                u, v, w = fcart_list[::sampling, iatom, :].T
                q = mlab.quiver3d(x,
                                  y,
                                  z,
                                  u,
                                  v,
                                  w,
                                  figure=figure,
                                  colormap=colormap,
                                  line_width=line_width,
                                  scale_factor=10)
                #mlab.colorbar(q, title='Forces [eV/Ang]', orientation='vertical')

        if show: mlab.show()
        return figure
예제 #3
0
파일: hist.py 프로젝트: gmatteo/abipy
 def anim():
     """Animate."""
     for it, structure in enumerate(self.structures):
     #for it in range(self.num_steps):
         print('Updating scene for iteration:', it)
         #mlab.clf(figure=figure)
         mvtk.plot_structure(structure, style=style, figure=figure)
         #x, y, z = xcart_list[it, :, :].T
         #nodes.mlab_source.set(x=x, y=y, z=z)
         #figure.scene.render()
         mlab.draw(figure=figure)
         yield
예제 #4
0
 def anim():
     """Animate."""
     for it, structure in enumerate(self.structures):
         #for it in range(self.num_steps):
         print('Updating scene for iteration:', it)
         #mlab.clf(figure=figure)
         mvtk.plot_structure(structure, style=style, figure=figure)
         #x, y, z = xcart_list[it, :, :].T
         #nodes.mlab_source.set(x=x, y=y, z=z)
         #figure.scene.render()
         mlab.draw(figure=figure)
         yield
예제 #5
0
파일: test_mvtk.py 프로젝트: gmatteo/abipy
    def test_mayavi_toolkit(self):
        """Test mayavi toolkit."""
        if not self.has_mayavi():
            raise self.SkipTest("This test requires mayavi!")

        figure, mlab = mvtk.get_fig_mlab(figure=None)

        si_structure = self.get_abistructure_from_abiref("si_nscf_GSR.nc")

        same_fig = mvtk.plot_wigner_seitz(si_structure.lattice, figure=figure)
        assert same_fig is figure

        figure = mvtk.plot_unit_cell(si_structure.lattice)
        assert mvtk.plot_lattice_vectors(si_structure.lattice, figure=figure) is figure

        assert mvtk.plot_structure(si_structure, frac_coords=False, to_unit_cell=False, style="points+labels",
                                   unit_cell_color=(0, 0, 0), color_scheme="VESTA", figure=None, show=False)
예제 #6
0
파일: test_mvtk.py 프로젝트: zbwang/abipy
    def test_mayavi_toolkit(self):
        """Test mayavi toolkit."""
        if not self.has_mayavi():
            raise self.SkipTest("This test requires mayavi!")

        figure, mlab = mvtk.get_fig_mlab(figure=None)

        si_structure = self.get_abistructure_from_abiref("si_nscf_GSR.nc")

        same_fig = mvtk.plot_wigner_seitz(si_structure.lattice, figure=figure)
        assert same_fig is figure

        figure = mvtk.plot_unit_cell(si_structure.lattice)
        assert mvtk.plot_lattice_vectors(si_structure.lattice,
                                         figure=figure) is figure

        assert mvtk.plot_structure(si_structure,
                                   frac_coords=False,
                                   to_unit_cell=False,
                                   style="points+labels",
                                   unit_cell_color=(0, 0, 0),
                                   color_scheme="VESTA",
                                   figure=None,
                                   show=False)