from cpartition import FCC, BCC, Interface, WBs, x2wp

import matplotlib
matplotlib.rc('font', **{'family':'sans-serif', 'sans-serif':['Arial'], 'size': 13})

# 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))
Exemple #2
0
control_itsteps = ControlIterationSteps([5e-5, 5e-4, 5e-3], [0, 2, 100, 1000])
total_time = control_itsteps.total_time
n_time = control_itsteps.ntime
dt = control_itsteps.dt
each = 200
control_itsteps.print_summary()

# Files containing the chemical potentials of bcc and fcc phases
tdata_fcc = os.path.join('..', 'thermo', 'cast_iron', '375-FCC.TXT')
tdata_bcc = os.path.join('..', 'thermo', 'cast_iron', '375-BCC.TXT')

# Instantiate BCC and FCC classes as mart and aust objects
# T_C: temperature; dt: Time step; z: positions of the nodes;
# c0: initial composition; tdata: location of file containing
# thermodynamical data (chemical potentials)
mart = BCC(T_C=T_C, dt=dt, z=np.linspace(-1.16, -.66, 50), c0=c0,
           tdata=tdata_bcc)
aust = FCC(T_C=T_C, dt=dt, z=np.linspace(-.66, 0, 200), c0=c0,
           tdata=tdata_fcc)

# Interface
intf = Interface(domain1=mart, domain2=aust, type_int='fixed.balance')

log = SimulationLog(basename)
log.set_domains([('mart', mart), ('aust', aust)])
log.set_interfaces([('intf', intf)])
log.set_conditions(c0, T_C, total_time, n_time)
log.initialize(False)

for i in control_itsteps.itlist:
    if i in control_itsteps.itstepi and i > 0:
        control_itsteps.next_itstep()
import numpy as np
import matplotlib.pyplot as plt
from cpartition import FCC, BCC, Interface
from scipy.interpolate import UnivariateSpline

T_C = 375.

tdata_fcc = 'thermo/FoFo/TCFE8/375-fcc.txt'
tdata_bcc = 'thermo/FoFo/TCFE8/375-bcc.txt'

mart = BCC(T_C=T_C, tdata=tdata_bcc)
aust = FCC(T_C=T_C, tdata=tdata_fcc)
intf = Interface(domain1=mart, domain2=aust, type_int='fixed.fluxes')

# ph = mart
ph = aust
x, y = ph.chempot['X(C)'], ph.chempot['MU(C)']

_f = UnivariateSpline(np.log(x), y)
_f_prime = _f.derivative()


def f(x):
    return _f(np.log(x))


def f_prime(x):
    return _f_prime(np.log(x)) / x


def M(x):
T_C = 375.

control_itsteps = ControlIterationSteps([5e-5, 5e-4, 5e-3, 5e-2],
                                        [0, .1, 1, 10, 1000])
total_time = control_itsteps.total_time
n_time = control_itsteps.ntime
dt = control_itsteps.dt
each = 20
control_itsteps.print_summary()

tdata_fcc = os.path.join('..', 'thermo', 'cast_iron', '375-FCC.TXT')
tdata_bcc = os.path.join('..', 'thermo', 'cast_iron', '375-BCC.TXT')

mart = BCC(T_C=T_C,
           dt=dt,
           z=np.linspace(-1.16, -.66, 50),
           c0=c0,
           tdata=tdata_bcc)
aus1 = FCC(T_C=T_C,
           dt=dt,
           z=np.linspace(-.66, -.33, 100),
           c0=c0,
           tdata=tdata_fcc)
fer1 = BCC(T_C=T_C,
           dt=dt,
           z=np.linspace(-.33, -.33, 10),
           c0=0.,
           tdata=tdata_bcc,
           E=WBs(T_C))
aus2 = FCC(T_C=T_C, dt=dt, z=np.linspace(-.33, 0, 100), c0=c0, tdata=tdata_fcc)
fer2 = BCC(T_C=T_C,
Exemple #5
0
                 Fe=9.4414085022e-1)

        for T in sys.argv[1:]:
            try:
                T = float(T)
            except:
                print('{} is not a valid temperature'.format(T))
                continue

            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)']))