Skip to content

Commit

Permalink
MAGEMin_C v1.6.4 (#62)
Browse files Browse the repository at this point in the history
- Added extended metapelite database to account for CO2 and S
- Added option to select combination of solution phase for metapelite and metabasite database
- Added “light” option to save minimum output from MAGEMin_C calculations
- Added several pseudocompounds for metapelite to improve phase diagrams quality 
- Corrected mistake when saving endmember wt fraction and end member wt composition
  • Loading branch information
NicolasRiel authored Nov 28, 2024
1 parent 813bb39 commit dac9941
Show file tree
Hide file tree
Showing 29 changed files with 38,449 additions and 571 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MAGEMin_C"
uuid = "e5d170eb-415a-4524-987b-12f1bce1ddab"
authors = ["Nicolas Riel <[email protected]> & Boris Kaus <[email protected]>"]
version = "1.6.3"
version = "1.6.4"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Expand All @@ -17,6 +17,6 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
CEnum = "0.4"
CSV = "0.10.14"
DataFrames = "1.6.1"
MAGEMin_jll = "1.5.9 - 1.5.9"
MAGEMin_jll = "1.6.0 - 1.6.0"
ProgressMeter = "1"
julia = "1.6"
171 changes: 159 additions & 12 deletions gen/magemin_library.jl
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,9 @@ mutable struct global_variables
limitCaOpx::Cint
CaOpxLim::Cdouble
mbCpx::Cint
mbIlm::Cint
mpSp::Cint
mpIlm::Cint
fluidSpec::Cint
n_fs_db::Cint
test::Cint
Expand Down Expand Up @@ -658,6 +661,7 @@ mutable struct global_variables
numPoint::Cint
global_ite::Cint
H2O_id::Cint
CO2_id::Cint
S_id::Cint
Al2O3_id::Cint
CaO_id::Cint
Expand Down Expand Up @@ -1188,6 +1192,7 @@ struct stb_systems
ph_frac_vol::Ptr{Cdouble}
ph_type::Ptr{Cint}
ph_id::Ptr{Cint}
ph_id_db::Ptr{Cint}
SS::Ptr{stb_SS_phase}
mSS::Ptr{mstb_SS_phase}
PP::Ptr{stb_PP_phase}
Expand Down Expand Up @@ -1319,10 +1324,10 @@ mutable struct metapelite_datasets
n_ss::Cint
ox::NTuple{11, NTuple{20, Cchar}}
PP::NTuple{23, NTuple{20, Cchar}}
SS::NTuple{16, NTuple{20, Cchar}}
verifyPC::NTuple{16, Cint}
n_SS_PC::NTuple{16, Cint}
SS_PC_stp::NTuple{16, Cdouble}
SS::NTuple{18, NTuple{20, Cchar}}
verifyPC::NTuple{18, Cint}
n_SS_PC::NTuple{18, Cint}
SS_PC_stp::NTuple{18, Cdouble}
PC_df_add::Cdouble
solver_switch_T::Cdouble
min_melt_T::Cdouble
Expand All @@ -1345,14 +1350,10 @@ mutable struct metabasite_datasets
n_ss::Cint
ox::NTuple{10, NTuple{20, Cchar}}
PP::NTuple{23, NTuple{20, Cchar}}
SS1::NTuple{15, NTuple{20, Cchar}}
verifyPC1::NTuple{15, Cint}
n_SS_PC1::NTuple{15, Cint}
SS_PC_stp1::NTuple{15, Cdouble}
SS2::NTuple{15, NTuple{20, Cchar}}
verifyPC2::NTuple{15, Cint}
n_SS_PC2::NTuple{15, Cint}
SS_PC_stp2::NTuple{15, Cdouble}
SS::NTuple{17, NTuple{20, Cchar}}
verifyPC::NTuple{17, Cint}
n_SS_PC::NTuple{17, Cint}
SS_PC_stp::NTuple{17, Cdouble}
PC_df_add::Cdouble
solver_switch_T::Cdouble
min_melt_T::Cdouble
Expand Down Expand Up @@ -1498,6 +1499,32 @@ end

const mantle_dataset = mantle_datasets

mutable struct metapelite_datasets_ext
ds_version::Cint
n_ox::Cint
n_pp::Cint
n_ss::Cint
ox::NTuple{13, NTuple{20, Cchar}}
PP::NTuple{25, NTuple{20, Cchar}}
SS::NTuple{23, NTuple{20, Cchar}}
verifyPC::NTuple{23, Cint}
n_SS_PC::NTuple{23, Cint}
SS_PC_stp::NTuple{23, Cdouble}
PC_df_add::Cdouble
solver_switch_T::Cdouble
min_melt_T::Cdouble
inner_PGE_ite::Cdouble
max_n_phase::Cdouble
max_g_phase::Cdouble
max_fac::Cdouble
merge_value::Cdouble
re_in_n::Cdouble
obj_tol::Cdouble
metapelite_datasets_ext() = new()
end

const metapelite_dataset_ext = metapelite_datasets_ext

function global_variable_TC_init(gv, z_b)
ccall((:global_variable_TC_init, libMAGEMin), global_variable, (global_variable, Ptr{bulk_info}), gv, z_b)
end
Expand All @@ -1514,6 +1541,10 @@ function get_bulk_mantle(gv)
ccall((:get_bulk_mantle, libMAGEMin), global_variable, (global_variable,), gv)
end

function get_bulk_metapelite_ext(gv)
ccall((:get_bulk_metapelite_ext, libMAGEMin), global_variable, (global_variable,), gv)
end

mutable struct stx11_datasets
ds_version::Cint
n_ox::Cint
Expand Down Expand Up @@ -1654,6 +1685,10 @@ function TC_SS_init_um_ext(SS_init, gv)
ccall((:TC_SS_init_um_ext, libMAGEMin), Cvoid, (Ptr{SS_init_type}, global_variable), SS_init, gv)
end

function TC_SS_init_mp_ext(SS_init, gv)
ccall((:TC_SS_init_mp_ext, libMAGEMin), Cvoid, (Ptr{SS_init_type}, global_variable), SS_init, gv)
end

function TC_SS_init_mtl(SS_init, gv)
ccall((:TC_SS_init_mtl, libMAGEMin), Cvoid, (Ptr{SS_init_type}, global_variable), SS_init, gv)
end
Expand Down Expand Up @@ -1690,6 +1725,10 @@ function G_SS_mtl_EM_function(gv, SS_ref_db, EM_dataset, z_b, name)
ccall((:G_SS_mtl_EM_function, libMAGEMin), SS_ref, (global_variable, SS_ref, Cint, bulk_info, Ptr{Cchar}), gv, SS_ref_db, EM_dataset, z_b, name)
end

function G_SS_mpe_EM_function(gv, SS_ref_db, EM_dataset, z_b, name)
ccall((:G_SS_mpe_EM_function, libMAGEMin), SS_ref, (global_variable, SS_ref, Cint, bulk_info, Ptr{Cchar}), gv, SS_ref_db, EM_dataset, z_b, name)
end

function TC_mb_objective_init_function(SS_objective, gv)
ccall((:TC_mb_objective_init_function, libMAGEMin), Cvoid, (Ptr{obj_type}, global_variable), SS_objective, gv)
end
Expand Down Expand Up @@ -1718,6 +1757,10 @@ function TC_mtl_objective_init_function(SS_objective, gv)
ccall((:TC_mtl_objective_init_function, libMAGEMin), Cvoid, (Ptr{obj_type}, global_variable), SS_objective, gv)
end

function TC_mpe_objective_init_function(SS_objective, gv)
ccall((:TC_mpe_objective_init_function, libMAGEMin), Cvoid, (Ptr{obj_type}, global_variable), SS_objective, gv)
end

function TC_SS_objective_init_function(SS_objective, gv)
ccall((:TC_SS_objective_init_function, libMAGEMin), Cvoid, (Ptr{obj_type}, global_variable), SS_objective, gv)
end
Expand Down Expand Up @@ -2097,6 +2140,98 @@ function obj_mtl_hpx(n, x, grad, SS_ref_db)
ccall((:obj_mtl_hpx, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_liq(n, x, grad, SS_ref_db)
ccall((:obj_mpe_liq, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_fsp(n, x, grad, SS_ref_db)
ccall((:obj_mpe_fsp, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_bi(n, x, grad, SS_ref_db)
ccall((:obj_mpe_bi, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_g(n, x, grad, SS_ref_db)
ccall((:obj_mpe_g, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_ep(n, x, grad, SS_ref_db)
ccall((:obj_mpe_ep, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_ma(n, x, grad, SS_ref_db)
ccall((:obj_mpe_ma, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_mu(n, x, grad, SS_ref_db)
ccall((:obj_mpe_mu, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_opx(n, x, grad, SS_ref_db)
ccall((:obj_mpe_opx, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_sa(n, x, grad, SS_ref_db)
ccall((:obj_mpe_sa, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_cd(n, x, grad, SS_ref_db)
ccall((:obj_mpe_cd, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_st(n, x, grad, SS_ref_db)
ccall((:obj_mpe_st, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_chl(n, x, grad, SS_ref_db)
ccall((:obj_mpe_chl, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_ctd(n, x, grad, SS_ref_db)
ccall((:obj_mpe_ctd, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_sp(n, x, grad, SS_ref_db)
ccall((:obj_mpe_sp, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_ilm(n, x, grad, SS_ref_db)
ccall((:obj_mpe_ilm, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_ilmm(n, x, grad, SS_ref_db)
ccall((:obj_mpe_ilmm, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_mt(n, x, grad, SS_ref_db)
ccall((:obj_mpe_mt, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_fl(n, x, grad, SS_ref_db)
ccall((:obj_mpe_fl, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_occm(n, x, grad, SS_ref_db)
ccall((:obj_mpe_occm, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_dio(n, x, grad, SS_ref_db)
ccall((:obj_mpe_dio, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_aug(n, x, grad, SS_ref_db)
ccall((:obj_mpe_aug, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_hb(n, x, grad, SS_ref_db)
ccall((:obj_mpe_hb, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_mpe_po(n, x, grad, SS_ref_db)
ccall((:obj_mpe_po, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end

function obj_aq17(n, x, grad, SS_ref_db)
ccall((:obj_aq17, libMAGEMin), Cdouble, (Cuint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), n, x, grad, SS_ref_db)
end
Expand Down Expand Up @@ -2133,6 +2268,10 @@ function TC_mtl_PC_init(PC_read, gv)
ccall((:TC_mtl_PC_init, libMAGEMin), Cvoid, (Ptr{PC_type}, global_variable), PC_read, gv)
end

function TC_mpe_PC_init(PC_read, gv)
ccall((:TC_mpe_PC_init, libMAGEMin), Cvoid, (Ptr{PC_type}, global_variable), PC_read, gv)
end

# typedef SS_ref ( * NLopt_type ) ( global_variable gv , SS_ref SS_ref_db )
const NLopt_type = Ptr{Cvoid}

Expand Down Expand Up @@ -2168,6 +2307,10 @@ function TC_NLopt_opt_init(NLopt_opt, gv)
ccall((:TC_NLopt_opt_init, libMAGEMin), Cvoid, (Ptr{NLopt_type}, global_variable), NLopt_opt, gv)
end

function TC_mpe_NLopt_opt_init(NLopt_opt, gv)
ccall((:TC_mpe_NLopt_opt_init, libMAGEMin), Cvoid, (Ptr{NLopt_type}, global_variable), NLopt_opt, gv)
end

function NLopt_opt_ig_spn_function(gv, SS_ref_db)
ccall((:NLopt_opt_ig_spn_function, libMAGEMin), SS_ref, (global_variable, SS_ref), gv, SS_ref_db)
end
Expand Down Expand Up @@ -2204,6 +2347,10 @@ function SS_mtl_pc_init_function(SS_pc_xeos, iss, name)
ccall((:SS_mtl_pc_init_function, libMAGEMin), Cvoid, (Ptr{PC_ref}, Cint, Ptr{Cchar}), SS_pc_xeos, iss, name)
end

function SS_mpe_pc_init_function(SS_pc_xeos, iss, name)
ccall((:SS_mpe_pc_init_function, libMAGEMin), Cvoid, (Ptr{PC_ref}, Cint, Ptr{Cchar}), SS_pc_xeos, iss, name)
end

function SB_SS_init(SS_init, gv)
ccall((:SB_SS_init, libMAGEMin), Cvoid, (Ptr{SS_init_type}, global_variable), SS_init, gv)
end
Expand Down
Loading

0 comments on commit dac9941

Please sign in to comment.