import numpy as np
from pycalphad import Database
from espei.analysis import truncate_arrays
from espei.utils import database_symbols_to_fit, optimal_parameters
= np.load("trace.npy")
trace = np.load("lnprob.npy")
lnprob = truncate_arrays(trace, lnprob)
trace, lnprob
= Database("Cu-Mg-generated.tdb")
dbf = dict(zip(database_symbols_to_fit(dbf), optimal_parameters(trace, lnprob)))
opt_params # Update the symbols in the database, this database can now be used in PyCalphad calculations
dbf.symbols.update(opt_params)# dbf.to_file("Cu-Mg-opt.tdb") # if desired, write out the database
Get optimal MCMC parameters
Load an existing database and optimal parameters from a tracefile and probfile: