Skip to content

Commit

Permalink
MAGEMin v1.5.8
Browse files Browse the repository at this point in the history
- Corrected segfault problem affecting MAGEMin_C (julia wrapper)
  • Loading branch information
NicolasRiel authored Nov 8, 2024
2 parents a4e7de0 + dcf32d2 commit 6c625b4
Show file tree
Hide file tree
Showing 15 changed files with 96 additions and 33 deletions.
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.7"
version = "1.5.8"

[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.7**
**MAGEMin v1.5.8**
==================

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.7 &mdash; MAGEMin 2022 documentation</title>
<title>MAGEMin v1.5.8 &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.7</strong></li>
<li><strong>MAGEMin v1.5.8</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.7</strong><a class="headerlink" href="#magemin-v1-5-0" title="Permalink to this headline"></a></h1>
<h1><strong>MAGEMin v1.5.8</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.7" href="index.html" />
<link rel="prev" title="MAGEMin v1.5.8" 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.7" 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.8" 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
4 changes: 4 additions & 0 deletions gen/magemin_library.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2457,6 +2457,10 @@ function init_ss_db(EM_database, z_b, gv, SS_ref_db)
ccall((:init_ss_db, libMAGEMin), global_variable, (Cint, bulk_info, global_variable, Ptr{SS_ref}), EM_database, z_b, gv, SS_ref_db)
end

function init_ss_db_sb(EM_database, z_b, gv, SS_ref_db)
ccall((:init_ss_db_sb, libMAGEMin), global_variable, (Cint, bulk_info, global_variable, Ptr{SS_ref}), EM_database, z_b, gv, SS_ref_db)
end

function print_help(gv)
ccall((:print_help, libMAGEMin), Cvoid, (global_variable,), gv)
end
Expand Down
1 change: 1 addition & 0 deletions ref_database/SB_ref_database/functions_ss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function get_sb_gss_init_function(sb_ver,ss)
sb_gss_init_function *= "SS_ref G_SS_$(sb_ver)_$(ss[i].abbrev)_init_function(SS_ref SS_ref_db, global_variable gv){\n\n"
sb_gss_init_function *= " SS_ref_db.is_liq = 0;\n"
sb_gss_init_function *= " SS_ref_db.symmetry = $sym;\n"
sb_gss_init_function *= " SS_ref_db.n_xeos = $(length(em));\n"
sb_gss_init_function *= " SS_ref_db.n_em = $(length(em));\n"
sb_gss_init_function *= " SS_ref_db.n_sf = $(length(mul));\n"
sb_gss_init_function *= " SS_ref_db.n_w = $(length(W));\n"
Expand Down
18 changes: 13 additions & 5 deletions src/MAGEMin.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,19 +330,27 @@ int runMAGEMin( int argc,
z_b, /** bulk rock informations */
gv, /** global variables (e.g. Gamma) */
PP_ref_db );

/* Calculate solution phase data at given P-T conditions (G0 based on G0 of endmembers) */
gv = init_ss_db( EM_database,
z_b,
gv,
SS_ref_db );
}
else if ( strcmp(gv.research_group, "sb") == 0 ){
gv = init_em_db_sb( EM_database,
z_b, /** bulk rock informations */
gv, /** global variables (e.g. Gamma) */
PP_ref_db );

/* Calculate solution phase data at given P-T conditions (G0 based on G0 of endmembers) */
gv = init_ss_db_sb( EM_database,
z_b,
gv,
SS_ref_db );
}

/* Calculate solution phase data at given P-T conditions (G0 based on G0 of endmembers) */
gv = init_ss_db( EM_database,
z_b,
gv,
SS_ref_db );


return gv;
}
Expand Down
19 changes: 7 additions & 12 deletions src/SB_database/SB_gem_function.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ PP_ref SB_G_EM_function( int EM_dataset,
int *id,
double *bulk_rock,
double *apo,
double P,
double Pkbar,
double T,
char *name,
char *state
){

/* Get thermodynamic data */
EM_db_sb EM_return;
int i, p_id = find_EM_id(name);
Expand All @@ -76,11 +77,10 @@ PP_ref SB_G_EM_function( int EM_dataset,
}

double kbar2bar = 1e3;
double RTlnf = 0.0;
double T0 = 298.15;
double P0 = 0.001;
double R = 8.31446261815324;

double P = Pkbar * kbar2bar;
/* declare the variables */
double nr9, nr9T0, c1, c2, c3, aii, aiikk2, aii2;
double r23, r59, t1, t2, nr9t, tht, thT0;
Expand All @@ -105,7 +105,7 @@ PP_ref SB_G_EM_function( int EM_dataset,

nr9 = -9.0 * n * R;
nr9T0 = nr9 * T0;
c1 = -9.0 * V0 * K0;
c1 = -9.0 * (-V0) * K0;
c2 = Kp / 2.0 - 2.0;
c3 = 3.0 * c1 * c2;
aii = 6.0 * gamma0;
Expand All @@ -118,6 +118,7 @@ PP_ref SB_G_EM_function( int EM_dataset,
t1 = z00 / T;
t2 = T / T0;
nr9t = nr9 * T;

tht = t1;
thT0 = tht * t2;

Expand All @@ -136,7 +137,7 @@ PP_ref SB_G_EM_function( int EM_dataset,
else{
V = V0;
}

ibad = 4;
bad = 1;

Expand All @@ -149,32 +150,27 @@ PP_ref SB_G_EM_function( int EM_dataset,
f = 0.5 * V23 - 0.5;
df = -V23 / V / 3.0;
d2f = r59 * V23 / pow(V,2.0);

dfc = (c3 * f + c1) * f * df;
d2fc = (2.0 * c3 * f + c1) * pow(df,2.0) + (c3 * f + c1) * f * d2f;

z = 1.0 + (aii + aiikk2 * f) * f;

if (z < 0.0 || V / V0 > 100.0 || V / V0 < 1e-2){
printf(" ERROR z or V/V0\n");
}

root = sqrt(z);

tht = t1 * root;
thT0 = tht * T / T0;

a2f = aii2 + aiikk2 * f;
da = a2f / root;
dtht = t1 * da * df;
d2tht = t1 * ((aiikk2 / root - pow(a2f,2.0) / pow(z,1.5)) * pow(df,2.0) + da * d2f);

dthT0 = dtht * t2;
d2thT0 = d2tht * T;
d2thT0 = d2tht * t2;

fpoly = 3.0 * plg(tht) / pow(tht,3.0);
fpoly0 = 3.0 * plg(thT0) / pow(thT0,3.0);

etht = exp(-tht);

if (1.0 - etht < 0.0){
Expand All @@ -185,7 +181,6 @@ PP_ref SB_G_EM_function( int EM_dataset,

dfth = (letht - fpoly) * nr9t * dtht / tht;
d2fth = ((4.0 * pow(dtht,2.0) / tht - d2tht) * (fpoly - letht) + pow(dtht,2.0) * etht / (1.0 - etht)) * nr9t / tht;

ethT0 = exp(-thT0);

if (1.0 - ethT0 < 0.0){
Expand Down
2 changes: 1 addition & 1 deletion src/SB_database/sb_gss_function.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ SS_ref G_SS_sb11_cf_function(SS_ref SS_ref_db, char* research_group, int EM_data
return SS_ref_db;
}

SS_ref G_SS_sb11_EM_function( global_variable gv,
SS_ref G_SS_sb11_EM_function( global_variable gv,
SS_ref SS_ref_db,
int EM_dataset,
bulk_info z_b,
Expand Down
15 changes: 14 additions & 1 deletion src/SB_database/sb_gss_init_function.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
#include "../MAGEMin.h"
#include "../all_solution_phases.h"
#include "sb_gss_init_function.h"

/**
allocate memory for sb11_plg
*/
SS_ref G_SS_sb11_plg_init_function(SS_ref SS_ref_db, global_variable gv){

SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 1;
SS_ref_db.n_xeos = 2;
SS_ref_db.n_em = 2;
SS_ref_db.n_sf = 1;
SS_ref_db.n_w = 1;
Expand All @@ -44,6 +44,7 @@ SS_ref G_SS_sb11_sp_init_function(SS_ref SS_ref_db, global_variable gv){

SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 1;
SS_ref_db.n_xeos = 2;
SS_ref_db.n_em = 2;
SS_ref_db.n_sf = 2;
SS_ref_db.n_w = 1;
Expand All @@ -58,6 +59,7 @@ SS_ref G_SS_sb11_ol_init_function(SS_ref SS_ref_db, global_variable gv){

SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 1;
SS_ref_db.n_xeos = 2;
SS_ref_db.n_em = 2;
SS_ref_db.n_sf = 1;
SS_ref_db.n_w = 1;
Expand All @@ -72,6 +74,7 @@ SS_ref G_SS_sb11_wa_init_function(SS_ref SS_ref_db, global_variable gv){

SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 1;
SS_ref_db.n_xeos = 2;
SS_ref_db.n_em = 2;
SS_ref_db.n_sf = 1;
SS_ref_db.n_w = 1;
Expand All @@ -86,6 +89,7 @@ SS_ref G_SS_sb11_ri_init_function(SS_ref SS_ref_db, global_variable gv){

SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 1;
SS_ref_db.n_xeos = 2;
SS_ref_db.n_em = 2;
SS_ref_db.n_sf = 1;
SS_ref_db.n_w = 1;
Expand All @@ -100,6 +104,7 @@ SS_ref G_SS_sb11_opx_init_function(SS_ref SS_ref_db, global_variable gv){

SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 1;
SS_ref_db.n_xeos = 4;
SS_ref_db.n_em = 4;
SS_ref_db.n_sf = 2;
SS_ref_db.n_w = 6;
Expand All @@ -114,6 +119,7 @@ SS_ref G_SS_sb11_cpx_init_function(SS_ref SS_ref_db, global_variable gv){

SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 0;
SS_ref_db.n_xeos = 5;
SS_ref_db.n_em = 5;
SS_ref_db.n_sf = 3;
SS_ref_db.n_w = 10;
Expand All @@ -129,6 +135,7 @@ SS_ref G_SS_sb11_hpcpx_init_function(SS_ref SS_ref_db, global_variable gv){

SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 1;
SS_ref_db.n_xeos = 2;
SS_ref_db.n_em = 2;
SS_ref_db.n_sf = 1;
SS_ref_db.n_w = 1;
Expand All @@ -143,6 +150,7 @@ SS_ref G_SS_sb11_ak_init_function(SS_ref SS_ref_db, global_variable gv){

SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 1;
SS_ref_db.n_xeos = 3;
SS_ref_db.n_em = 3;
SS_ref_db.n_sf = 2;
SS_ref_db.n_w = 3;
Expand All @@ -157,6 +165,7 @@ SS_ref G_SS_sb11_gtmj_init_function(SS_ref SS_ref_db, global_variable gv){

SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 1;
SS_ref_db.n_xeos = 5;
SS_ref_db.n_em = 5;
SS_ref_db.n_sf = 3;
SS_ref_db.n_w = 10;
Expand All @@ -171,6 +180,7 @@ SS_ref G_SS_sb11_pv_init_function(SS_ref SS_ref_db, global_variable gv){

SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 0;
SS_ref_db.n_xeos = 3;
SS_ref_db.n_em = 3;
SS_ref_db.n_sf = 2;
SS_ref_db.n_w = 3;
Expand All @@ -186,6 +196,7 @@ SS_ref G_SS_sb11_ppv_init_function(SS_ref SS_ref_db, global_variable gv){

SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 1;
SS_ref_db.n_xeos = 3;
SS_ref_db.n_em = 3;
SS_ref_db.n_sf = 2;
SS_ref_db.n_w = 3;
Expand All @@ -200,6 +211,7 @@ SS_ref G_SS_sb11_mw_init_function(SS_ref SS_ref_db, global_variable gv){

SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 1;
SS_ref_db.n_xeos = 2;
SS_ref_db.n_em = 2;
SS_ref_db.n_sf = 1;
SS_ref_db.n_w = 1;
Expand All @@ -214,6 +226,7 @@ SS_ref G_SS_sb11_cf_init_function(SS_ref SS_ref_db, global_variable gv){

SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 1;
SS_ref_db.n_xeos = 3;
SS_ref_db.n_em = 3;
SS_ref_db.n_sf = 2;
SS_ref_db.n_w = 3;
Expand Down
2 changes: 1 addition & 1 deletion src/initialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ global_variable global_variable_alloc( bulk_info *z_b ){
}

strcpy(gv.outpath,"./output/"); /** define the outpath to save logs and final results file */
strcpy(gv.version,"1.5.7 [17/10/2024]"); /** MAGEMin version */
strcpy(gv.version,"1.5.8 [7/11/2024]"); /** MAGEMin version */

/* generate parameters */
strcpy(gv.buffer,"none");
Expand Down
10 changes: 5 additions & 5 deletions src/simplex_levelling.c
Original file line number Diff line number Diff line change
Expand Up @@ -1064,11 +1064,11 @@ void run_simplex_pseudocompounds( bulk_info z_b,
k += 1;
d->swp = 0;
t = clock();
swap_pure_endmembers( z_b,
splx_data,
gv,
PP_ref_db,
SS_ref_db );
// swap_pure_endmembers( z_b,
// splx_data,
// gv,
// PP_ref_db,
// SS_ref_db );

swap_pure_phases( z_b,
splx_data,
Expand Down
Loading

0 comments on commit 6c625b4

Please sign in to comment.