Skip to content

Commit

Permalink
MAGEMin v1.5.7
Browse files Browse the repository at this point in the history
- Added 1atom basis to output structure
- Added buffer and buffer_n to output structure
- Re-added consideration of pure-end member to the minimization, improves performance and accuracy
  • Loading branch information
NicolasRiel authored Nov 7, 2024
2 parents 21c7b72 + fb2c312 commit 8a31103
Show file tree
Hide file tree
Showing 37 changed files with 1,892 additions and 207 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ SOURCES=src/MAGEMin.c \
src/SB_database/SB_init_database.c \
src/SB_database/SB_endmembers.c \
src/SB_database/SB_gem_function.c \
src/SB_database/sb_gss_init_function.c \
src/toolkit.c \
src/io_function.c \
src/gem_function.c \
src/TC_database/tc_gss_init_function.c \
src/TC_database/tc_gss_function.c \
src/SB_database/sb_gss_init_function.c \
src/SB_database/sb_gss_function.c \
src/TC_database/NLopt_opt_function.c \
src/TC_database/objective_functions.c \
src/TC_database/SS_xeos_PC_mp.c \
Expand Down
2 changes: 1 addition & 1 deletion 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 = ["Boris Kaus <[email protected]> & Nicolas Riel <[email protected]>"]
version = "1.5.6"
version = "1.5.7"

[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Expand Down
2 changes: 1 addition & 1 deletion doc_raw/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

|
**MAGEMin v1.5.6**
**MAGEMin v1.5.7**
==================

MAGEMin (Mineral Assemblage Gibbs Energy Minimization) is a parallel C library callable from any petrological/geodynamic tool. For a given set of pressure, temperature and bulk-rock composition MAGEMin uses a combination of linear programming, extended Partitioning Gibbs free Energy and gradient-based local minimization to compute the most stable mineral assemblage
Expand Down
6 changes: 3 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MAGEMin v1.5.6 &mdash; MAGEMin 2022 documentation</title>
<title>MAGEMin v1.5.7 &mdash; MAGEMin 2022 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
Expand Down Expand Up @@ -247,7 +247,7 @@
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="#" class="icon icon-home"></a> &raquo;</li>
<li><strong>MAGEMin v1.5.6</strong></li>
<li><strong>MAGEMin v1.5.7</strong></li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/index.rst.txt" rel="nofollow"> View page source</a>
</li>
Expand All @@ -263,7 +263,7 @@
<div class="line"><br /></div>
</div>
<section id="magemin-v1-5-0">
<h1><strong>MAGEMin v1.5.6</strong><a class="headerlink" href="#magemin-v1-5-0" title="Permalink to this headline"></a></h1>
<h1><strong>MAGEMin v1.5.7</strong><a class="headerlink" href="#magemin-v1-5-0" title="Permalink to this headline"></a></h1>
<p>MAGEMin (Mineral Assemblage Gibbs Energy Minimization) is a parallel C library callable from any petrological/geodynamic tool. For a given set of pressure, temperature and bulk-rock composition MAGEMin uses a combination of linear programming, extended Partitioning Gibbs free Energy and gradient-based local minimization to compute the most stable mineral assemblage</p>
<p>A full description of the minimization approach used in MAGEMin is given in:</p>
<p>Riel, N., Kaus, B. J. P., Green, E. C. R., &amp; Berlie, N. (2022). MAGEMin, an efficient Gibbs energy minimizer: Application to igneous systems. Geochemistry, Geophysics, Geosystems, 23, e2022GC010427. <a class="reference external" href="https://doi.org/10.1029/2022GC010427">https://doi.org/10.1029/2022GC010427</a></p>
Expand Down
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/stp.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="External libraries" href="stp/Linux.html" />
<link rel="prev" title="MAGEMin v1.5.6" href="index.html" />
<link rel="prev" title="MAGEMin v1.5.7" href="index.html" />
</head>

<body class="wy-body-for-nav">
Expand Down Expand Up @@ -292,7 +292,7 @@ <h1>Optional (developers)<a class="headerlink" href="#optional-developers" title
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="index.html" class="btn btn-neutral float-left" title="MAGEMin v1.5.6" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="index.html" class="btn btn-neutral float-left" title="MAGEMin v1.5.7" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="stp/Linux.html" class="btn btn-neutral float-right" title="External libraries" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>

Expand Down
38 changes: 30 additions & 8 deletions gen/magemin_library.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ function rho_wat_calc(wat, Pbar, TK, opt)
end

mutable struct EM_db_sb_
Name::NTuple{20, Cchar}
FullName::NTuple{50, Cchar}
Equation::NTuple{50, Cchar}
Name::NTuple{50, Cchar}
FullName::NTuple{80, Cchar}
Equation::NTuple{90, Cchar}
Comp::NTuple{6, Cdouble}
input_1::NTuple{10, Cdouble}
input_2::NTuple{3, Cdouble}
Expand All @@ -146,6 +146,10 @@ function Access_SB_EM_DB(id, EM_dataset)
ccall((:Access_SB_EM_DB, libMAGEMin), EM_db_sb, (Cint, Cint), id, EM_dataset)
end

function SB_G_EM_function(EM_database, len_ox, id, bulk_rock, apo, P, T, name, state)
ccall((:SB_G_EM_function, libMAGEMin), PP_ref, (Cint, Cint, Ptr{Cint}, Ptr{Cdouble}, Ptr{Cdouble}, Cdouble, Cdouble, Ptr{Cchar}, Ptr{Cchar}), EM_database, len_ox, id, bulk_rock, apo, P, T, name, state)
end

# typedef double ( * nlopt_func ) ( unsigned n , const double * x , double * gradient , /* NULL if not needed */ void * func_data )
const nlopt_func = Ptr{Cvoid}

Expand Down Expand Up @@ -1114,6 +1118,7 @@ const stb_PP_phase = stb_PP_phases
struct stb_systems
MAGEMin_ver::Ptr{Cchar}
dataset::Ptr{Cchar}
database::Ptr{Cchar}
bulk_res_norm::Cdouble
n_iterations::Cint
status::Cint
Expand All @@ -1125,6 +1130,8 @@ struct stb_systems
X::Cdouble
bulk::Ptr{Cdouble}
bulk_wt::Ptr{Cdouble}
buffer::Ptr{Cchar}
buffer_n::Cdouble
gamma::Ptr{Cdouble}
G::Cdouble
M_sys::Cdouble
Expand Down Expand Up @@ -1175,6 +1182,7 @@ struct stb_systems
ph::Ptr{Ptr{Cchar}}
ph_frac::Ptr{Cdouble}
ph_frac_wt::Ptr{Cdouble}
ph_frac_1at::Ptr{Cdouble}
ph_frac_vol::Ptr{Cdouble}
ph_type::Ptr{Cint}
ph_id::Ptr{Cint}
Expand Down Expand Up @@ -1506,7 +1514,7 @@ mutable struct stx11_datasets
n_pp::Cint
n_ss::Cint
ox::NTuple{6, NTuple{20, Cchar}}
PP::NTuple{10, NTuple{20, Cchar}}
PP::NTuple{9, NTuple{20, Cchar}}
SS::NTuple{14, NTuple{20, Cchar}}
verifyPC::NTuple{14, Cint}
n_SS_PC::NTuple{14, Cint}
Expand Down Expand Up @@ -2196,6 +2204,14 @@ 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 SB_SS_init(SS_init, gv)
ccall((:SB_SS_init, libMAGEMin), Cvoid, (Ptr{SS_init_type}, global_variable), SS_init, gv)
end

function G_SS_sb11_EM_function(gv, SS_ref_db, EM_dataset, z_b, name)
ccall((:G_SS_sb11_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 PGE(z_b, gv, PC_read, SS_objective, NLopt_opt, splx_data, PP_ref_db, SS_ref_db, cp)
ccall((:PGE, libMAGEMin), global_variable, (bulk_info, global_variable, Ptr{PC_type}, Ptr{obj_type}, Ptr{NLopt_type}, Ptr{simplex_data}, Ptr{PP_ref}, Ptr{SS_ref}, Ptr{csd_phase_set}), z_b, gv, PC_read, SS_objective, NLopt_opt, splx_data, PP_ref_db, SS_ref_db, cp)
end
Expand Down Expand Up @@ -2287,22 +2303,20 @@ function read_in_data(gv, input_data, n_points)
ccall((:read_in_data, libMAGEMin), Cvoid, (global_variable, Ptr{io_data}, Cint), gv, input_data, n_points)
end

mutable struct ketopt_t
struct ketopt_t
ind::Cint
opt::Cint
arg::Ptr{Cchar}
longidx::Cint
i::Cint
pos::Cint
n_args::Cint
ketopt_t() = new()
end

mutable struct ko_longopt_t
struct ko_longopt_t
name::Ptr{Cchar}
has_arg::Cint
val::Cint
ko_longopt_t() = new()
end

function ketopt_permute(argv, j, n)
Expand Down Expand Up @@ -2351,6 +2365,10 @@ function init_em_db(EM_database, z_b, gv, PP_ref_db)
ccall((:init_em_db, libMAGEMin), global_variable, (Cint, bulk_info, global_variable, Ptr{PP_ref}), EM_database, z_b, gv, PP_ref_db)
end

function init_em_db_sb(EM_database, z_b, gv, PP_ref_db)
ccall((:init_em_db_sb, libMAGEMin), global_variable, (Cint, bulk_info, global_variable, Ptr{PP_ref}), EM_database, z_b, gv, PP_ref_db)
end

function update_dG(splx_data)
ccall((:update_dG, libMAGEMin), Cvoid, (Ptr{simplex_data},), splx_data)
end
Expand Down Expand Up @@ -2451,6 +2469,10 @@ function convert_system_comp(gv, sys_in, z_b)
ccall((:convert_system_comp, libMAGEMin), Cvoid, (global_variable, Ptr{Cchar}, bulk_info), gv, sys_in, z_b)
end

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

function get_act_sf_id(result, A, n)
ccall((:get_act_sf_id, libMAGEMin), Cvoid, (Ptr{Cint}, Ptr{Cdouble}, Cint), result, A, n)
end
Expand Down
Loading

0 comments on commit 8a31103

Please sign in to comment.