Modeling magmatic systems; thermodynamic relations