Skip to content

Commit e607e6f

Browse files
committed
corrected Ws for mp and mpe sp
1 parent 9997e1e commit e607e6f

17 files changed

+295
-55
lines changed

gen/magemin_library.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,10 +1177,13 @@ struct stb_systems
11771177
rho_F::Cdouble
11781178
bulk_S_wt::Ptr{Cdouble}
11791179
frac_S_wt::Cdouble
1180+
frac_S_vol::Cdouble
11801181
bulk_M_wt::Ptr{Cdouble}
11811182
frac_M_wt::Cdouble
1183+
frac_M_vol::Cdouble
11821184
bulk_F_wt::Ptr{Cdouble}
11831185
frac_F_wt::Cdouble
1186+
frac_F_vol::Cdouble
11841187
n_ph::Cint
11851188
n_PP::Cint
11861189
n_SS::Cint
@@ -1323,7 +1326,7 @@ mutable struct metapelite_datasets
13231326
n_pp::Cint
13241327
n_ss::Cint
13251328
ox::NTuple{11, NTuple{20, Cchar}}
1326-
PP::NTuple{23, NTuple{20, Cchar}}
1329+
PP::NTuple{24, NTuple{20, Cchar}}
13271330
SS::NTuple{18, NTuple{20, Cchar}}
13281331
verifyPC::NTuple{18, Cint}
13291332
n_SS_PC::NTuple{18, Cint}
@@ -1349,7 +1352,7 @@ mutable struct metabasite_datasets
13491352
n_pp::Cint
13501353
n_ss::Cint
13511354
ox::NTuple{10, NTuple{20, Cchar}}
1352-
PP::NTuple{23, NTuple{20, Cchar}}
1355+
PP::NTuple{24, NTuple{20, Cchar}}
13531356
SS::NTuple{17, NTuple{20, Cchar}}
13541357
verifyPC::NTuple{17, Cint}
13551358
n_SS_PC::NTuple{17, Cint}
@@ -1505,7 +1508,7 @@ mutable struct metapelite_datasets_ext
15051508
n_pp::Cint
15061509
n_ss::Cint
15071510
ox::NTuple{13, NTuple{20, Cchar}}
1508-
PP::NTuple{25, NTuple{20, Cchar}}
1511+
PP::NTuple{26, NTuple{20, Cchar}}
15091512
SS::NTuple{23, NTuple{20, Cchar}}
15101513
verifyPC::NTuple{23, Cint}
15111514
n_SS_PC::NTuple{23, Cint}

julia/MAGEMin_wrappers.jl

Lines changed: 14 additions & 6 deletions
Large diffs are not rendered by default.

ref_database/.DS_Store

0 Bytes
Binary file not shown.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#=
2+
3+
Test for Aqueous minimizer
4+
5+
=#
6+
7+
species = ["H2O", "Al(OH)2+", "Al(OH)3@", "Al(OH)4-", "Al+3", "AlH3SiO4+2", "AlOH+2", "Ca+2", "CaHSiO3+", "CaOH+", "CaSiO3@", "HSiO3-", "K+", "KAlO2@", "KOH@", "Mg+2", "MgHSiO3+", "MgOH+", "MgSiO3@", "Na+", "NaAl(OH)4@", "NaHSiO3@", "NaOH@", "OH-", "SiO2@"]
8+
G0s = [-378.991999, -1012.553295, -1405.559155, -1669.882646, -260.382070, -2061.778806, -641.559594, -536.589068, -1772.464205, -761.449349, -1705.193764, -1154.160844, -375.639412, -1280.307808, -585.973831, -400.958279, -1617.254393, -701.376817, -1567.329979, -350.424257, -2035.360551, -1485.410150, -563.302949, -179.482769, -970.840788]
9+
10+
oxide_names = ["SiO2", "Al2O3", "CaO", "MgO", "FeO", "K2O", "Na2O", "TiO2", "O", "MnO", "H2O"]
11+
gamma_pc = [-966.661516, -1766.267094, -808.803681, -688.195348, -369.432486, -936.439987, -876.096639, -1018.881760, -238.219822, -526.537851, -379.011475]
12+
13+
matrix = [ 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0;
14+
0.0 0.5 0.0 0.0 0.0 0.0 0.0 0.0 -0.5 0.0 1.0;
15+
0.0 0.5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.5;
16+
0.0 0.5 0.0 0.0 0.0 0.0 0.0 0.0 0.5 0.0 2.0;
17+
0.0 0.5 0.0 0.0 0.0 0.0 0.0 0.0 -1.5 0.0 0.0;
18+
1.0 0.5 0.0 0.0 0.0 0.0 0.0 0.0 -1.0 0.0 1.5;
19+
0.0 0.5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O = gO2/2.0
47+
48+
49+
gH2 = G0s[id_H2O] - gO
50+
gH = gH2/2.0
51+
52+
G_H2 = (G0s[id_H2O] - G0s[id_OHm])
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Aqueous species formulation, using Miron et al., 2017 database.
2+
3+
4+
```math
5+
G_{aq} = \sum_{i=1}^{n^{em}} n_i \mu_i
6+
```
7+
8+
where $n_i$ the molar fraction and $\mu_i$ is the chemical potential of the species $i$.
9+
10+
```math
11+
\mu_i = G_i^0 + RT ln(\gamma_i m_i)
12+
```
13+
14+
where $m_i$ is the molal fraction (!?)
15+
16+
And then develops into:
17+
18+
19+
20+
```math
21+
\mu_i = G_i^0 + RT( ln(\gamma_i) + ln(m_i))
22+
```
23+
24+
```math
25+
\mu_i = G_i^0 + RT( ln(\gamma_i) + ln(\frac{n_i}{n_{H2O} M_{H2O}}))
26+
```
27+
28+
```math
29+
\mu_i = G_i^0 + RT( ln(\gamma_i) + ln(\frac{n_i}{18.015 * n_{H2O}}))
30+
```
31+
32+
33+
---
34+
35+
For solute (aqueous species, excluding water), and assuming $\gamma_i$ = 1 (for now)
36+
37+
```math
38+
\mu_i = G_i^0 + RT ln(m_i)
39+
```
40+
41+
where
42+
43+
```math
44+
m_i = \frac{n_i}{m_{H2O}}
45+
```
46+
47+
so here $n_i$ is again the molar fraction and $m_{H2O}$ is mass of water? Should it be water density?
48+
49+
I could find the following definition:
50+
51+
```math
52+
m_i = \frac{n_i}{n_{H2O} M_{H2O}}
53+
```
54+
and here $n_i$ is the molarity and $M_{H2O}$ is the Molar mass of water (18.015). However, here density of water like we discussed is not appearing, is that right?
55+
56+
Should it simply be:
57+
58+
```math
59+
m_i = \frac{n_i}{\rho_{H2O}}
60+
```
61+
62+
---
63+
64+
For solvant (water):
65+
66+
```math
67+
\mu_{H2O} = G_{H2O }^0 + RT ln(\frac{1}{M_{H2O}})
68+
```
69+
70+
!?

src/MAGEMin.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -769,10 +769,10 @@ typedef struct stb_systems {
769769
double *bulk_M; double frac_M; double rho_M; /* Melt system informations */
770770
double *bulk_F; double frac_F; double rho_F; /* Fluid system informations */
771771

772-
double *bulk_S_wt; double frac_S_wt; /* Solid system informations */
773-
double *bulk_M_wt; double frac_M_wt; /* Melt system informations */
774-
double *bulk_F_wt; double frac_F_wt; /* Fluid system informations */
775-
772+
double *bulk_S_wt; double frac_S_wt; double frac_S_vol; /* Solid system informations */
773+
double *bulk_M_wt; double frac_M_wt; double frac_M_vol; /* Melt system informations */
774+
double *bulk_F_wt; double frac_F_wt; double frac_F_vol; /* Fluid system informations */
775+
776776
int n_ph; /* number of predicted stable phases */
777777
int n_PP; /* number of predicted stable pure phases */
778778
int n_SS; /* number of predicted stable solution phases */

src/TC_database/NLopt_opt_function.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7718,7 +7718,7 @@ SS_ref NLopt_opt_aq17_function(global_variable gv, SS_ref SS_ref_db){
77187718
SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
77197719
}
77207720

7721-
SS_ref_db.opt = nlopt_create(NLOPT_LN_COBYLA, (n));
7721+
SS_ref_db.opt = nlopt_create(NLOPT_LD_SLSQP, (n));
77227722
nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
77237723
nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
77247724
nlopt_set_min_objective(SS_ref_db.opt, obj_aq17, &SS_ref_db);

src/TC_database/TC_gem_function.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,11 +1035,11 @@ PP_ref G_FS_function( int len_ox,
10351035
PP_ref_db.factor = factor;
10361036
PP_ref_db.phase_shearModulus = 0.0;
10371037

1038-
// printf(" %4s %+10f | factor: %+10f\n",name,PP_ref_db.gbase,PP_ref_db.factor);
1038+
// printf(" %4s %+10f %+10f | factor: %+10f\n",name,G,PP_ref_db.gbase,PP_ref_db.factor);
10391039
// for (i = 0; i < len_ox; i++){
10401040
// printf("%+10f",PP_ref_db.Comp[i]*PP_ref_db.factor);
10411041
// }
1042-
// printf("\n");
1042+
// printf("\n\n");
10431043

10441044
return (PP_ref_db);
10451045
}

src/TC_database/TC_init_database.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ oxide_data oxide_info = {
3535
metapelite_dataset metapelite_db = {
3636
62, /* Endmember default dataset number */
3737
11, /* number of oxides */
38-
23, /* number of pure phases */
38+
24, /* number of pure phases */
3939
17, /* number of solution phases */
4040
{"SiO2" ,"Al2O3","CaO" ,"MgO" ,"FeO" ,"K2O" ,"Na2O" ,"TiO2" ,"O" ,"MnO" ,"H2O" },
41-
{"q" ,"crst" ,"trd" ,"coe" ,"stv" ,"ky" ,"sill" ,"and" ,"ru" ,"sph" ,"O2" ,"H2O" ,
41+
{"q" ,"crst" ,"trd" ,"coe" ,"stv" ,"ky" ,"sill" ,"and" ,"ru" ,"sph" ,"O2" ,"H2O" ,"zo" ,
4242
"qfm" ,"qif" ,"nno" ,"hm" ,"cco" ,"aH2O" , "aO2" ,"aMgO" ,"aFeO" ,"aAl2O3" ,"aTiO2" },
4343
{"liq" ,"fsp" ,"bi" ,"g" ,"ep" ,"ma" ,"mu" ,"opx" ,"sa" ,"cd" ,"st" ,"chl" ,"ctd" ,"sp" ,"mt" ,"ilm" ,"ilmm" ,"aq17" },
4444

@@ -63,10 +63,10 @@ metapelite_dataset metapelite_db = {
6363
metabasite_dataset metabasite_db = {
6464
62, /* Endmember default dataset number */
6565
10, /* number of oxides */
66-
23, /* number of pure phases */
66+
24, /* number of pure phases */
6767
17, /* number of solution phases */
6868
{"SiO2" ,"Al2O3","CaO" ,"MgO" ,"FeO" ,"K2O" ,"Na2O" ,"TiO2" ,"O" ,"H2O" },
69-
{"q" ,"crst" ,"trd" ,"coe" ,"law" ,"ky" ,"sill" ,"and" ,"ru" ,"sph" ,"ab" ,"H2O" ,
69+
{"q" ,"crst" ,"trd" ,"coe" ,"law" ,"ky" ,"sill" ,"and" ,"ru" ,"sph" ,"ab" ,"H2O" ,"zo" ,
7070
"qfm" ,"qif" ,"nno" ,"hm" ,"cco" ,"aH2O" ,"aO2" ,"aMgO" ,"aFeO" ,"aAl2O3" ,"aTiO2" },
7171
{"sp" ,"opx" ,"fsp" ,"liq" ,"mu" ,"ilmm" ,"ilm" ,"ol" ,"hb" ,"ep" ,"g" ,"chl" ,"bi" ,"dio" ,"aug" ,"abc" ,"spn" },
7272

@@ -232,10 +232,10 @@ mantle_dataset mantle_db = {
232232
metapelite_dataset_ext metapelite_ext_db = {
233233
62, /* Endmember default dataset number */
234234
13, /* number of oxides */
235-
25, /* number of pure phases */
235+
26, /* number of pure phases */
236236
23, /* number of solution phases */
237237
{"SiO2" ,"Al2O3","CaO" ,"MgO" ,"FeO" ,"K2O" ,"Na2O" ,"TiO2" ,"O" ,"MnO" ,"H2O" ,"CO2" ,"S" },
238-
{"q" ,"crst" ,"trd" ,"coe" ,"stv" ,"ky" ,"sill" ,"and" ,"ru" ,"sph" ,"O2" ,"pyr" ,"gph" ,"law" ,
238+
{"q" ,"crst" ,"trd" ,"coe" ,"stv" ,"ky" ,"sill" ,"and" ,"ru" ,"sph" ,"O2" ,"pyr" ,"gph" ,"law" ,"zo" ,
239239
"qfm" ,"qif" ,"nno" ,"hm" ,"cco" ,"aH2O" , "aO2" ,"aMgO" ,"aFeO" ,"aAl2O3" ,"aTiO2" },
240240
{"liq" ,"fsp" ,"bi" ,"g" ,"ep" ,"ma" ,"mu" ,"opx" ,"sa" ,"cd" ,"st" ,"chl" ,"ctd" ,"sp" ,"mt" ,"ilm" ,"ilmm" ,"occm" ,"fl" ,"po" ,"dio" ,"aug" ,"hb" },
241241

src/TC_database/TC_init_database.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
int n_pp;
2323
int n_ss;
2424
char ox[11][20];
25-
char PP[23][20];
25+
char PP[24][20];
2626
char SS[18][20];
2727

2828
int verifyPC[18];
@@ -54,7 +54,7 @@
5454
int n_pp;
5555
int n_ss;
5656
char ox[10][20];
57-
char PP[23][20];
57+
char PP[24][20];
5858

5959
char SS[17][20];
6060
int verifyPC[17];
@@ -246,7 +246,7 @@
246246
int n_pp;
247247
int n_ss;
248248
char ox[13][20];
249-
char PP[25][20];
249+
char PP[26][20];
250250
char SS[23][20];
251251

252252
int verifyPC[23];

0 commit comments

Comments
 (0)