Surrogate Models
To speed up calculations, kawin supports the use of surrogate models on thermodynamic and kinetic calculations. The functions surrogate module are designed to be interchangeable with the corresponding functions in the thermodynamics module. For binary systems, surrogates can be made for driving forces, interfacial compositions and diffusivities. For multicomponent systems, surrogates can be made for driving forces and growth rates/interfacial compositions.
Creating a surrogate model involves sampling a set of points ($\boldsymbol x$) on the desired function, where the sampling density is ideally constant. The distance between any two points will be defined as $r_{ij}$.
$$ r_{ij} = \lvert \lvert \boldsymbol x_i - \boldsymbol x_j \rvert \rvert $$
The surrogate module in kawin relies on radial basis functions ($\phi$) which are only dependent on $r$. Common functions include
Gaussian: $\phi(r) = \exp{\left(\left(-\frac{r}{\varepsilon} \right)^2 \right)}$
Multiquadric: $\phi(r) = \sqrt{\left(\frac{r}{\varepsilon} \right)^2 + 1}$
Inverse multiquadric: $\phi(r) = \frac{1}{\sqrt{\left(\frac{r}{\varepsilon} \right)^2 + 1}}$
Polynomial: $\phi(r) = \left(\frac{r}{\varepsilon} \right)^n \text{ for n = 1,3,5,…}$
Given $n$ samples, the value at a new point $x_m$ can be found by interpolating between the kernel functions evaluated between the samples and the new point using weights $\boldsymbol w$.
$$ \left[ \begin{array}{cccc} \phi(r_{m1}) & \phi(r_{m2}) & \ldots & \phi(r_{mn}) \end{array} \right] \left[ \begin{array}{c} w_1 \newline w_2 \newline \vdots \newline w_n \end{array} \right] = y_m $$
Where the weights are found from the training samples.
$$ \left[ \begin{array}{cccc} \phi(r_{11}) & \phi(r_{12}) & \ldots & \phi(r_{1n}) \newline \phi(r_{21}) & \phi(r_{22}) & \ldots & \phi(r_{2n}) \newline \vdots & \vdots & \ddots & \vdots \newline \phi(r_{n1}) & \phi(r_{n2}) & \ldots & \phi(r_{nn}) \end{array} \right] \left[ \begin{array}{c} w_1 \newline w_2 \newline \vdots \newline w_n \end{array} \right] = \left[ \begin{array}{c} y_1 \newline y_2 \newline \vdots \newline y_n \end{array} \right] $$
In practice, kawin will scale the position of the samples so the average distance between each point is around 1. In addition, the composition inputs and outputs may be transformed to a logarithmic form, which can be necessary for dilute solutions.