Skip to content

Commit

Permalink
MAGEMin_C v1.6.0 (#58)
Browse files Browse the repository at this point in the history
- corrected mass conservation issue when buffer is active
- corrected outputing of bulk_wt that was introduced in version 1.5.5
  • Loading branch information
NicolasRiel authored Oct 22, 2024
1 parent 7ec90fb commit 4390cbf
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 4 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 = ["Boris Kaus <[email protected]> & Nicolas Riel <[email protected]>"]
version = "1.5.9"
version = "1.6.0"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Expand All @@ -17,6 +17,6 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
CEnum = "0.4"
DataFrames = "1.6.1"
CSV = "0.10.14"
MAGEMin_jll = "1.5.5 - 1.5.5"
MAGEMin_jll = "1.5.6 - 1.5.6"
ProgressMeter = "1"
julia = "1.6"
1 change: 1 addition & 0 deletions src/dump_function.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ void fill_output_struct( global_variable gv,
double mass_bulk = 0.0;
for (i = 0; i < nox; i++){
mass_bulk += z_b.bulk_rock[i] * z_b.masspo[i];
sp[0].bulk_wt[i] = z_b.bulk_rock[i] * z_b.masspo[i];
}
for (i = 0; i < nox; i++){
sp[0].bulk_wt[i] /= mass_bulk;
Expand Down
2 changes: 1 addition & 1 deletion src/initialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,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.5 [17/10/2024]"); /** MAGEMin version */
strcpy(gv.version,"1.5.6 [17/10/2024]"); /** MAGEMin version */

/* generate parameters */
strcpy(gv.buffer,"none");
Expand Down
2 changes: 1 addition & 1 deletion src/toolkit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ global_variable compute_phase_mol_fraction( global_variable gv,

/* pure phases */
for (int i = 0; i < gv.len_pp; i++){
if (gv.pp_flags[i][1] == 1){
if (gv.pp_flags[i][1] == 1 && gv.pp_flags[i][4] == 0){

sum = 0.0;
for (int j = 0; j < gv.len_ox; j++){
Expand Down
48 changes: 48 additions & 0 deletions test/tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,54 @@ out = point_wise_minimization(P,T, data);
@test sort(out.ph) == sort(["g", "ring", "wad"])
Finalize_MAGEMin(data)

# Tests from L. Candioti - ETH - Oct 2024
@testset "test mass conservation" begin

# Without a buffer at 1100.0 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_hT = single_point_minimization(P, T, data, X=X, Xoxides=Xoxides, sys_in=sys_in)
Δρ_hT = abs( out_hT.rho - ((out_hT.frac_M_wt * out_hT.rho_M + out_hT.frac_S_wt * out_hT.rho_S )) )
@test Δρ_hT < 1e-10
Finalize_MAGEMin(data)


# Without a buffer at 800.0 C
data = Initialize_MAGEMin("ig", verbose=false);
P,T = 10.0, 800.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_lT = single_point_minimization(P, T, data, X=X, Xoxides=Xoxides, sys_in=sys_in)
Δρ_lT = abs( out_lT.rho - ((out_lT.frac_M_wt * out_lT.rho_M + out_lT.frac_S_wt * out_lT.rho_S )) )
@test Δρ_lT < 1e-10
Finalize_MAGEMin(data)

# With a buffer at 1100.0 C
data = Initialize_MAGEMin("ig", buffer = "nno", 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_BhT = single_point_minimization(P, T, data, X=X, B=0.0, Xoxides=Xoxides, sys_in=sys_in)
Δρ_BhT = abs( out_BhT.rho - ((out_BhT.frac_M_wt * out_BhT.rho_M + out_BhT.frac_S_wt * out_BhT.rho_S )) )
@test Δρ_BhT < 1e-10
Finalize_MAGEMin(data)

# With a buffer at 800.0 C
data = Initialize_MAGEMin("ig", verbose=false);
P,T = 10.0, 800.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_BlT = single_point_minimization(P, T, data, X=X, B=0.0, Xoxides=Xoxides, sys_in=sys_in)
Δρ_BlT = abs( out_BlT.rho - ((out_BlT.frac_M_wt * out_BlT.rho_M + out_BlT.frac_S_wt * out_BlT.rho_S )) )
@test Δρ_BlT < 1e-10
Finalize_MAGEMin(data)
end

@testset "test activity buffers" begin
# Initialize database - new way
Expand Down

0 comments on commit 4390cbf

Please sign in to comment.