def plot_cavg(files, key='mart.cavg', labels=None, styles=None, ax=None, plotcarbides=False, **kwargs): if ax is None: fig, ax = plt.subplots() if labels: cylbls = cycle(labels) if styles: cysty = cycle(styles) x = kwargs.pop('x', None) w = kwargs.pop('w', None) y = kwargs.pop('y', None) for fname in files: df = pd.read_csv(fname, sep=' ') args = [] if labels: kwargs.update(dict(label=next(cylbls))) if styles: args.append(next(cysty)) ax.plot(df.t, x2wp(df[key], x=x, w=w, y=y), *args, **kwargs) ax.set_xlim(-.5, 100.5) yrng = np.array([-1e-4, 4.5e-2]) ax.set_ylim(x2wp(yrng, x=x, w=w, y=y)) ax.set_xlabel('Partitioning time (s)') ax.set_ylabel(r"Carbon in $\alpha' + \theta$ (wt.%)") if plotcarbides: ax2 = ax.twinx() ax2.set_ylim(100 * x2vcem(yrng / .25)) ax2.set_ylabel("Carbides fraction (vol.%)") ax.legend(loc='lower right', fancybox=False) return ax, ax2 else: return ax
# Site fraction of substitutional elements in cast iron's austenite T_C = 375 y = dict(Cu=3.55354266E-3, Mn=2.05516602E-3, Si=5.02504411E-2, Fe=9.4414085022e-1) cint = pd.read_csv('../C_extremities/coupled_FoFo_375_CCE.txt', sep=' ') pos = pd.read_csv('../pos_extremities/coupled_FoFo_375_CCE.txt', sep=' ') # For calculating WBs aust = FCC(T_C=T_C, tdata='../thermo/FoFo/TCFE8/375-fcc.txt') ferr = BCC(T_C=T_C, tdata='../thermo/FoFo/TCFE8/375-bcc.txt', E=WBs(T_C)) intf = Interface(domain1=aust, domain2=ferr, type_int='mobile.eq') # WBs composition _, cwbs = intf.comp() cwbs = x2wp(cwbs, y=y) # Driving force DF = -intf.chem_driving_force(ci_bcc=cint['fer1.ci0'], ci_fcc=cint['aus1.cin']) posf = pos['aus1.sn'].values[-1] tf = pos['t'].values[-1] # Ploting interface position and composition # Setting pre-plot parameters fig1, ax1 = plt.subplots(figsize=(3.5, 3.5)) # composition ax1.plot(cint['t'], x2wp(cint['aus1.cin'], y=y), 'k-', label=r'$c^\gamma_{int_1}$')
def x2wp(self, x): return x2wp(x, y=self.yalloy)
rcParams.update({ 'font.family': 'sans-serif', 'font.sans-serif': 'Arial', 'font.size': 13 }) files = ['../C_avg/coupled_FoFo_375_mu20e3.txt'] labels = [r'$\mu_C =$' + u' 20,0 kJ/mol'] fig, ax = plt.subplots(figsize=(5, 4)) y = dict(Cu=3.55354266E-3, Mn=2.05516602E-3, Si=5.02504411E-2, Fe=9.4414085022e-1) c0 = x2wp(3.34414e-02, y=y) WBs = 1.5902 ax = plot_cavg(files, labels, ax=ax, lw=1, y=y, plotcarbides=False) ax.axhline(c0, ls=':', color='k', lw=1) ax.axhline(WBs, ls=':', color='k', lw=1) ax.set_xscale('log') ax.set_xlim(1e-2, 1000) ax.set_ylim(0, 1.4) ax.set_xlabel('Tempo (s)') ax.set_ylabel(u'Carbono médio em ' + r"$\alpha' + \theta$ (%)") ax.legend(loc='best', fancybox=False, ncol=2) fout = '/home/arthur/tese/img/cpartition/coupled_cavg_mu20e3.svg'
'mathtext.fontset': 'stix' }) fig, axes = plt.subplots(2, 2, figsize=(12, 8)) ax0, ax1, ax2, ax3 = axes.ravel() plt.subplots_adjust(wspace=.2, hspace=.35) ########################################################### # y, c0, and WBs for the high manganese, high carbon region (cell boundary) y = dict(Si=0.034356055114394574, Mn=0.003731497480722358, Cu=0.0027562013887263755) y['Fe'] = 1. - sum(y.values()) c0 = x2wp(3.8553489675740495e-2, y=y) WBs = 1.5424 ########################################################### labels = [('aus1', r'$\gamma$', 1), ('aus2', r'$\gamma$', 1), ('fer1', r'$\alpha_{b}$', 1), ('fer2', r'$\alpha_{b}$', 1), ('fer3', r'$\alpha_{b}$', 1)] p0 = CProfiles('bainite_FoFo_375', '../C_profiles') ax0.axhline(c0, ls=':', color='k', lw=1) ax0.axhline(WBs, ls=':', color='k', lw=1) ax0.text(-1.1, c0, r'c$_0$', ha='left', va='bottom', size=10) ax0.text(-1.15, WBs, 'WBs', ha='left', va='bottom', size=10) p0.plot_cprofiles(tlist=[1, 10, 100, 300],
from matplotlib import rcParams rcParams.update({ 'font.family': 'sans-serif', 'font.sans-serif': 'Arial', 'font.size': 13 }) fname = '../C_avg/mart_FoFo_CCE.txt' df = pd.read_csv(fname, sep=' ') y = dict(Cu=3.55354266E-3, Mn=2.05516602E-3, Si=5.02504411E-2, Fe=9.4414085022e-1) c0 = x2wp(3.34414e-02, y=y) fig, ax = plt.subplots(figsize=(6, 4)) ax.plot(df['t'], x2wp(df['aust.cavg'], y=y), 'k--', label=r"$\gamma$") ax.plot(df['t'], x2wp(df['mart.cavg'], y=y), 'k-', label=r"$\alpha'$") ax.axhline(c0, ls=':', color='k', lw=1) ax.set_xscale('log') ax.set_xlim(1e-4, 1000) # ax.set_ylim(0, 1.4) ax.set_xlabel('Tempo (s)') ax.set_ylabel(u'Teor de carbono médio na fase (% massa)') ax.legend(loc='best', fancybox=False) ax.annotate(s=r'$c_0$', xy=(.8e3, c0 * 1.05), ha='right') fout = '/home/arthur/tese/img/cpartition/CCE_cavg.svg'
y = dict(Cu=3.55354266E-3, Mn=2.05516602E-3, Si=5.02504411E-2, Fe=9.4414085022e-1) parser = argparse.ArgumentParser() parser.add_argument('basenames', nargs='+') parser.add_argument('-S', '--save', action='store_true', help='Save plot') args = parser.parse_args() for basename in args.basenames: cprofiles = CProfiles(basename) print(cprofiles.basename) ax = cprofiles.plot_colormap(mirror=True, func=lambda x: x2wp(x, y=y), vmin=0, vmax=1.8) ax.set_xlabel(u'Position (μm)') ax.set_ylabel('Time (s)') ax.set_title(cprofiles.basename) if args.save: plt.savefig(os.path.join('img', cprofiles.basename + '.png'), dpi=150) plt.close() plt.show()
tdata_fcc = 'thermo/FoFo/TCFE8/{:.0f}-fcc.txt'.format(T) tdata_bcc = 'thermo/FoFo/TCFE8/{:.0f}-bcc.txt'.format(T) # tdata_fcc = 'thermo/FoFo/TCFE0/375-FCC.TXT' # tdata_bcc = 'thermo/FoFo/TCFE0/375-BCC.TXT' try: aust = FCC(T_C=T, tdata=tdata_fcc) ferr = BCC(T_C=T, tdata=tdata_bcc, E=WBs(T)) except: print('Failed to initialize ferr and/or aust') continue # We want to find the zero of this function, which # is the difference between muZ(aust) and muZ(ferr) # both expressed as functions of muC # When g(muC) = 0, then muC and muZ are equal for # ferr and aust def g(muC): return aust.muC2muZ(muC) - ferr.muC2muZ(muC) # minimum and maximum values of mu_C lo = max(min(aust.chempot['MU(C)']), min(ferr.chempot['MU(C)'])) hi = min(max(aust.chempot['MU(C)']), max(ferr.chempot['MU(C)'])) muC = bisect(g, lo, hi, xtol=1e-3) cferr = ferr.mu2x['C'](muC) caust = aust.mu2x['C'](muC) print('{:g} oC, muC={:g} J/mol, caust={:g} wt.%'.format( T, muC, x2wp(caust, y=y)))
########################################################## # c0 = x2wp(3.34414e-02, y=y) # WBs = 1.5902 for fname_position, fname_cavg, label in zip(files_position, files_cavg, labels): average_carbon = calculate_average_carbon(fname_position, fname_cavg) if 'bainite' not in fname_position: y = dict(Cu=3.55354266E-3, Mn=2.05516602E-3, Si=5.02504411E-2, Fe=9.4414085022e-1) ax1.plot(average_carbon.t, x2wp(average_carbon.mart, y=y), label=label, lw=1) else: y = dict(Si=0.034356055114394574, Mn=0.003731497480722358, Cu=0.0027562013887263755) y['Fe'] = 1. - sum(y.values()) ax2.plot(average_carbon.t, x2wp(average_carbon.aus, y=y), label=label, lw=1) ax1.set_xlabel('Isothermal holding (partitioning) time (s)') ax1.set_ylabel(r"$\overline{c^{\alpha' + \theta}}$ (wt.%)")
import argparse colorcycle = cycle( matplotlib.rcParams['axes.prop_cycle'].by_key()['color']) y = dict(Cu=3.55354266E-3, Mn=2.05516602E-3, Si=5.02504411E-2, Fe=9.4414085022e-1) # For calculating WBs T_C = 375. aust = FCC(T_C=T_C, tdata='thermo/FoFo/TCFE8/375-fcc.txt') ferr = BCC(T_C=T_C, tdata='thermo/FoFo/TCFE8/375-bcc.txt', E=WBs(T_C)) intf = Interface(domain1=aust, domain2=ferr, type_int='mobile.eq') # WBs composition _, cwbs = intf.comp() cwbs = x2wp(cwbs, y=y) parser = argparse.ArgumentParser() parser.add_argument('basenames', nargs='+') parser.add_argument('-s', '--silent', action='store_false') parser.add_argument('-S', '--save', action='store_true') parser.add_argument('-d', '--dir', default='/home/arthur/tese/img/cpartition/cprofiles') parser.add_argument('-e', '--ext', default='.svg') parser.add_argument('-a', '--append', default='') parser.add_argument('-f', '--figsize', type=float, nargs=2, default=[6, 4]) parser.add_argument('-m', '--mirror', action='store_true') parser.add_argument('-x', '--xlim', type=float, nargs=2, default=[None, None])