CALPHAD free energies are formulated in terms of sublattice concentrations

F(c_1,c_2,\dots,c_n)

while the phase field equations are formulated as functions of total concentrations. The constraint equations relating the total concentration $$c$$$to the sublattice concentrations are known (provided by pycalphad) c(c_1,c_2,\dots,c_n) Thus two problems need to be solved: 1. Constrained minimization of the free energy density with respect to the sublattice compositions 2. Calculate chemical potentials (i.e. derivatives $$\frac{\partial F}{\partial c}$$$ of the free energy w.r.t. the total concentrations)

We will attempt at minimizing $$F$$$with an applied Lagrange Multiplier constraint constructed from the constraint equations (this should be easy). The derivatives will be determined utilizing \frac{\partial c_i}{\partial c}\frac{\partial c}{\partial c_i}=1\quad\Rightarrow\quad \frac{\partial c_i}{\partial c} = \left(\frac{\partial c}{\partial c_i}\right)^{-1}, where $$\frac{\partial c}{\partial c_i}$$$ is simply the derivative of the constraint equation.

## First derivatives

\begin{align} \frac{\partial F}{\partial c} & = \frac{\partial F}{\partial c_1}\frac{\partial c_1}{\partial c} + \frac{\partial F}{\partial c_2}\frac{\partial c_2}{\partial c} + \dots + \frac{\partial F}{\partial c_n}\frac{\partial c_n}{\partial c} \\ & = \sum_i \frac{\partial F}{\partial c_i}\frac{\partial c_i}{\partial c} \\ & = \sum_i \frac{\partial F}{\partial c_i}\left(\frac{\partial c}{\partial c_i}\right)^{-1} \end{align}

## Second derivatives

\begin{align} \frac{\partial^2 F}{\partial c^2} & = \sum_i \frac{\partial}{\partial c}\left(\frac{\partial F}{\partial c_i}\frac{\partial c_i}{\partial c}\right) \\ & = \sum_i \frac{\partial}{\partial c_i}\left(\frac{\partial F}{\partial c_i}\frac{\partial c_i}{\partial c}\right)\frac{\partial c_i}{\partial c} \\ & = \sum_i \left(\frac{\partial^2 F}{\partial c_i^2}\frac{\partial c_i}{\partial c} + \frac{\partial F}{\partial c_i}\underbrace{\frac{\partial^2 c_i}{\partial c_i\partial c}}_{\equiv 0}\right)\frac{\partial c_i}{\partial c}\\ & = \sum_i \frac{\partial^2 F}{\partial c_i^2}\left(\frac{\partial c_i}{\partial c}\right)^2 \\ & = \sum_i \frac{\partial^2 F}{\partial c_i^2}\left(\frac{\partial c}{\partial c_i}\right)^{-2} \end{align}