Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct breaking changes from new version #22

Merged
merged 12 commits into from
Jan 29, 2024
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- '1.7'
- '1.9'
- 'nightly'
- '1.10'
Expand Down
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ julia> out = point_wise_minimization(P,T, data);
Mode : 0.24229 0.58808 0.14165 0.02798
```


### Example 2 - custom composition
And here a case in which you specify your own bulk rock composition.
```julia
Expand All @@ -59,14 +60,14 @@ julia> sys_in = "wt"
julia> out = single_point_minimization(P, T, data, X=X, Xoxides=Xoxides, sys_in=sys_in)
Pressure : 10.0 [kbar]
Temperature : 1100.0 [Celsius]
Stable phase | Fraction (mol 1 atom basis)
liq 0.73698
cpx 0.17241
pl4T 0.04846
Stable phase | Fraction (wt fraction)
liq 0.70765
cpx 0.18894
pl4T 0.05083
Stable phase | Fraction (mol fraction)
liq 0.73698
cpx 0.17241
pl4T 0.04846
Stable phase | Fraction (wt fraction)
liq 0.70765
cpx 0.18894
pl4T 0.05083
Gibbs free energy : -907.392253 (22 iterations; 62.25 ms)
Oxygen fugacity : 3.400537515666476e-9
```
Expand Down Expand Up @@ -104,8 +105,6 @@ By default, this will show a progressbar (which you can deactivate with the `pro

You can also specify a custom bulk rock for all points (see above), or a custom bulk rock for every point.



### Running it in parallel
Julia can be run in parallel using multi-threading. To take advantage of this, you need to start julia from the terminal with:
```bash
Expand Down
237 changes: 121 additions & 116 deletions julia/MAGEMin_wrappers.jl

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion julia/install_MAGEMin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ end

write_environmental_variables_file()

println("Succesfully downloaded the MAGEMin_jll package")
println("Successfully downloaded the MAGEMin_jll package")
println("And installed the environmental_variables.m file in: $(pwd())")

# Show the version number
Expand Down
2 changes: 1 addition & 1 deletion test/gen_tests_ig.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This script helps to generate a lsit of points for testing MAGEMin using reference built-in bulk-rock compositions
# This script helps to generate a list of points for testing MAGEMin using reference built-in bulk-rock compositions

cur_dir = pwd();
if cur_dir[end-3:end]=="test"
Expand Down
2 changes: 1 addition & 1 deletion test/gen_tests_mb.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This script helps to generate a lsit of points for testing MAGEMin using reference built-in bulk-rock compositions
# This script helps to generate a list of points for testing MAGEMin using reference built-in bulk-rock compositions

cur_dir = pwd();
if cur_dir[end-3:end]=="test"
Expand Down
2 changes: 1 addition & 1 deletion test/gen_tests_mp.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This script helps to generate a lsit of points for testing MAGEMin using reference built-in bulk-rock compositions
# This script helps to generate a list of points for testing MAGEMin using reference built-in bulk-rock compositions

cur_dir = pwd();
if cur_dir[end-3:end]=="test"
Expand Down
59 changes: 38 additions & 21 deletions test/tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ finalize_MAGEMin(gv,DB,z_b)
n = 100;
P = fill(8.0,n)
T = fill(800.0,n)
db = "ig"
db = "ig"
data = Initialize_MAGEMin(db, verbose=false);
out = multi_point_minimization(P, T, data, test=0);
@test out[end].G_system ≈ -797.7491828675325
Expand All @@ -57,16 +57,16 @@ finalize_MAGEMin(gv,DB,z_b)
end

@testset "specify bulk rock" begin


data = Initialize_MAGEMin("ig", verbose=false);

# One bulk rock for all points
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, Xoxides=Xoxides, sys_in=sys_in)
sys_in = "wt"
out = single_point_minimization(P, T, data, X=X, Xoxides=Xoxides, sys_in=sys_in)

@test abs(out.G_system + 916.8283889543869)/abs(916.8283889543869) < 2e-4

Expand All @@ -78,9 +78,9 @@ end
X1 = [48.43; 15.19; 11.57; 10.13; 6.65; 1.64; 0.59; 1.87; 0.68; 0.0; 3.0];
X2 = [49.43; 14.19; 11.57; 10.13; 6.65; 1.64; 0.59; 1.87; 0.68; 0.0; 3.0];
X = [X1,X2]
sys_in = "wt"
out = multi_point_minimization(P, T, data, X, Xoxides=Xoxides, sys_in=sys_in)
sys_in = "wt"
out = multi_point_minimization(P, T, data, X=X, Xoxides=Xoxides, sys_in=sys_in)

@test out[1].G_system ≈ -916.8283889543869 rtol=2e-4
@test out[2].G_system ≈ -912.5920719174167 rtol=2e-4

Expand All @@ -100,13 +100,32 @@ end
X = [[1.0], X]
X_view = @view X[2,:]

out = single_point_minimization(P, T, data, X_view, Xoxides=Xoxides, sys_in=sys_in)
out = single_point_minimization(P, T, data, X=X_view, Xoxides=Xoxides, sys_in=sys_in)

@test abs(out.G_system + 916.8283889543869)/abs(916.8283889543869) < 2e-4

Finalize_MAGEMin(data)
end

@testset "view array PT" begin

data = Initialize_MAGEMin("ig", verbose=false);

# different bulk rock per point
P = [10.0, 10.0, 0]
T = [1100.0, 1100.0, 0]
Xoxides = ["SiO2"; "Al2O3"; "CaO"; "MgO"; "FeO"; "Fe2O3"; "K2O"; "Na2O"; "TiO2"; "Cr2O3"; "H2O"];
X1 = [48.43; 15.19; 11.57; 10.13; 6.65; 1.64; 0.59; 1.87; 0.68; 0.0; 3.0];
X2 = [49.43; 14.19; 11.57; 10.13; 6.65; 1.64; 0.59; 1.87; 0.68; 0.0; 3.0];
X = [X1,X2]
sys_in = "wt"
P_view = @view P[1:2]
T_view = @view T[1:2]
out = multi_point_minimization(P_view, T_view, data, X=X, Xoxides=Xoxides, sys_in=sys_in)

Finalize_MAGEMin(data)
end

@testset "convert bulk rock" begin

bulk_in_ox = ["SiO2"; "Al2O3"; "CaO"; "MgO"; "FeO"; "Fe2O3"; "K2O"; "Na2O"; "TiO2"; "Cr2O3"; "H2O"];
Expand Down Expand Up @@ -148,9 +167,9 @@ end
end

# Stores data of tests
mutable struct outP{ _T }
mutable struct outP{ _T }
P :: _T
T :: _T
T :: _T
test :: Int64

G :: _T
Expand Down Expand Up @@ -183,16 +202,16 @@ function VerifyPoint(out, list, i)
# We need to sort the phases (sometimes they are ordered differently)
ind_sol = sortperm(list.ph)
ind_out = sortperm(out.ph)

result1 = @test out.G_system ≈ list.G rtol=1e-3
result2 = @test out.ph[ind_out] == list.ph[ind_sol]
result3 = @test sort(out.ph_frac) ≈ sort(list.ph_frac) atol=5e-2 # ok, this is really large (needs fixing for test6!)

# print more info about the point if one of the tests above fails
if isa(result1,Test.Fail) || isa(result2,Test.Fail) || isa(result3,Test.Fail)
print_error_msg(i,list)
end

return nothing
end

Expand All @@ -204,7 +223,7 @@ println("Testing points from the reference diagrams:")
println(" Starting KLB-1 peridotite tests")
db = "ig" # database: ig, igneous (Holland et al., 2018); mp, metapelite (White et al 2014b)
data = Initialize_MAGEMin(db, verbose=false);

gv.verbose=-1;
@testset "IG-DB - KLB-1 peridotite" begin
include("test_diagram_test0.jl")
Expand All @@ -220,7 +239,7 @@ println("Testing points from the reference diagrams:")
include("test_diagram_test1.jl")
TestPoints(list, data)
end

println(" Starting Wet MORB tests")
db = "ig" # database: ig, igneous (Holland et al., 2018); mp, metapelite (White et al 2014b)
data = Initialize_MAGEMin(db, verbose=false);
Expand All @@ -234,7 +253,7 @@ println("Testing points from the reference diagrams:")
println(" Starting WM Pelite tests")
db = "mp" # database: ig, igneous (Holland et al., 2018); mp, metapelite (White et al 2014b)
data = Initialize_MAGEMin(db, verbose=false);

gv.verbose=-1;
@testset "MP-DB - WM Pelite" begin
include("test_diagram_test0_mp.jl")
Expand All @@ -245,7 +264,7 @@ println("Testing points from the reference diagrams:")
println(" Starting Gt-Migmatite tests")
db = "mp" # database: ig, igneous (Holland et al., 2018); mp, metapelite (White et al 2014b)
data = Initialize_MAGEMin(db, verbose=false);

gv.verbose=-1;
@testset "MP-DB - Gt-Migmatite" begin
include("test_diagram_test4_mp.jl")
Expand All @@ -257,13 +276,11 @@ println("Testing points from the reference diagrams:")
println(" Starting SQA Amphibole tests")
db = "mb" # database: ig, igneous (Holland et al., 2018); mp, metapelite (White et al 2014b)
data = Initialize_MAGEMin(db, verbose=false, mbCpx = 1);

gv.verbose=-1;
@testset "MB-DB - SQA Amphibole" begin
include("test_diagram_test0_mb.jl")
TestPoints(list, data)
end
Finalize_MAGEMin(data)


end
Loading