import pandas as pd
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
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,
           dt=dt,
           z=np.linspace(0, 0, 10),
           c0=0.,
           tdata=tdata_bcc,
           E=WBs(T_C))
Пример #3
0
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()
        dt = control_itsteps.dt
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):