.. MAGEMin documentation

THERMOCALC-like output
======================

If ``verbose`` is set to 1:

.. code-block:: shell

   --Verb=1

a file named ``_thermocalc_style_output.txt`` containing the information of the stable phase equilibrium is saved in ``./output/`` directory.

|


..  _MATLAB-target:

MATLAB output
=============

If:

.. code-block:: shell

   --out_matlab=1

a file named ``_matlab_output.txt`` containing the information of the stable phase equilibrium is saved in ``./output/`` directory.
This file, although similar to ``_thermocalc_style_output.txt`` in structure, this option saves the result of the minimization in more human friendly units:
phase fraction and composition are expressed in :literal:`[wt fraction]`.

Note that this output is used by the Matlab notebook ``MAGEMin_EquilibriumPath.mlx`` developped by Dr. Tobias Keller (tobias.keller@erdw.ethz.ch) and added to MAGEMin in version v1.2.4.

|

As a nested structure
=====================

Stable phase equilibrium and related thermodynamically derived parameters such as density are automatically saved as a nested structure containing the information about the system.

The nested structure is defined as a ``stb_systems`` type and contains the following informations


Computation information
***********************

+--------------------------------------------------------------------------------------------------------------+
| ``sb``                                                                                                       |
+---------------+-------------------+--------------------------------------------------------------------------+
| **data type** | **variable name** | **definition**                                                           |
+---------------+-------------------+--------------------------------------------------------------------------+
| char *        | MAGEMin_ver       | MAGEMin version used for calculation                                     |
+---------------+-------------------+--------------------------------------------------------------------------+
| int           | nOx               | number of oxides                                                         |
+---------------+-------------------+--------------------------------------------------------------------------+
| int           | n_iterations      | number of iterations                                                     |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | bulk_res_norm     | system mass constraint residual norm                                     |
+---------------+-------------------+--------------------------------------------------------------------------+
| char **       | oxides            | oxide names                                                              |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | P                 | Pressure :literal:`[kbar]`                                               |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | T                 | Temperature :literal:`[C]`                                               |
+---------------+-------------------+--------------------------------------------------------------------------+
| double *      | bulk              | system bulk composition  :literal:`[mol fraction]`                       |
+---------------+-------------------+--------------------------------------------------------------------------+
| double *      | bulk_wt           | system bulk composition  :literal:`[wt fraction]`                        |
+---------------+-------------------+--------------------------------------------------------------------------+

System information
*******************

+---------------+-------------------+-------------------------------------------------------------------------+
| ``sb``        |                   |                                                                         |
+---------------+-------------------+-------------------------------------------------------------------------+
| **data type** | **variable name** | **definition**                                                          |
+---------------+-------------------+-------------------------------------------------------------------------+
| double *      | gamma             | chemical potential of the pure components :literal:`[Gibbs hyperplane]` |
+---------------+-------------------+-------------------------------------------------------------------------+
| double        | G                 | system Gibbs energy :literal:`[J]`                                      |
+---------------+-------------------+-------------------------------------------------------------------------+
| double        | V                 | system molar volume :literal: `[cm^3/mol]`                            |
+---------------+-------------------+-------------------------------------------------------------------------+
| double        | rho               | system density :literal:`[wt fraction]`                                 |
+---------------+-------------------+-------------------------------------------------------------------------+
| double *      | bulk_S            | solid agregate bulk composition :literal:`[mol fraction]`               |
+---------------+-------------------+-------------------------------------------------------------------------+
| double *      | bulk_S_wt         | solid agregate bulk composition :literal:`[wt fraction]`                |
+---------------+-------------------+-------------------------------------------------------------------------+
| double        | frac_S            | solid agregate fraction :literal:`[mol fraction]`                       |
+---------------+-------------------+-------------------------------------------------------------------------+
| double        | frac_S_wt         | solid agregate fraction :literal:`[wt fraction]`                        |
+---------------+-------------------+-------------------------------------------------------------------------+
| double        | rho_S             | solid agregate density :literal:`[wt fraction]`                         |
+---------------+-------------------+-------------------------------------------------------------------------+
| double *      | bulk_M            | melt bulk composition :literal:`[mol fraction]`                         |
+---------------+-------------------+-------------------------------------------------------------------------+
| double *      | bulk_M_wt         | melt bulk composition :literal:`[wt fraction]`                          |
+---------------+-------------------+-------------------------------------------------------------------------+
| double        | frac_M            | melt fraction :literal:`[mol fraction]`                                 |
+---------------+-------------------+-------------------------------------------------------------------------+
| double        | frac_M_wt         | melt fraction :literal:`[wt fraction]`                                  |
+---------------+-------------------+-------------------------------------------------------------------------+
| double        | rho_M             | melt density :literal:`[wt fraction]`                                   |
+---------------+-------------------+-------------------------------------------------------------------------+
| double *      | bulk_F            | fluid bulk composition :literal:`[mol fraction]`                        |
+---------------+-------------------+-------------------------------------------------------------------------+
| double *      | bulk_F_wt         | fluid bulk composition :literal:`[wt fraction]`                         |
+---------------+-------------------+-------------------------------------------------------------------------+
| double        | frac_F            | fluid fraction :literal:`[mol fraction]`                                |
+---------------+-------------------+-------------------------------------------------------------------------+
| double        | frac_F_wt         | fluid fraction :literal:`[wt fraction]`                                 |
+---------------+-------------------+-------------------------------------------------------------------------+
| double        | rho_F             | fluid density :literal:`[wt fraction]`                                  |
+---------------+-------------------+-------------------------------------------------------------------------+

+--------------------------------------------------------------------------------------------------------------+
| ``sb``                                                                                                       |
+---------------+-------------------+--------------------------------------------------------------------------+
| **data type** | **variable name** | **definition**                                                           |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | entropy           | system entropy  :literal:`[J/K]`                                         |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | enthalpy          | system enthalpy  :literal:`[J]`                                          |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | bulkMod           | system bulk modulus  :literal:`[GPa]`                                    |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | shearMod          | system shear modulus  :literal:`[GPa]`                                   |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | bulkModulus_M     | melt bulk modulus  :literal:`[GPa]`                                      |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | bulkModulus_S     | solid bulk modulus  :literal:`[GPa]`                                     |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | shearModulus_S    | solid shear modulus  :literal:`[GPa]`                                    |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | Vp                | system P-wave velocity  :literal:`[km/s]`                                |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | Vs                | system S-wave velocity  :literal:`[km/s]`                                |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | Vp_S              | solid P-wave velocity  :literal:`[km/s]`                                 |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | Vs_S              | solid S-wave velocity  :literal:`[km/s]`                                 |
+---------------+-------------------+--------------------------------------------------------------------------+

Phase proportions
*****************

+--------------------------------------------------------------------------------------------------------------+
| ``sb``                                                                                                       |
+---------------+-------------------+--------------------------------------------------------------------------+
| **data type** | **variable name** | **definition**                                                           |
+---------------+-------------------+--------------------------------------------------------------------------+
| int           | n_ph              | total number of predicted stable phases                                  |
+---------------+-------------------+--------------------------------------------------------------------------+
| int           | n_PP              | number of predicted pure phases                                          |
+---------------+-------------------+--------------------------------------------------------------------------+
| int           | n_SS              | number of predicted solution phases                                      |
+---------------+-------------------+--------------------------------------------------------------------------+
| char **       | ph                | stable phases names                                                      |
+---------------+-------------------+--------------------------------------------------------------------------+
| double *      | ph_frac           | stable phases fractions  :literal:`[mol fraction]`                       |
+---------------+-------------------+--------------------------------------------------------------------------+
| double *      | ph_frac_wt        | stable phases fractions  :literal:`[wt fraction]`                        |
+---------------+-------------------+--------------------------------------------------------------------------+
| int *         | ph_type           | stable phase type: 0 -> pure phase, 1 -> solution phase                  |
+---------------+-------------------+--------------------------------------------------------------------------+
| int *         | ph_id             | stable phase id :literal:`[to retrieve individual phase properties]`     |
+---------------+-------------------+--------------------------------------------------------------------------+
| stb_SS_phase  | SS                | structure holding solution phases information                            |
+---------------+-------------------+--------------------------------------------------------------------------+
| stb_PP_phase  | PP                | structure holding pure phases information                                |
+---------------+-------------------+--------------------------------------------------------------------------+

Solution phases information
***************************

+--------------------------------------------------------------------------------------------------------------+
| ``sp[0].SS[n_SS].``                                                                                          |
+---------------+-------------------+--------------------------------------------------------------------------+
| **data type** | **variable name** | **definition**                                                           |
+---------------+-------------------+--------------------------------------------------------------------------+
| int           | n_xeos            | number of compositional variables                                        |
+---------------+-------------------+--------------------------------------------------------------------------+
| int           | n_em              | number of end-members                                                    |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | f                 | normalization factor                                                     |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | G                 | Gibbs energy of solution phase :literal:`[J]`                            |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | deltaG            | ΔG between solution phase and Gibbs-hyperplane :literal:`[J]`            |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | V                 | molar volume of the solution phase :literal:`[cm^3/mol]`                 |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | alpha             | thermal expansivity  :literal:`[1/K]`                                    |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | cp                | heat capacity  :literal:`[kJ/K]`                                         |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | rho               | density  :literal:`[kg/m3]`                                              |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | entropy           | entropy  :literal:`[J/K]`                                                |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | enthalpy          | enthalpy  :literal:`[J]`                                                 |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | bulkMod           | bulk modulus  :literal:`[GPa]`                                           |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | shearMod          | shear modulus  :literal:`[GPa]`                                          |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | Vp                | P-wave velocity  :literal:`[km/s]`                                       |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | Vs                | S-wave velocity  :literal:`[km/s]`                                       |
+---------------+-------------------+--------------------------------------------------------------------------+
| double *      | compVariables     | compositional variables                                                  |
+---------------+-------------------+--------------------------------------------------------------------------+
| double *      | Comp              | solution phase composition :literal:`[mol fraction]`                     |
+---------------+-------------------+--------------------------------------------------------------------------+
| double *      | Comp_wt           | solution phase composition :literal:`[wt fraction]`                      |
+---------------+-------------------+--------------------------------------------------------------------------+
| char **       | emNames           | end-members name                                                         |
+---------------+-------------------+--------------------------------------------------------------------------+
| double *      | emFrac            | end-members fractions :literal:`[mol fraction]`                          |
+---------------+-------------------+--------------------------------------------------------------------------+
| double *      | emFrac_wt         | end-members fractions :literal:`[wt fraction]`                           |
+---------------+-------------------+--------------------------------------------------------------------------+
| double *      | emChemPot         | end-members chemical potential :literal:`[J]`                            |
+---------------+-------------------+--------------------------------------------------------------------------+
| double **     | emComp            | end-members composition :literal:`[mol fraction]`                        |
+---------------+-------------------+--------------------------------------------------------------------------+
| double **     | emComp_wt         | end-members composition :literal:`[wt fraction]`                         |
+---------------+-------------------+--------------------------------------------------------------------------+

Solution phases information
***************************

+--------------------------------------------------------------------------------------------------------------+
| ``sp[0].PP[n_PP].``                                                                                          |
+---------------+-------------------+--------------------------------------------------------------------------+
| **data type** | **variable name** | **definition**                                                           |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | f                 | normalization factor                                                     |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | G                 | Gibbs energy of pure phase :literal:`[J]`                                |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | deltaG            | ΔG between pure phase and Gibbs-hyperplane :literal:`[J]`                |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | V                 | molar volume of the pure phase :literal:`[cm^3/mol]`                 |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | alpha             | thermal expansivity  :literal:`[1/K]`                                    |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | cp                | heat capacity  :literal:`[kJ/K]`                                         |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | rho               | density  :literal:`[kg/m3]`                                              |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | entropy           | entropy  :literal:`[J/K]`                                                |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | enthalpy          | enthalpy  :literal:`[J]`                                                 |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | bulkMod           | bulk modulus  :literal:`[GPa]`                                           |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | shearMod          | shear modulus  :literal:`[GPa]`                                          |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | Vp                | P-wave velocity  :literal:`[km/s]`                                       |
+---------------+-------------------+--------------------------------------------------------------------------+
| double        | Vs                | S-wave velocity  :literal:`[km/s]`                                       |
+---------------+-------------------+--------------------------------------------------------------------------+
| double *      | Comp              | pure phase composition :literal:`[mol fraction]`                         |
+---------------+-------------------+--------------------------------------------------------------------------+
| double *      | Comp_wt           | pure phase composition :literal:`[wt fraction]`                          |
+---------------+-------------------+--------------------------------------------------------------------------+



