示例#1
0
 def _test_from_pm(self):
     """
     MPのデータをプロット
     """
     ent_list = []
     mpr = MPRester("WTxsDhRV7g2Mcbqw")
     composition = ['Fe', 'Ni', 'Si']
     entries = mpr.get_entries_in_chemsys(composition)
     for entry in entries:
         formula = entry.as_dict()['data']['unit_cell_formula']
         formation_e = entry.as_dict()['data']['formation_energy_per_atom']
         if formation_e <= 0:
             single_data = []
             sum_atoms = 0
             for elements, index in formula.items():
                 sum_atoms += index
             for element in composition:
                 try:
                     single_data.append(formula[element] / sum_atoms)
                 except KeyError:
                     single_data.append(0)
             single_data.append(formation_e * 96.485344520851)
             ent_list.append(single_data)
     initial_base = [[x[0], x[1], x[3]] for x in ent_list[0:3]]
     not_base = [[x[0], x[1], x[3]] for x in ent_list[3:]]
     fig = pylab.figure()
     ax = Axes3D(fig)
     convex_hull.draw_convex_hull(ax, initial_base, not_base,
                                  ['Fe', 'Ni', 'Si'], [-60, 5],
                                  color='magenta')
     #pint(not_base)
     pylab.show()
    def _test_draw_convex_hull(self):
        data = pylab.loadtxt(self.path, comments="#")
        initial_base = [list(x) for x in data[0:3, [0, 2, 3]]]
        not_base = [list(x) for x in data[3:, [0, 2, 3]]]

        fig = pylab.figure()
        ax = Axes3D(fig)
        convex_hull.draw_convex_hull(ax, initial_base, not_base, ["Fe", "Ni", "Si"], [-60, 5])
        # pint(not_base)
        pylab.show()
示例#3
0
    def test_ternary(self):
        out = uspex.Output(os.path.join(self.path3, 'OUTPUT.txt'))
        aux = uspex.Auxiliary.from_file(self.path3)
        aux.ternary()
        initial_base, not_bases, meta_stables = aux.separate_bases()
        fig = pylab.figure()
        ax = Axes3D(fig)
        with open('/Users/enoki/pickle', 'wb') as wbfile:
            data = pickle.dump(meta_stables, wbfile)

        convex_hull.draw_convex_hull(ax, initial_base, not_bases,
                                          out.elements, [-60, 5])
        pylab.show()
示例#4
0
 def test_ternary(self):
     out = uspex.Output(os.path.join(self.path3, 'OUTPUT.txt'))
     aux = uspex.Auxiliary.from_file(self.path3)
     aux.ternary()
     initial_base, not_bases, meta_stables = aux.separate_bases()
     ax = convex_hull.draw_convex_hull(initial_base, not_bases,
                                       out.elements, [-60, 5])
     pylab.show()
    def test_convex(self):
        """
        アニメーション
        """
        base_list = [os.path.join(self.path, "Fe")]
        # FeNi3 = GibbsWithComp.from_dirc(os.path.join(self.path, 'Fe3Ni_L12'))
        base_list.append(os.path.join(self.path, "Ni"))
        base_list.append(os.path.join(self.path, "Si"))
        ref = References.from_directories(base_list)

        compounds = glob.glob(os.path.join(self.path, "*", "gibbs-temperature.dat"))
        compounds = [os.path.dirname(x) for x in compounds]

        fig = pylab.figure()
        ax = Axes3D(fig)
        i = 0
        elems = ["Fe", "Ni", "Si"]
        pressure = 0
        for i in [0, 2]:
            temp_list = [0, 1000, 0]
            temp = temp_list[i]
            pres_list = [0, 0, 10]
            pressure = pres_list[i]
            bases = []
            for base in base_list:
                mwc = MurnaghanWithComp.from_directory(base)
                ent = Enthalpy(mwc, ref)
                ent["enthalpy"] = ent.enthalpy(pressure)
                bases.append(ent.atT_with_comp(temp, elems))
                bases[-1][-1] *= 96.485344520851

            not_bases = []
            for compound in compounds:
                mwc = MurnaghanWithComp.from_directory(compound)
                ent = Enthalpy(mwc, ref)
                ent["enthalpy"] = ent.enthalpy(pressure)
                not_bases.append(ent.atT_with_comp(temp, elems))
                not_bases[-1][-1] *= 96.485344520851

            mwc = MurnaghanWithComp.from_directory(os.path.join(self.path, "Fe2NiSi_5to10"))
            ent = Enthalpy(mwc, ref)
            ent["enthalpy"] = ent.enthalpy(pressure)
            heusler = ent.atT_with_comp(temp, elems)
            heusler[-1] *= 96.485344520851
            not_bases.remove(bases[0])
            not_bases.remove(bases[1])
            not_bases.remove(bases[2])

            tri = FindGS.collect_base_triangles(bases, not_bases)
            fromgs = FindGS.fromGround(tri, [heusler])
            print("{0} {1} {2}".format(temp, fromgs[0][2], heusler[-1]))

            color = ["blue", "magenta", "green"]
            convex_hull.draw_convex_hull(ax, bases, not_bases, ["Fe", "Ni", "Si"], [-80, 5], color=color[i])
            i += 1

        def animate(i):
            ax.view_init(30, 2 * i)
            fig.canvas.draw()

        FFwriter = animation.FFMpegWriter(fps=15, metadata=dict(artist="Me"), bitrate=1800)
        anim = animation.FuncAnimation(fig, animate, frames=180, interval=1, blit=False)
        anim.save("test.mp4", writer=FFwriter)

        pylab.show()