ComputationalThermodynamics / MAGEMin_C.jl

Julia interface to the MAGEMin C package
GNU General Public License v3.0
12 stars 4 forks source link

Multithreading support #3

Closed boriskaus closed 1 year ago

boriskaus commented 1 year ago

This PR brings multi-threading support to MAGEMin_C and simplifies running it for multiple points for cases where we have variable chemistry (thanks to @ranocha).

Simple example:

julia> using MAGEMin_C
julia> db   = "ig"  # database: ig, igneous (Holland et al., 2018); mp, metapelite (White et al 2014b)
julia> DAT  = Initialize_MAGEMin(db, verbose=false);
julia> test = 0         #KLB1
julia> n    = 1000 
julia> P    = rand(8.0:40,n);
julia> T    = rand(800.0:2000.0, n);
julia> out  = multi_point_minimization(P,T, DAT, test=test);

Example with custom chemistry:

julia> Xoxides = ["SiO2"; "Al2O3"; "CaO"; "MgO"; "FeO"; "Fe2O3"; "K2O"; "Na2O"; "TiO2"; "Cr2O3"; "H2O"];
julia> X = [48.43; 15.19; 11.57; 10.13; 6.65; 1.64; 0.59; 1.87; 0.68; 0.0; 3.0];
julia> sys_in = "wt" 
julia> out = multi_point_minimization(P, T, DAT, X=X, Xoxides=Xoxides, sys_in=sys_in)

Finalise the calculations with:

julia> Finalize_MAGEMin(DAT)
boriskaus commented 1 year ago

Do you also run some CI tests with multiple threads? We found this helpful with Trixi.jl, but it required disabling code coverage reports for the multi-threaded runs since they were extremely slow with the Julia version we used back then. I don't know how it is with current versions.

no, we don't test that currently (wasn't clear to me how to do that).