예제 #1
0
    def test_icvm_log(self):
        """
        icvm log
        """
        path = os.path.join(TEST_PATH, 'montecarlo/i-s/fcci/Ti1C1/str_energy.txt')
        path = os.path.join(TEST_PATH, 'montecarlo/i-s/fcci/Ti1C1/R5N4/log.txt')
        log = CVMLogEnth.from_file_ternary(path)
        log.stable.data += log.meta.data

        print(log.stable['c_a'] )
        conc_A = log.stable['c_a']
        print(conc_A)

        conc_C = log.stable['c_c']  / (0.5 + log.stable['c_a'])
        print(conc_C)

        data_xyz = np.c_[conc_A, conc_C,
                         log.stable['enth']]

        fig = pylab.figure()
        ax = Axes3D(fig)
        pt3d = convex_hull.PlotTriangularCoord(ax)
        pt3d.plt_dot(data_xyz)

        path = os.path.join(TEST_PATH, 'montecarlo/i-s/fcci/Ti0C1/str_energy.txt')
        log = CVMLogEnth.from_file_ternary(path)
        log.stable.data += log.meta.data

        print(log.stable['c_a'] )
        conc_A = log.stable['c_a']
        print(conc_A)

        conc_C = (0.5 - log.stable['c_c'])  / (0.5 + log.stable['c_a'])
        print(conc_C)

        data_xyz = np.c_[conc_A, conc_C,
                         log.stable['enth']]

        pt3d.plt_dot(data_xyz, color='r')

        pylab.show()
예제 #2
0
def plot(save, log_file, with_cem, vac_corr, end, wo_zero_zero,
         set_yrange, set_xrange):
    def get_correction(x, vac_corr):
        if Fraction(vac_corr):
            return 1/(x+Fraction(vac_corr))
        else:
            return 1

    def get_slope(x, end):
        return end[0]*(1-x) + end[1]*(x)

    data = CVMCv1Parser.from_file('cv1.txt')
    seaborn.set_style('whitegrid')

    fig = pylab.figure()
    plot1 = fig.add_subplot(111)
    plot1.set_ylabel("Free energy (kJ/mol)", fontsize=16)
    plot1.set_xlabel("Fraction of atom A", fontsize=16)
    pylab.xticks(fontsize=14)
    pylab.ylabel("Free energy (kJ/mol)", fontsize=16)
    pylab.xlabel("Fraction of atom A", fontsize=16)
    pylab.yticks(fontsize=14)
    fig.subplots_adjust(bottom=0.15)
    # seaborn.set_palette("winter", len(data.data))
    dict_data = {}
    for data_tmp in data.data:
        dict_data.update({data_tmp['temp']: data_tmp['data']})

    for i, temp in enumerate(sorted(dict_data.keys())):
        color = pylab.cm.cool(i/len(dict_data)) #pylint: disable=E1101
        if wo_zero_zero:
            dict_data[temp].set_free_energy_00(0, 0)
        else:
            dict_data[temp].set_free_energy_00_from_logtxt(log_file)
        dict_data[temp].set_end_energy(end[0], end[1])
        label = str(temp) + "K"
        x = dict_data[temp]['comp1']
        corr = get_correction(x, vac_corr)

        pylab.plot(x*corr, dict_data[temp]['corrected_g']*corr,
                   'o', label=label, color=color)

    pylab.legend(loc='lower left')

    if with_cem:
        cem = CVMLogEnth.from_file(log_file)
        x = cem.stable['c_a']
        corr = get_correction(x, vac_corr)
        pylab.plot(x * corr,
                   (cem.stable['enth']*96.485/1000+get_slope(x, end))*corr, '*',
                   color='orange')
        x = cem.meta['c_a']
        corr = get_correction(x, vac_corr)
        pylab.plot(x * corr,
                   (cem.meta['enth']*96.485/1000+get_slope(x, end))*corr, '*',
                   color='orange')
        x = cem.unstable['c_a']
        corr = get_correction(x, vac_corr)
        pylab.plot(x * corr,
                   (cem.unstable['enth']*96.485/1000+get_slope(x, end))*corr,
                   '*', color='orange')
        x = cem.exact['c_a']
        corr = get_correction(x, vac_corr)
        pylab.plot(x * corr,
                   (cem.exact['exact']*96.485/1000+get_slope(x, end))*corr,
                   '.', color='magenta')

    if set_yrange != (0, 0):
        pylab.ylim(*set_yrange)
    if set_xrange != (0, 0):
        pylab.xlim(*set_xrange)

    if save:
        pylab.savefig("plot.eps")
    else:
        pylab.show()
예제 #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
cvm 関連の perser
"""
from parse_cvm import CVMLogEnth
from pyhull import qconvex

# 二元系のみ対応
# もしかしたら使えるかもしれないが、三元系以上は未検証

log = CVMLogEnth.from_file('log.txt')
lines = log.print_all_phase_energy()
# print(lines)

# # print gs
# data = [(float(x.split()[0]), float(x.split()[1]))
#         for x in lines.split('\n')[1:-1]]
# # print(qconvex('s i', data))
# gs = qconvex('s p', data)
# print('\nGS_calc')
# for g in gs[2:]:
#     print(g)

# # print gs
# data = [(float(x.split()[0]), float(x.split()[2])) for x in lines.split('\n')[1:-1]]
# # print(qconvex('s i', data))
# gs = qconvex('s p', data)
# print('\nGS_exact')
# for g in gs[2:]:
#     print(g)
예제 #4
0
#!/opt/anaconda/bin/python
# -*- coding: utf-8 -*-
"""
cvm 関連の perser
"""
from parse_cvm import CVMLogEnth

log = CVMLogEnth.from_file("log.txt")
log.print_all_phase_energy()