In [2]:
from pycalphad import Model, Database
from pycalphad.core.autograd_utils import build_functions as bf_interpreted
from pycalphad.core.custom_ufuncify import ufuncify
from pycalphad.core.sympydiff_utils import build_functions as bf_compiled
import pycalphad.variables as v
from sympy.printing.ccode import CCodePrinter
import numpy as np
dbf = Database('2016-04-09-AlNi.tdb')
mod = Model(dbf, ['AL', 'NI', 'VA'], 'FCC_L12')
In [3]:
%lprun -f CCodePrinter._print_Piecewise obj, grad, hess = bf_compiled(mod.ast, tuple([v.T] + mod.site_fractions))
temps = np.linspace(300., 2000., 1000)
In [3]:
%time res1 = hess(300, 0.4, 0.6, 0.4, 0.6, 0.4, 0.6, 0.4, 0.6, 1)
In [4]:
%time ag_obj, ag_grad, ag_hess = bf_interpreted(mod.ast, [v.T] + mod.site_fractions)
In [5]:
%time res2 = ag_hess(300, 0.4, 0.6, 0.4, 0.6, 0.4, 0.6, 0.4, 0.6, 1)
In [6]:
np.testing.assert_allclose(np.squeeze(res1), np.squeeze(res2))
In [ ]: