```python
import numpy as np
from pycalphad import Model, Database, calculate, equilibrium
import pycalphad.variables as v

#dbf = Database('2016-08-10-AlGdMgand18RLPSO-for 3d plot.tdb')
dbf = Database('alfe_sei.TDB')
models = {key: Model(dbf, ['AL', 'FE', 'VA'], key) for key in dbf.phases.keys()}
```

```python
#Set compiler directives (cf. http://docs.cython.org/src/reference/compilation.html)
%load_ext cython
from Cython.Compiler.Options import _directive_defaults

_directive_defaults['linetrace'] = True
_directive_defaults['binding'] = True
```

    /home/rotis/anaconda/envs/calphadpy3/lib/python3.5/site-packages/Cython/Distutils/old_build_ext.py:30: UserWarning: Cython.Distutils.old_build_ext does not properly handle dependencies and is deprecated.
      "Cython.Distutils.old_build_ext does not properly handle dependencies "

```cython
%%cython -a -f --compile-args=-DCYTHON_TRACE=1
import pycalphad.variables as v
from pycalphad.core.utils import unpack_kwarg
from pycalphad.core.utils import unpack_condition, unpack_phases
from pycalphad import calculate, Model
from pycalphad.constraints import mole_fraction
from pycalphad.core.lower_convex_hull import lower_convex_hull
from pycalphad.core.sympydiff_utils import build_functions as compiled_build_functions
from pycalphad.core.constants import MIN_SITE_FRACTION
from pycalphad.core.eqsolver import _solve_eq_at_conditions
from sympy import Add, Symbol
import dask
from dask import delayed
import dask.multiprocessing, dask.async
from xarray import Dataset
cimport numpy as np
import numpy as np
from collections import namedtuple, OrderedDict
from datetime import datetime
from pycalphad.core.phase_rec cimport PhaseRecord, obj, grad, hess
cimport cython

@cython.boundscheck(False)
@cython.wraparound(False)
def _build_multiphase_system(int[:] phase_dof, phases, cur_conds, double[:] site_fracs, double[:] phase_fracs,
                              l_constraints, constraint_jac,
                              np.ndarray[ndim=3, dtype=np.float64_t] constraint_hess,
                              np.ndarray[ndim=1, dtype=np.float64_t] l_multipliers,
                              phase_records):
    cdef double[::1] obj_result =  np.empty(1)
    cdef double[::1] obj_res = np.empty(1)
    cdef int max_phase_dof = max(phase_dof)
    cdef double[::1] grad_res = np.empty(2+max_phase_dof)
    cdef double[::1,:] tmp_hess = np.empty((2+max_phase_dof, 2+max_phase_dof), order='F')
    cdef double* tmp_hess_ptr = &tmp_hess[0,0]
    cdef double[::1] dof = np.empty(2+max_phase_dof)
    cdef double[::1,:] dof_2d_view = <double[:1:1, :dof.shape[0]]>&dof[0]
    cdef int num_vars = len(site_fracs) + len(phases)
    cdef double[::1,:] l_hessian = np.zeros((num_vars, num_vars), order='F')
    cdef double[::1] gradient_term = np.zeros(num_vars)
    cdef int var_offset = 0
    cdef int phase_idx = 0
    cdef int cur_phase_dof, constraint_idx, dof_x_idx, dof_y_idx, hess_x, hess_y, hess_idx
    cdef double phase_frac
    cdef PhaseRecord prn
    dof[0] = cur_conds['P']
    dof[1] = cur_conds['T']

    for name, phase_frac in zip(phases, phase_fracs):
        prn = phase_records[name]
        with nogil:
            cur_phase_dof = <int>phase_dof[phase_idx]
            dof[2:2+cur_phase_dof] = site_fracs[var_offset:var_offset + cur_phase_dof]
            obj(prn, obj_res, dof_2d_view, 1)
            grad(prn, grad_res, dof)
            hess(prn, tmp_hess, dof)
            for dof_x_idx in range(cur_phase_dof):
                gradient_term[var_offset + dof_x_idx] = \
                    phase_frac * grad_res[2+dof_x_idx]  # Remove P,T grad part
            gradient_term[site_fracs.shape[0] + phase_idx] = obj_res[0]

            for dof_x_idx in range(cur_phase_dof):
                for dof_y_idx in range(dof_x_idx,cur_phase_dof):
                    l_hessian[var_offset+dof_x_idx, var_offset+dof_y_idx] = \
                      phase_frac * tmp_hess_ptr[2+dof_x_idx + (2+cur_phase_dof)*(2+dof_y_idx)]
                    l_hessian[var_offset+dof_y_idx, var_offset+dof_x_idx] = \
                      l_hessian[var_offset+dof_x_idx, var_offset+dof_y_idx]
                # Phase fraction / site fraction cross derivative
                l_hessian[site_fracs.shape[0] + phase_idx, var_offset + dof_x_idx] = \
                     grad_res[2+dof_x_idx] # Remove P,T grad part
                l_hessian[var_offset + dof_x_idx, site_fracs.shape[0] + phase_idx] = grad_res[2+dof_x_idx]
            var_offset += cur_phase_dof
            phase_idx += 1
    l_hessian -= np.einsum('i,ijk->jk', l_multipliers, constraint_hess, order='F')
    return np.asarray(l_hessian), np.asarray(gradient_term)
```

<!DOCTYPE html>
<!-- Generated by Cython 0.25.1 -->
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Cython: _cython_magic_c9e2ae6042f41ab910df839a817d1108.pyx</title>
    <style type="text/css">

body.cython { font-family: courier; font-size: 12; }

.cython.tag  {  }
.cython.line { margin: 0em }
.cython.code { font-size: 9; color: #444444; display: none; margin: 0px 0px 0px 8px; border-left: 8px none; }

.cython.line .run { background-color: #B0FFB0; }
.cython.line .mis { background-color: #FFB0B0; }
.cython.code.run  { border-left: 8px solid #B0FFB0; }
.cython.code.mis  { border-left: 8px solid #FFB0B0; }

.cython.code .py_c_api  { color: red; }
.cython.code .py_macro_api  { color: #FF7000; }
.cython.code .pyx_c_api  { color: #FF3000; }
.cython.code .pyx_macro_api  { color: #FF7000; }
.cython.code .refnanny  { color: #FFA000; }
.cython.code .trace  { color: #FFA000; }
.cython.code .error_goto  { color: #FFA000; }

.cython.code .coerce  { color: #008000; border: 1px dotted #008000 }
.cython.code .py_attr { color: #FF0000; font-weight: bold; }
.cython.code .c_attr  { color: #0000FF; }
.cython.code .py_call { color: #FF0000; font-weight: bold; }
.cython.code .c_call  { color: #0000FF; }

.cython.score-0 {background-color: #FFFFff;}
.cython.score-1 {background-color: #FFFFe7;}
.cython.score-2 {background-color: #FFFFd4;}
.cython.score-3 {background-color: #FFFFc4;}
.cython.score-4 {background-color: #FFFFb6;}
.cython.score-5 {background-color: #FFFFaa;}
.cython.score-6 {background-color: #FFFF9f;}
.cython.score-7 {background-color: #FFFF96;}
.cython.score-8 {background-color: #FFFF8d;}
.cython.score-9 {background-color: #FFFF86;}
.cython.score-10 {background-color: #FFFF7f;}
.cython.score-11 {background-color: #FFFF79;}
.cython.score-12 {background-color: #FFFF73;}
.cython.score-13 {background-color: #FFFF6e;}
.cython.score-14 {background-color: #FFFF6a;}
.cython.score-15 {background-color: #FFFF66;}
.cython.score-16 {background-color: #FFFF62;}
.cython.score-17 {background-color: #FFFF5e;}
.cython.score-18 {background-color: #FFFF5b;}
.cython.score-19 {background-color: #FFFF57;}
.cython.score-20 {background-color: #FFFF55;}
.cython.score-21 {background-color: #FFFF52;}
.cython.score-22 {background-color: #FFFF4f;}
.cython.score-23 {background-color: #FFFF4d;}
.cython.score-24 {background-color: #FFFF4b;}
.cython.score-25 {background-color: #FFFF48;}
.cython.score-26 {background-color: #FFFF46;}
.cython.score-27 {background-color: #FFFF44;}
.cython.score-28 {background-color: #FFFF43;}
.cython.score-29 {background-color: #FFFF41;}
.cython.score-30 {background-color: #FFFF3f;}
.cython.score-31 {background-color: #FFFF3e;}
.cython.score-32 {background-color: #FFFF3c;}
.cython.score-33 {background-color: #FFFF3b;}
.cython.score-34 {background-color: #FFFF39;}
.cython.score-35 {background-color: #FFFF38;}
.cython.score-36 {background-color: #FFFF37;}
.cython.score-37 {background-color: #FFFF36;}
.cython.score-38 {background-color: #FFFF35;}
.cython.score-39 {background-color: #FFFF34;}
.cython.score-40 {background-color: #FFFF33;}
.cython.score-41 {background-color: #FFFF32;}
.cython.score-42 {background-color: #FFFF31;}
.cython.score-43 {background-color: #FFFF30;}
.cython.score-44 {background-color: #FFFF2f;}
.cython.score-45 {background-color: #FFFF2e;}
.cython.score-46 {background-color: #FFFF2d;}
.cython.score-47 {background-color: #FFFF2c;}
.cython.score-48 {background-color: #FFFF2b;}
.cython.score-49 {background-color: #FFFF2b;}
.cython.score-50 {background-color: #FFFF2a;}
.cython.score-51 {background-color: #FFFF29;}
.cython.score-52 {background-color: #FFFF29;}
.cython.score-53 {background-color: #FFFF28;}
.cython.score-54 {background-color: #FFFF27;}
.cython.score-55 {background-color: #FFFF27;}
.cython.score-56 {background-color: #FFFF26;}
.cython.score-57 {background-color: #FFFF26;}
.cython.score-58 {background-color: #FFFF25;}
.cython.score-59 {background-color: #FFFF24;}
.cython.score-60 {background-color: #FFFF24;}
.cython.score-61 {background-color: #FFFF23;}
.cython.score-62 {background-color: #FFFF23;}
.cython.score-63 {background-color: #FFFF22;}
.cython.score-64 {background-color: #FFFF22;}
.cython.score-65 {background-color: #FFFF22;}
.cython.score-66 {background-color: #FFFF21;}
.cython.score-67 {background-color: #FFFF21;}
.cython.score-68 {background-color: #FFFF20;}
.cython.score-69 {background-color: #FFFF20;}
.cython.score-70 {background-color: #FFFF1f;}
.cython.score-71 {background-color: #FFFF1f;}
.cython.score-72 {background-color: #FFFF1f;}
.cython.score-73 {background-color: #FFFF1e;}
.cython.score-74 {background-color: #FFFF1e;}
.cython.score-75 {background-color: #FFFF1e;}
.cython.score-76 {background-color: #FFFF1d;}
.cython.score-77 {background-color: #FFFF1d;}
.cython.score-78 {background-color: #FFFF1c;}
.cython.score-79 {background-color: #FFFF1c;}
.cython.score-80 {background-color: #FFFF1c;}
.cython.score-81 {background-color: #FFFF1c;}
.cython.score-82 {background-color: #FFFF1b;}
.cython.score-83 {background-color: #FFFF1b;}
.cython.score-84 {background-color: #FFFF1b;}
.cython.score-85 {background-color: #FFFF1a;}
.cython.score-86 {background-color: #FFFF1a;}
.cython.score-87 {background-color: #FFFF1a;}
.cython.score-88 {background-color: #FFFF1a;}
.cython.score-89 {background-color: #FFFF19;}
.cython.score-90 {background-color: #FFFF19;}
.cython.score-91 {background-color: #FFFF19;}
.cython.score-92 {background-color: #FFFF19;}
.cython.score-93 {background-color: #FFFF18;}
.cython.score-94 {background-color: #FFFF18;}
.cython.score-95 {background-color: #FFFF18;}
.cython.score-96 {background-color: #FFFF18;}
.cython.score-97 {background-color: #FFFF17;}
.cython.score-98 {background-color: #FFFF17;}
.cython.score-99 {background-color: #FFFF17;}
.cython.score-100 {background-color: #FFFF17;}
.cython.score-101 {background-color: #FFFF16;}
.cython.score-102 {background-color: #FFFF16;}
.cython.score-103 {background-color: #FFFF16;}
.cython.score-104 {background-color: #FFFF16;}
.cython.score-105 {background-color: #FFFF16;}
.cython.score-106 {background-color: #FFFF15;}
.cython.score-107 {background-color: #FFFF15;}
.cython.score-108 {background-color: #FFFF15;}
.cython.score-109 {background-color: #FFFF15;}
.cython.score-110 {background-color: #FFFF15;}
.cython.score-111 {background-color: #FFFF15;}
.cython.score-112 {background-color: #FFFF14;}
.cython.score-113 {background-color: #FFFF14;}
.cython.score-114 {background-color: #FFFF14;}
.cython.score-115 {background-color: #FFFF14;}
.cython.score-116 {background-color: #FFFF14;}
.cython.score-117 {background-color: #FFFF14;}
.cython.score-118 {background-color: #FFFF13;}
.cython.score-119 {background-color: #FFFF13;}
.cython.score-120 {background-color: #FFFF13;}
.cython.score-121 {background-color: #FFFF13;}
.cython.score-122 {background-color: #FFFF13;}
.cython.score-123 {background-color: #FFFF13;}
.cython.score-124 {background-color: #FFFF13;}
.cython.score-125 {background-color: #FFFF12;}
.cython.score-126 {background-color: #FFFF12;}
.cython.score-127 {background-color: #FFFF12;}
.cython.score-128 {background-color: #FFFF12;}
.cython.score-129 {background-color: #FFFF12;}
.cython.score-130 {background-color: #FFFF12;}
.cython.score-131 {background-color: #FFFF12;}
.cython.score-132 {background-color: #FFFF11;}
.cython.score-133 {background-color: #FFFF11;}
.cython.score-134 {background-color: #FFFF11;}
.cython.score-135 {background-color: #FFFF11;}
.cython.score-136 {background-color: #FFFF11;}
.cython.score-137 {background-color: #FFFF11;}
.cython.score-138 {background-color: #FFFF11;}
.cython.score-139 {background-color: #FFFF11;}
.cython.score-140 {background-color: #FFFF11;}
.cython.score-141 {background-color: #FFFF10;}
.cython.score-142 {background-color: #FFFF10;}
.cython.score-143 {background-color: #FFFF10;}
.cython.score-144 {background-color: #FFFF10;}
.cython.score-145 {background-color: #FFFF10;}
.cython.score-146 {background-color: #FFFF10;}
.cython.score-147 {background-color: #FFFF10;}
.cython.score-148 {background-color: #FFFF10;}
.cython.score-149 {background-color: #FFFF10;}
.cython.score-150 {background-color: #FFFF0f;}
.cython.score-151 {background-color: #FFFF0f;}
.cython.score-152 {background-color: #FFFF0f;}
.cython.score-153 {background-color: #FFFF0f;}
.cython.score-154 {background-color: #FFFF0f;}
.cython.score-155 {background-color: #FFFF0f;}
.cython.score-156 {background-color: #FFFF0f;}
.cython.score-157 {background-color: #FFFF0f;}
.cython.score-158 {background-color: #FFFF0f;}
.cython.score-159 {background-color: #FFFF0f;}
.cython.score-160 {background-color: #FFFF0f;}
.cython.score-161 {background-color: #FFFF0e;}
.cython.score-162 {background-color: #FFFF0e;}
.cython.score-163 {background-color: #FFFF0e;}
.cython.score-164 {background-color: #FFFF0e;}
.cython.score-165 {background-color: #FFFF0e;}
.cython.score-166 {background-color: #FFFF0e;}
.cython.score-167 {background-color: #FFFF0e;}
.cython.score-168 {background-color: #FFFF0e;}
.cython.score-169 {background-color: #FFFF0e;}
.cython.score-170 {background-color: #FFFF0e;}
.cython.score-171 {background-color: #FFFF0e;}
.cython.score-172 {background-color: #FFFF0e;}
.cython.score-173 {background-color: #FFFF0d;}
.cython.score-174 {background-color: #FFFF0d;}
.cython.score-175 {background-color: #FFFF0d;}
.cython.score-176 {background-color: #FFFF0d;}
.cython.score-177 {background-color: #FFFF0d;}
.cython.score-178 {background-color: #FFFF0d;}
.cython.score-179 {background-color: #FFFF0d;}
.cython.score-180 {background-color: #FFFF0d;}
.cython.score-181 {background-color: #FFFF0d;}
.cython.score-182 {background-color: #FFFF0d;}
.cython.score-183 {background-color: #FFFF0d;}
.cython.score-184 {background-color: #FFFF0d;}
.cython.score-185 {background-color: #FFFF0d;}
.cython.score-186 {background-color: #FFFF0d;}
.cython.score-187 {background-color: #FFFF0c;}
.cython.score-188 {background-color: #FFFF0c;}
.cython.score-189 {background-color: #FFFF0c;}
.cython.score-190 {background-color: #FFFF0c;}
.cython.score-191 {background-color: #FFFF0c;}
.cython.score-192 {background-color: #FFFF0c;}
.cython.score-193 {background-color: #FFFF0c;}
.cython.score-194 {background-color: #FFFF0c;}
.cython.score-195 {background-color: #FFFF0c;}
.cython.score-196 {background-color: #FFFF0c;}
.cython.score-197 {background-color: #FFFF0c;}
.cython.score-198 {background-color: #FFFF0c;}
.cython.score-199 {background-color: #FFFF0c;}
.cython.score-200 {background-color: #FFFF0c;}
.cython.score-201 {background-color: #FFFF0c;}
.cython.score-202 {background-color: #FFFF0c;}
.cython.score-203 {background-color: #FFFF0b;}
.cython.score-204 {background-color: #FFFF0b;}
.cython.score-205 {background-color: #FFFF0b;}
.cython.score-206 {background-color: #FFFF0b;}
.cython.score-207 {background-color: #FFFF0b;}
.cython.score-208 {background-color: #FFFF0b;}
.cython.score-209 {background-color: #FFFF0b;}
.cython.score-210 {background-color: #FFFF0b;}
.cython.score-211 {background-color: #FFFF0b;}
.cython.score-212 {background-color: #FFFF0b;}
.cython.score-213 {background-color: #FFFF0b;}
.cython.score-214 {background-color: #FFFF0b;}
.cython.score-215 {background-color: #FFFF0b;}
.cython.score-216 {background-color: #FFFF0b;}
.cython.score-217 {background-color: #FFFF0b;}
.cython.score-218 {background-color: #FFFF0b;}
.cython.score-219 {background-color: #FFFF0b;}
.cython.score-220 {background-color: #FFFF0b;}
.cython.score-221 {background-color: #FFFF0b;}
.cython.score-222 {background-color: #FFFF0a;}
.cython.score-223 {background-color: #FFFF0a;}
.cython.score-224 {background-color: #FFFF0a;}
.cython.score-225 {background-color: #FFFF0a;}
.cython.score-226 {background-color: #FFFF0a;}
.cython.score-227 {background-color: #FFFF0a;}
.cython.score-228 {background-color: #FFFF0a;}
.cython.score-229 {background-color: #FFFF0a;}
.cython.score-230 {background-color: #FFFF0a;}
.cython.score-231 {background-color: #FFFF0a;}
.cython.score-232 {background-color: #FFFF0a;}
.cython.score-233 {background-color: #FFFF0a;}
.cython.score-234 {background-color: #FFFF0a;}
.cython.score-235 {background-color: #FFFF0a;}
.cython.score-236 {background-color: #FFFF0a;}
.cython.score-237 {background-color: #FFFF0a;}
.cython.score-238 {background-color: #FFFF0a;}
.cython.score-239 {background-color: #FFFF0a;}
.cython.score-240 {background-color: #FFFF0a;}
.cython.score-241 {background-color: #FFFF0a;}
.cython.score-242 {background-color: #FFFF0a;}
.cython.score-243 {background-color: #FFFF0a;}
.cython.score-244 {background-color: #FFFF0a;}
.cython.score-245 {background-color: #FFFF0a;}
.cython.score-246 {background-color: #FFFF09;}
.cython.score-247 {background-color: #FFFF09;}
.cython.score-248 {background-color: #FFFF09;}
.cython.score-249 {background-color: #FFFF09;}
.cython.score-250 {background-color: #FFFF09;}
.cython.score-251 {background-color: #FFFF09;}
.cython.score-252 {background-color: #FFFF09;}
.cython.score-253 {background-color: #FFFF09;}
.cython.score-254 {background-color: #FFFF09;}
.cython .hll { background-color: #ffffcc }
.cython  { background: #f8f8f8; }
.cython .c { color: #408080; font-style: italic } /* Comment */
.cython .err { border: 1px solid #FF0000 } /* Error */
.cython .k { color: #008000; font-weight: bold } /* Keyword */
.cython .o { color: #666666 } /* Operator */
.cython .ch { color: #408080; font-style: italic } /* Comment.Hashbang */
.cython .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.cython .cp { color: #BC7A00 } /* Comment.Preproc */
.cython .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
.cython .c1 { color: #408080; font-style: italic } /* Comment.Single */
.cython .cs { color: #408080; font-style: italic } /* Comment.Special */
.cython .gd { color: #A00000 } /* Generic.Deleted */
.cython .ge { font-style: italic } /* Generic.Emph */
.cython .gr { color: #FF0000 } /* Generic.Error */
.cython .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.cython .gi { color: #00A000 } /* Generic.Inserted */
.cython .go { color: #888888 } /* Generic.Output */
.cython .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.cython .gs { font-weight: bold } /* Generic.Strong */
.cython .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.cython .gt { color: #0044DD } /* Generic.Traceback */
.cython .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.cython .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.cython .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.cython .kp { color: #008000 } /* Keyword.Pseudo */
.cython .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.cython .kt { color: #B00040 } /* Keyword.Type */
.cython .m { color: #666666 } /* Literal.Number */
.cython .s { color: #BA2121 } /* Literal.String */
.cython .na { color: #7D9029 } /* Name.Attribute */
.cython .nb { color: #008000 } /* Name.Builtin */
.cython .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.cython .no { color: #880000 } /* Name.Constant */
.cython .nd { color: #AA22FF } /* Name.Decorator */
.cython .ni { color: #999999; font-weight: bold } /* Name.Entity */
.cython .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.cython .nf { color: #0000FF } /* Name.Function */
.cython .nl { color: #A0A000 } /* Name.Label */
.cython .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.cython .nt { color: #008000; font-weight: bold } /* Name.Tag */
.cython .nv { color: #19177C } /* Name.Variable */
.cython .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.cython .w { color: #bbbbbb } /* Text.Whitespace */
.cython .mb { color: #666666 } /* Literal.Number.Bin */
.cython .mf { color: #666666 } /* Literal.Number.Float */
.cython .mh { color: #666666 } /* Literal.Number.Hex */
.cython .mi { color: #666666 } /* Literal.Number.Integer */
.cython .mo { color: #666666 } /* Literal.Number.Oct */
.cython .sb { color: #BA2121 } /* Literal.String.Backtick */
.cython .sc { color: #BA2121 } /* Literal.String.Char */
.cython .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.cython .s2 { color: #BA2121 } /* Literal.String.Double */
.cython .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.cython .sh { color: #BA2121 } /* Literal.String.Heredoc */
.cython .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.cython .sx { color: #008000 } /* Literal.String.Other */
.cython .sr { color: #BB6688 } /* Literal.String.Regex */
.cython .s1 { color: #BA2121 } /* Literal.String.Single */
.cython .ss { color: #19177C } /* Literal.String.Symbol */
.cython .bp { color: #008000 } /* Name.Builtin.Pseudo */
.cython .vc { color: #19177C } /* Name.Variable.Class */
.cython .vg { color: #19177C } /* Name.Variable.Global */
.cython .vi { color: #19177C } /* Name.Variable.Instance */
.cython .il { color: #666666 } /* Literal.Number.Integer.Long */
    </style>

</head>
<body class="cython">
<p><span style="border-bottom: solid 1px grey;">Generated by Cython 0.25.1</span></p>
<p>
    <span style="background-color: #FFFF00">Yellow lines</span> hint at Python interaction.<br />
    Click on a line that starts with a "<code>+</code>" to see the C code that Cython generated for it.
</p>
<div class="cython"><pre class="cython line score-27" onclick='toggleDiv(this)'>+<span class="">01</span>: <span class="k">import</span> <span class="nn">pycalphad.variables</span> <span class="k">as</span> <span class="nn">v</span></pre>
<pre class='cython code score-27 '>  <span class='trace'>__Pyx_TraceLine</span>(1,0,__PYX_ERR(0, 1, __pyx_L1_error))
  __pyx_t_2 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s__35);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s__35);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s__35);
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_variables, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_v, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
/* … */
  <span class='trace'>__Pyx_TraceLine</span>(1,0,__PYX_ERR(0, 1, __pyx_L1_error))
  __pyx_t_2 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">02</span>: <span class="k">from</span> <span class="nn">pycalphad.core.utils</span> <span class="k">import</span> <span class="n">unpack_kwarg</span></pre>
<pre class='cython code score-19 '>  <span class='trace'>__Pyx_TraceLine</span>(2,0,__PYX_ERR(0, 2, __pyx_L1_error))
  __pyx_t_3 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_unpack_kwarg);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_unpack_kwarg);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_3, 0, __pyx_n_s_unpack_kwarg);
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_core_utils, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_unpack_kwarg); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_unpack_kwarg, __pyx_t_3) < 0) __PYX_ERR(0, 2, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-29" onclick='toggleDiv(this)'>+<span class="">03</span>: <span class="k">from</span> <span class="nn">pycalphad.core.utils</span> <span class="k">import</span> <span class="n">unpack_condition</span><span class="p">,</span> <span class="n">unpack_phases</span></pre>
<pre class='cython code score-29 '>  <span class='trace'>__Pyx_TraceLine</span>(3,0,__PYX_ERR(0, 3, __pyx_L1_error))
  __pyx_t_2 = <span class='py_c_api'>PyList_New</span>(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_unpack_condition);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_unpack_condition);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s_unpack_condition);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_unpack_phases);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_unpack_phases);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 1, __pyx_n_s_unpack_phases);
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_core_utils, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_3, __pyx_n_s_unpack_condition); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_unpack_condition, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_3, __pyx_n_s_unpack_phases); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_unpack_phases, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-29" onclick='toggleDiv(this)'>+<span class="">04</span>: <span class="k">from</span> <span class="nn">pycalphad</span> <span class="k">import</span> <span class="n">calculate</span><span class="p">,</span> <span class="n">Model</span></pre>
<pre class='cython code score-29 '>  <span class='trace'>__Pyx_TraceLine</span>(4,0,__PYX_ERR(0, 4, __pyx_L1_error))
  __pyx_t_3 = <span class='py_c_api'>PyList_New</span>(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_calculate);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_calculate);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_3, 0, __pyx_n_s_calculate);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_Model);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_Model);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_3, 1, __pyx_n_s_Model);
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_calculate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_calculate, __pyx_t_3) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_Model); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_Model, __pyx_t_3) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">05</span>: <span class="k">from</span> <span class="nn">pycalphad.constraints</span> <span class="k">import</span> <span class="n">mole_fraction</span></pre>
<pre class='cython code score-19 '>  <span class='trace'>__Pyx_TraceLine</span>(5,0,__PYX_ERR(0, 5, __pyx_L1_error))
  __pyx_t_2 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_mole_fraction);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_mole_fraction);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s_mole_fraction);
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_constraints, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_3, __pyx_n_s_mole_fraction); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_mole_fraction, __pyx_t_2) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">06</span>: <span class="k">from</span> <span class="nn">pycalphad.core.lower_convex_hull</span> <span class="k">import</span> <span class="n">lower_convex_hull</span></pre>
<pre class='cython code score-19 '>  <span class='trace'>__Pyx_TraceLine</span>(6,0,__PYX_ERR(0, 6, __pyx_L1_error))
  __pyx_t_3 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_lower_convex_hull);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_lower_convex_hull);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_3, 0, __pyx_n_s_lower_convex_hull);
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_core_lower_convex_hull, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_lower_convex_hull); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_lower_convex_hull, __pyx_t_3) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">07</span>: <span class="k">from</span> <span class="nn">pycalphad.core.sympydiff_utils</span> <span class="k">import</span> <span class="n">build_functions</span> <span class="k">as</span> <span class="n">compiled_build_functions</span></pre>
<pre class='cython code score-19 '>  <span class='trace'>__Pyx_TraceLine</span>(7,0,__PYX_ERR(0, 7, __pyx_L1_error))
  __pyx_t_2 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_build_functions);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_build_functions);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s_build_functions);
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_core_sympydiff_utils, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_3, __pyx_n_s_build_functions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_compiled_build_functions, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">08</span>: <span class="k">from</span> <span class="nn">pycalphad.core.constants</span> <span class="k">import</span> <span class="n">MIN_SITE_FRACTION</span></pre>
<pre class='cython code score-19 '>  <span class='trace'>__Pyx_TraceLine</span>(8,0,__PYX_ERR(0, 8, __pyx_L1_error))
  __pyx_t_3 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_MIN_SITE_FRACTION);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_MIN_SITE_FRACTION);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_3, 0, __pyx_n_s_MIN_SITE_FRACTION);
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_core_constants, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_MIN_SITE_FRACTION); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_MIN_SITE_FRACTION, __pyx_t_3) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">09</span>: <span class="k">from</span> <span class="nn">pycalphad.core.eqsolver</span> <span class="k">import</span> <span class="n">_solve_eq_at_conditions</span></pre>
<pre class='cython code score-19 '>  <span class='trace'>__Pyx_TraceLine</span>(9,0,__PYX_ERR(0, 9, __pyx_L1_error))
  __pyx_t_2 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_solve_eq_at_conditions);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_solve_eq_at_conditions);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s_solve_eq_at_conditions);
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_core_eqsolver, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_3, __pyx_n_s_solve_eq_at_conditions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_solve_eq_at_conditions, __pyx_t_2) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-29" onclick='toggleDiv(this)'>+<span class="">10</span>: <span class="k">from</span> <span class="nn">sympy</span> <span class="k">import</span> <span class="n">Add</span><span class="p">,</span> <span class="n">Symbol</span></pre>
<pre class='cython code score-29 '>  <span class='trace'>__Pyx_TraceLine</span>(10,0,__PYX_ERR(0, 10, __pyx_L1_error))
  __pyx_t_3 = <span class='py_c_api'>PyList_New</span>(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 10, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_Add);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_Add);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_3, 0, __pyx_n_s_Add);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_Symbol);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_Symbol);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_3, 1, __pyx_n_s_Symbol);
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_sympy, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_Add); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 10, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_Add, __pyx_t_3) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_Symbol); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 10, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_Symbol, __pyx_t_3) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">11</span>: <span class="k">import</span> <span class="nn">dask</span></pre>
<pre class='cython code score-8 '>  <span class='trace'>__Pyx_TraceLine</span>(11,0,__PYX_ERR(0, 11, __pyx_L1_error))
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_dask, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_dask, __pyx_t_2) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">12</span>: <span class="k">from</span> <span class="nn">dask</span> <span class="k">import</span> <span class="n">delayed</span></pre>
<pre class='cython code score-19 '>  <span class='trace'>__Pyx_TraceLine</span>(12,0,__PYX_ERR(0, 12, __pyx_L1_error))
  __pyx_t_2 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_delayed);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_delayed);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s_delayed);
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_dask, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 12, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_3, __pyx_n_s_delayed); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_delayed, __pyx_t_2) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-16" onclick='toggleDiv(this)'>+<span class="">13</span>: <span class="k">import</span> <span class="nn">dask.multiprocessing</span><span class="o">,</span> <span class="nn">dask.async</span></pre>
<pre class='cython code score-16 '>  <span class='trace'>__Pyx_TraceLine</span>(13,0,__PYX_ERR(0, 13, __pyx_L1_error))
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_dask_multiprocessing, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 13, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_dask, __pyx_t_3) < 0) __PYX_ERR(0, 13, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_dask_async, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 13, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_dask, __pyx_t_3) < 0) __PYX_ERR(0, 13, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">14</span>: <span class="k">from</span> <span class="nn">xarray</span> <span class="k">import</span> <span class="n">Dataset</span></pre>
<pre class='cython code score-19 '>  <span class='trace'>__Pyx_TraceLine</span>(14,0,__PYX_ERR(0, 14, __pyx_L1_error))
  __pyx_t_3 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 14, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_Dataset);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_Dataset);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_3, 0, __pyx_n_s_Dataset);
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_xarray, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_Dataset); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 14, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_Dataset, __pyx_t_3) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-0"> <span class="">15</span>: <span class="k">cimport</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span></pre>
<pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">16</span>: <span class="k">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span></pre>
<pre class='cython code score-8 '>  <span class='trace'>__Pyx_TraceLine</span>(16,0,__PYX_ERR(0, 16, __pyx_L1_error))
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-29" onclick='toggleDiv(this)'>+<span class="">17</span>: <span class="k">from</span> <span class="nn">collections</span> <span class="k">import</span> <span class="n">namedtuple</span><span class="p">,</span> <span class="n">OrderedDict</span></pre>
<pre class='cython code score-29 '>  <span class='trace'>__Pyx_TraceLine</span>(17,0,__PYX_ERR(0, 17, __pyx_L1_error))
  __pyx_t_2 = <span class='py_c_api'>PyList_New</span>(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_namedtuple);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_namedtuple);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s_namedtuple);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_OrderedDict);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_OrderedDict);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 1, __pyx_n_s_OrderedDict);
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_collections, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 17, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_3, __pyx_n_s_namedtuple); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_namedtuple, __pyx_t_2) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_3, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_OrderedDict, __pyx_t_2) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">18</span>: <span class="k">from</span> <span class="nn">datetime</span> <span class="k">import</span> <span class="n">datetime</span></pre>
<pre class='cython code score-19 '>  <span class='trace'>__Pyx_TraceLine</span>(18,0,__PYX_ERR(0, 18, __pyx_L1_error))
  __pyx_t_3 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 18, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_datetime);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_datetime);
  <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_3, 0, __pyx_n_s_datetime);
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_datetime, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 18, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_datetime, __pyx_t_3) < 0) __PYX_ERR(0, 18, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-0"> <span class="">19</span>: <span class="k">from</span> <span class="nn">pycalphad.core.phase_rec</span> <span class="k">cimport</span> <span class="n">PhaseRecord</span><span class="p">,</span> <span class="n">obj</span><span class="p">,</span> <span class="n">grad</span><span class="p">,</span> <span class="n">hess</span></pre>
<pre class="cython line score-0"> <span class="">20</span>: <span class="k">cimport</span> <span class="nn">cython</span></pre>
<pre class="cython line score-0"> <span class="">21</span>: </pre>
<pre class="cython line score-0"> <span class="">22</span>: <span class="nd">@cython</span><span class="o">.</span><span class="n">boundscheck</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span></pre>
<pre class="cython line score-0"> <span class="">23</span>: <span class="nd">@cython</span><span class="o">.</span><span class="n">wraparound</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span></pre>
<pre class="cython line score-154" onclick='toggleDiv(this)'>+<span class="">24</span>: <span class="k">def</span> <span class="nf">_build_multiphase_system</span><span class="p">(</span><span class="nb">int</span><span class="p">[:]</span> <span class="n">phase_dof</span><span class="p">,</span> <span class="n">phases</span><span class="p">,</span> <span class="n">cur_conds</span><span class="p">,</span> <span class="n">double</span><span class="p">[:]</span> <span class="n">site_fracs</span><span class="p">,</span> <span class="n">double</span><span class="p">[:]</span> <span class="n">phase_fracs</span><span class="p">,</span></pre>
<pre class='cython code score-154 '>/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_c9e2ae6042f41ab910df839a817d1108_1_build_multiphase_system(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_46_cython_magic_c9e2ae6042f41ab910df839a817d1108_1_build_multiphase_system = {"_build_multiphase_system", (PyCFunction)__pyx_pw_46_cython_magic_c9e2ae6042f41ab910df839a817d1108_1_build_multiphase_system, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_46_cython_magic_c9e2ae6042f41ab910df839a817d1108_1_build_multiphase_system(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  __Pyx_memviewslice __pyx_v_phase_dof = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_phases = 0;
  PyObject *__pyx_v_cur_conds = 0;
  __Pyx_memviewslice __pyx_v_site_fracs = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_phase_fracs = { 0, 0, { 0 }, { 0 }, { 0 } };
  CYTHON_UNUSED PyObject *__pyx_v_l_constraints = 0;
  CYTHON_UNUSED PyObject *__pyx_v_constraint_jac = 0;
  PyArrayObject *__pyx_v_constraint_hess = 0;
  PyArrayObject *__pyx_v_l_multipliers = 0;
  PyObject *__pyx_v_phase_records = 0;
  PyObject *__pyx_r = 0;
  <span class='refnanny'>__Pyx_RefNannyDeclarations</span>
  <span class='refnanny'>__Pyx_RefNannySetupContext</span>("_build_multiphase_system (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_phase_dof,&__pyx_n_s_phases,&__pyx_n_s_cur_conds,&__pyx_n_s_site_fracs,&__pyx_n_s_phase_fracs,&__pyx_n_s_l_constraints,&__pyx_n_s_constraint_jac,&__pyx_n_s_constraint_hess,&__pyx_n_s_l_multipliers,&__pyx_n_s_phase_records,0};
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args);
      switch (pos_args) {
        case 10: values[9] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 9);
        case  9: values[8] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 8);
        case  8: values[7] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 7);
        case  7: values[6] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 6);
        case  6: values[5] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 5);
        case  5: values[4] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 4);
        case  4: values[3] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 3);
        case  3: values[2] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 2);
        case  2: values[1] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 1);
        case  1: values[0] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = <span class='py_c_api'>PyDict_Size</span>(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_phase_dof)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_phases)) != 0)) kw_args--;
        else {
          <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_build_multiphase_system", 1, 10, 10, 1); __PYX_ERR(0, 24, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_cur_conds)) != 0)) kw_args--;
        else {
          <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_build_multiphase_system", 1, 10, 10, 2); __PYX_ERR(0, 24, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_site_fracs)) != 0)) kw_args--;
        else {
          <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_build_multiphase_system", 1, 10, 10, 3); __PYX_ERR(0, 24, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_phase_fracs)) != 0)) kw_args--;
        else {
          <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_build_multiphase_system", 1, 10, 10, 4); __PYX_ERR(0, 24, __pyx_L3_error)
        }
        case  5:
        if (likely((values[5] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_l_constraints)) != 0)) kw_args--;
        else {
          <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_build_multiphase_system", 1, 10, 10, 5); __PYX_ERR(0, 24, __pyx_L3_error)
        }
        case  6:
        if (likely((values[6] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_constraint_jac)) != 0)) kw_args--;
        else {
          <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_build_multiphase_system", 1, 10, 10, 6); __PYX_ERR(0, 24, __pyx_L3_error)
        }
        case  7:
        if (likely((values[7] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_constraint_hess)) != 0)) kw_args--;
        else {
          <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_build_multiphase_system", 1, 10, 10, 7); __PYX_ERR(0, 24, __pyx_L3_error)
        }
        case  8:
        if (likely((values[8] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_l_multipliers)) != 0)) kw_args--;
        else {
          <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_build_multiphase_system", 1, 10, 10, 8); __PYX_ERR(0, 24, __pyx_L3_error)
        }
        case  9:
        if (likely((values[9] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_phase_records)) != 0)) kw_args--;
        else {
          <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_build_multiphase_system", 1, 10, 10, 9); __PYX_ERR(0, 24, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(<span class='pyx_c_api'>__Pyx_ParseOptionalKeywords</span>(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_build_multiphase_system") < 0)) __PYX_ERR(0, 24, __pyx_L3_error)
      }
    } else if (<span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args) != 10) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 0);
      values[1] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 1);
      values[2] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 2);
      values[3] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 3);
      values[4] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 4);
      values[5] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 5);
      values[6] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 6);
      values[7] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 7);
      values[8] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 8);
      values[9] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 9);
    }
    __pyx_v_phase_dof = <span class='pyx_c_api'>__Pyx_PyObject_to_MemoryviewSlice_ds_int</span>(values[0]); if (unlikely(!__pyx_v_phase_dof.memview)) __PYX_ERR(0, 24, __pyx_L3_error)
    __pyx_v_phases = values[1];
    __pyx_v_cur_conds = values[2];
    __pyx_v_site_fracs = <span class='pyx_c_api'>__Pyx_PyObject_to_MemoryviewSlice_ds_double</span>(values[3]); if (unlikely(!__pyx_v_site_fracs.memview)) __PYX_ERR(0, 24, __pyx_L3_error)
    __pyx_v_phase_fracs = <span class='pyx_c_api'>__Pyx_PyObject_to_MemoryviewSlice_ds_double</span>(values[4]); if (unlikely(!__pyx_v_phase_fracs.memview)) __PYX_ERR(0, 24, __pyx_L3_error)
    __pyx_v_l_constraints = values[5];
    __pyx_v_constraint_jac = values[6];
    __pyx_v_constraint_hess = ((PyArrayObject *)values[7]);
    __pyx_v_l_multipliers = ((PyArrayObject *)values[8]);
    __pyx_v_phase_records = values[9];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_build_multiphase_system", 1, 10, 10, <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args)); __PYX_ERR(0, 24, __pyx_L3_error)
  __pyx_L3_error:;
  <span class='pyx_c_api'>__Pyx_AddTraceback</span>("_cython_magic_c9e2ae6042f41ab910df839a817d1108._build_multiphase_system", __pyx_clineno, __pyx_lineno, __pyx_filename);
  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!<span class='pyx_c_api'>__Pyx_ArgTypeTest</span>(((PyObject *)__pyx_v_constraint_hess), __pyx_ptype_5numpy_ndarray, 1, "constraint_hess", 0))) __PYX_ERR(0, 26, __pyx_L1_error)
  if (unlikely(!<span class='pyx_c_api'>__Pyx_ArgTypeTest</span>(((PyObject *)__pyx_v_l_multipliers), __pyx_ptype_5numpy_ndarray, 1, "l_multipliers", 0))) __PYX_ERR(0, 27, __pyx_L1_error)
  __pyx_r = __pyx_pf_46_cython_magic_c9e2ae6042f41ab910df839a817d1108__build_multiphase_system(__pyx_self, __pyx_v_phase_dof, __pyx_v_phases, __pyx_v_cur_conds, __pyx_v_site_fracs, __pyx_v_phase_fracs, __pyx_v_l_constraints, __pyx_v_constraint_jac, __pyx_v_constraint_hess, __pyx_v_l_multipliers, __pyx_v_phase_records);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_c9e2ae6042f41ab910df839a817d1108__build_multiphase_system(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_phase_dof, PyObject *__pyx_v_phases, PyObject *__pyx_v_cur_conds, __Pyx_memviewslice __pyx_v_site_fracs, __Pyx_memviewslice __pyx_v_phase_fracs, CYTHON_UNUSED PyObject *__pyx_v_l_constraints, CYTHON_UNUSED PyObject *__pyx_v_constraint_jac, PyArrayObject *__pyx_v_constraint_hess, PyArrayObject *__pyx_v_l_multipliers, PyObject *__pyx_v_phase_records) {
  CYTHON_UNUSED __Pyx_memviewslice __pyx_v_obj_result = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_obj_res = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_max_phase_dof;
  __Pyx_memviewslice __pyx_v_grad_res = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_tmp_hess = { 0, 0, { 0 }, { 0 }, { 0 } };
  double *__pyx_v_tmp_hess_ptr;
  __Pyx_memviewslice __pyx_v_dof = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_dof_2d_view = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_num_vars;
  __Pyx_memviewslice __pyx_v_l_hessian = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_gradient_term = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_var_offset;
  int __pyx_v_phase_idx;
  int __pyx_v_cur_phase_dof;
  int __pyx_v_dof_x_idx;
  int __pyx_v_dof_y_idx;
  double __pyx_v_phase_frac;
  struct PhaseRecordObject *__pyx_v_prn = 0;
  PyObject *__pyx_v_name = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_constraint_hess;
  __Pyx_Buffer __pyx_pybuffer_constraint_hess;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_l_multipliers;
  __Pyx_Buffer __pyx_pybuffer_l_multipliers;
  PyObject *__pyx_r = NULL;
  <span class='trace'>__Pyx_TraceDeclarations</span>
  <span class='trace'>__Pyx_TraceFrameInit</span>(__pyx_codeobj_)
  <span class='refnanny'>__Pyx_RefNannyDeclarations</span>
  <span class='refnanny'>__Pyx_RefNannySetupContext</span>("_build_multiphase_system", 0);
  <span class='trace'>__Pyx_TraceCall</span>("_build_multiphase_system", __pyx_f[0], 24, 0, __PYX_ERR(0, 24, __pyx_L1_error));
  __pyx_pybuffer_constraint_hess.pybuffer.buf = NULL;
  __pyx_pybuffer_constraint_hess.refcount = 0;
  __pyx_pybuffernd_constraint_hess.data = NULL;
  __pyx_pybuffernd_constraint_hess.rcbuffer = &__pyx_pybuffer_constraint_hess;
  __pyx_pybuffer_l_multipliers.pybuffer.buf = NULL;
  __pyx_pybuffer_l_multipliers.refcount = 0;
  __pyx_pybuffernd_l_multipliers.data = NULL;
  __pyx_pybuffernd_l_multipliers.rcbuffer = &__pyx_pybuffer_l_multipliers;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_constraint_hess.rcbuffer->pybuffer, (PyObject*)__pyx_v_constraint_hess, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 24, __pyx_L1_error)
  }
  __pyx_pybuffernd_constraint_hess.diminfo[0].strides = __pyx_pybuffernd_constraint_hess.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_constraint_hess.diminfo[0].shape = __pyx_pybuffernd_constraint_hess.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_constraint_hess.diminfo[1].strides = __pyx_pybuffernd_constraint_hess.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_constraint_hess.diminfo[1].shape = __pyx_pybuffernd_constraint_hess.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_constraint_hess.diminfo[2].strides = __pyx_pybuffernd_constraint_hess.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_constraint_hess.diminfo[2].shape = __pyx_pybuffernd_constraint_hess.rcbuffer->pybuffer.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer, (PyObject*)__pyx_v_l_multipliers, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 24, __pyx_L1_error)
  }
  __pyx_pybuffernd_l_multipliers.diminfo[0].strides = __pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_l_multipliers.diminfo[0].shape = __pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer.shape[0];
/* … */
  /* function exit code */
  __pyx_L1_error:;
  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1);
  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2);
  __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_5);
  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_6);
  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(((PyObject *)__pyx_t_13));
  __PYX_XDEC_MEMVIEW(&__pyx_t_22, 1);
  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_42);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    <span class='pyx_c_api'>__Pyx_ErrFetch</span>(&__pyx_type, &__pyx_value, &__pyx_tb);
    <span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_constraint_hess.rcbuffer->pybuffer);
    <span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer);
  <span class='pyx_c_api'>__Pyx_ErrRestore</span>(__pyx_type, __pyx_value, __pyx_tb);}
  <span class='pyx_c_api'>__Pyx_AddTraceback</span>("_cython_magic_c9e2ae6042f41ab910df839a817d1108._build_multiphase_system", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  <span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_constraint_hess.rcbuffer->pybuffer);
  <span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer);
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_obj_result, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_obj_res, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_grad_res, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_tmp_hess, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_dof, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_dof_2d_view, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_l_hessian, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_gradient_term, 1);
  <span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_prn);
  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_name);
  __PYX_XDEC_MEMVIEW(&__pyx_v_phase_dof, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_site_fracs, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_phase_fracs, 1);
  <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r);
  <span class='trace'>__Pyx_TraceReturn</span>(__pyx_r, 0);
  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();
  return __pyx_r;
}
/* … */
  __pyx_tuple__36 = <span class='py_c_api'>PyTuple_Pack</span>(33, __pyx_n_s_phase_dof, __pyx_n_s_phases, __pyx_n_s_cur_conds, __pyx_n_s_site_fracs, __pyx_n_s_phase_fracs, __pyx_n_s_l_constraints, __pyx_n_s_constraint_jac, __pyx_n_s_constraint_hess, __pyx_n_s_l_multipliers, __pyx_n_s_phase_records, __pyx_n_s_obj_result, __pyx_n_s_obj_res, __pyx_n_s_max_phase_dof, __pyx_n_s_grad_res, __pyx_n_s_tmp_hess, __pyx_n_s_tmp_hess_ptr, __pyx_n_s_dof, __pyx_n_s_dof_2d_view, __pyx_n_s_num_vars, __pyx_n_s_l_hessian, __pyx_n_s_gradient_term, __pyx_n_s_var_offset, __pyx_n_s_phase_idx, __pyx_n_s_cur_phase_dof, __pyx_n_s_constraint_idx, __pyx_n_s_dof_x_idx, __pyx_n_s_dof_y_idx, __pyx_n_s_hess_x, __pyx_n_s_hess_y, __pyx_n_s_hess_idx, __pyx_n_s_phase_frac, __pyx_n_s_prn, __pyx_n_s_name); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 24, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__36);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__36);
/* … */
  <span class='trace'>__Pyx_TraceLine</span>(24,0,__PYX_ERR(0, 24, __pyx_L1_error))
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_CyFunction_NewEx</span>(&__pyx_mdef_46_cython_magic_c9e2ae6042f41ab910df839a817d1108_1_build_multiphase_system, 0, __pyx_n_s_build_multiphase_system, NULL, __pyx_n_s_cython_magic_c9e2ae6042f41ab910, __pyx_d, ((PyObject *)__pyx_codeobj_)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_build_multiphase_system, __pyx_t_2) < 0) __PYX_ERR(0, 24, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj_ = (PyObject*)<span class='pyx_c_api'>__Pyx_PyCode_New</span>(10, 0, 33, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_rotis_cache_ipython_cython, __pyx_n_s_build_multiphase_system, 24, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj_)) __PYX_ERR(0, 24, __pyx_L1_error)
</pre><pre class="cython line score-0"> <span class="">25</span>:                               <span class="n">l_constraints</span><span class="p">,</span> <span class="n">constraint_jac</span><span class="p">,</span></pre>
<pre class="cython line score-0"> <span class="">26</span>:                               <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">[</span><span class="n">ndim</span><span class="o">=</span><span class="mf">3</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float64_t</span><span class="p">]</span> <span class="n">constraint_hess</span><span class="p">,</span></pre>
<pre class="cython line score-0"> <span class="">27</span>:                               <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">[</span><span class="n">ndim</span><span class="o">=</span><span class="mf">1</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float64_t</span><span class="p">]</span> <span class="n">l_multipliers</span><span class="p">,</span></pre>
<pre class="cython line score-0"> <span class="">28</span>:                               <span class="n">phase_records</span><span class="p">):</span></pre>
<pre class="cython line score-16" onclick='toggleDiv(this)'>+<span class="">29</span>:     <span class="k">cdef</span> <span class="kt">double</span>[<span class="p">::</span><span class="mf">1</span><span class="p">]</span> <span class="n">obj_result</span> <span class="o">=</span>  <span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="mf">1</span><span class="p">)</span></pre>
<pre class='cython code score-16 '>  <span class='trace'>__Pyx_TraceLine</span>(29,0,__PYX_ERR(0, 29, __pyx_L1_error))
  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_2, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_to_MemoryviewSlice_dc_double</span>(__pyx_t_1);
  if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 29, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_obj_result = __pyx_t_3;
  __pyx_t_3.memview = NULL;
  __pyx_t_3.data = NULL;
/* … */
  __pyx_tuple__2 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_int_1); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 29, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__2);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__2);
</pre><pre class="cython line score-16" onclick='toggleDiv(this)'>+<span class="">30</span>:     <span class="k">cdef</span> <span class="kt">double</span>[<span class="p">::</span><span class="mf">1</span><span class="p">]</span> <span class="n">obj_res</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="mf">1</span><span class="p">)</span></pre>
<pre class='cython code score-16 '>  <span class='trace'>__Pyx_TraceLine</span>(30,0,__PYX_ERR(0, 30, __pyx_L1_error))
  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_2, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_to_MemoryviewSlice_dc_double</span>(__pyx_t_1);
  if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 30, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_obj_res = __pyx_t_3;
  __pyx_t_3.memview = NULL;
  __pyx_t_3.data = NULL;
/* … */
  __pyx_tuple__3 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_int_1); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 30, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__3);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__3);
</pre><pre class="cython line score-17" onclick='toggleDiv(this)'>+<span class="">31</span>:     <span class="k">cdef</span> <span class="kt">int</span> <span class="nf">max_phase_dof</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">phase_dof</span><span class="p">)</span></pre>
<pre class='cython code score-17 '>  <span class='trace'>__Pyx_TraceLine</span>(31,0,__PYX_ERR(0, 31, __pyx_L1_error))
  __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_phase_dof, 1, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  __pyx_t_2 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_1);
  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_max, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyInt_As_int</span>(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) __PYX_ERR(0, 31, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_max_phase_dof = __pyx_t_4;
</pre><pre class="cython line score-49" onclick='toggleDiv(this)'>+<span class="">32</span>:     <span class="k">cdef</span> <span class="kt">double</span>[<span class="p">::</span><span class="mf">1</span><span class="p">]</span> <span class="n">grad_res</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="mf">2</span><span class="o">+</span><span class="n">max_phase_dof</span><span class="p">)</span></pre>
<pre class='cython code score-49 '>  <span class='trace'>__Pyx_TraceLine</span>(32,0,__PYX_ERR(0, 32, __pyx_L1_error))
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  __pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 32, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyInt_From_long</span>((2 + __pyx_v_max_phase_dof)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_5))) {
    __pyx_t_6 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_5);
      <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_6);
      <span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
      <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_2};
      __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
      <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_6); __pyx_t_6 = 0;
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_2};
      __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
      <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_6); __pyx_t_6 = 0;
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_7 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 32, __pyx_L1_error)
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
      <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_6); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
      <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2);
      <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0+1, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
    }
  }
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_to_MemoryviewSlice_dc_double</span>(__pyx_t_1);
  if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 32, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_grad_res = __pyx_t_3;
  __pyx_t_3.memview = NULL;
  __pyx_t_3.data = NULL;
</pre><pre class="cython line score-40" onclick='toggleDiv(this)'>+<span class="">33</span>:     <span class="k">cdef</span> <span class="kt">double</span>[<span class="p">::</span><span class="mf">1</span><span class="p">,:]</span> <span class="n">tmp_hess</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">((</span><span class="mf">2</span><span class="o">+</span><span class="n">max_phase_dof</span><span class="p">,</span> <span class="mf">2</span><span class="o">+</span><span class="n">max_phase_dof</span><span class="p">),</span> <span class="n">order</span><span class="o">=</span><span class="s">'F'</span><span class="p">)</span></pre>
<pre class='cython code score-40 '>  <span class='trace'>__Pyx_TraceLine</span>(33,0,__PYX_ERR(0, 33, __pyx_L1_error))
  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  __pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 33, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyInt_From_long</span>((2 + __pyx_v_max_phase_dof)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  __pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyInt_From_long</span>((2 + __pyx_v_max_phase_dof)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 33, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
  __pyx_t_2 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_1);
  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0, __pyx_t_1);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7);
  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 1, __pyx_t_7);
  __pyx_t_1 = 0;
  __pyx_t_7 = 0;
  __pyx_t_7 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 33, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2);
  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_t_2, __pyx_n_s_order, __pyx_n_u_F) < 0) __PYX_ERR(0, 33, __pyx_L1_error)
  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_5, __pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_5); __pyx_t_5 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = <span class='pyx_c_api'>__Pyx_PyObject_to_MemoryviewSlice_dcd__double</span>(__pyx_t_1);
  if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 33, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_tmp_hess = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">34</span>:     <span class="k">cdef</span> <span class="kt">double</span>* <span class="nf">tmp_hess_ptr</span> <span class="o">=</span> <span class="o">&</span><span class="n">tmp_hess</span><span class="p">[</span><span class="mf">0</span><span class="p">,</span><span class="mf">0</span><span class="p">]</span></pre>
<pre class='cython code score-0 '>  <span class='trace'>__Pyx_TraceLine</span>(34,0,__PYX_ERR(0, 34, __pyx_L1_error))
  __pyx_t_9 = 0;
  __pyx_t_10 = 0;
  __pyx_v_tmp_hess_ptr = (&(*((double *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((double *) __pyx_v_tmp_hess.data) + __pyx_t_9)) ) + __pyx_t_10 * __pyx_v_tmp_hess.strides[1]) ))));
</pre><pre class="cython line score-49" onclick='toggleDiv(this)'>+<span class="">35</span>:     <span class="k">cdef</span> <span class="kt">double</span>[<span class="p">::</span><span class="mf">1</span><span class="p">]</span> <span class="n">dof</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="mf">2</span><span class="o">+</span><span class="n">max_phase_dof</span><span class="p">)</span></pre>
<pre class='cython code score-49 '>  <span class='trace'>__Pyx_TraceLine</span>(35,0,__PYX_ERR(0, 35, __pyx_L1_error))
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  __pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 35, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyInt_From_long</span>((2 + __pyx_v_max_phase_dof)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_7))) {
    __pyx_t_5 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_7);
    if (likely(__pyx_t_5)) {
      PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_7);
      <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_5);
      <span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
      <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_7, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_7)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_2};
      __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
      <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_5); __pyx_t_5 = 0;
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_7)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_2};
      __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
      <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_5); __pyx_t_5 = 0;
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_6 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 35, __pyx_L1_error)
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6);
      <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_5); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
      <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2);
      <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_6, 0+1, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_7, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_6); __pyx_t_6 = 0;
    }
  }
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_to_MemoryviewSlice_dc_double</span>(__pyx_t_1);
  if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 35, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dof = __pyx_t_3;
  __pyx_t_3.memview = NULL;
  __pyx_t_3.data = NULL;
</pre><pre class="cython line score-18" onclick='toggleDiv(this)'>+<span class="">36</span>:     <span class="k">cdef</span> <span class="kt">double</span>[<span class="p">::</span><span class="mf">1</span><span class="p">,:]</span> <span class="n">dof_2d_view</span> <span class="o">=</span> <span class="o"><</span><span class="n">double</span><span class="p">[:</span><span class="mf">1</span><span class="p">:</span><span class="mf">1</span><span class="p">,</span> <span class="p">:</span><span class="n">dof</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mf">0</span><span class="p">]]</span><span class="o">>&</span><span class="n">dof</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span></pre>
<pre class='cython code score-18 '>  <span class='trace'>__Pyx_TraceLine</span>(36,0,__PYX_ERR(0, 36, __pyx_L1_error))
  __pyx_t_11 = 0;
  __pyx_t_12 = (&(*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dof.data) + __pyx_t_11)) ))));
  if (unlikely(!__pyx_v_dof.memview)) { <span class='pyx_c_api'>__Pyx_RaiseUnboundLocalError</span>("dof"); __PYX_ERR(0, 36, __pyx_L1_error) }
  if (!__pyx_t_12) {
    <span class='py_c_api'>PyErr_SetString</span>(PyExc_ValueError,"Cannot create cython.array from NULL pointer");
    __PYX_ERR(0, 36, __pyx_L1_error)
  }
  __pyx_t_7 = __pyx_format_from_typeinfo(&__Pyx_TypeInfo_double);
  __pyx_t_1 = Py_BuildValue((char*) "("  __PYX_BUILD_PY_SSIZE_T  __PYX_BUILD_PY_SSIZE_T  ")", ((Py_ssize_t)1), ((Py_ssize_t)(__pyx_v_dof.shape[0])));
  if (unlikely(!__pyx_t_7 || !__pyx_t_1 || !<span class='py_c_api'>PyBytes_AsString</span>(__pyx_t_7))) __PYX_ERR(0, 36, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  __pyx_t_13 = __pyx_array_new(__pyx_t_1, sizeof(double), <span class='py_macro_api'>PyBytes_AS_STRING</span>(__pyx_t_7), (char *) "fortran", (char *) __pyx_t_12);
  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 36, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_13);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_8 = <span class='pyx_c_api'>__Pyx_PyObject_to_MemoryviewSlice_dcd__double</span>(((PyObject *)__pyx_t_13));
  if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 36, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
  __pyx_v_dof_2d_view = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
</pre><pre class="cython line score-11" onclick='toggleDiv(this)'>+<span class="">37</span>:     <span class="k">cdef</span> <span class="kt">int</span> <span class="nf">num_vars</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">site_fracs</span><span class="p">)</span> <span class="o">+</span> <span class="nb">len</span><span class="p">(</span><span class="n">phases</span><span class="p">)</span></pre>
<pre class='cython code score-11 '>  <span class='trace'>__Pyx_TraceLine</span>(37,0,__PYX_ERR(0, 37, __pyx_L1_error))
  __pyx_t_7 = __pyx_memoryview_fromslice(__pyx_v_site_fracs, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 37, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
  __pyx_t_14 = <span class='py_c_api'>PyObject_Length</span>(__pyx_t_7); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(0, 37, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_15 = <span class='py_c_api'>PyObject_Length</span>(__pyx_v_phases); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 37, __pyx_L1_error)
  __pyx_v_num_vars = (__pyx_t_14 + __pyx_t_15);
</pre><pre class="cython line score-40" onclick='toggleDiv(this)'>+<span class="">38</span>:     <span class="k">cdef</span> <span class="kt">double</span>[<span class="p">::</span><span class="mf">1</span><span class="p">,:]</span> <span class="n">l_hessian</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="n">num_vars</span><span class="p">,</span> <span class="n">num_vars</span><span class="p">),</span> <span class="n">order</span><span class="o">=</span><span class="s">'F'</span><span class="p">)</span></pre>
<pre class='cython code score-40 '>  <span class='trace'>__Pyx_TraceLine</span>(38,0,__PYX_ERR(0, 38, __pyx_L1_error))
  __pyx_t_7 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 38, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_7, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyInt_From_int</span>(__pyx_v_num_vars); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 38, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
  __pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyInt_From_int</span>(__pyx_v_num_vars); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 38, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6);
  __pyx_t_2 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7);
  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0, __pyx_t_7);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_6);
  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 1, __pyx_t_6);
  __pyx_t_7 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 38, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2);
  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_6, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_t_2, __pyx_n_s_order, __pyx_n_u_F) < 0) __PYX_ERR(0, 38, __pyx_L1_error)
  __pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_1, __pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 38, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_6); __pyx_t_6 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = <span class='pyx_c_api'>__Pyx_PyObject_to_MemoryviewSlice_dcd__double</span>(__pyx_t_7);
  if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 38, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_l_hessian = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
</pre><pre class="cython line score-49" onclick='toggleDiv(this)'>+<span class="">39</span>:     <span class="k">cdef</span> <span class="kt">double</span>[<span class="p">::</span><span class="mf">1</span><span class="p">]</span> <span class="n">gradient_term</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">num_vars</span><span class="p">)</span></pre>
<pre class='cython code score-49 '>  <span class='trace'>__Pyx_TraceLine</span>(39,0,__PYX_ERR(0, 39, __pyx_L1_error))
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  __pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 39, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyInt_From_int</span>(__pyx_v_num_vars); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_6))) {
    __pyx_t_1 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_6);
    if (likely(__pyx_t_1)) {
      PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_6);
      <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_1);
      <span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
      <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 39, __pyx_L1_error)
    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
  } else {
    #if CYTHON_FAST_PYCALL
    if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_2};
      __pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 39, __pyx_L1_error)
      <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_2};
      __pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 39, __pyx_L1_error)
      <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_5 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 39, __pyx_L1_error)
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);
      <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_1); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
      <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2);
      <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_5, 0+1, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 39, __pyx_L1_error)
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_to_MemoryviewSlice_dc_double</span>(__pyx_t_7);
  if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 39, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_gradient_term = __pyx_t_3;
  __pyx_t_3.memview = NULL;
  __pyx_t_3.data = NULL;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">40</span>:     <span class="k">cdef</span> <span class="kt">int</span> <span class="nf">var_offset</span> <span class="o">=</span> <span class="mf">0</span></pre>
<pre class='cython code score-0 '>  <span class='trace'>__Pyx_TraceLine</span>(40,0,__PYX_ERR(0, 40, __pyx_L1_error))
  __pyx_v_var_offset = 0;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">41</span>:     <span class="k">cdef</span> <span class="kt">int</span> <span class="nf">phase_idx</span> <span class="o">=</span> <span class="mf">0</span></pre>
<pre class='cython code score-0 '>  <span class='trace'>__Pyx_TraceLine</span>(41,0,__PYX_ERR(0, 41, __pyx_L1_error))
  __pyx_v_phase_idx = 0;
</pre><pre class="cython line score-0"> <span class="">42</span>:     <span class="k">cdef</span> <span class="kt">int</span> <span class="nf">cur_phase_dof</span><span class="p">,</span> <span class="nf">constraint_idx</span><span class="p">,</span> <span class="nf">dof_x_idx</span><span class="p">,</span> <span class="nf">dof_y_idx</span><span class="p">,</span> <span class="nf">hess_x</span><span class="p">,</span> <span class="nf">hess_y</span><span class="p">,</span> <span class="nf">hess_idx</span></pre>
<pre class="cython line score-0"> <span class="">43</span>:     <span class="k">cdef</span> <span class="kt">double</span> <span class="nf">phase_frac</span></pre>
<pre class="cython line score-0"> <span class="">44</span>:     <span class="k">cdef</span> <span class="kt">PhaseRecord</span> <span class="nf">prn</span></pre>
<pre class="cython line score-16" onclick='toggleDiv(this)'>+<span class="">45</span>:     <span class="n">dof</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">cur_conds</span><span class="p">[</span><span class="s">'P'</span><span class="p">]</span></pre>
<pre class='cython code score-16 '>  <span class='trace'>__Pyx_TraceLine</span>(45,0,__PYX_ERR(0, 45, __pyx_L1_error))
  __pyx_t_7 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_cur_conds, __pyx_n_u_P); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 45, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
  __pyx_t_16 = __pyx_<span class='py_c_api'>PyFloat_AsDouble</span>(__pyx_t_7); if (unlikely((__pyx_t_16 == (double)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) __PYX_ERR(0, 45, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_17 = 0;
  *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dof.data) + __pyx_t_17)) )) = __pyx_t_16;
</pre><pre class="cython line score-16" onclick='toggleDiv(this)'>+<span class="">46</span>:     <span class="n">dof</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">cur_conds</span><span class="p">[</span><span class="s">'T'</span><span class="p">]</span></pre>
<pre class='cython code score-16 '>  <span class='trace'>__Pyx_TraceLine</span>(46,0,__PYX_ERR(0, 46, __pyx_L1_error))
  __pyx_t_7 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_cur_conds, __pyx_n_u_T); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 46, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
  __pyx_t_16 = __pyx_<span class='py_c_api'>PyFloat_AsDouble</span>(__pyx_t_7); if (unlikely((__pyx_t_16 == (double)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) __PYX_ERR(0, 46, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_18 = 1;
  *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dof.data) + __pyx_t_18)) )) = __pyx_t_16;
</pre><pre class="cython line score-0"> <span class="">47</span>: </pre>
<pre class="cython line score-116" onclick='toggleDiv(this)'>+<span class="">48</span>:     <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">phase_frac</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">phases</span><span class="p">,</span> <span class="n">phase_fracs</span><span class="p">):</span></pre>
<pre class='cython code score-116 '>  <span class='trace'>__Pyx_TraceLine</span>(48,0,__PYX_ERR(0, 48, __pyx_L1_error))
  __pyx_t_7 = __pyx_memoryview_fromslice(__pyx_v_phase_fracs, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 48, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
  __pyx_t_6 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 48, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_phases);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_phases);
  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_6, 0, __pyx_v_phases);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7);
  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_6, 1, __pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_zip, __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 48, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_6); __pyx_t_6 = 0;
  if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_7)) || <span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_t_7)) {
    __pyx_t_6 = __pyx_t_7; <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_6); __pyx_t_15 = 0;
    __pyx_t_19 = NULL;
  } else {
    __pyx_t_15 = -1; __pyx_t_6 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 48, __pyx_L1_error)
    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6);
    __pyx_t_19 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 48, __pyx_L1_error)
  }
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
  for (;;) {
    if (likely(!__pyx_t_19)) {
      if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_6))) {
        if (__pyx_t_15 >= <span class='py_macro_api'>PyList_GET_SIZE</span>(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_7 = <span class='py_macro_api'>PyList_GET_ITEM</span>(__pyx_t_6, __pyx_t_15); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_7); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 48, __pyx_L1_error)
        #else
        __pyx_t_7 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 48, __pyx_L1_error)
        <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
        #endif
      } else {
        if (__pyx_t_15 >= <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_7 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_t_6, __pyx_t_15); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_7); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 48, __pyx_L1_error)
        #else
        __pyx_t_7 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 48, __pyx_L1_error)
        <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
        #endif
      }
    } else {
      __pyx_t_7 = __pyx_t_19(__pyx_t_6);
      if (unlikely(!__pyx_t_7)) {
        PyObject* exc_type = <span class='py_c_api'>PyErr_Occurred</span>();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || <span class='py_c_api'>PyErr_GivenExceptionMatches</span>(exc_type, PyExc_StopIteration))) <span class='py_c_api'>PyErr_Clear</span>();
          else __PYX_ERR(0, 48, __pyx_L1_error)
        }
        break;
      }
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
    }
    if ((likely(<span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_t_7))) || (<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_7))) {
      PyObject* sequence = __pyx_t_7;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = <span class='py_c_api'>PySequence_Size</span>(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) <span class='pyx_c_api'>__Pyx_RaiseTooManyValuesError</span>(2);
        else if (size >= 0) <span class='pyx_c_api'>__Pyx_RaiseNeedMoreValuesError</span>(size);
        __PYX_ERR(0, 48, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(<span class='py_c_api'>PyTuple_CheckExact</span>(sequence))) {
        __pyx_t_5 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 0);
        __pyx_t_2 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 1);
      } else {
        __pyx_t_5 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 0);
        __pyx_t_2 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 1);
      }
      <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_5);
      <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_2);
      #else
      __pyx_t_5 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 48, __pyx_L1_error)
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);
      __pyx_t_2 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error)
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
      #endif
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_1 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_20 = Py_TYPE(__pyx_t_1)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_20(__pyx_t_1); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);
      index = 1; __pyx_t_2 = __pyx_t_20(__pyx_t_1); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
      if (<span class='pyx_c_api'>__Pyx_IternextUnpackEndCheck</span>(__pyx_t_20(__pyx_t_1), 2) < 0) __PYX_ERR(0, 48, __pyx_L1_error)
      __pyx_t_20 = NULL;
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_20 = NULL;
      if (<span class='pyx_c_api'>__Pyx_IterFinish</span>() == 0) <span class='pyx_c_api'>__Pyx_RaiseNeedMoreValuesError</span>(index);
      __PYX_ERR(0, 48, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __pyx_t_16 = __pyx_<span class='py_c_api'>PyFloat_AsDouble</span>(__pyx_t_2); if (unlikely((__pyx_t_16 == (double)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) __PYX_ERR(0, 48, __pyx_L1_error)
    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
    <span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_name, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_v_phase_frac = __pyx_t_16;
/* … */
    <span class='trace'>__Pyx_TraceLine</span>(48,0,__PYX_ERR(0, 48, __pyx_L1_error))
  }
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_6); __pyx_t_6 = 0;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">49</span>:         <span class="n">prn</span> <span class="o">=</span> <span class="n">phase_records</span><span class="p">[</span><span class="n">name</span><span class="p">]</span></pre>
<pre class='cython code score-8 '>    <span class='trace'>__Pyx_TraceLine</span>(49,0,__PYX_ERR(0, 49, __pyx_L1_error))
    __pyx_t_7 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_phase_records, __pyx_v_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 49, __pyx_L1_error)
    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
    if (!(likely(((__pyx_t_7) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_7, __pyx_ptype_9pycalphad_4core_9phase_rec_PhaseRecord))))) __PYX_ERR(0, 49, __pyx_L1_error)
    <span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_prn, ((struct PhaseRecordObject *)__pyx_t_7));
    __pyx_t_7 = 0;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">50</span>:         <span class="k">with</span> <span class="k">nogil</span><span class="p">:</span></pre>
<pre class='cython code score-0 '>    <span class='trace'>__Pyx_TraceLine</span>(50,0,__PYX_ERR(0, 50, __pyx_L1_error))
    {
        #ifdef WITH_THREAD
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        #endif
        /*try:*/ {
/* … */
        <span class='trace'>__Pyx_TraceLine</span>(50,1,__PYX_ERR(0, 50, __pyx_L1_error))
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            Py_BLOCK_THREADS
            #endif
            goto __pyx_L11;
          }
          __pyx_L10_error: {
            #ifdef WITH_THREAD
            Py_BLOCK_THREADS
            #endif
            goto __pyx_L1_error;
          }
          __pyx_L11:;
        }
    }
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">51</span>:             <span class="n">cur_phase_dof</span> <span class="o">=</span> <span class="p"><</span><span class="kt">int</span><span class="p">></span><span class="n">phase_dof</span><span class="p">[</span><span class="n">phase_idx</span><span class="p">]</span></pre>
<pre class='cython code score-0 '>          <span class='trace'>__Pyx_TraceLine</span>(51,1,__PYX_ERR(0, 51, __pyx_L10_error))
          __pyx_t_21 = __pyx_v_phase_idx;
          __pyx_v_cur_phase_dof = ((int)(*((int *) ( /* dim=0 */ (__pyx_v_phase_dof.data + __pyx_t_21 * __pyx_v_phase_dof.strides[0]) ))));
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">52</span>:             <span class="n">dof</span><span class="p">[</span><span class="mf">2</span><span class="p">:</span><span class="mf">2</span><span class="o">+</span><span class="n">cur_phase_dof</span><span class="p">]</span> <span class="o">=</span> <span class="n">site_fracs</span><span class="p">[</span><span class="n">var_offset</span><span class="p">:</span><span class="n">var_offset</span> <span class="o">+</span> <span class="n">cur_phase_dof</span><span class="p">]</span></pre>
<pre class='cython code score-0 '>          <span class='trace'>__Pyx_TraceLine</span>(52,1,__PYX_ERR(0, 52, __pyx_L10_error))
          __pyx_t_22.data = __pyx_v_site_fracs.data;
          __pyx_t_22.memview = __pyx_v_site_fracs.memview;
          __PYX_INC_MEMVIEW(&__pyx_t_22, 0);
          __pyx_t_4 = -1;
          if (unlikely(__pyx_memoryview_slice_memviewslice(
    &__pyx_t_22,
    __pyx_v_site_fracs.shape[0], __pyx_v_site_fracs.strides[0], __pyx_v_site_fracs.suboffsets[0],
    0,
    0,
    &__pyx_t_4,
    __pyx_v_var_offset,
    (__pyx_v_var_offset + __pyx_v_cur_phase_dof),
    0,
    1,
    1,
    0,
    1) < 0))
{
    __PYX_ERR(0, 52, __pyx_L10_error)
}

__pyx_t_3.data = __pyx_v_dof.data;
          __pyx_t_3.memview = __pyx_v_dof.memview;
          __PYX_INC_MEMVIEW(&__pyx_t_3, 0);
          __pyx_t_4 = -1;
          if (unlikely(__pyx_memoryview_slice_memviewslice(
    &__pyx_t_3,
    __pyx_v_dof.shape[0], __pyx_v_dof.strides[0], __pyx_v_dof.suboffsets[0],
    0,
    0,
    &__pyx_t_4,
    2,
    (2 + __pyx_v_cur_phase_dof),
    0,
    1,
    1,
    0,
    1) < 0))
{
    __PYX_ERR(0, 52, __pyx_L10_error)
}

if (unlikely(__pyx_memoryview_copy_contents(__pyx_t_22, __pyx_t_3, 1, 1, 0) < 0)) __PYX_ERR(0, 52, __pyx_L10_error)
          __PYX_XDEC_MEMVIEW(&__pyx_t_3, 0);
          __pyx_t_3.memview = NULL;
          __pyx_t_3.data = NULL;
          __PYX_XDEC_MEMVIEW(&__pyx_t_22, 0);
          __pyx_t_22.memview = NULL;
          __pyx_t_22.data = NULL;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">53</span>:             <span class="n">obj</span><span class="p">(</span><span class="n">prn</span><span class="p">,</span> <span class="n">obj_res</span><span class="p">,</span> <span class="n">dof_2d_view</span><span class="p">,</span> <span class="mf">1</span><span class="p">)</span></pre>
<pre class='cython code score-0 '>          <span class='trace'>__Pyx_TraceLine</span>(53,1,__PYX_ERR(0, 53, __pyx_L10_error))
          __pyx_f_9pycalphad_4core_9phase_rec_obj(__pyx_v_prn, __pyx_v_obj_res, __pyx_v_dof_2d_view, 1);
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">54</span>:             <span class="n">grad</span><span class="p">(</span><span class="n">prn</span><span class="p">,</span> <span class="n">grad_res</span><span class="p">,</span> <span class="n">dof</span><span class="p">)</span></pre>
<pre class='cython code score-0 '>          <span class='trace'>__Pyx_TraceLine</span>(54,1,__PYX_ERR(0, 54, __pyx_L10_error))
          __pyx_f_9pycalphad_4core_9phase_rec_grad(__pyx_v_prn, __pyx_v_grad_res, __pyx_v_dof);
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">55</span>:             <span class="n">hess</span><span class="p">(</span><span class="n">prn</span><span class="p">,</span> <span class="n">tmp_hess</span><span class="p">,</span> <span class="n">dof</span><span class="p">)</span></pre>
<pre class='cython code score-0 '>          <span class='trace'>__Pyx_TraceLine</span>(55,1,__PYX_ERR(0, 55, __pyx_L10_error))
          __pyx_f_9pycalphad_4core_9phase_rec_hess(__pyx_v_prn, __pyx_v_tmp_hess, __pyx_v_dof);
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">56</span>:             <span class="k">for</span> <span class="n">dof_x_idx</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">cur_phase_dof</span><span class="p">):</span></pre>
<pre class='cython code score-0 '>          <span class='trace'>__Pyx_TraceLine</span>(56,1,__PYX_ERR(0, 56, __pyx_L10_error))
          __pyx_t_4 = __pyx_v_cur_phase_dof;
          for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_4; __pyx_t_23+=1) {
            __pyx_v_dof_x_idx = __pyx_t_23;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">57</span>:                 <span class="n">gradient_term</span><span class="p">[</span><span class="n">var_offset</span> <span class="o">+</span> <span class="n">dof_x_idx</span><span class="p">]</span> <span class="o">=</span> \</pre>
<pre class='cython code score-0 '>            <span class='trace'>__Pyx_TraceLine</span>(57,1,__PYX_ERR(0, 57, __pyx_L10_error))
            __pyx_t_25 = (__pyx_v_var_offset + __pyx_v_dof_x_idx);
            *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_gradient_term.data) + __pyx_t_25)) )) = (__pyx_v_phase_frac * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_grad_res.data) + __pyx_t_24)) ))));
          }
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">58</span>:                     <span class="n">phase_frac</span> <span class="o">*</span> <span class="n">grad_res</span><span class="p">[</span><span class="mf">2</span><span class="o">+</span><span class="n">dof_x_idx</span><span class="p">]</span>  <span class="c"># Remove P,T grad part</span></pre>
<pre class='cython code score-0 '>            <span class='trace'>__Pyx_TraceLine</span>(58,1,__PYX_ERR(0, 58, __pyx_L10_error))
            __pyx_t_24 = (2 + __pyx_v_dof_x_idx);
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">59</span>:             <span class="n">gradient_term</span><span class="p">[</span><span class="n">site_fracs</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span> <span class="o">+</span> <span class="n">phase_idx</span><span class="p">]</span> <span class="o">=</span> <span class="n">obj_res</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span></pre>
<pre class='cython code score-0 '>          <span class='trace'>__Pyx_TraceLine</span>(59,1,__PYX_ERR(0, 59, __pyx_L10_error))
          __pyx_t_26 = 0;
          __pyx_t_27 = ((__pyx_v_site_fracs.shape[0]) + __pyx_v_phase_idx);
          *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_gradient_term.data) + __pyx_t_27)) )) = (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_obj_res.data) + __pyx_t_26)) )));
</pre><pre class="cython line score-0"> <span class="">60</span>: </pre>
<pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">61</span>:             <span class="k">for</span> <span class="n">dof_x_idx</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">cur_phase_dof</span><span class="p">):</span></pre>
<pre class='cython code score-0 '>          <span class='trace'>__Pyx_TraceLine</span>(61,1,__PYX_ERR(0, 61, __pyx_L10_error))
          __pyx_t_4 = __pyx_v_cur_phase_dof;
          for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_4; __pyx_t_23+=1) {
            __pyx_v_dof_x_idx = __pyx_t_23;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">62</span>:                 <span class="k">for</span> <span class="n">dof_y_idx</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">dof_x_idx</span><span class="p">,</span><span class="n">cur_phase_dof</span><span class="p">):</span></pre>
<pre class='cython code score-0 '>            <span class='trace'>__Pyx_TraceLine</span>(62,1,__PYX_ERR(0, 62, __pyx_L10_error))
            __pyx_t_28 = __pyx_v_cur_phase_dof;
            for (__pyx_t_29 = __pyx_v_dof_x_idx; __pyx_t_29 < __pyx_t_28; __pyx_t_29+=1) {
              __pyx_v_dof_y_idx = __pyx_t_29;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">63</span>:                     <span class="n">l_hessian</span><span class="p">[</span><span class="n">var_offset</span><span class="o">+</span><span class="n">dof_x_idx</span><span class="p">,</span> <span class="n">var_offset</span><span class="o">+</span><span class="n">dof_y_idx</span><span class="p">]</span> <span class="o">=</span> \</pre>
<pre class='cython code score-0 '>              <span class='trace'>__Pyx_TraceLine</span>(63,1,__PYX_ERR(0, 63, __pyx_L10_error))
              __pyx_t_30 = (__pyx_v_var_offset + __pyx_v_dof_x_idx);
              __pyx_t_31 = (__pyx_v_var_offset + __pyx_v_dof_y_idx);
              *((double *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((double *) __pyx_v_l_hessian.data) + __pyx_t_30)) ) + __pyx_t_31 * __pyx_v_l_hessian.strides[1]) )) = (__pyx_v_phase_frac * (__pyx_v_tmp_hess_ptr[((2 + __pyx_v_dof_x_idx) + ((2 + __pyx_v_cur_phase_dof) * (2 + __pyx_v_dof_y_idx)))]));
</pre><pre class="cython line score-0"> <span class="">64</span>:                       <span class="n">phase_frac</span> <span class="o">*</span> <span class="n">tmp_hess_ptr</span><span class="p">[</span><span class="mf">2</span><span class="o">+</span><span class="n">dof_x_idx</span> <span class="o">+</span> <span class="p">(</span><span class="mf">2</span><span class="o">+</span><span class="n">cur_phase_dof</span><span class="p">)</span><span class="o">*</span><span class="p">(</span><span class="mf">2</span><span class="o">+</span><span class="n">dof_y_idx</span><span class="p">)]</span></pre>
<pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">65</span>:                     <span class="n">l_hessian</span><span class="p">[</span><span class="n">var_offset</span><span class="o">+</span><span class="n">dof_y_idx</span><span class="p">,</span> <span class="n">var_offset</span><span class="o">+</span><span class="n">dof_x_idx</span><span class="p">]</span> <span class="o">=</span> \</pre>
<pre class='cython code score-0 '>              <span class='trace'>__Pyx_TraceLine</span>(65,1,__PYX_ERR(0, 65, __pyx_L10_error))
              __pyx_t_34 = (__pyx_v_var_offset + __pyx_v_dof_y_idx);
              __pyx_t_35 = (__pyx_v_var_offset + __pyx_v_dof_x_idx);
              *((double *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((double *) __pyx_v_l_hessian.data) + __pyx_t_34)) ) + __pyx_t_35 * __pyx_v_l_hessian.strides[1]) )) = (*((double *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((double *) __pyx_v_l_hessian.data) + __pyx_t_32)) ) + __pyx_t_33 * __pyx_v_l_hessian.strides[1]) )));
            }
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">66</span>:                       <span class="n">l_hessian</span><span class="p">[</span><span class="n">var_offset</span><span class="o">+</span><span class="n">dof_x_idx</span><span class="p">,</span> <span class="n">var_offset</span><span class="o">+</span><span class="n">dof_y_idx</span><span class="p">]</span></pre>
<pre class='cython code score-0 '>              <span class='trace'>__Pyx_TraceLine</span>(66,1,__PYX_ERR(0, 66, __pyx_L10_error))
              __pyx_t_32 = (__pyx_v_var_offset + __pyx_v_dof_x_idx);
              __pyx_t_33 = (__pyx_v_var_offset + __pyx_v_dof_y_idx);
</pre><pre class="cython line score-0"> <span class="">67</span>:                 <span class="c"># Phase fraction / site fraction cross derivative</span></pre>
<pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">68</span>:                 <span class="n">l_hessian</span><span class="p">[</span><span class="n">site_fracs</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span> <span class="o">+</span> <span class="n">phase_idx</span><span class="p">,</span> <span class="n">var_offset</span> <span class="o">+</span> <span class="n">dof_x_idx</span><span class="p">]</span> <span class="o">=</span> \</pre>
<pre class='cython code score-0 '>            <span class='trace'>__Pyx_TraceLine</span>(68,1,__PYX_ERR(0, 68, __pyx_L10_error))
            __pyx_t_37 = ((__pyx_v_site_fracs.shape[0]) + __pyx_v_phase_idx);
            __pyx_t_38 = (__pyx_v_var_offset + __pyx_v_dof_x_idx);
            *((double *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((double *) __pyx_v_l_hessian.data) + __pyx_t_37)) ) + __pyx_t_38 * __pyx_v_l_hessian.strides[1]) )) = (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_grad_res.data) + __pyx_t_36)) )));
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">69</span>:                      <span class="n">grad_res</span><span class="p">[</span><span class="mf">2</span><span class="o">+</span><span class="n">dof_x_idx</span><span class="p">]</span> <span class="c"># Remove P,T grad part</span></pre>
<pre class='cython code score-0 '>            <span class='trace'>__Pyx_TraceLine</span>(69,1,__PYX_ERR(0, 69, __pyx_L10_error))
            __pyx_t_36 = (2 + __pyx_v_dof_x_idx);
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">70</span>:                 <span class="n">l_hessian</span><span class="p">[</span><span class="n">var_offset</span> <span class="o">+</span> <span class="n">dof_x_idx</span><span class="p">,</span> <span class="n">site_fracs</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span> <span class="o">+</span> <span class="n">phase_idx</span><span class="p">]</span> <span class="o">=</span> <span class="n">grad_res</span><span class="p">[</span><span class="mf">2</span><span class="o">+</span><span class="n">dof_x_idx</span><span class="p">]</span></pre>
<pre class='cython code score-0 '>            <span class='trace'>__Pyx_TraceLine</span>(70,1,__PYX_ERR(0, 70, __pyx_L10_error))
            __pyx_t_39 = (2 + __pyx_v_dof_x_idx);
            __pyx_t_40 = (__pyx_v_var_offset + __pyx_v_dof_x_idx);
            __pyx_t_41 = ((__pyx_v_site_fracs.shape[0]) + __pyx_v_phase_idx);
            *((double *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((double *) __pyx_v_l_hessian.data) + __pyx_t_40)) ) + __pyx_t_41 * __pyx_v_l_hessian.strides[1]) )) = (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_grad_res.data) + __pyx_t_39)) )));
          }
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">71</span>:             <span class="n">var_offset</span> <span class="o">+=</span> <span class="n">cur_phase_dof</span></pre>
<pre class='cython code score-0 '>          <span class='trace'>__Pyx_TraceLine</span>(71,1,__PYX_ERR(0, 71, __pyx_L10_error))
          __pyx_v_var_offset = (__pyx_v_var_offset + __pyx_v_cur_phase_dof);
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">72</span>:             <span class="n">phase_idx</span> <span class="o">+=</span> <span class="mf">1</span></pre>
<pre class='cython code score-0 '>          <span class='trace'>__Pyx_TraceLine</span>(72,1,__PYX_ERR(0, 72, __pyx_L10_error))
          __pyx_v_phase_idx = (__pyx_v_phase_idx + 1);
        }
</pre><pre class="cython line score-41" onclick='toggleDiv(this)'>+<span class="">73</span>:     <span class="n">l_hessian</span> <span class="o">-=</span> <span class="n">np</span><span class="o">.</span><span class="n">einsum</span><span class="p">(</span><span class="s">'i,ijk->jk'</span><span class="p">,</span> <span class="n">l_multipliers</span><span class="p">,</span> <span class="n">constraint_hess</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="s">'F'</span><span class="p">)</span></pre>
<pre class='cython code score-41 '>  <span class='trace'>__Pyx_TraceLine</span>(73,0,__PYX_ERR(0, 73, __pyx_L1_error))
  __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_l_hessian, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 73, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6);
  __pyx_t_7 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 73, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_7, __pyx_n_s_einsum); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = <span class='py_c_api'>PyTuple_New</span>(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 73, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_kp_u_i_ijk_jk);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_kp_u_i_ijk_jk);
  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0, __pyx_kp_u_i_ijk_jk);
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_l_multipliers));
  <span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_l_multipliers));
  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 1, ((PyObject *)__pyx_v_l_multipliers));
  <span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_constraint_hess));
  <span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_constraint_hess));
  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 2, ((PyObject *)__pyx_v_constraint_hess));
  __pyx_t_5 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 73, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);
  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_t_5, __pyx_n_s_order, __pyx_n_u_F) < 0) __PYX_ERR(0, 73, __pyx_L1_error)
  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_2, __pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = <span class='py_c_api'>PyNumber_InPlaceSubtract</span>(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 73, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_6); __pyx_t_6 = 0;
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_8 = <span class='pyx_c_api'>__Pyx_PyObject_to_MemoryviewSlice_dcd__double</span>(__pyx_t_5);
  if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 73, __pyx_L1_error)
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_5); __pyx_t_5 = 0;
  __PYX_XDEC_MEMVIEW(&__pyx_v_l_hessian, 1);
  __pyx_v_l_hessian = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
</pre><pre class="cython line score-96" onclick='toggleDiv(this)'>+<span class="">74</span>:     <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">l_hessian</span><span class="p">),</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">gradient_term</span><span class="p">)</span></pre>
<pre class='cython code score-96 '>  <span class='trace'>__Pyx_TraceLine</span>(74,0,__PYX_ERR(0, 74, __pyx_L1_error))
  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r);
  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  __pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 74, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_l_hessian, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_6))) {
    __pyx_t_7 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_6);
    if (likely(__pyx_t_7)) {
      PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_6);
      <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_7);
      <span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
      <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 74, __pyx_L1_error)
    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);
  } else {
    #if CYTHON_FAST_PYCALL
    if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
      __pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 74, __pyx_L1_error)
      <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
      __pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 74, __pyx_L1_error)
      <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_2 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
      <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0, __pyx_t_7); __pyx_t_7 = NULL;
      <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_1);
      <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0+1, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_6, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 74, __pyx_L1_error)
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
    }
  }
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_gradient_term, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_1))) {
    __pyx_t_7 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_1);
    if (likely(__pyx_t_7)) {
      PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_1);
      <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_7);
      <span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
      <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 74, __pyx_L1_error)
    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6);
  } else {
    #if CYTHON_FAST_PYCALL
    if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_2};
      __pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 74, __pyx_L1_error)
      <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_2};
      __pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 74, __pyx_L1_error)
      <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_42 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_42)) __PYX_ERR(0, 74, __pyx_L1_error)
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_42);
      <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_42, 0, __pyx_t_7); __pyx_t_7 = NULL;
      <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2);
      <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_42, 0+1, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_1, __pyx_t_42, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 74, __pyx_L1_error)
      <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6);
      <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_42); __pyx_t_42 = 0;
    }
  }
  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error)
  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_5);
  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_1, 0, __pyx_t_5);
  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_6);
  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_1, 1, __pyx_t_6);
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
</pre></div></body></html>

```python
%load_ext line_profiler
%lprun -f _build_multiphase_system equilibrium(dbf, ['AL', 'FE', 'VA'], list(dbf.phases.keys()), {v.T: 700, v.X('AL'): (0,1,0.02), v.P: 101325}, model=models, build_multiphase_system=_build_multiphase_system)
```

    The line_profiler extension is already loaded. To reload it, use:
      %reload_ext line_profiler

```python

```

```python

```