## Combining Multiphysics Modeling and Solution Thermodynamics Using M4Dlib, an External Library

**Published in**2015

An external library, M4Dlib [1], has been developed to solve multiphysics problems coupled to solution thermodynamics. This approach extends the local equilibrium concept[2] to multiphysics modeling by incorporating a full Gibbs energy minimization routine at each numerical node to calculate the equilibrium based on global temperature, enthalpy or concentration conditions (Figure 1). The application of M4Dlib allows for complex multiphysics simulations involving multicomponent, ideal and non-ideal systems, speciation, reactive and multiphase flows and phase-transition processes.

Examples involving solidification in multicomponent non-ideal systems are described and the results are compared to the 0D classical equilibrium approaches such as equilibrium solidification or Scheil cooling as well as to previous approaches to multiphysics solidification simulation [3,4].

When modeling real multicomponent-multiphase chemical systems it is often the case that a mixture of various phases can be present depending on the local conditions. In more complex cases, the presence of miscibility gaps can exists within the same phase or among different phases, resulting in the coexistence of two or more liquid phases. This is often the case in high temperature chemical systems such as liquid metal, mattes or slags. One advantage of using M4Dlib to simulate phase transition processes over previous models [3,4] is that the system is not limited to just binary systems.

The complex minimization routine solves a multi-dimension constrained optimization problem for each numerical node in the multiphysics domain. This process is carried out by M4Dlib, providing COMSOL Multiphysics® software with all the thermodynamic information required. The constrained minimization problem for a binary system is illustrated in (Figure 2), where the Gibbs free energy of mixing is described by two variables: the solid fraction (Sf) and the concentration of component A in the solid phase (XAS).

M4Dlib is available as a dynamic library for Windows and OS X and can be called directly from COMSOL software by the use of an “external function”. The thermodynamic data necessary to describe the chemical system is loaded during the initialization of the model, allowing to solve for various chemical system by simply changing the filename of the thermodynamic database. These, can be created from publicly available information for pure stoichiometric compounds [5,6] and the specific knowledge of the solution model of interest. Alternatively, private thermodynamic database files can be requested to M4Dynamics for specific applications based on available literature information.

The COMSOL Application Builder has been used to create an application for the simulation of a binary solution model as shown in Figure (3), calculating the corresponding phase diagram described by the selected thermodynamic database, expressed as surface plot of the solid fraction of the system as a function of temperature and global composition. The application also plots the integral Gibbs free energy of mixing for both solid and liquid solutions as a function of temperature.

The application of M4Dlib as an external library is demonstrated by solving the solidification of a liquid mixture inside a crucible as a function of time (Figure 4).

#### Download

- marin-alvarado_presentation.pdf - 1.34MB
- marin-alvarado_paper.pdf - 1.1MB
- marin-alvarado_abstract.pdf - 0.02MB