MAGEMin_C.jl: Output structures:
This part decribes the content of the output structure of MAGEMin_C. These structures save the results of the phase equilibrium prediction. The first one MAGEMin_C gmin_struct stores the result of the minimization while the second one out_TE_struct stores the results of the trace-element partitioning model.
Both of the structures can be (and should be) pre-allocated when performing multiple minimizations. Pre-allocation of the output structures is achieved as:
Out_XY = Vector{out_struct}(undef,n_calc)
Out_TE_XY = Vector{out_TE_struct}(undef,n_calc)where n_calc is the number of calculations you want to perform (e.g., the number of steps of a fractional crystallization experiment).
In the most simple form (where we don't pre-allocate), the output structure out is simply returned when the single_point_minimization() function is called:
using MAGEMin_C
data = Initialize_MAGEMin("ig", verbose=false);
P,T = 10.0, 1100.0
Xoxides = ["SiO2"; "Al2O3"; "CaO"; "MgO"; "FeO"; "Fe2O3"; "K2O"; "Na2O"; "TiO2"; "Cr2O3"; "H2O"];
X = [48.43; 15.19; 11.57; 10.13; 6.65; 1.64; 0.59; 1.87; 0.68; 0.0; 3.0];
sys_in = "wt"
out = single_point_minimization(P, T, data, X=X, Xoxides=Xoxides, sys_in=sys_in)How to navitage the (nested) structures?
The content of the output structure out can be accessed as any Julia structure:
julia> out.
G_system Gamma MAGEMin_ver M_sys PP_syms PP_vec P_kbar SS_syms SS_vec T_C V
Vp Vp_S Vs Vs_S X aAl2O3 aFeO aH2O aMgO aSiO2 aTiO2
alpha buffer buffer_n bulk bulkMod bulkModulus_M bulkModulus_S bulk_F bulk_F_wt bulk_M bulk_M_wt
bulk_S bulk_S_wt bulk_res_norm bulk_wt dQFM database dataset elements enthalpy entropy fO2
frac_F frac_F_vol frac_F_wt frac_M frac_M_vol frac_M_wt frac_S frac_S_vol frac_S_wt iter mSS_vec
n_PP n_SS n_mSS oxides ph ph_frac ph_frac_1at ph_frac_vol ph_frac_wt ph_id ph_id_db
ph_type rho rho_F rho_M rho_S s_cp shearMod shearModulus_S sol_name status time_msNote
- To display the content of the structure in a
juliaterminal after perform the calculation simply typeout.and then hitTABkey. This will display the content of the structure as shown above.
The system oxides are stored in out.oxides:
julia> out.oxides
11-element Vector{String}:
"SiO2"
"Al2O3"
"CaO"
"MgO"
"FeO"
"K2O"
"Na2O"
"TiO2"
"O"
"Cr2O3"
"H2O"The list of stable phases can be accessed as:
julia> out.ph
4-element Vector{String}:
"ol"
"spl"
"cpx"
"opx"The phase fraction in weight fraction:
julia> out.ph_frac_wt
4-element Vector{Float64}:
0.5828145797692089
0.0329389249905903
0.1489250586188556
0.23532143662134522and for instance the content of the solution phase ol (olivine) nested strucure as:
julia> out.SS_vec[1].
Comp Comp_apfu Comp_wt G V Vp
Vs alpha bulkMod compVariables compVariablesNames cp
deltaG emChemPot emComp emComp_apfu emComp_wt emFrac
emFrac_wt emNames enthalpy entropy f rho
shearMod siteFractions siteFractionsNameswhere [1] is the index of olivine in the out.SS_vec structure. The composition of olivine in weight fraction can be retrieved using:
julia> out.SS_vec[1].Comp_wt
11-element Vector{Float64}:
0.40825577403516533
0.0
0.00019320141395582851
0.4913560738016318
0.10019495074924696
0.0
0.0
0.0
0.0
0.0
0.0The index of a solution-phase can be retrieved using:
id_ol = nothing
if haskey(out.SS_syms, :ol)
id_ol = out.SS_syms[:ol]
endand for a pure-phase
id_ru = nothing
if haskey(id_ru, :ru)
id_ru = out.PP_syms[:ru]
endwere out.SS_syms and out.PP_syms are symbol dictionaries, linking a phase name to its proper structure index.
Note
In the latter case
ru(rutile) is not stable, thereforeid_ru = nothing.Accessing the phase structure using symbols can be useful for instance when extracting specific phases composition and/or to ease vizualisation.
(...)
The list of all entries is presented below and can be accessed (and used) in a similar manner.
Note that you can define the out structure as vector or a matrix (or any n-D array). In such cases the information of individual points can be accessed using their index:
julia> out[i].or
julia> out[i,j].where i and j are indices.
MAGEMin_C gmin_struct
The main structure stores the properties of the system.
├─ MAGEMin_ver :: String # [-] MAGEMin version
├─ dataset :: String # [-] Used thermodynamic dataset
├─ database :: String # [-] Acronym of the thermodynamic database
├─ buffer :: String # [-] Used oxygen/activity buffer
├─ buffer_n :: Float64 # [RTlog] oxygen fugacity offset
├─ G_system :: Float64 # [kJ/mol] Gibbs energy of the system (per mol of bulk oxides)
├─ Gamma :: Vector{Float64} # [kJ/mol] Chemical potential of system components (oxides e.g, SiO2, Al2O3 etc.)
├─ P_kbar :: Float64 # [kbar] pressure
├─ T_C :: Float64 # [°C] temperature
├─ X :: Vector{Float64} # 0 -> 1 x coordinate used when computing T-X, P-X or PT-X diagrams
├─ M_sys :: Float64 # [g/mol] normalized molar mass of the bulk rock composition
├─ bulk :: Vector{Float64} # [mol_i] bulk rock composition
├─ bulk_M :: Vector{Float64} # [mol_i] bulk mole composition of melt part
├─ bulk_S :: Vector{Float64} # [mol_i] bulk mole composition of solid part
├─ bulk_F :: Vector{Float64} # [mol_i] bulk mole composition of fluid part
├─ bulk_wt :: Vector{Float64} # [wt_i] bulk rock composition
├─ bulk_M_wt :: Vector{Float64} # [wt_i] bulk weight composition of melt part
├─ bulk_S_wt :: Vector{Float64} # [wt_i] bulk weight composition of solid par
├─ bulk_F_wt :: Vector{Float64} # [wt_i] bulk weight composition of fluid part
├─ frac_M :: Float64 # [mol_i] melt mole fraction
├─ frac_S :: Float64 # [mol_i] solid mole fraction
├─ frac_F :: Float64 # [mol_i] fluid/H2O mole fraction
├─ frac_M_wt :: Float64 # [wt_i] melt weight fraction
├─ frac_S_wt :: Float64 # [wt_i] solid weight fraction
├─ frac_F_wt :: Float64 # [wt_i] fluid/H2O weight fraction
├─ frac_M_vol :: Float64 # [vol_i] melt volume fraction
├─ frac_S_vol :: Float64 # [vol_i] solid volume fraction
├─ frac_F_vol :: Float64 # [vol_i] fluid volume fraction
├─ alpha :: Vector{Float64} # [1/K] isobaric thermal expansivity of the system
├─ beta :: Float64 # [1/GPa] isothermal compressibility of the system
├─ V :: Float64 # [cm^3/mol] system volume (per mol of bulk oxides); dG/dP in kJ/kbar = V/10
├─ V_cm3 :: Float64 # [cm^3/kg] specific volume of the system (1/rho)
├─ s_cp :: Vector{Float64} # [J/K/kg] specific isobaric heat capacity
├─ rho :: Float64 # [kg/m^3] system density
├─ rho_M :: Float64 # [kg/m^3] melt density
├─ rho_S :: Float64 # [kg/m^3] solid density
├─ rho_F :: Float64 # [kg/m^3] fluid/H2O density
├─ eta_M :: Float64 # [Pa.s] viscosity of the melt (after Giordano et al., 2008)
├─ fO2 :: Float64 # [-] oxygen fugacity
├─ system_oxygen :: Float64 # [mol_i]] mol fraction of oxygen bound in the solutions
├─ Fe3_Fe2_ratio :: Float64 # [-] Fe3 / (Fe3 + Fe2) mol ratio
├─ dQFM :: Float64 # [-] oxygen fugacity offset from QFM buffer
├─ aH2O :: Float64 # [-] system H2O activity
├─ aSiO2 :: Float64 # [-] system SiO2 activity
├─ aTiO2 :: Float64 # [-] system TiO2 activity
├─ aAl2O3 :: Float64 # [-] system Al2O3 activity
├─ aMgO :: Float64 # [-] system MgO activity
├─ aFeO :: Float64 # [-] system FeO activity
├─ n_PP :: Int64 # [-] number of stable pure phases
├─ n_SS :: Int64 # [-] number of stables solution phases
├─ n_mSS :: Int64 # [-] number of metastable phases (used for initial guess)
├─ ph_frac :: Vector{Float64} # [mol_i] phases mole fraction
├─ ph_frac_wt :: Vector{Float64} # [wt_i] phases weight fraction
├─ ph_frac_1at :: Vector{Float64} # [mol_i 1at] phase mole fraction on a 1 atom basis
├─ ph_frac_vol :: Vector{Float64} # [vol_i] phase volume fraction
├─ ph_type :: Vector{Int64} # [0,1] phase type: 0 -> pure phase, 1 -> solution phase
├─ ph_id :: Vector{Int64} # [0-n] phase id
├─ ph_id_db :: Vector{Int64} # [0-m] phase id as in the C code
├─ ph :: Vector{String} # [-] acronym of the stable phases
├─ sol_name :: Vector{String} # [-] stable solution phases acronym with version
├─ SS_syms :: Dict{Symbol, Int64} # [-] symbol list for stable solution phases, returns the ph_id number of corresponding solution phase
├─ PP_syms :: Dict{Symbol, Int64} # [-] symbol list for stable pure phases, returns the ph_id number of corresponding pure phase
├─ SS_vec :: Vector{MAGEMin_C.LibMAGEMin.SS_data} # [-] vector of solution phase structures, storing the informations related to solution phases
├─ mSS_vec :: Vector{MAGEMin_C.LibMAGEMin.mSS_data} # [-] vector of metastable phase structures, storing the informations related to metastable solution phases
├─ PP_vec :: Vector{MAGEMin_C.LibMAGEMin.PP_data} # [-] vector of pure phase structures, storing the informations related to pures phases
├─ oxides :: Vector{String} # [-] list of oxides names
├─ elements :: Vector{String} # [-] list of elements
├─ Vp :: Float64 # [km/s] P-wave system velocity
├─ Vs :: Float64 # [km/s] S-wave system velocity
├─ Vp_S :: Float64 # [km/s] P-wave solid velocity
├─ Vs_S :: Float64 # [km/s] S-wave solid velocity
├─ Vp_cor :: Float64 # [km/s] corrected P-wave solid velocity (shalow porosity, anelasticity and melt/fluid connectivity)
├─ Vs_cor :: Float64 # [km/s] corrected S-wave solid velocity (shalow porosity, anelasticity and melt/fluid connectivity)
├─ bulkMod :: Float64 # [GPa] system adiabatic bulk modulus
├─ shearMod :: Float64 # [GPa] system shear modulus
├─ bulkModulus_M :: Float64 # [GPa] melt bulk modulus
├─ bulkModulus_S :: Float64 # [GPa] solid bulk modulus
├─ shearModulus_S :: Float64 # [GPa] solid shear modulus
├─ entropy :: Vector{Float64} # [kJ/K/mol] system entropy (per mol of bulk oxides)
├─ entropy_F :: Float64 # [kJ/K/mol] fluid entropy (per mol of bulk oxides)
├─ entropy_M :: Float64 # [kJ/K/mol] melt entropy (per mol of bulk oxides)
├─ entropy_S :: Float64 # [kJ/K/mol] solid entropy (per mol of bulk oxides)
├─ enthalpy :: Vector{Float64} # [kJ/mol] system enthalpy (per mol of bulk oxides)
├─ iter :: Int64 # [-] number of iterations to reach convergence
├─ bulk_res_norm :: Float64 # [-] bulk rock composition residual
├─ time_ms :: Float64 # [ms] solution time
├─ status :: Int64 # [-] status of the minimization (Success,Relaxed1,Relaxed2,Failure)Units and normalisation
Extensive system properties (
G_system,entropy,enthalpy,V,entropy_M/S/F) are given per mol of bulk oxides, the bulk-rock composition being normalised to 1 mol. They are the exact derivatives of the system Gibbs energy:V/10= ∂G/∂P [kJ/kbar] andentropy= −∂G/∂T [kJ/K].Extensive phase properties (
G,entropy,enthalpy,cp,VinSS_vecandPP_vec) are given per mol of oxides of the phase, so that the system value is theph_frac-weighted sum of the phase values (e.g.out.V ≈ sum(out.ph_frac .* V_phase)).V_fugives the phase volume per mol of formula unit.Phase
alpha,beta,cpandbulkModare computed at fixed phase composition from the full Gibbs energy of the phase, including excess (mixing) terms.bulkModis the adiabatic bulk modulus,K_S = K_T·Cp/CvwithK_T = 1/beta. Systemalphaandbetaare the volume-weighted means of the phase values.System
s_cpandalphaare by default computed at fixed phase compositions and amounts; withscp = 1they are computed from finite differences of full equilibria and include the latent heat of reactions.
SS_vec
This sub-structure stores the properties of the stable solution phases.
├─ SS_vec :: Vector{MAGEMin_C.LibMAGEMin.SS_data}
├─ f :: Float64 # [-] normalization factor to convert from mole to mole on 1 atom basis
├─ G :: Float64 # [kJ/mol] Gibbs energy per mol of oxides of the phase (= Σ Comp·Gamma)
├─ deltaG :: Float64 # [kJ] driving force (distance from the Gibbs hyperplane)
├─ V :: Float64 # [cm^3/mol] volume per mol of oxides of the phase
├─ V_fu :: Float64 # [cm^3/mol] volume per mol of formula unit
├─ alpha :: Float64 # [1/K] isobaric thermal expansivity
├─ beta :: Float64 # [1/GPa] isothermal compressibility
├─ entropy :: Float64 # [kJ/K/mol] entropy per mol of oxides of the phase
├─ enthalpy :: Float64 # [kJ/mol] enthalpy per mol of oxides of the phase
├─ cp :: Float64 # [kJ/K/mol] isobaric heat capacity per mol of oxides of the phase (J/K/kg: cp*1e9/(rho*V))
├─ rho :: Float64 # [kg/m^3] density
├─ bulkMod :: Float64 # [GPa] adiabatic bulk modulus
├─ shearMod :: Float64 # [GPa] shear modulus
├─ Vp :: Float64 # [km/s] P-wave velocity of the phase
├─ Vs :: Float64 # [km/s] S-wave velocity of the phase
├─ pH :: Float64 # [-] pH of the aqueous fluid (DEW only, NaN otherwise)
├─ chargeResidual :: Float64 # [mol/kg] charge balance residual of the aqueous fluid (DEW only, NaN otherwise)
├─ sumMolality :: Float64 # [mol/kg] total solute molality (DEW only, NaN otherwise)
├─ G_water :: Float64 # [kJ/mol] chemical potential of water (DEW only, NaN otherwise)
├─ Comp :: Vector{Float64} # [mol_i] composition in mole fracton
├─ Comp_wt :: Vector{Float64} # [wt_i] composition in weight fraction
├─ Comp_apfu :: Vector{Float64} # [apfu] composition in atim per formula unit
├─ compVariables :: Vector{Float64} # [-] compositional variables as described in THERMOCALC (https://hpxeosandthermocalc.org/the-thermocalc-software/)
├─ compVariablesNames :: Vector{String} # [-] compositional names
├─ siteFractions :: Vector{Float64} # [-] site fractions
├─ siteFractionsNames :: Vector{String} # [-] site fractions names
├─ emNames :: Vector{String} # [-] names of the end-members
├─ molality :: Vector{Float64} # [mol/kg] species molalities (DEW only)
├─ activity :: Vector{Float64} # [-] species activities (DEW only)
├─ emFrac :: Vector{Float64} # [mol_i] end-members fraction in mole
├─ emFrac_wt :: Vector{Float64} # [wt_i] end-members fraction in weight
├─ emChemPot :: Vector{Float64} # [kJ/mol·f] chemical potentials of the end-members per mol of end-member, multiplied by f (divide by f for kJ/mol)
├─ emComp :: Vector{Vector{Float64}} # [mol_i] composition of the endmembers in mole fracton
├─ emComp_wt :: Vector{Vector{Float64}} # [wt_i] composition of the endmembers in weight fracton
├─ emComp_apfu :: Vector{Vector{Float64}} # [-] composition of the endmembers in atom per formula unitPP_vec
This sub-structure stores the properties of the stable pure phases.
├─ PP_vec :: Vector{MAGEMin_C.LibMAGEMin.PP_data}
├─ f :: Float64 # [-] normalization factor to convert from mole to mole on 1 atom basis
├─ G :: Float64 # [kJ/mol] Gibbs energy per mol of oxides of the phase (= Σ Comp·Gamma)
├─ deltaG :: Float64 # [kJ] distance from the Gibbs hyperplane
├─ V :: Float64 # [cm^3/mol] volume per mol of oxides of the phase
├─ V_fu :: Float64 # [cm^3/mol] volume per mol of formula unit
├─ alpha :: Float64 # [1/K] isobaric thermal expansivity
├─ beta :: Float64 # [1/GPa] isothermal compressibility
├─ entropy :: Float64 # [kJ/K/mol] entropy per mol of oxides of the phase
├─ enthalpy :: Float64 # [kJ/mol] enthalpy per mol of oxides of the phase
├─ cp :: Float64 # [kJ/K/mol] isobaric heat capacity per mol of oxides of the phase (J/K/kg: cp*1e9/(rho*V))
├─ rho :: Float64 # [kg/m^3] density
├─ bulkMod :: Float64 # [GPa] adiabatic bulk modulus
├─ shearMod :: Float64 # [GPa] shear modulus
├─ Vp :: Float64 # [km/s] P-wave velocity of the phase
├─ Vs :: Float64 # [km/s] S-wave velocity of the phase
├─ Comp :: Vector{Float64} # [mol_i] composition in mole fracton
├─ Comp_wt :: Vector{Float64} # [wt_i] composition in weight fraction
├─ Comp_apfu :: Vector{Float64} # [apfu] composition in atim per formula unitmSS_vec
This sub-structure stores the properties of the metastable assemblage i.e., the informations of the phases not far from the Gibbs hyperplane.
├─ mSS_vec :: Vector{MAGEMin_C.LibMAGEMin.mSS_data}
├─ ph_name :: String # [-] name of the phases
├─ ph_type :: String # [-] type of the phase "ss" or "pp"
├─ info :: String # [-] origin of the phase in terms of minimization stage
├─ ph_id :: Int32 # [-] id of the phase in the C code
├─ em_id :: Int32 # [-] if end-member, id of the end-member
├─ n_xeos :: Int32 # [-] number of compositional variables
├─ n_em :: Int32 # [-] number of endmembers (n_xeos +1)
├─ G_Ppc :: Float64 # [-] Gibbs energy of the pseudocompound
├─ DF_Ppc :: Float64 # [-] driving force of the pseudocompound (distance from the Gibbs hyperplane)
├─ comp_Ppc :: Vector{Float64} # [mol_i] composition of the pseudocompound
├─ p_Ppc :: Vector{Float64} # [mol_i] end-member fractions of the pseudocompound
├─ mu_Ppc :: Vector{Float64} # [kJ/f] chemical potentials of the end-members
├─ xeos_Ppc :: Vector{Float64} # [-] compositional variablesout_TE_struct
This structure stores the properties of the trace elements and accessory minerals.
├─ C0 :: Union{Nothing, Vector{Float64}} # [ug/g] trace-elements concentration
├─ Csol :: Union{Nothing, Vector{Float64}} # [ug/g] trace-elements concentration in the solid
├─ Cliq :: Union{Nothing, Vector{Float64}} # [ug/g] trace-elements concentration in the melt
├─ Cmin :: Union{Nothing, Matrix{Float64}} # [ug/g] trace-elements concentration in the stable phases
├─ Sat_P2O5_liq :: Union{Nothing, Float64} # [ug/g] P2O5 (fluorapatite) saturation of the melt (computed using several saturation models)
├─ Sat_S_liq :: Union{Nothing, Float64} # [ug/g] sulfur (sulfide) saturation of the melt (computed using several saturation models)
├─ Sat_Zr_liq :: Union{Nothing, Float64} # [ug/g] zirconium saturation of the melt (computed using several saturation models)
├─ Sat_CO2_liq :: Union{Nothing, Float64} # [ug/g] CO2 (fluid) saturation of the melt (computed using several saturation models)
├─ bulk_D :: Union{Nothing, Float64} # [-] bulk partition coefficient
├─ bulk_cor_wt :: Union{Nothing, Vector{Float64}} # [wt_i] wt fraction corrected bulk rock composition after phase crystallization from saturation models
├─ bulk_cor_mol :: Union{Nothing, Vector{Float64}} # [mol_i] mol fraction corrected bulk rock composition after phase crystallization from saturation models
├─ elements :: Union{Nothing, Vector{String}} # [-] trace-elements names
├─ liq_wt_norm :: Union{Nothing, Float64} # [wt_i] normalized weight melt fraction
├─ ph_TE :: Union{Nothing, Vector{String}} # [-] names of the trace-elements-bearing phases (defined when settings the KDs)
├─ ph_wt_norm :: Union{Nothing, Vector{Float64}} # [wt_i] normalized weight fraction of the trace-elements-bearing phases (renormalized as KDs are not necessarily given for all phases)
├─ fapt_wt :: Union{Nothing, Float64} # [wt] calculated fluorapatite weight fraction
├─ sulf_wt :: Union{Nothing, Float64} # [wt] calculated sulfide weight fraction
├─ zrc_wt :: Union{Nothing, Float64} # [wt] calculated zircon weight fraction
├─ fl_CO2_wt :: Union{Nothing, Float64} # [wt] calculated CO2 fluid weight fractionNote
Sat_CO2_liq/fl_CO2_wt are only populated when CO2Sat_model= is passed to TE_prediction - see Saturation models: E.5 CO2 saturation model example.