init_simplex_B_em( &splx_data,
gv );
-
/*
initialize output
*/
@@ -406,9 +401,16 @@ Source code for MAGEMin.c
/*
get bulk rock composition parsed from args
*/
- gv = get_bulk( gv );
+ if (gv.EM_database == 0){
+ gv = get_bulk_metapelite( gv );
+ }
+ else if (gv.EM_database == 2){
+ gv = get_bulk_igneous( gv );
+ }
+ else{
+ printf(" Wrong database...\n");
+ }
-
/****************************************************************************************/
/** LAUNCH MINIMIZATION ROUTINE **/
/****************************************************************************************/
@@ -898,8 +900,12 @@ Source code for MAGEMin.c
/** pointer array to objective functions */
obj_type SS_objective[gv.len_ss];
-
- if (EM_database == 2){ // Igneous database //
+
+ if (EM_database == 0){ // Igneous database //
+ SS_mp_objective_init_function( SS_objective,
+ gv );
+ }
+ else if (EM_database == 2){ // Igneous database //
SS_ig_objective_init_function( SS_objective,
gv );
}
@@ -976,8 +982,12 @@ Source code for MAGEMin.c
Launch legacy solver (LP, Theriak-Domino like algorithm)
*/
if ((gv.div == 1 || z_b.T <= gv.solver_switch_T ) && gv.solver == 1){
- // if (gv.div == 1 && gv.solver == 1){
- printf("\n[PGE failed -> legacy solver...]\n");
+ if (gv.div == 1){
+ printf("\n[PGE failed (residual: %+.4f, PT: [%+.5f,%+.5f])-> legacy solver...]\n",gv.BR_norm,z_b.P,z_b.T-273.15);
+ }
+ if (z_b.T <= gv.solver_switch_T){
+ printf("\n Low Temperature conditions (T < %+5f) -> legacy solver...",gv.solver_switch_T);
+ }
gv.div = 0;
gv.status = 0;
@@ -1055,6 +1065,7 @@ Source code for MAGEMin.c
int i;
static ko_longopt_t longopts[] = {
{ "Verb", ko_optional_argument, 301 },
+ { "db", ko_optional_argument, 302 },
{ "File", ko_optional_argument, 303 },
{ "n_points ", ko_optional_argument, 304 },
{ "test", ko_optional_argument, 305 },
@@ -1082,11 +1093,12 @@ Source code for MAGEMin.c
else if (c == 316){ gv.solver = atoi(opt.arg); if (gv.verbose == 1){ printf("--solver : solver = %i \n", gv.solver );}}
else if (c == 318){ gv.output_matlab = atoi(opt.arg); if (gv.verbose == 1){ printf("--out_matlab : out_matlab = %i \n", gv.output_matlab );}}
else if (c == 303){ strcpy(gv.File,opt.arg); if (gv.verbose == 1){ printf("--File : File = %s \n", gv.File );}}
+ else if (c == 302){ strcpy(gv.db,opt.arg); if (gv.verbose == 1){ printf("--db : db = %s \n", gv.db );}}
else if (c == 317){ strcpy(gv.sys_in,opt.arg); if (gv.verbose == 1){ printf("--sys_in : sys_in = %s \n", gv.sys_in );}}
else if (c == 304){ gv.n_points = atoi(opt.arg); if (gv.verbose == 1){ printf("--n_points : n_points = %i \n", gv.n_points );}}
else if (c == 305){ gv.test = atoi(opt.arg); if (gv.verbose == 1){ printf("--test : Test = %i \n", gv.test );}}
- else if (c == 306){ z_b->T=strtof(opt.arg,NULL)+273.15; if (gv.verbose == 1){ printf("--Temp : Temperature = %f C \n", z_b->T-273.15 );}}
- else if (c == 307){ z_b->P = strtof(opt.arg,NULL); if (gv.verbose == 1){ printf("--Pres : Pressure = %f kbar \n", z_b->P );}}
+ else if (c == 306){ z_b->T=strtold(opt.arg,NULL)+273.15;if (gv.verbose == 1){ printf("--Temp : Temperature = %f C \n", z_b->T-273.15000 );}}
+ else if (c == 307){ z_b->P = strtold(opt.arg,NULL); if (gv.verbose == 1){ printf("--Pres : Pressure = %f kbar \n", z_b->P );}}
else if (c == 308){ strcpy(gv.Phase,opt.arg); if (gv.verbose == 1){ printf("--Phase : Phase name = %s \n", gv.Phase );}}
else if (c == 313){ gv.maxeval = strtof(opt.arg,NULL); if (gv.verbose == 1){
if (gv.maxeval==0){ printf("--maxeval : Max. # of local iter. = infinite \n" ); }
@@ -1125,6 +1137,17 @@ Source code for MAGEMin.c
}
}
+ /* set-up database acronym here*/
+ if (strcmp(gv.db, "mp") == 0){
+ gv.EM_database = 0;
+ }
+ else if (strcmp(gv.db, "ig") == 0){
+ gv.EM_database = 2;
+ }
+ else {
+ printf(" No or wrong database acronym has been provided, using default (Igneous [ig])\n");
+ gv.EM_database = 2;
+ }
return gv;
}
diff --git a/docs/_modules/NLopt_opt_function.c.html b/docs/_modules/NLopt_opt_function.c.html
index 98ad53d6..e9e57732 100644
--- a/docs/_modules/NLopt_opt_function.c.html
+++ b/docs/_modules/NLopt_opt_function.c.html
@@ -137,11 +137,7 @@
Access output structure
-Provide custom bulk rock composition
-
+Provide custom bulk rock composition
@@ -259,7 +255,884 @@ Source code for NLopt_opt_function.c
#include "NLopt_opt_function.h"
#include "toolkit.h"
-#define eps_sf -1e-10 // eps to shift site fraction from zero
+#define eps_sf -1e-10 // eps to shift site fraction from zero
+
+[docs]/**
+ Inequality constraints for liq_mp
+*/
+void liq_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf + x[6] - 1.0);
+ result[1] = ( eps_sf + -x[0]);
+ result[2] = ( eps_sf + -x[1]*x[2]);
+ result[3] = ( eps_sf + -x[1]*(1.0 - x[2]));
+ result[4] = ( eps_sf + -x[3]);
+ result[5] = ( eps_sf + x[3] + x[1] + x[6] + x[4] + x[0] - 1.0);
+ result[6] = ( eps_sf + -x[4]);
+ result[7] = ( eps_sf + -x[5]);
+ result[8] = ( eps_sf + x[5] - 1.0);
+ result[9] = ( eps_sf + -x[6]);
+
+ if (grad) {
+ grad[0] = 0.0;
+ grad[1] = 0.0;
+ grad[2] = 0.0;
+ grad[3] = 0.0;
+ grad[4] = 0.0;
+ grad[5] = 0.0;
+ grad[6] = 1.0;
+ grad[7] = -1.0;
+ grad[8] = 0.0;
+ grad[9] = 0.0;
+ grad[10] = 0.0;
+ grad[11] = 0.0;
+ grad[12] = 0.0;
+ grad[13] = 0.0;
+ grad[14] = 0.0;
+ grad[15] = -x[2];
+ grad[16] = -x[1];
+ grad[17] = 0.0;
+ grad[18] = 0.0;
+ grad[19] = 0.0;
+ grad[20] = 0.0;
+ grad[21] = 0.0;
+ grad[22] = x[2] - 1.0;
+ grad[23] = x[1];
+ grad[24] = 0.0;
+ grad[25] = 0.0;
+ grad[26] = 0.0;
+ grad[27] = 0.0;
+ grad[28] = 0.0;
+ grad[29] = 0.0;
+ grad[30] = 0.0;
+ grad[31] = -1.0;
+ grad[32] = 0.0;
+ grad[33] = 0.0;
+ grad[34] = 0.0;
+ grad[35] = 1.0;
+ grad[36] = 1.0;
+ grad[37] = 0.0;
+ grad[38] = 1.0;
+ grad[39] = 1.0;
+ grad[40] = 0.0;
+ grad[41] = 1.0;
+ grad[42] = 0.0;
+ grad[43] = 0.0;
+ grad[44] = 0.0;
+ grad[45] = 0.0;
+ grad[46] = -1.0;
+ grad[47] = 0.0;
+ grad[48] = 0.0;
+ grad[49] = 0.0;
+ grad[50] = 0.0;
+ grad[51] = 0.0;
+ grad[52] = 0.0;
+ grad[53] = 0.0;
+ grad[54] = -1.0;
+ grad[55] = 0.0;
+ grad[56] = 0.0;
+ grad[57] = 0.0;
+ grad[58] = 0.0;
+ grad[59] = 0.0;
+ grad[60] = 0.0;
+ grad[61] = 1.0;
+ grad[62] = 0.0;
+ grad[63] = 0.0;
+ grad[64] = 0.0;
+ grad[65] = 0.0;
+ grad[66] = 0.0;
+ grad[67] = 0.0;
+ grad[68] = 0.0;
+ grad[69] = -1.0;
+ }
+
+ return;
+};
+
+[docs]/**
+ Inequality constraints for st_mp
+*/
+void st_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf + -x[1]*x[0] + x[1] + x[0] - 1.0);
+ result[1] = ( eps_sf + x[1]*x[0] - x[0]);
+ result[2] = ( eps_sf + -x[1]);
+ result[3] = ( eps_sf + x[2] + 1.33333333333333*x[3] - 1.0);
+ result[4] = ( eps_sf + -x[2]);
+ result[5] = ( eps_sf + -x[3]);
+ result[6] = ( eps_sf + -0.333333333333333*x[3]);
+
+ if (grad) {
+ grad[0] = 1.0 - x[1];
+ grad[1] = 1.0 - x[0];
+ grad[2] = 0.0;
+ grad[3] = 0.0;
+ grad[4] = x[1] - 1.0;
+ grad[5] = x[0];
+ grad[6] = 0.0;
+ grad[7] = 0.0;
+ grad[8] = 0.0;
+ grad[9] = -1.0;
+ grad[10] = 0.0;
+ grad[11] = 0.0;
+ grad[12] = 0.0;
+ grad[13] = 0.0;
+ grad[14] = 1.0;
+ grad[15] = 1.33333333333333;
+ grad[16] = 0.0;
+ grad[17] = 0.0;
+ grad[18] = -1.0;
+ grad[19] = 0.0;
+ grad[20] = 0.0;
+ grad[21] = 0.0;
+ grad[22] = 0.0;
+ grad[23] = -1.0;
+ grad[24] = 0.0;
+ grad[25] = 0.0;
+ grad[26] = 0.0;
+ grad[27] = -0.333333333333333;
+ }
+
+ return;
+};
+
+[docs]/**
+ Inequality constraints for sp_mp
+*/
+void sp_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf + -x[1]);
+ result[1] = ( eps_sf + x[1] + x[2] - 1.0);
+ result[2] = ( eps_sf + -x[2]);
+ result[3] = ( eps_sf + x[0] - 1.0);
+ result[4] = ( eps_sf + -x[0]);
+
+ if (grad) {
+ grad[0] = 0.0;
+ grad[1] = -1.0;
+ grad[2] = 0.0;
+ grad[3] = 0.0;
+ grad[4] = 1.0;
+ grad[5] = 1.0;
+ grad[6] = 0.0;
+ grad[7] = 0.0;
+ grad[8] = -1.0;
+ grad[9] = 1.0;
+ grad[10] = 0.0;
+ grad[11] = 0.0;
+ grad[12] = -1.0;
+ grad[13] = 0.0;
+ grad[14] = 0.0;
+ }
+
+ return;
+};
+
+[docs]/**
+ Inequality constraints for sa_mp
+*/
+void sa_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf + -x[2]*x[0] + x[2] - 0.75*x[3] - x[0]*x[1] + x[0] + x[1] - 1.0);
+ result[1] = ( eps_sf + x[2]*x[0] + 0.75*x[3] + x[0]*x[1] - x[0]);
+ result[2] = ( eps_sf + -x[2]);
+ result[3] = ( eps_sf + -x[1]);
+ result[4] = ( eps_sf + 0.25*x[3] + x[0] - 1.0);
+ result[5] = ( eps_sf + -0.25*x[3] - x[0]);
+ result[6] = ( eps_sf + x[2] + x[1] - 1.0);
+ result[7] = ( eps_sf + -x[2] - x[1]);
+
+ if (grad) {
+ grad[0] = -x[2] - x[1] + 1.0;
+ grad[1] = 1.0 - x[0];
+ grad[2] = 1.0 - x[0];
+ grad[3] = -0.75;
+ grad[4] = x[2] + x[1] - 1.0;
+ grad[5] = x[0];
+ grad[6] = x[0];
+ grad[7] = 0.75;
+ grad[8] = 0.0;
+ grad[9] = 0.0;
+ grad[10] = -1.0;
+ grad[11] = 0.0;
+ grad[12] = 0.0;
+ grad[13] = -1.0;
+ grad[14] = 0.0;
+ grad[15] = 0.0;
+ grad[16] = 1.0;
+ grad[17] = 0.0;
+ grad[18] = 0.0;
+ grad[19] = 0.25;
+ grad[20] = -1.0;
+ grad[21] = 0.0;
+ grad[22] = 0.0;
+ grad[23] = -0.25;
+ grad[24] = 0.0;
+ grad[25] = 1.0;
+ grad[26] = 1.0;
+ grad[27] = 0.0;
+ grad[28] = 0.0;
+ grad[29] = -1.0;
+ grad[30] = -1.0;
+ grad[31] = 0.0;
+ }
+
+ return;
+};
+
+[docs]/**
+ Inequality constraints for pl4tr_mp
+*/
+void pl4tr_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf + x[0] + x[1] - 1.0);
+ result[1] = ( eps_sf + -x[0]);
+ result[2] = ( eps_sf + -x[1]);
+ result[3] = ( eps_sf + -0.25*x[0] - 0.25);
+ result[4] = ( eps_sf + 0.25*x[0] - 0.75);
+
+ if (grad) {
+ grad[0] = 1.0;
+ grad[1] = 1.0;
+ grad[2] = -1.0;
+ grad[3] = 0.0;
+ grad[4] = 0.0;
+ grad[5] = -1.0;
+ grad[6] = -0.25;
+ grad[7] = 0.0;
+ grad[8] = 0.25;
+ grad[9] = 0.0;
+ }
+
+ return;
+};
+
+[docs]/**
+ Inequality constraints for opx_mp
+*/
+void opx_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf + 0.5*x[4]*x[5] - x[3]*x[0] + x[3] + 0.5*x[1]*x[5] - x[1]*x[0] + x[1] - 0.5*x[5] - x[0]*x[2] + x[0] + x[2] - 1.0);
+ result[1] = ( eps_sf + -0.5*x[4]*x[5] + x[3]*x[0] - 0.5*x[1]*x[5] + x[1]*x[0] + 0.5*x[5] + x[0]*x[2] - x[0]);
+ result[2] = ( eps_sf + -x[1]);
+ result[3] = ( eps_sf + -x[3]);
+ result[4] = ( eps_sf + -x[2]);
+ result[5] = ( eps_sf + -0.5*x[4]*x[5] - x[4]*x[0] + x[4] - 0.5*x[1]*x[5] - x[1]*x[0] + x[1] + 0.5*x[5] + x[0] - 1.0);
+ result[6] = ( eps_sf + 0.5*x[4]*x[5] + x[4]*x[0] + 0.5*x[1]*x[5] + x[1]*x[0] - 0.5*x[5] - x[0]);
+ result[7] = ( eps_sf + -x[1]);
+ result[8] = ( eps_sf + -x[4]);
+ result[9] = ( eps_sf + -0.5*x[3] - 0.5*x[2]);
+ result[10] = ( eps_sf + 0.5*x[3] + 0.5*x[2] - 1.0);
+
+ if (grad) {
+ grad[0] = -x[3] - x[1] - x[2] + 1.0;
+ grad[1] = 0.5*x[5] - x[0] + 1.0;
+ grad[2] = 1.0 - x[0];
+ grad[3] = 1.0 - x[0];
+ grad[4] = 0.5*x[5];
+ grad[5] = 0.5*x[4] + 0.5*x[1] - 0.5;
+ grad[6] = x[3] + x[1] + x[2] - 1.0;
+ grad[7] = -0.5*x[5] + x[0];
+ grad[8] = x[0];
+ grad[9] = x[0];
+ grad[10] = -0.5*x[5];
+ grad[11] = -0.5*x[4] - 0.5*x[1] + 0.5;
+ grad[12] = 0.0;
+ grad[13] = -1.0;
+ grad[14] = 0.0;
+ grad[15] = 0.0;
+ grad[16] = 0.0;
+ grad[17] = 0.0;
+ grad[18] = 0.0;
+ grad[19] = 0.0;
+ grad[20] = 0.0;
+ grad[21] = -1.0;
+ grad[22] = 0.0;
+ grad[23] = 0.0;
+ grad[24] = 0.0;
+ grad[25] = 0.0;
+ grad[26] = -1.0;
+ grad[27] = 0.0;
+ grad[28] = 0.0;
+ grad[29] = 0.0;
+ grad[30] = -x[4] - x[1] + 1.0;
+ grad[31] = -0.5*x[5] - x[0] + 1.0;
+ grad[32] = 0.0;
+ grad[33] = 0.0;
+ grad[34] = -0.5*x[5] - x[0] + 1.0;
+ grad[35] = -0.5*x[4] - 0.5*x[1] + 0.5;
+ grad[36] = x[4] + x[1] - 1.0;
+ grad[37] = 0.5*x[5] + x[0];
+ grad[38] = 0.0;
+ grad[39] = 0.0;
+ grad[40] = 0.5*x[5] + x[0];
+ grad[41] = 0.5*x[4] + 0.5*x[1] - 0.5;
+ grad[42] = 0.0;
+ grad[43] = -1.0;
+ grad[44] = 0.0;
+ grad[45] = 0.0;
+ grad[46] = 0.0;
+ grad[47] = 0.0;
+ grad[48] = 0.0;
+ grad[49] = 0.0;
+ grad[50] = 0.0;
+ grad[51] = 0.0;
+ grad[52] = -1.0;
+ grad[53] = 0.0;
+ grad[54] = 0.0;
+ grad[55] = 0.0;
+ grad[56] = -0.50;
+ grad[57] = -0.50;
+ grad[58] = 0.0;
+ grad[59] = 0.0;
+ grad[60] = 0.0;
+ grad[61] = 0.0;
+ grad[62] = 0.50;
+ grad[63] = 0.50;
+ grad[64] = 0.0;
+ grad[65] = 0.0;
+ }
+
+ return;
+};
+
+[docs]/**
+ Inequality constraints for mu_mp
+*/
+void mu_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf + x[4] + x[3] - 1.0);
+ result[1] = ( eps_sf + -x[3]);
+ result[2] = ( eps_sf + -x[4]);
+ result[3] = ( eps_sf + -x[0]*x[1] + x[0] + x[1] - 1.0);
+ result[4] = ( eps_sf + x[0]*x[1] - x[0]);
+ result[5] = ( eps_sf + -x[1]);
+ result[6] = ( eps_sf + x[2] - 1.0);
+ result[7] = ( eps_sf + -x[2]);
+ result[8] = ( eps_sf + 0.5*x[4] + 0.5*x[1] - 1.0);
+ result[9] = ( eps_sf + -0.5*x[4] - 0.5*x[1]);
+
+ if (grad) {
+ grad[0] = 0.0;
+ grad[1] = 0.0;
+ grad[2] = 0.0;
+ grad[3] = 1.0;
+ grad[4] = 1.0;
+ grad[5] = 0.0;
+ grad[6] = 0.0;
+ grad[7] = 0.0;
+ grad[8] = -1.0;
+ grad[9] = 0.0;
+ grad[10] = 0.0;
+ grad[11] = 0.0;
+ grad[12] = 0.0;
+ grad[13] = 0.0;
+ grad[14] = -1.0;
+ grad[15] = 1.0 - x[1];
+ grad[16] = 1.0 - x[0];
+ grad[17] = 0.0;
+ grad[18] = 0.0;
+ grad[19] = 0.0;
+ grad[20] = x[1] - 1.0;
+ grad[21] = x[0];
+ grad[22] = 0.0;
+ grad[23] = 0.0;
+ grad[24] = 0.0;
+ grad[25] = 0.0;
+ grad[26] = -1.0;
+ grad[27] = 0.0;
+ grad[28] = 0.0;
+ grad[29] = 0.0;
+ grad[30] = 0.0;
+ grad[31] = 0.0;
+ grad[32] = 1.0;
+ grad[33] = 0.0;
+ grad[34] = 0.0;
+ grad[35] = 0.0;
+ grad[36] = 0.0;
+ grad[37] = -1.0;
+ grad[38] = 0.0;
+ grad[39] = 0.0;
+ grad[40] = 0.0;
+ grad[41] = 0.50;
+ grad[42] = 0.0;
+ grad[43] = 0.0;
+ grad[44] = 0.50;
+ grad[45] = 0.0;
+ grad[46] = -0.50;
+ grad[47] = 0.0;
+ grad[48] = 0.0;
+ grad[49] = -0.50;
+ }
+
+ return;
+};
+
+[docs]/**
+ Inequality constraints for mt_mp
+*/
+void mt_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf + 0.5*x[0] - 0.5);
+ result[1] = ( eps_sf + 0.5*x[1] - x[0]);
+ result[2] = ( eps_sf + -0.5*x[1] + 0.5*x[0] - 0.5);
+ result[3] = ( eps_sf + -x[1]);
+ result[4] = ( eps_sf + x[1] - 1.0);
+
+ if (grad) {
+ grad[0] = 0.50;
+ grad[1] = 0.0;
+ grad[2] = -1.0;
+ grad[3] = 0.50;
+ grad[4] = 0.50;
+ grad[5] = -0.50;
+ grad[6] = 0.0;
+ grad[7] = -1.0;
+ grad[8] = 0.0;
+ grad[9] = 1.0;
+ }
+
+ return;
+};
+
+[docs]/**
+ Inequality constraints for ma_mp
+*/
+void ma_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf + x[4] + x[3] - 1.0);
+ result[1] = ( eps_sf + -x[3]);
+ result[2] = ( eps_sf + -x[4]);
+ result[3] = ( eps_sf + -x[0]*x[1] + x[0] + x[1] - 1.0);
+ result[4] = ( eps_sf + x[0]*x[1] - x[0]);
+ result[5] = ( eps_sf + -x[1]);
+ result[6] = ( eps_sf + x[2] - 1.0);
+ result[7] = ( eps_sf + -x[2]);
+ result[8] = ( eps_sf + 0.5*x[4] + 0.5*x[1] - 1.0);
+ result[9] = ( eps_sf + -0.5*x[4] - 0.5*x[1]);
+
+ if (grad) {
+ grad[0] = 0.0;
+ grad[1] = 0.0;
+ grad[2] = 0.0;
+ grad[3] = 1.0;
+ grad[4] = 1.0;
+ grad[5] = 0.0;
+ grad[6] = 0.0;
+ grad[7] = 0.0;
+ grad[8] = -1.0;
+ grad[9] = 0.0;
+ grad[10] = 0.0;
+ grad[11] = 0.0;
+ grad[12] = 0.0;
+ grad[13] = 0.0;
+ grad[14] = -1.0;
+ grad[15] = 1.0 - x[1];
+ grad[16] = 1.0 - x[0];
+ grad[17] = 0.0;
+ grad[18] = 0.0;
+ grad[19] = 0.0;
+ grad[20] = x[1] - 1.0;
+ grad[21] = x[0];
+ grad[22] = 0.0;
+ grad[23] = 0.0;
+ grad[24] = 0.0;
+ grad[25] = 0.0;
+ grad[26] = -1.0;
+ grad[27] = 0.0;
+ grad[28] = 0.0;
+ grad[29] = 0.0;
+ grad[30] = 0.0;
+ grad[31] = 0.0;
+ grad[32] = 1.0;
+ grad[33] = 0.0;
+ grad[34] = 0.0;
+ grad[35] = 0.0;
+ grad[36] = 0.0;
+ grad[37] = -1.0;
+ grad[38] = 0.0;
+ grad[39] = 0.0;
+ grad[40] = 0.0;
+ grad[41] = 0.50;
+ grad[42] = 0.0;
+ grad[43] = 0.0;
+ grad[44] = 0.50;
+ grad[45] = 0.0;
+ grad[46] = -0.50;
+ grad[47] = 0.0;
+ grad[48] = 0.0;
+ grad[49] = -0.50;
+ }
+
+ return;
+};
+
+[docs]/**
+ Inequality constraints for ilm_mp
+*/
+void ilm_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf + 0.5*x[2] - 0.5*x[3] - 0.5*x[0] + 0.5*x[1]);
+ result[1] = ( eps_sf + 0.5*x[2] + 0.5*x[3] - 0.5*x[0] + 0.5*x[1]);
+ result[2] = ( eps_sf + -x[1]);
+ result[3] = ( eps_sf + -x[2]);
+ result[4] = ( eps_sf + x[0] - 1.0);
+ result[5] = ( eps_sf + -0.5*x[2] - 0.5*x[3] - 0.5*x[0] - 0.5*x[1]);
+
+ if (grad) {
+ grad[0] = -0.50;
+ grad[1] = 0.50;
+ grad[2] = 0.50;
+ grad[3] = -0.50;
+ grad[4] = -0.50;
+ grad[5] = 0.50;
+ grad[6] = 0.50;
+ grad[7] = 0.50;
+ grad[8] = 0.0;
+ grad[9] = -1.0;
+ grad[10] = 0.0;
+ grad[11] = 0.0;
+ grad[12] = 0.0;
+ grad[13] = 0.0;
+ grad[14] = -1.0;
+ grad[15] = 0.0;
+ grad[16] = 1.0;
+ grad[17] = 0.0;
+ grad[18] = 0.0;
+ grad[19] = 0.0;
+ grad[20] = -0.50;
+ grad[21] = -0.50;
+ grad[22] = -0.50;
+ grad[23] = -0.50;
+ }
+
+ return;
+};
+
+[docs]/**
+ Inequality constraints for g_mp
+*/
+void g_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf - x[2]*x[0] + x[2] - x[0]*x[1] + x[0] + x[1] - 1.0);
+ result[1] = ( eps_sf + x[2]*x[0] + x[0]*x[1] - x[0]);
+ result[2] = ( eps_sf - x[2]);
+ result[3] = ( eps_sf - x[1]);
+ result[4] = ( eps_sf - 1.0 + x[3]);
+ result[5] = ( eps_sf - x[3]);
+
+ if (grad) {
+ grad[0] = -x[2] - x[1] + 1.0;
+ grad[1] = 1.0 - x[0];
+ grad[2] = 1.0 - x[0];
+ grad[3] = 0.0;
+ grad[4] = x[2] + x[1] - 1.0;
+ grad[5] = x[0];
+ grad[6] = x[0];
+ grad[7] = 0.0;
+ grad[8] = 0.0;
+ grad[9] = 0.0;
+ grad[10] = -1.0;
+ grad[11] = 0.0;
+ grad[12] = 0.0;
+ grad[13] = -1.0;
+ grad[14] = 0.0;
+ grad[15] = 0.0;
+ grad[16] = 0.0;
+ grad[17] = 0.0;
+ grad[18] = 0.0;
+ grad[19] = 1.0;
+ grad[20] = 0.0;
+ grad[21] = 0.0;
+ grad[22] = 0.0;
+ grad[23] = -1.0;
+ }
+
+ return;
+};
+
+[docs]/**
+ Inequality constraints for ep_mp
+*/
+void ep_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf + -x[0] + x[1]);
+ result[1] = ( eps_sf + x[0] - x[1] - 1.0);
+ result[2] = ( eps_sf + -x[0] - x[1]);
+ result[3] = ( eps_sf + x[0] + x[1] - 1.0);
+
+ if (grad) {
+ grad[0] = -1.0;
+ grad[1] = 1.0;
+ grad[2] = 1.0;
+ grad[3] = -1.0;
+ grad[4] = -1.0;
+ grad[5] = -1.0;
+ grad[6] = 1.0;
+ grad[7] = 1.0;
+ }
+
+ return;
+};
+
+[docs]/**
+ Inequality constraints for ctd_mp
+*/
+void ctd_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf + x[2] - 1.0);
+ result[1] = ( eps_sf + -x[2]);
+ result[2] = ( eps_sf + x[1]*x[0] - x[0]);
+ result[3] = ( eps_sf + -x[1]*x[0] + x[1] + x[0] - 1.0);
+ result[4] = ( eps_sf + -x[1]);
+
+ if (grad) {
+ grad[0] = 0.0;
+ grad[1] = 0.0;
+ grad[2] = 1.0;
+ grad[3] = 0.0;
+ grad[4] = 0.0;
+ grad[5] = -1.0;
+ grad[6] = x[1] - 1.0;
+ grad[7] = x[0];
+ grad[8] = 0.0;
+ grad[9] = 1.0 - x[1];
+ grad[10] = 1.0 - x[0];
+ grad[11] = 0.0;
+ grad[12] = 0.0;
+ grad[13] = -1.0;
+ grad[14] = 0.0;
+ }
+
+ return;
+}
+
+[docs]/**
+ Inequality constraints for chl_mp
+*/
+void chl_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf + x[3]*x[5] - x[3]*x[0] + x[3] - x[5]*x[4] + x[5]*x[1] - x[5] + x[4]*x[0] - x[4] - x[0]*x[1] + x[0] + x[1] - 1.0);
+ result[1] = ( eps_sf + -x[3]*x[5] + x[3]*x[0] + x[5]*x[4] - x[5]*x[1] + x[5] - x[4]*x[0] + x[0]*x[1] - x[0]);
+ result[2] = ( eps_sf + x[4] - x[1]);
+ result[3] = ( eps_sf + -0.25*x[2]*x[6] - 0.25*x[3]*x[5] - x[3]*x[0] + x[3] + 0.25*x[5]*x[4] - 0.25*x[5]*x[1] + 0.25*x[5] - 0.25*x[6]*x[4] - 0.25*x[6]*x[1] + 0.25*x[6] + x[0] - 1.0);
+ result[4] = ( eps_sf + -x[3]);
+ result[5] = ( eps_sf + 0.25*x[2]*x[6] + 0.25*x[3]*x[5] + x[3]*x[0] - 0.25*x[5]*x[4] + 0.25*x[5]*x[1] - 0.25*x[5] + 0.25*x[6]*x[4] + 0.25*x[6]*x[1] - 0.25*x[6] - x[0]);
+ result[6] = ( eps_sf + x[2]*x[6] - x[2]*x[0] + x[2] + x[6]*x[4] + x[6]*x[1] - x[6] - x[4]*x[0] + x[4] - x[0]*x[1] + x[0] + x[1] - 1.0);
+ result[7] = ( eps_sf + -x[2]*x[6] + x[2]*x[0] - x[6]*x[4] - x[6]*x[1] + x[6] + x[4]*x[0] + x[0]*x[1] - x[0]);
+ result[8] = ( eps_sf + -x[2]);
+ result[9] = ( eps_sf + -x[4] - x[1]);
+ result[10] = ( eps_sf + 0.5*x[2] + x[1] - 1.0);
+ result[11] = ( eps_sf + -0.5*x[2] - x[1]);
+
+ if (grad) {
+ grad[0] = -x[3] + x[4] - x[1] + 1.0;
+ grad[1] = x[5] - x[0] + 1.0;
+ grad[2] = 0.0;
+ grad[3] = x[5] - x[0] + 1.0;
+ grad[4] = -x[5] + x[0] - 1.0;
+ grad[5] = x[3] - x[4] + x[1] - 1.0;
+ grad[6] = 0.0;
+ grad[7] = x[3] - x[4] + x[1] - 1.0;
+ grad[8] = -x[5] + x[0];
+ grad[9] = 0.0;
+ grad[10] = -x[5] + x[0];
+ grad[11] = x[5] - x[0];
+ grad[12] = -x[3] + x[4] - x[1] + 1.0;
+ grad[13] = 0.0;
+ grad[14] = 0.0;
+ grad[15] = -1.0;
+ grad[16] = 0.0;
+ grad[17] = 0.0;
+ grad[18] = 1.0;
+ grad[19] = 0.0;
+ grad[20] = 0.0;
+ grad[21] = 1.0 - x[3];
+ grad[22] = -0.25*x[5] - 0.25*x[6];
+ grad[23] = -0.25*x[6];
+ grad[24] = -0.25*x[5] - x[0] + 1.0;
+ grad[25] = 0.25*x[5] - 0.25*x[6];
+ grad[26] = -0.25*x[3] + 0.25*x[4] - 0.25*x[1] + 0.25;
+ grad[27] = -0.25*x[2] - 0.25*x[4] - 0.25*x[1] + 0.25;
+ grad[28] = 0.0;
+ grad[29] = 0.0;
+ grad[30] = 0.0;
+ grad[31] = -1.0;
+ grad[32] = 0.0;
+ grad[33] = 0.0;
+ grad[34] = 0.0;
+ grad[35] = x[3] - 1.0;
+ grad[36] = 0.25*x[5] + 0.25*x[6];
+ grad[37] = 0.25*x[6];
+ grad[38] = 0.25*x[5] + x[0];
+ grad[39] = -0.25*x[5] + 0.25*x[6];
+ grad[40] = 0.25*x[3] - 0.25*x[4] + 0.25*x[1] - 0.25;
+ grad[41] = 0.25*x[2] + 0.25*x[4] + 0.25*x[1] - 0.25;
+ grad[42] = -x[2] - x[4] - x[1] + 1.0;
+ grad[43] = x[6] - x[0] + 1.0;
+ grad[44] = x[6] - x[0] + 1.0;
+ grad[45] = 0.0;
+ grad[46] = x[6] - x[0] + 1.0;
+ grad[47] = 0.0;
+ grad[48] = x[2] + x[4] + x[1] - 1.0;
+ grad[49] = x[2] + x[4] + x[1] - 1.0;
+ grad[50] = -x[6] + x[0];
+ grad[51] = -x[6] + x[0];
+ grad[52] = 0.0;
+ grad[53] = -x[6] + x[0];
+ grad[54] = 0.0;
+ grad[55] = -x[2] - x[4] - x[1] + 1.0;
+ grad[56] = 0.0;
+ grad[57] = 0.0;
+ grad[58] = -1.0;
+ grad[59] = 0.0;
+ grad[60] = 0.0;
+ grad[61] = 0.0;
+ grad[62] = 0.0;
+ grad[63] = 0.0;
+ grad[64] = -1.0;
+ grad[65] = 0.0;
+ grad[66] = 0.0;
+ grad[67] = -1.0;
+ grad[68] = 0.0;
+ grad[69] = 0.0;
+ grad[70] = 0.0;
+ grad[71] = 1.0;
+ grad[72] = 0.50;
+ grad[73] = 0.0;
+ grad[74] = 0.0;
+ grad[75] = 0.0;
+ grad[76] = 0.0;
+ grad[77] = 0.0;
+ grad[78] = -1.0;
+ grad[79] = -0.50;
+ grad[80] = 0.0;
+ grad[81] = 0.0;
+ grad[82] = 0.0;
+ grad[83] = 0.0;
+ }
+
+ return;
+};
+
+[docs]/**
+ Inequality constraints for cd_mp
+*/
+void cd_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf + -x[0]);
+ result[1] = ( eps_sf + x[0] - 1.0);
+ result[2] = ( eps_sf + -x[1]);
+ result[3] = ( eps_sf + -x[2]);
+ result[4] = ( eps_sf + x[2] - 1.0);
+
+ if (grad) {
+ grad[0] = -1.0;
+ grad[1] = 0.0;
+ grad[2] = 0.0;
+ grad[3] = 1.0;
+ grad[4] = 0.0;
+ grad[5] = 0.0;
+ grad[6] = 0.0;
+ grad[7] = -1.0;
+ grad[8] = 0.0;
+ grad[9] = 0.0;
+ grad[10] = 0.0;
+ grad[11] = -1.0;
+ grad[12] = 0.0;
+ grad[13] = 0.0;
+ grad[14] = 1.0;
+ }
+
+ return;
+};
+
+[docs]/**
+ Inequality constraints for bi_mp
+*/
+void bi_mp_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
+ result[0] = ( eps_sf - x[3]*x[0] + x[3] - 3.0*x[1]*x[0] + x[1] + 2.0/3.0*x[5] - x[4]*x[0] + x[4] - x[0]*x[2] + x[0] + x[2] - 1.0);
+ result[1] = ( eps_sf - x[1]);
+ result[2] = ( eps_sf + x[3]*x[0] + 3.0*x[1]*x[0] - 2.0/3.0*x[5] + x[4]*x[0] + x[0]*x[2] - x[0]);
+ result[3] = ( eps_sf - x[3]);
+ result[4] = ( eps_sf - x[4]);
+ result[5] = ( eps_sf - x[2]);
+ result[6] = ( eps_sf + x[1] - 1.0/3.0*x[5] + x[0] - 1.0);
+ result[7] = ( eps_sf - x[1]);
+ result[8] = ( eps_sf + 1.0/3.0*x[5] - x[0]);
+ result[9] = ( eps_sf + 0.5*x[3] + 0.5*x[2] - 0.5);
+ result[10] = ( eps_sf - 0.5*x[3] - 0.5*x[2] - 0.5);
+ result[11] = ( eps_sf + x[4] - 1.0);
+ result[12] = ( eps_sf - x[4]);
+
+ if (grad) {
+ grad[0] = -x[3] - 3.0*x[1] - x[4] - x[2] + 1.0;
+ grad[1] = 1.0 - 3.0*x[0];
+ grad[2] = 1.0 - x[0];
+ grad[3] = 1.0 - x[0];
+ grad[4] = 1.0 - x[0];
+ grad[5] = 2.0/3.0;
+ grad[6] = 0.0;
+ grad[7] = -1.0;
+ grad[8] = 0.0;
+ grad[9] = 0.0;
+ grad[10] = 0.0;
+ grad[11] = 0.0;
+ grad[12] = x[3] + 3.0*x[1] + x[4] + x[2] - 1.0;
+ grad[13] = 3.0*x[0];
+ grad[14] = x[0];
+ grad[15] = x[0];
+ grad[16] = x[0];
+ grad[17] = -2.0/3.0;
+ grad[18] = 0.0;
+ grad[19] = 0.0;
+ grad[20] = 0.0;
+ grad[21] = -1.0;
+ grad[22] = 0.0;
+ grad[23] = 0.0;
+ grad[24] = 0.0;
+ grad[25] = 0.0;
+ grad[26] = 0.0;
+ grad[27] = 0.0;
+ grad[28] = -1.0;
+ grad[29] = 0.0;
+ grad[30] = 0.0;
+ grad[31] = 0.0;
+ grad[32] = -1.0;
+ grad[33] = 0.0;
+ grad[34] = 0.0;
+ grad[35] = 0.0;
+ grad[36] = 1.0;
+ grad[37] = 1.0;
+ grad[38] = 0.0;
+ grad[39] = 0.0;
+ grad[40] = 0.0;
+ grad[41] = -1.0/3.0;
+ grad[42] = 0.0;
+ grad[43] = -1.0;
+ grad[44] = 0.0;
+ grad[45] = 0.0;
+ grad[46] = 0.0;
+ grad[47] = 0.0;
+ grad[48] = -1.0;
+ grad[49] = 0.0;
+ grad[50] = 0.0;
+ grad[51] = 0.0;
+ grad[52] = 0.0;
+ grad[53] = 1.0/3.0;
+ grad[54] = 0.0;
+ grad[55] = 0.0;
+ grad[56] = 0.50;
+ grad[57] = 0.50;
+ grad[58] = 0.0;
+ grad[59] = 0.0;
+ grad[60] = 0.0;
+ grad[61] = 0.0;
+ grad[62] = -0.50;
+ grad[63] = -0.50;
+ grad[64] = 0.0;
+ grad[65] = 0.0;
+ grad[66] = 0.0;
+ grad[67] = 0.0;
+ grad[68] = 0.0;
+ grad[69] = 0.0;
+ grad[70] = 1.0;
+ grad[71] = 0.0;
+ grad[72] = 0.0;
+ grad[73] = 0.0;
+ grad[74] = 0.0;
+ grad[75] = 0.0;
+ grad[76] = -1.0;
+ grad[77] = 0.0;
+ }
+
+ return;
+};
[docs]/**
local minimization for clinopyroxene
@@ -1430,28 +2303,28 @@ Source code for NLopt_opt_function.c
local minimization for biotite
*/
void bi_ig_c(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data){
- result[0] = ( eps_sf + -1.0*x[2]*x[0] + 1.0*x[2] + 2.0/3.0*x[4] - 1.0*x[3]*x[0] + 1.0*x[3] - 1.0*x[0]*x[1] + 1.0*x[0] + 1.0*x[1] - 1.0);
- result[1] = ( eps_sf + 1.0*x[2]*x[0] - 2.0/3.0*x[4] + 1.0*x[3]*x[0] + 1.0*x[0]*x[1] - 1.0*x[0]);
- result[2] = ( eps_sf + -1.0*x[2]);
- result[3] = ( eps_sf + -1.0*x[3]);
- result[4] = ( eps_sf + -1.0*x[1]);
- result[5] = ( eps_sf + -1.0/3.0*x[4] + 1.0*x[0] - 1.0);
- result[6] = ( eps_sf + 1.0/3.0*x[4] - 1.0*x[0]);
+ result[0] = ( eps_sf + -x[2]*x[0] + x[2] + 2.0/3.0*x[4] - x[3]*x[0] + x[3] - x[0]*x[1] + x[0] + x[1] - 1.0);
+ result[1] = ( eps_sf + x[2]*x[0] - 2.0/3.0*x[4] + x[3]*x[0] + x[0]*x[1] - x[0]);
+ result[2] = ( eps_sf + -x[2]);
+ result[3] = ( eps_sf + -x[3]);
+ result[4] = ( eps_sf + -x[1]);
+ result[5] = ( eps_sf + -1.0/3.0*x[4] + x[0] - 1.0);
+ result[6] = ( eps_sf + 1.0/3.0*x[4] - x[0]);
result[7] = ( eps_sf + 0.5*x[2] + 0.5*x[1] - 0.5);
result[8] = ( eps_sf + -0.5*x[2] - 0.5*x[1] - 0.5);
- result[9] = ( eps_sf + 1.0*x[3] - 1.0);
- result[10] = ( eps_sf + -1.0*x[3]);
+ result[9] = ( eps_sf + x[3] - 1.0);
+ result[10] = ( eps_sf + -x[3]);
if (grad) {
- grad[0] = -1.0*x[2] - 1.0*x[3] - 1.0*x[1] + 1.0;
- grad[1] = 1.0 - 1.0*x[0];
- grad[2] = 1.0 - 1.0*x[0];
- grad[3] = 1.0 - 1.0*x[0];
+ grad[0] = -x[2] - x[3] - x[1] + 1.0;
+ grad[1] = 1.0 - x[0];
+ grad[2] = 1.0 - x[0];
+ grad[3] = 1.0 - x[0];
grad[4] = 2.0/3.0;
- grad[5] = 1.0*x[2] + 1.0*x[3] + 1.0*x[1] - 1.0;
- grad[6] = 1.0*x[0];
- grad[7] = 1.0*x[0];
- grad[8] = 1.0*x[0];
+ grad[5] = x[2] + x[3] + x[1] - 1.0;
+ grad[6] = x[0];
+ grad[7] = x[0];
+ grad[8] = x[0];
grad[9] = -2.0/3.0;
grad[10] = 0.0;
grad[11] = 0.0;
@@ -1538,6 +2411,664 @@ Source code for NLopt_opt_function.c
} global_min_data;
+
+SS_ref NLopt_opt_mp_st_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_SLSQP, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_st, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, st_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_st(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
+SS_ref NLopt_opt_mp_sp_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_CCSAQ, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_sp, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, sp_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_sp(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
+SS_ref NLopt_opt_mp_sa_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_CCSAQ, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_sa, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, sa_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_sa(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
+SS_ref NLopt_opt_mp_pl4tr_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_CCSAQ, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_pl4tr, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, pl4tr_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_pl4tr(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
+SS_ref NLopt_opt_mp_opx_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_SLSQP, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_opx, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, opx_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_opx(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
+SS_ref NLopt_opt_mp_mu_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_SLSQP, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_mu, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, mu_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_mu(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
+SS_ref NLopt_opt_mp_mt_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_CCSAQ, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_mt, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, mt_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_mt(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
+SS_ref NLopt_opt_mp_ma_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_SLSQP, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_ma, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, ma_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_ma(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
+SS_ref NLopt_opt_mp_ilm_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_CCSAQ, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_ilm, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, ilm_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_ilm(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
+SS_ref NLopt_opt_mp_g_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_SLSQP, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_g, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, g_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_g(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
+SS_ref NLopt_opt_mp_ep_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_CCSAQ, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_ep, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, ep_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_ep(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
+SS_ref NLopt_opt_mp_ctd_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_CCSAQ, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_ctd, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, ctd_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_ctd(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
+SS_ref NLopt_opt_mp_chl_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_SLSQP, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_chl, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, chl_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_chl(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
+SS_ref NLopt_opt_mp_cd_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_CCSAQ, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_cd, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, cd_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_cd(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
+SS_ref NLopt_opt_mp_bi_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_CCSAQ, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_bi, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, bi_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_bi(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
+
+SS_ref NLopt_opt_mp_liq_function(global_variable gv, SS_ref SS_ref_db){
+
+ int n_em = SS_ref_db.n_em;
+ unsigned int n = SS_ref_db.n_xeos;
+ unsigned int m = SS_ref_db.n_sf;
+
+ double *x = SS_ref_db.iguess;
+
+ for (int i = 0; i < (SS_ref_db.n_xeos); i++){
+ SS_ref_db.lb[i] = SS_ref_db.bounds[i][0];
+ SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
+ }
+
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_SLSQP, (n));
+ nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
+ nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
+ nlopt_set_min_objective(SS_ref_db.opt, obj_mp_liq, &SS_ref_db);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, liq_mp_c, NULL, SS_ref_db.tol_sf);
+ nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+
+ double minf;
+ if (gv.maxeval==1){
+ // we are only interested in evaluating the objective function
+ minf = obj_mp_liq(n, x, NULL, &SS_ref_db);
+ }
+ else{
+ // do optimization
+ SS_ref_db.status = nlopt_optimize(SS_ref_db.opt, x, &minf);
+ }
+ /* Send back needed local solution parameters */
+ for (int i = 0; i < SS_ref_db.n_xeos; i++){
+ SS_ref_db.xeos[i] = x[i];
+ }
+
+ SS_ref_db.df = minf;
+ nlopt_destroy(SS_ref_db.opt);
+
+ return SS_ref_db;
+};
+
SS_ref NLopt_opt_ig_bi_function(global_variable gv, SS_ref SS_ref_db){
int n_em = SS_ref_db.n_em;
@@ -1551,7 +3082,7 @@ Source code for NLopt_opt_function.c
SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
}
- SS_ref_db.opt = nlopt_create(NLOPT_LD_CCSAQ, (n));
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_SLSQP, (n));
nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
nlopt_set_min_objective(SS_ref_db.opt, obj_ig_bi, &SS_ref_db);
@@ -1592,13 +3123,13 @@ Source code for NLopt_opt_function.c
SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
}
- SS_ref_db.opt = nlopt_create(NLOPT_LD_CCSAQ, (n));
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_CCSAQ, (n));
nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
nlopt_set_min_objective(SS_ref_db.opt, obj_ig_cd, &SS_ref_db);
- nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, cd_ig_c, NULL, SS_ref_db.tol_sf);
+ nlopt_add_inequality_mconstraint(SS_ref_db.opt, m, cd_ig_c, NULL, SS_ref_db.tol_sf);
nlopt_set_ftol_rel(SS_ref_db.opt, gv.obj_tol);
- nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
+ nlopt_set_maxeval(SS_ref_db.opt, gv.maxeval);
double minf;
if (gv.maxeval==1){
@@ -1803,7 +3334,7 @@ Source code for NLopt_opt_function.c
SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
}
- SS_ref_db.opt = nlopt_create(NLOPT_LD_CCSAQ, (n));
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_SLSQP, (n));
nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
nlopt_set_min_objective(SS_ref_db.opt, obj_ig_hb, &SS_ref_db);
@@ -2012,7 +3543,7 @@ Source code for NLopt_opt_function.c
SS_ref_db.ub[i] = SS_ref_db.bounds[i][1];
}
- SS_ref_db.opt = nlopt_create(NLOPT_LD_CCSAQ, (n));
+ SS_ref_db.opt = nlopt_create(NLOPT_LD_SLSQP, (n));
nlopt_set_lower_bounds(SS_ref_db.opt, SS_ref_db.lb);
nlopt_set_upper_bounds(SS_ref_db.opt, SS_ref_db.ub);
nlopt_set_min_objective(SS_ref_db.opt, obj_ig_opx, &SS_ref_db);
@@ -2136,38 +3667,80 @@ Source code for NLopt_opt_function.c
t = clock();
/* Associate the right solid-solution data */
- if (strcmp( gv.SS_list[index], "bi") == 0 ){
- SS_ref_db = NLopt_opt_ig_bi_function( gv, SS_ref_db); }
- else if (strcmp( gv.SS_list[index], "cd") == 0){
- SS_ref_db = NLopt_opt_ig_cd_function( gv, SS_ref_db); }
- else if (strcmp( gv.SS_list[index], "cpx") == 0){
- SS_ref_db = NLopt_opt_ig_ig_cpx_function( gv, SS_ref_db);}
- else if (strcmp( gv.SS_list[index], "ep") == 0){
- SS_ref_db = NLopt_opt_ig_ep_function( gv, SS_ref_db); }
- else if (strcmp( gv.SS_list[index], "fl") == 0){
- SS_ref_db = NLopt_opt_ig_fl_function( gv, SS_ref_db); }
- else if (strcmp( gv.SS_list[index], "g") == 0){
- SS_ref_db = NLopt_opt_ig_g_function( gv, SS_ref_db); }
- else if (strcmp( gv.SS_list[index], "hb") == 0){
- SS_ref_db = NLopt_opt_ig_hb_function( gv, SS_ref_db); }
- else if (strcmp( gv.SS_list[index], "ilm") == 0){
- SS_ref_db = NLopt_opt_ig_ilm_function( gv, SS_ref_db);}
- else if (strcmp( gv.SS_list[index], "liq") == 0){
- SS_ref_db = NLopt_opt_ig_liq_function( gv, SS_ref_db);}
- else if (strcmp( gv.SS_list[index], "mu") == 0){
- SS_ref_db = NLopt_opt_ig_mu_function( gv, SS_ref_db); }
- else if (strcmp( gv.SS_list[index], "ol") == 0){
- SS_ref_db = NLopt_opt_ig_ol_function( gv, SS_ref_db); }
- else if (strcmp( gv.SS_list[index], "opx") == 0){
- SS_ref_db = NLopt_opt_ig_opx_function( gv, SS_ref_db);}
- else if (strcmp( gv.SS_list[index], "pl4T") == 0){
- SS_ref_db = NLopt_opt_ig_pl4T_function( gv, SS_ref_db); }
- else if (strcmp( gv.SS_list[index], "spn") == 0){
- SS_ref_db = NLopt_opt_ig_spn_function( gv, SS_ref_db);
- }
- else{
- printf("\nsolid solution '%s index %d' is not in the database\n",gv.SS_list[index], index); }
-
+ if(gv.EM_database == 0){
+ if (strcmp( gv.SS_list[index], "liq") == 0 ){
+ SS_ref_db = NLopt_opt_mp_liq_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "pl4tr") == 0){
+ SS_ref_db = NLopt_opt_mp_pl4tr_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "bi") == 0){
+ SS_ref_db = NLopt_opt_mp_bi_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "g") == 0){
+ SS_ref_db = NLopt_opt_mp_g_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "ep") == 0){
+ SS_ref_db = NLopt_opt_mp_ep_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "ma") == 0){
+ SS_ref_db = NLopt_opt_mp_ma_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "mu") == 0){
+ SS_ref_db = NLopt_opt_mp_mu_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "opx") == 0){
+ SS_ref_db = NLopt_opt_mp_opx_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "sa") == 0){
+ SS_ref_db = NLopt_opt_mp_sa_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "cd") == 0){
+ SS_ref_db = NLopt_opt_mp_cd_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "st") == 0){
+ SS_ref_db = NLopt_opt_mp_st_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "chl") == 0){
+ SS_ref_db = NLopt_opt_mp_chl_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "ctd") == 0){
+ SS_ref_db = NLopt_opt_mp_ctd_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "sp") == 0){
+ SS_ref_db = NLopt_opt_mp_sp_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "ilm") == 0){
+ SS_ref_db = NLopt_opt_mp_ilm_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "mt") == 0){
+ SS_ref_db = NLopt_opt_mp_mt_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "mt") == 0){
+ SS_ref_db = NLopt_opt_mp_mt_function( gv, SS_ref_db);
+ }
+ else{
+ printf("\nsolid solution '%s index %d' is not in the database\n",gv.SS_list[index], index);
+ }
+ }
+ else if(gv.EM_database == 2){ // igneous
+ if (strcmp( gv.SS_list[index], "bi") == 0 ){
+ SS_ref_db = NLopt_opt_ig_bi_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "cd") == 0){
+ SS_ref_db = NLopt_opt_ig_cd_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "cpx") == 0){
+ SS_ref_db = NLopt_opt_ig_ig_cpx_function( gv, SS_ref_db);}
+ else if (strcmp( gv.SS_list[index], "ep") == 0){
+ SS_ref_db = NLopt_opt_ig_ep_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "fl") == 0){
+ SS_ref_db = NLopt_opt_ig_fl_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "g") == 0){
+ SS_ref_db = NLopt_opt_ig_g_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "hb") == 0){
+ SS_ref_db = NLopt_opt_ig_hb_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "ilm") == 0){
+ SS_ref_db = NLopt_opt_ig_ilm_function( gv, SS_ref_db);}
+ else if (strcmp( gv.SS_list[index], "liq") == 0){
+ SS_ref_db = NLopt_opt_ig_liq_function( gv, SS_ref_db);}
+ else if (strcmp( gv.SS_list[index], "mu") == 0){
+ SS_ref_db = NLopt_opt_ig_mu_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "ol") == 0){
+ SS_ref_db = NLopt_opt_ig_ol_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "opx") == 0){
+ SS_ref_db = NLopt_opt_ig_opx_function( gv, SS_ref_db);}
+ else if (strcmp( gv.SS_list[index], "pl4T") == 0){
+ SS_ref_db = NLopt_opt_ig_pl4T_function( gv, SS_ref_db); }
+ else if (strcmp( gv.SS_list[index], "spn") == 0){
+ SS_ref_db = NLopt_opt_ig_spn_function( gv, SS_ref_db);
+ }
+ else{
+ printf("\nsolid solution '%s index %d' is not in the database\n",gv.SS_list[index], index);
+ }
+ }
t = clock() - t;
SS_ref_db.LM_time = ((double)t)/CLOCKS_PER_SEC*1000; // in seconds
diff --git a/docs/_modules/PGE_function.c.html b/docs/_modules/PGE_function.c.html
index 5e037a93..a05c9b23 100644
--- a/docs/_modules/PGE_function.c.html
+++ b/docs/_modules/PGE_function.c.html
@@ -137,11 +137,7 @@
Access output structure
-Provide custom bulk rock composition
-
+Provide custom bulk rock composition
@@ -338,7 +334,7 @@ Source code for PGE_function.c
for (int i = 0; i < gv.len_cp; i++){
if (cp[i].ss_flags[0] == 1 && cp[i].ss_flags[2] == 1){
- printf(" %d | %4s | %+10f | %+10f | %+10f | %+10f | ",cp[i].ss_flags[1],cp[i].name,cp[i].ss_n,cp[i].df,cp[i].factor,cp[i].sum_xi);
+ printf(" %d | %4s | %+10f | %+10f | %+10f | %+10f | ",cp[i].ss_flags[1],cp[i].name,cp[i].ss_n,cp[i].df*cp[i].factor,cp[i].factor,cp[i].sum_xi);
for (int k = 0; k < cp[i].n_em; k++) {
printf(" %+10f",(cp[i].p_em[k]-cp[i].xi_em[k]*cp[i].p_em[k])*SS_ref_db[cp[i].id].z_em[k]);
@@ -498,14 +494,12 @@ Source code for PGE_function.c
if (cp[ph].ss_flags[1] == 1 && SS_ref_db[cp[ph].id].CstFactor == 0){
ss = cp[ph].id;
- double dp[cp[ph].n_em];
- for (k = 0; k < cp[ph].n_em; k++){
- dp[k] = (cp[ph].p_em[k]-cp[ph].xi_em[k]*cp[ph].p_em[k])*SS_ref_db[ss].z_em[k];
- }
-
for (k = 0; k < cp[ph].n_em; k++){
SS_ref_db[ss].p[k] = cp[ph].p_em[k]*cp[ph].xi_em[k];
}
+
+ norm_array( SS_ref_db[ss].p,
+ cp[ph].n_em );
SS_ref_db[ss] = P2X( gv,
SS_ref_db[ss],
@@ -755,7 +749,7 @@ Source code for PGE_function.c
gv.gamma_norm[gv.global_ite] = norm_vector(gv.dGamma, z_b.nzEl_val);
- /* Update solusion phase (SS) fractions */
+ /* Update solution phase (SS) fractions */
for (i = 0; i < gv.n_cp_phase; i++){
cp[gv.cp_id[i]].delta_ss_n = gv.dn_cp[i]*alpha;
cp[gv.cp_id[i]].ss_n += gv.dn_cp[i]*alpha;
@@ -896,7 +890,7 @@ Source code for PGE_function.c
fc_norm_t0 = gv.fc_norm_t1;
/**
- calculate delta_G of pure phases
+ calculate delta_G of pure phases
*/
pp_min_function( gv,
z_b,
@@ -1659,8 +1653,9 @@ Source code for PGE_function.c
/** CHECK MINIMIZATION STATUS */
/*********************************************************/
- /* checks for full convergence */
- if (gv.BR_norm < gv.br_max_tol){ gv.status = 0; iterate = 0;}
+ /* checks for full convergence */
+ /* the second term checks if solution phase have been tested in case convergence is too fast */
+ if (gv.BR_norm < gv.br_max_tol && gv.check_PC2 == 1){ gv.status = 0; iterate = 0;}
/* checks for dampened convergence */
if (gv.global_ite > gv.it_1 && gv.BR_norm < gv.br_max_tol*gv.ur_1){ if (gv.verbose != -1){printf(" >%d iterations, under-relax mass constraint norm (*%.1f)\n\n", gv.it_1, gv.ur_1);}; gv.status = 1; iterate = 0;}
diff --git a/docs/_modules/dump_function.c.html b/docs/_modules/dump_function.c.html
index 4aa28aa0..7e007698 100644
--- a/docs/_modules/dump_function.c.html
+++ b/docs/_modules/dump_function.c.html
@@ -137,11 +137,7 @@
Access output structure
-Provide custom bulk rock composition
-
+Provide custom bulk rock composition
diff --git a/docs/_modules/gem_function.c.html b/docs/_modules/gem_function.c.html
index 59bc2c18..7e103b2a 100644
--- a/docs/_modules/gem_function.c.html
+++ b/docs/_modules/gem_function.c.html
@@ -137,11 +137,7 @@
Access output structure
-Provide custom bulk rock composition
-
+Provide custom bulk rock composition
diff --git a/docs/_modules/gss_function.c.html b/docs/_modules/gss_function.c.html
index 6db8bc16..0c0c7949 100644
--- a/docs/_modules/gss_function.c.html
+++ b/docs/_modules/gss_function.c.html
@@ -137,11 +137,7 @@
Access output structure
-Provide custom bulk rock composition
-
+Provide custom bulk rock composition
@@ -277,40 +273,1719 @@ Source code for gss_function.c
}
}
-void init_pp(int len_ox, void *PP_db ){
- PP_ref *d = (PP_ref *) PP_db;
- for (int i = 0; i < len_ox; i++){
- d->Comp[i] = 0.0;
- }
+void init_pp(int len_ox, void *PP_db ){
+ PP_ref *d = (PP_ref *) PP_db;
+ for (int i = 0; i < len_ox; i++){
+ d->Comp[i] = 0.0;
+ }
+}
+
+
+/**
+ function to easely get gb and comp in order to define solid solutions
+*/
+typedef struct em_datas{
+ double C[15];
+ double ElShearMod;
+ double gb;
+} em_data;
+
+em_data get_em_data( int EM_database,
+ int len_ox,
+ bulk_info z_b,
+ double P,
+ double T,
+ char *name,
+ char *state ){
+
+ em_data data;
+ PP_ref PP_db = G_EM_function(EM_database, len_ox, z_b.bulk_rock, z_b.apo, P, T, name, state);
+ data.ElShearMod = PP_db.phase_shearModulus;
+ data.gb = PP_db.gbase;
+
+ for (int i = 0; i < len_ox; i++){
+ data.C[i] = PP_db.Comp[i];
+ }
+ return data;
+}
+
+[docs]/**
+ retrieve reference thermodynamic data for mp_liq
+*/
+SS_ref G_SS_mp_liq_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"q4L","abL","kspL","anL","slL","fo2L","fa2L","h2oL"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = 12.0 - 0.4*SS_ref_db.P;
+ SS_ref_db.W[1] = -0.5*SS_ref_db.P - 2.0;
+ SS_ref_db.W[2] = 5.0;
+ SS_ref_db.W[3] = 12.0;
+ SS_ref_db.W[4] = 12.0 - 0.4*SS_ref_db.P;
+ SS_ref_db.W[5] = 14.0;
+ SS_ref_db.W[6] = 17.0 - 0.5*SS_ref_db.P;
+ SS_ref_db.W[7] = 3.0*SS_ref_db.P - 6.0;
+ SS_ref_db.W[8] = 0.0;
+ SS_ref_db.W[9] = 12.0;
+ SS_ref_db.W[10] = 10.0;
+ SS_ref_db.W[11] = 2.0;
+ SS_ref_db.W[12] = -0.3*SS_ref_db.P - 1.5;
+ SS_ref_db.W[13] = -SS_ref_db.P;
+ SS_ref_db.W[14] = 12.0;
+ SS_ref_db.W[15] = 12.0;
+ SS_ref_db.W[16] = 12.0;
+ SS_ref_db.W[17] = 9.5 - 0.3*SS_ref_db.P;
+ SS_ref_db.W[18] = 0.0;
+ SS_ref_db.W[19] = 0.0;
+ SS_ref_db.W[20] = 0.0;
+ SS_ref_db.W[21] = 7.5 - 0.5*SS_ref_db.P;
+ SS_ref_db.W[22] = 12.0;
+ SS_ref_db.W[23] = 12.0;
+ SS_ref_db.W[24] = 11.0;
+ SS_ref_db.W[25] = 18.0;
+ SS_ref_db.W[26] = 11.0- 0.5*SS_ref_db.P;
+ SS_ref_db.W[27] = 12.0;
+
+
+ em_data qL_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "qL",
+ "equilibrium" );
+
+ em_data abL_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "abL",
+ "equilibrium" );
+
+ em_data kspL_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "kspL",
+ "equilibrium" );
+
+ em_data anL_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "anL",
+ "equilibrium" );
+
+ em_data silL_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "silL",
+ "equilibrium" );
+
+ em_data foL_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "foL",
+ "equilibrium" );
+
+ em_data faL_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "faL",
+ "equilibrium" );
+
+ em_data h2oL_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "h2oL",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = 4.0*qL_eq.gb;
+ SS_ref_db.gbase[1] = abL_eq.gb;
+ SS_ref_db.gbase[2] = kspL_eq.gb;
+ SS_ref_db.gbase[3] = anL_eq.gb;
+ SS_ref_db.gbase[4] = 1.6*silL_eq.gb - 23.0;
+ SS_ref_db.gbase[5] = 2.0*foL_eq.gb - 10.0;
+ SS_ref_db.gbase[6] = -1.3*z_b.P + 2.0*faL_eq.gb - 9.0;
+ SS_ref_db.gbase[7] = h2oL_eq.gb;
+
+ SS_ref_db.ElShearMod[0] = 4.0*qL_eq.ElShearMod;
+ SS_ref_db.ElShearMod[1] = abL_eq.ElShearMod;
+ SS_ref_db.ElShearMod[2] = kspL_eq.ElShearMod;
+ SS_ref_db.ElShearMod[3] = anL_eq.ElShearMod;
+ SS_ref_db.ElShearMod[4] = 1.6*silL_eq.ElShearMod;
+ SS_ref_db.ElShearMod[5] = 2.0*foL_eq.ElShearMod;
+ SS_ref_db.ElShearMod[6] = 2.0*faL_eq.ElShearMod;
+ SS_ref_db.ElShearMod[7] = h2oL_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = 4.0*qL_eq.C[i];
+ SS_ref_db.Comp[1][i] = abL_eq.C[i];
+ SS_ref_db.Comp[2][i] = kspL_eq.C[i];
+ SS_ref_db.Comp[3][i] = anL_eq.C[i];
+ SS_ref_db.Comp[4][i] = 1.6*silL_eq.C[i];
+ SS_ref_db.Comp[5][i] = 2.0*foL_eq.C[i];
+ SS_ref_db.Comp[6][i] = 2.0*faL_eq.C[i];
+ SS_ref_db.Comp[7][i] = h2oL_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[2][0] = 0.0+eps; SS_ref_db.bounds_ref[2][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[3][0] = 0.0+eps; SS_ref_db.bounds_ref[3][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[4][0] = 0.0+eps; SS_ref_db.bounds_ref[4][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[5][0] = 0.0+eps; SS_ref_db.bounds_ref[5][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[6][0] = 0.0+eps; SS_ref_db.bounds_ref[6][1] = 1.0-eps;
+
+ return SS_ref_db;
+}
+
+[docs]/**
+ retrieve reference thermodynamic data for mp_bi
+*/
+SS_ref G_SS_mp_bi_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"phl","annm","obi","east","tbi","fbi","mmbi"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = 12.0;
+ SS_ref_db.W[1] = 4.0;
+ SS_ref_db.W[2] = 10.0;
+ SS_ref_db.W[3] = 30.0;
+ SS_ref_db.W[4] = 8.0;
+ SS_ref_db.W[5] = 9.0;
+ SS_ref_db.W[6] = 8.0;
+ SS_ref_db.W[7] = 15.0;
+ SS_ref_db.W[8] = 32.0;
+ SS_ref_db.W[9] = 13.6;
+ SS_ref_db.W[10] = 6.3;
+ SS_ref_db.W[11] = 7.0;
+ SS_ref_db.W[12] = 24.0;
+ SS_ref_db.W[13] = 5.6;
+ SS_ref_db.W[14] = 8.1;
+ SS_ref_db.W[15] = 40.0;
+ SS_ref_db.W[16] = 1.0;
+ SS_ref_db.W[17] = 13.0;
+ SS_ref_db.W[18] = 40.0;
+ SS_ref_db.W[19] = 30.0;
+ SS_ref_db.W[20] = 11.6;
+
+
+ em_data phl_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "phl",
+ "equilibrium" );
+
+ em_data ann_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "ann",
+ "equilibrium" );
+
+ em_data east_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "east",
+ "equilibrium" );
+
+ em_data br_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "br",
+ "equilibrium" );
+
+ em_data ru_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "ru",
+ "equilibrium" );
+
+ em_data andr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "andr",
+ "equilibrium" );
+
+ em_data gr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "gr",
+ "equilibrium" );
+
+ em_data mnbi_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "mnbi",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = phl_eq.gb;
+ SS_ref_db.gbase[1] = ann_eq.gb - 3.0;
+ SS_ref_db.gbase[2] = 0.333333333333333*ann_eq.gb + 0.666666666666667*phl_eq.gb - 3.0;
+ SS_ref_db.gbase[3] = east_eq.gb;
+ SS_ref_db.gbase[4] = -1.0*br_eq.gb + phl_eq.gb + ru_eq.gb + 55.0;
+ SS_ref_db.gbase[5] = 0.5*andr_eq.gb + east_eq.gb - 0.5*gr_eq.gb - 3.0;
+ SS_ref_db.gbase[6] = mnbi_eq.gb - 7.89;
+
+ SS_ref_db.ElShearMod[0] = phl_eq.ElShearMod;
+ SS_ref_db.ElShearMod[1] = ann_eq.ElShearMod;
+ SS_ref_db.ElShearMod[2] = 0.333333333333333*ann_eq.ElShearMod + 0.666666666666667*phl_eq.ElShearMod;
+ SS_ref_db.ElShearMod[3] = east_eq.ElShearMod;
+ SS_ref_db.ElShearMod[4] = -1.0*br_eq.ElShearMod + phl_eq.ElShearMod + ru_eq.ElShearMod;
+ SS_ref_db.ElShearMod[5] = 0.5*andr_eq.ElShearMod + east_eq.ElShearMod - 0.5*gr_eq.ElShearMod;
+ SS_ref_db.ElShearMod[6] = mnbi_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = phl_eq.C[i];
+ SS_ref_db.Comp[1][i] = ann_eq.C[i];
+ SS_ref_db.Comp[2][i] = 0.333333333333333*ann_eq.C[i] + 0.666666666666667*phl_eq.C[i];
+ SS_ref_db.Comp[3][i] = east_eq.C[i];
+ SS_ref_db.Comp[4][i] = -1.0*br_eq.C[i] + phl_eq.C[i] + ru_eq.C[i];
+ SS_ref_db.Comp[5][i] = 0.5*andr_eq.C[i] + east_eq.C[i] - 0.5*gr_eq.C[i];
+ SS_ref_db.Comp[6][i] = mnbi_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[2][0] = 0.0+eps; SS_ref_db.bounds_ref[2][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[3][0] = 0.0+eps; SS_ref_db.bounds_ref[3][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[4][0] = 0.0+eps; SS_ref_db.bounds_ref[4][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[5][0] = 0.0+eps; SS_ref_db.bounds_ref[5][1] = 1.0-eps;
+
+ return SS_ref_db;
+}
+
+[docs]/**
+ retrieve reference thermodynamic data for mp_cd
+*/
+SS_ref G_SS_mp_cd_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"crd","fcrd","hcrd","mncd"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = 8.0;
+ SS_ref_db.W[1] = 0.0;
+ SS_ref_db.W[2] = 6.0;
+ SS_ref_db.W[3] = 9.0;
+ SS_ref_db.W[4] = 7.0;
+ SS_ref_db.W[5] = 6.0;
+
+
+ em_data crd_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "crd",
+ "equilibrium" );
+
+ em_data fcrd_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "fcrd",
+ "equilibrium" );
+
+ em_data hcrd_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "hcrd",
+ "equilibrium" );
+
+ em_data mncrd_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "mncrd",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = crd_eq.gb;
+ SS_ref_db.gbase[1] = fcrd_eq.gb;
+ SS_ref_db.gbase[2] = hcrd_eq.gb;
+ SS_ref_db.gbase[3] = mncrd_eq.gb - 4.21;
+
+ SS_ref_db.ElShearMod[0] = crd_eq.ElShearMod;
+ SS_ref_db.ElShearMod[1] = fcrd_eq.ElShearMod;
+ SS_ref_db.ElShearMod[2] = hcrd_eq.ElShearMod;
+ SS_ref_db.ElShearMod[3] = mncrd_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = crd_eq.C[i];
+ SS_ref_db.Comp[1][i] = fcrd_eq.C[i];
+ SS_ref_db.Comp[2][i] = hcrd_eq.C[i];
+ SS_ref_db.Comp[3][i] = mncrd_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[2][0] = 0.0+eps; SS_ref_db.bounds_ref[2][1] = 1.0-eps;
+
+ return SS_ref_db;
+}
+
+[docs]/**
+ retrieve reference thermodynamic data for mp_chl
+*/
+SS_ref G_SS_mp_chl_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"clin","afchl","ames","daph","ochl1","ochl4","f3clin","mmchl"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = 17.0;
+ SS_ref_db.W[1] = 17.0;
+ SS_ref_db.W[2] = 20.0;
+ SS_ref_db.W[3] = 30.0;
+ SS_ref_db.W[4] = 21.0;
+ SS_ref_db.W[5] = 2.0;
+ SS_ref_db.W[6] = 6.0;
+ SS_ref_db.W[7] = 16.0;
+ SS_ref_db.W[8] = 37.0;
+ SS_ref_db.W[9] = 20.0;
+ SS_ref_db.W[10] = 4.0;
+ SS_ref_db.W[11] = 15.0;
+ SS_ref_db.W[12] = 23.0;
+ SS_ref_db.W[13] = 30.0;
+ SS_ref_db.W[14] = 29.0;
+ SS_ref_db.W[15] = 13.0;
+ SS_ref_db.W[16] = 19.0;
+ SS_ref_db.W[17] = 17.0;
+ SS_ref_db.W[18] = 18.0;
+ SS_ref_db.W[19] = 33.0;
+ SS_ref_db.W[20] = 22.0;
+ SS_ref_db.W[21] = 4.0;
+ SS_ref_db.W[22] = 24.0;
+ SS_ref_db.W[23] = 28.6;
+ SS_ref_db.W[24] = 19.0;
+ SS_ref_db.W[25] = 19.0;
+ SS_ref_db.W[26] = 22.0;
+ SS_ref_db.W[27] = 8.0;
+
+
+ em_data clin_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "clin",
+ "equilibrium" );
+
+ em_data afchl_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "afchl",
+ "equilibrium" );
+
+ em_data ames_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "ames",
+ "equilibrium" );
+
+ em_data daph_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "daph",
+ "equilibrium" );
+
+ em_data gr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "gr",
+ "equilibrium" );
+
+ em_data andr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "andr",
+ "equilibrium" );
+
+ em_data mnchl_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "mnchl",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = clin_eq.gb;
+ SS_ref_db.gbase[1] = afchl_eq.gb;
+ SS_ref_db.gbase[2] = ames_eq.gb;
+ SS_ref_db.gbase[3] = daph_eq.gb;
+ SS_ref_db.gbase[4] = afchl_eq.gb - 1.0*clin_eq.gb + daph_eq.gb + 3.0;
+ SS_ref_db.gbase[5] = afchl_eq.gb - 0.2*clin_eq.gb + 0.2*daph_eq.gb + 2.4;
+ SS_ref_db.gbase[6] = 0.5*andr_eq.gb + clin_eq.gb - 0.5*gr_eq.gb + 2.0;
+ SS_ref_db.gbase[7] = mnchl_eq.gb - 5.67;
+
+ SS_ref_db.ElShearMod[0] = clin_eq.ElShearMod;
+ SS_ref_db.ElShearMod[1] = afchl_eq.ElShearMod;
+ SS_ref_db.ElShearMod[2] = ames_eq.ElShearMod;
+ SS_ref_db.ElShearMod[3] = daph_eq.ElShearMod;
+ SS_ref_db.ElShearMod[4] = afchl_eq.ElShearMod - 1.0*clin_eq.ElShearMod + daph_eq.ElShearMod;
+ SS_ref_db.ElShearMod[5] = afchl_eq.ElShearMod - 0.2*clin_eq.ElShearMod + 0.2*daph_eq.ElShearMod;
+ SS_ref_db.ElShearMod[6] = 0.5*andr_eq.ElShearMod + clin_eq.ElShearMod - 0.5*gr_eq.ElShearMod;
+ SS_ref_db.ElShearMod[7] = mnchl_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = clin_eq.C[i];
+ SS_ref_db.Comp[1][i] = afchl_eq.C[i];
+ SS_ref_db.Comp[2][i] = ames_eq.C[i];
+ SS_ref_db.Comp[3][i] = daph_eq.C[i];
+ SS_ref_db.Comp[4][i] = afchl_eq.C[i] - 1.0*clin_eq.C[i] + daph_eq.C[i];
+ SS_ref_db.Comp[5][i] = afchl_eq.C[i] - 0.2*clin_eq.C[i] + 0.2*daph_eq.C[i];
+ SS_ref_db.Comp[6][i] = 0.5*andr_eq.C[i] + clin_eq.C[i] - 0.5*gr_eq.C[i];
+ SS_ref_db.Comp[7][i] = mnchl_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[2][0] = 0.0+eps; SS_ref_db.bounds_ref[2][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[3][0] = 0.0+eps; SS_ref_db.bounds_ref[3][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[4][0] = -1.0+eps; SS_ref_db.bounds_ref[4][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[5][0] = -1.0+eps; SS_ref_db.bounds_ref[5][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[6][0] = -1.0+eps; SS_ref_db.bounds_ref[6][1] = 1.0-eps;
+
+ return SS_ref_db;
+}
+
+[docs]/**
+ retrieve reference thermodynamic data for mp_ctd
+*/
+SS_ref G_SS_mp_ctd_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"mctd","fctd","mnct","ctdo"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = 4.0;
+ SS_ref_db.W[1] = 3.0;
+ SS_ref_db.W[2] = 1.0;
+ SS_ref_db.W[3] = 3.0;
+ SS_ref_db.W[4] = 5.0;
+ SS_ref_db.W[5] = 4.0;
+
+
+ em_data mctd_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "mctd",
+ "equilibrium" );
+
+ em_data fctd_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "fctd",
+ "equilibrium" );
+
+ em_data mnctd_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "mnctd",
+ "equilibrium" );
+
+ em_data andr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "andr",
+ "equilibrium" );
+
+ em_data gr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "gr",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = mctd_eq.gb;
+ SS_ref_db.gbase[1] = fctd_eq.gb;
+ SS_ref_db.gbase[2] = mnctd_eq.gb + 0.66;
+ SS_ref_db.gbase[3] = 0.25*andr_eq.gb - 0.25*gr_eq.gb + mctd_eq.gb + 13.5;
+
+ SS_ref_db.ElShearMod[0] = mctd_eq.ElShearMod;
+ SS_ref_db.ElShearMod[1] = fctd_eq.ElShearMod;
+ SS_ref_db.ElShearMod[2] = mnctd_eq.ElShearMod;
+ SS_ref_db.ElShearMod[3] = 0.25*andr_eq.ElShearMod - 0.25*gr_eq.ElShearMod + mctd_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = mctd_eq.C[i];
+ SS_ref_db.Comp[1][i] = fctd_eq.C[i];
+ SS_ref_db.Comp[2][i] = mnctd_eq.C[i];
+ SS_ref_db.Comp[3][i] = 0.25*andr_eq.C[i] - 0.25*gr_eq.C[i] + mctd_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[2][0] = 0.0+eps; SS_ref_db.bounds_ref[2][1] = 1.0-eps;
+
+ return SS_ref_db;
+}
+
+[docs]/**
+ retrieve reference thermodynamic data for mp_ep
+*/
+SS_ref G_SS_mp_ep_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"cz","ep","fep"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = 1.0;
+ SS_ref_db.W[1] = 3.0;
+ SS_ref_db.W[2] = 1.0;
+
+
+ em_data cz_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "cz",
+ "equilibrium" );
+
+ em_data ep_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "ep",
+ "equilibrium" );
+
+ em_data fep_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "fep",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = cz_eq.gb;
+ SS_ref_db.gbase[1] = ep_eq.gb;
+ SS_ref_db.gbase[2] = fep_eq.gb;
+
+ SS_ref_db.ElShearMod[0] = cz_eq.ElShearMod;
+ SS_ref_db.ElShearMod[1] = ep_eq.ElShearMod;
+ SS_ref_db.ElShearMod[2] = fep_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = cz_eq.C[i];
+ SS_ref_db.Comp[1][i] = ep_eq.C[i];
+ SS_ref_db.Comp[2][i] = fep_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 0.5-eps;
+
+ return SS_ref_db;
+}
+
+[docs]/**
+ retrieve reference thermodynamic data for mp_g
+*/
+SS_ref G_SS_mp_g_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"py","alm","spss","gr","kho"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = 2.5;
+ SS_ref_db.W[1] = 2.0;
+ SS_ref_db.W[2] = 31.0;
+ SS_ref_db.W[3] = 5.4;
+ SS_ref_db.W[4] = 2.0;
+ SS_ref_db.W[5] = 5.0;
+ SS_ref_db.W[6] = 22.6;
+ SS_ref_db.W[7] = 0.0;
+ SS_ref_db.W[8] = 29.4;
+ SS_ref_db.W[9] = -15.3;
+
+ SS_ref_db.v[0] = 1.0;
+ SS_ref_db.v[1] = 1.0;
+ SS_ref_db.v[2] = 1.0;
+ SS_ref_db.v[3] = 2.7;
+ SS_ref_db.v[4] = 1.0;
+
+
+ em_data py_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "py",
+ "equilibrium" );
+
+ em_data alm_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "alm",
+ "equilibrium" );
+
+ em_data spss_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "spss",
+ "equilibrium" );
+
+ em_data gr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "gr",
+ "equilibrium" );
+
+ em_data andr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "andr",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = py_eq.gb;
+ SS_ref_db.gbase[1] = alm_eq.gb;
+ SS_ref_db.gbase[2] = spss_eq.gb;
+ SS_ref_db.gbase[3] = gr_eq.gb;
+ SS_ref_db.gbase[4] = andr_eq.gb - 1.0*gr_eq.gb + py_eq.gb + 27.0;
+
+ SS_ref_db.ElShearMod[0] = py_eq.ElShearMod;
+ SS_ref_db.ElShearMod[1] = alm_eq.ElShearMod;
+ SS_ref_db.ElShearMod[2] = spss_eq.ElShearMod;
+ SS_ref_db.ElShearMod[3] = gr_eq.ElShearMod;
+ SS_ref_db.ElShearMod[4] = andr_eq.ElShearMod - 1.0*gr_eq.ElShearMod + py_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = py_eq.C[i];
+ SS_ref_db.Comp[1][i] = alm_eq.C[i];
+ SS_ref_db.Comp[2][i] = spss_eq.C[i];
+ SS_ref_db.Comp[3][i] = gr_eq.C[i];
+ SS_ref_db.Comp[4][i] = andr_eq.C[i] - 1.0*gr_eq.C[i] + py_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[2][0] = 0.0+eps; SS_ref_db.bounds_ref[2][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[3][0] = 0.0+eps; SS_ref_db.bounds_ref[3][1] = 1.0-eps;
+
+ return SS_ref_db;
+}
+
+[docs]/**
+ retrieve reference thermodynamic data for mp_ilm
+*/
+SS_ref G_SS_mp_ilm_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"oilm","dilm","dhem","geik","pnt"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = 15.6;
+ SS_ref_db.W[1] = 26.6;
+ SS_ref_db.W[2] = 4.0;
+ SS_ref_db.W[3] = 2.0;
+ SS_ref_db.W[4] = 11.0;
+ SS_ref_db.W[5] = 4.0;
+ SS_ref_db.W[6] = 2.0;
+ SS_ref_db.W[7] = 36.0;
+ SS_ref_db.W[8] = 25.0;
+ SS_ref_db.W[9] = 4.0;
+
+
+ em_data ilm_di = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "ilm",
+ "disordered" );
+
+ em_data hem_di = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "hem",
+ "disordered" );
+
+ em_data geik_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "geik",
+ "equilibrium" );
+
+ em_data pnt_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "pnt",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = 0.009426*z_b.T + ilm_di.gb - 13.6075;
+ SS_ref_db.gbase[1] = -0.0021*z_b.T + ilm_di.gb + 1.9928;
+ SS_ref_db.gbase[2] = hem_di.gb;
+ SS_ref_db.gbase[3] = geik_eq.gb;
+ SS_ref_db.gbase[4] = pnt_eq.gb;
+
+ SS_ref_db.ElShearMod[0] = ilm_di.ElShearMod;
+ SS_ref_db.ElShearMod[1] = ilm_di.ElShearMod;
+ SS_ref_db.ElShearMod[2] = hem_di.ElShearMod;
+ SS_ref_db.ElShearMod[3] = geik_eq.ElShearMod;
+ SS_ref_db.ElShearMod[4] = pnt_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = ilm_di.C[i];
+ SS_ref_db.Comp[1][i] = ilm_di.C[i];
+ SS_ref_db.Comp[2][i] = hem_di.C[i];
+ SS_ref_db.Comp[3][i] = geik_eq.C[i];
+ SS_ref_db.Comp[4][i] = pnt_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[2][0] = 0.0+eps; SS_ref_db.bounds_ref[2][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[3][0] = -1.0+eps; SS_ref_db.bounds_ref[3][1] = 1.0-eps;
+
+ return SS_ref_db;
+}
+
+[docs]/**
+ retrieve reference thermodynamic data for mp_ma
+*/
+SS_ref G_SS_mp_ma_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"mut","celt","fcelt","pat","ma","fmu"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = 0.2*SS_ref_db.P;
+ SS_ref_db.W[1] = 0.2*SS_ref_db.P;
+ SS_ref_db.W[2] = 0.353*SS_ref_db.P + 0.0034*SS_ref_db.T + 10.12;
+ SS_ref_db.W[3] = 34.0;
+ SS_ref_db.W[4] = 0.0;
+ SS_ref_db.W[5] = 0.0;
+ SS_ref_db.W[6] = 0.25*SS_ref_db.P + 45.0;
+ SS_ref_db.W[7] = 50.0;
+ SS_ref_db.W[8] = 0.0;
+ SS_ref_db.W[9] = 0.25*SS_ref_db.P + 45.0;
+ SS_ref_db.W[10] = 50.0;
+ SS_ref_db.W[11] = 0.0;
+ SS_ref_db.W[12] = 18.0;
+ SS_ref_db.W[13] = 30.0;
+ SS_ref_db.W[14] = 35.0;
+
+ SS_ref_db.v[0] = 0.63;
+ SS_ref_db.v[1] = 0.63;
+ SS_ref_db.v[2] = 0.63;
+ SS_ref_db.v[3] = 0.37;
+ SS_ref_db.v[4] = 0.63;
+ SS_ref_db.v[5] = 0.63;
+
+
+ em_data mu_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "mu",
+ "equilibrium" );
+
+ em_data cel_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "cel",
+ "equilibrium" );
+
+ em_data fcel_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "fcel",
+ "equilibrium" );
+
+ em_data pa_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "pa",
+ "equilibrium" );
+
+ em_data ma_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "ma",
+ "equilibrium" );
+
+ em_data andr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "andr",
+ "equilibrium" );
+
+ em_data gr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "gr",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = mu_eq.gb + 1.0;
+ SS_ref_db.gbase[1] = cel_eq.gb + 5.0;
+ SS_ref_db.gbase[2] = fcel_eq.gb + 5.0;
+ SS_ref_db.gbase[3] = pa_eq.gb + 4.0;
+ SS_ref_db.gbase[4] = ma_eq.gb;
+ SS_ref_db.gbase[5] = 0.5*andr_eq.gb - 0.5*gr_eq.gb + mu_eq.gb + 25.0;
+
+ SS_ref_db.ElShearMod[0] = mu_eq.ElShearMod;
+ SS_ref_db.ElShearMod[1] = cel_eq.ElShearMod;
+ SS_ref_db.ElShearMod[2] = fcel_eq.ElShearMod;
+ SS_ref_db.ElShearMod[3] = pa_eq.ElShearMod;
+ SS_ref_db.ElShearMod[4] = ma_eq.ElShearMod;
+ SS_ref_db.ElShearMod[5] = 0.5*andr_eq.ElShearMod - 0.5*gr_eq.ElShearMod + mu_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = mu_eq.C[i];
+ SS_ref_db.Comp[1][i] = cel_eq.C[i];
+ SS_ref_db.Comp[2][i] = fcel_eq.C[i];
+ SS_ref_db.Comp[3][i] = pa_eq.C[i];
+ SS_ref_db.Comp[4][i] = ma_eq.C[i];
+ SS_ref_db.Comp[5][i] = 0.5*andr_eq.C[i] - 0.5*gr_eq.C[i] + mu_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[2][0] = 0.0+eps; SS_ref_db.bounds_ref[2][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[3][0] = 0.0+eps; SS_ref_db.bounds_ref[3][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[4][0] = 0.0+eps; SS_ref_db.bounds_ref[4][1] = 1.0-eps;
+
+ return SS_ref_db;
+}
+
+[docs]/**
+ retrieve reference thermodynamic data for mp_mt
+*/
+SS_ref G_SS_mp_mt_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"imt","dmt","usp"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = 2.4;
+ SS_ref_db.W[1] = 1.0;
+ SS_ref_db.W[2] = -5.0;
+
+
+ em_data mt_di = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "mt",
+ "disordered" );
+
+ em_data usp_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "usp",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = 0.003166*z_b.T + mt_di.gb - 1.8595;
+ SS_ref_db.gbase[1] = -0.001184*z_b.T + mt_di.gb + 1.3305;
+ SS_ref_db.gbase[2] = usp_eq.gb;
+
+ SS_ref_db.ElShearMod[0] = mt_di.ElShearMod;
+ SS_ref_db.ElShearMod[1] = mt_di.ElShearMod;
+ SS_ref_db.ElShearMod[2] = usp_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = mt_di.C[i];
+ SS_ref_db.Comp[1][i] = mt_di.C[i];
+ SS_ref_db.Comp[2][i] = usp_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 1.0-eps;
+
+ return SS_ref_db;
+}
+
+[docs]/**
+ retrieve reference thermodynamic data for mp_mu
+*/
+SS_ref G_SS_mp_mu_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"mut","cel","fcel","pat","ma","fmu"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = 0.2*SS_ref_db.P;
+ SS_ref_db.W[1] = 0.2*SS_ref_db.P;
+ SS_ref_db.W[2] = 0.353*SS_ref_db.P + 0.0034*SS_ref_db.T + 10.12;
+ SS_ref_db.W[3] = 35.0;
+ SS_ref_db.W[4] = 0.0;
+ SS_ref_db.W[5] = 0.0;
+ SS_ref_db.W[6] = 0.25*SS_ref_db.P + 45.0;
+ SS_ref_db.W[7] = 50.0;
+ SS_ref_db.W[8] = 0.0;
+ SS_ref_db.W[9] = 0.25*SS_ref_db.P + 45.0;
+ SS_ref_db.W[10] = 50.0;
+ SS_ref_db.W[11] = 0.0;
+ SS_ref_db.W[12] = 15.0;
+ SS_ref_db.W[13] = 30.0;
+ SS_ref_db.W[14] = 35.0;
+
+ SS_ref_db.v[0] = 0.63;
+ SS_ref_db.v[1] = 0.63;
+ SS_ref_db.v[2] = 0.63;
+ SS_ref_db.v[3] = 0.37;
+ SS_ref_db.v[4] = 0.63;
+ SS_ref_db.v[5] = 0.63;
+
+
+ em_data mu_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "mu",
+ "equilibrium" );
+
+ em_data cel_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "cel",
+ "equilibrium" );
+
+ em_data fcel_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "fcel",
+ "equilibrium" );
+
+ em_data pa_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "pa",
+ "equilibrium" );
+
+ em_data ma_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "ma",
+ "equilibrium" );
+
+ em_data andr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "andr",
+ "equilibrium" );
+
+ em_data gr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "gr",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = mu_eq.gb;
+ SS_ref_db.gbase[1] = cel_eq.gb;
+ SS_ref_db.gbase[2] = fcel_eq.gb;
+ SS_ref_db.gbase[3] = pa_eq.gb;
+ SS_ref_db.gbase[4] = ma_eq.gb + 5.0;
+ SS_ref_db.gbase[5] = 0.5*andr_eq.gb - 0.5*gr_eq.gb + mu_eq.gb + 25.0;
+
+ SS_ref_db.ElShearMod[0] = mu_eq.ElShearMod;
+ SS_ref_db.ElShearMod[1] = cel_eq.ElShearMod;
+ SS_ref_db.ElShearMod[2] = fcel_eq.ElShearMod;
+ SS_ref_db.ElShearMod[3] = pa_eq.ElShearMod;
+ SS_ref_db.ElShearMod[4] = ma_eq.ElShearMod;
+ SS_ref_db.ElShearMod[5] = 0.5*andr_eq.ElShearMod - 0.5*gr_eq.ElShearMod + mu_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = mu_eq.C[i];
+ SS_ref_db.Comp[1][i] = cel_eq.C[i];
+ SS_ref_db.Comp[2][i] = fcel_eq.C[i];
+ SS_ref_db.Comp[3][i] = pa_eq.C[i];
+ SS_ref_db.Comp[4][i] = ma_eq.C[i];
+ SS_ref_db.Comp[5][i] = 0.5*andr_eq.C[i] - 0.5*gr_eq.C[i] + mu_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[2][0] = 0.0+eps; SS_ref_db.bounds_ref[2][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[3][0] = 0.0+eps; SS_ref_db.bounds_ref[3][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[4][0] = 0.0+eps; SS_ref_db.bounds_ref[4][1] = 1.0-eps;
+
+ return SS_ref_db;
+}
+
+[docs]/**
+ retrieve reference thermodynamic data for mp_opx
+*/
+SS_ref G_SS_mp_opx_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"en","fs","fm","mgts","fopx","mnopx","odi"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = 7.0;
+ SS_ref_db.W[1] = 4.0;
+ SS_ref_db.W[2] = 13.0 - 0.15*SS_ref_db.P;
+ SS_ref_db.W[3] = 11.0 - 0.15*SS_ref_db.P;
+ SS_ref_db.W[4] = 5.0;
+ SS_ref_db.W[5] = 0.12*SS_ref_db.P + 32.2;
+ SS_ref_db.W[6] = 4.0;
+ SS_ref_db.W[7] = 13.0 - 0.15*SS_ref_db.P;
+ SS_ref_db.W[8] = 11.6 - 0.15*SS_ref_db.P;
+ SS_ref_db.W[9] = 4.2;
+ SS_ref_db.W[10] = 0.084*SS_ref_db.P + 25.54;
+ SS_ref_db.W[11] = 17.0 - 0.15*SS_ref_db.P;
+ SS_ref_db.W[12] = 15.0 - 0.15*SS_ref_db.P;
+ SS_ref_db.W[13] = 5.1;
+ SS_ref_db.W[14] = 0.084*SS_ref_db.P + 22.54;
+ SS_ref_db.W[15] = 1.0;
+ SS_ref_db.W[16] = 12.0 - 0.15*SS_ref_db.P;
+ SS_ref_db.W[17] = 75.4 - 0.94*SS_ref_db.P;
+ SS_ref_db.W[18] = 10.6 - 0.15*SS_ref_db.P;
+ SS_ref_db.W[19] = 73.4 - 0.94*SS_ref_db.P;
+ SS_ref_db.W[20] = 0.084*SS_ref_db.P + 24.54;
+
+ SS_ref_db.v[0] = 1.0;
+ SS_ref_db.v[1] = 1.0;
+ SS_ref_db.v[2] = 1.0;
+ SS_ref_db.v[3] = 1.0;
+ SS_ref_db.v[4] = 1.0;
+ SS_ref_db.v[5] = 1.0;
+ SS_ref_db.v[6] = 1.2;
+
+
+ em_data en_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "en",
+ "equilibrium" );
+
+ em_data fs_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "fs",
+ "equilibrium" );
+
+ em_data mgts_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "mgts",
+ "equilibrium" );
+
+ em_data andr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "andr",
+ "equilibrium" );
+
+ em_data gr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "gr",
+ "equilibrium" );
+
+ em_data pxmn_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "pxmn",
+ "equilibrium" );
+
+ em_data di_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "di",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = en_eq.gb;
+ SS_ref_db.gbase[1] = fs_eq.gb;
+ SS_ref_db.gbase[2] = 0.5*en_eq.gb + 0.5*fs_eq.gb - 6.6;
+ SS_ref_db.gbase[3] = mgts_eq.gb;
+ SS_ref_db.gbase[4] = 0.5*andr_eq.gb - 0.5*gr_eq.gb + mgts_eq.gb + 2.0;
+ SS_ref_db.gbase[5] = 2.0*pxmn_eq.gb + 6.68;
+ SS_ref_db.gbase[6] = 0.005*z_b.P + 0.000211*z_b.T + di_eq.gb - 0.1;
+
+ SS_ref_db.ElShearMod[0] = en_eq.ElShearMod;
+ SS_ref_db.ElShearMod[1] = fs_eq.ElShearMod;
+ SS_ref_db.ElShearMod[2] = 0.5*en_eq.ElShearMod + 0.5*fs_eq.ElShearMod;
+ SS_ref_db.ElShearMod[3] = mgts_eq.ElShearMod;
+ SS_ref_db.ElShearMod[4] = 0.5*andr_eq.ElShearMod - 0.5*gr_eq.ElShearMod + mgts_eq.ElShearMod;
+ SS_ref_db.ElShearMod[5] = 2.0*pxmn_eq.ElShearMod;
+ SS_ref_db.ElShearMod[6] = di_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = en_eq.C[i];
+ SS_ref_db.Comp[1][i] = fs_eq.C[i];
+ SS_ref_db.Comp[2][i] = 0.5*en_eq.C[i] + 0.5*fs_eq.C[i];
+ SS_ref_db.Comp[3][i] = mgts_eq.C[i];
+ SS_ref_db.Comp[4][i] = 0.5*andr_eq.C[i] - 0.5*gr_eq.C[i] + mgts_eq.C[i];
+ SS_ref_db.Comp[5][i] = 2.0*pxmn_eq.C[i];
+ SS_ref_db.Comp[6][i] = di_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[2][0] = 0.0+eps; SS_ref_db.bounds_ref[2][1] = 2.0-eps;
+ SS_ref_db.bounds_ref[3][0] = 0.0+eps; SS_ref_db.bounds_ref[3][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[4][0] = 0.0+eps; SS_ref_db.bounds_ref[4][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[5][0] = 0.0+eps; SS_ref_db.bounds_ref[5][1] = 1.0-eps;
+
+ return SS_ref_db;
+}
+
+[docs]/**
+ retrieve reference thermodynamic data for mp_pl4tr
+*/
+SS_ref G_SS_mp_pl4tr_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"ab","an","san"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = -0.04*SS_ref_db.P - 0.00935*SS_ref_db.T + 14.6;
+ SS_ref_db.W[1] = 0.338*SS_ref_db.P - 0.00957*SS_ref_db.T + 24.1;
+ SS_ref_db.W[2] = 48.5 - 0.13*SS_ref_db.P;
+
+ SS_ref_db.v[0] = 0.674;
+ SS_ref_db.v[1] = 0.55;
+ SS_ref_db.v[2] = 1.0;
+
+
+ em_data ab_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "ab",
+ "equilibrium" );
+
+ em_data an_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "an",
+ "equilibrium" );
+
+ em_data san_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "san",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = ab_eq.gb;
+ SS_ref_db.gbase[1] = an_eq.gb;
+ SS_ref_db.gbase[2] = san_eq.gb;
+
+ SS_ref_db.ElShearMod[0] = ab_eq.ElShearMod;
+ SS_ref_db.ElShearMod[1] = an_eq.ElShearMod;
+ SS_ref_db.ElShearMod[2] = san_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = ab_eq.C[i];
+ SS_ref_db.Comp[1][i] = an_eq.C[i];
+ SS_ref_db.Comp[2][i] = san_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 1.0-eps;
+
+ return SS_ref_db;
+}
+
+[docs]/**
+ retrieve reference thermodynamic data for mp_sa
+*/
+SS_ref G_SS_mp_sa_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"spr4","spr5","fspm","spro","ospr"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = 10. - 0.02*SS_ref_db.P;
+ SS_ref_db.W[1] = 16.;
+ SS_ref_db.W[2] = 12.;
+ SS_ref_db.W[3] = 8. - 0.02*SS_ref_db.P;
+ SS_ref_db.W[4] = 19. - 0.02*SS_ref_db.P;
+ SS_ref_db.W[5] = 22. - 0.02*SS_ref_db.P;
+ SS_ref_db.W[6] = 1.;
+ SS_ref_db.W[7] = 4.;
+ SS_ref_db.W[8] = 17.6 - 0.02*SS_ref_db.P;
+ SS_ref_db.W[9] = 20. - 0.02*SS_ref_db.P;
+
+
+ em_data spr4_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "spr4",
+ "equilibrium" );
+
+ em_data spr5_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "spr5",
+ "equilibrium" );
+
+ em_data fspr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "fspr",
+ "equilibrium" );
+
+ em_data gr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "gr",
+ "equilibrium" );
+
+ em_data andr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "andr",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = spr4_eq.gb;
+ SS_ref_db.gbase[1] = spr5_eq.gb;
+ SS_ref_db.gbase[2] = fspr_eq.gb - 2.0;
+ SS_ref_db.gbase[3] = 0.75*fspr_eq.gb + 0.25*spr4_eq.gb - 3.5;
+ SS_ref_db.gbase[4] = 0.5*andr_eq.gb - 0.5*gr_eq.gb + spr5_eq.gb - 16.0;
+
+ SS_ref_db.ElShearMod[0] = spr4_eq.ElShearMod;
+ SS_ref_db.ElShearMod[1] = spr5_eq.ElShearMod;
+ SS_ref_db.ElShearMod[2] = fspr_eq.ElShearMod;
+ SS_ref_db.ElShearMod[3] = 0.75*fspr_eq.ElShearMod + 0.25*spr4_eq.ElShearMod;
+ SS_ref_db.ElShearMod[4] = 0.5*andr_eq.ElShearMod - 0.5*gr_eq.ElShearMod + spr5_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = spr4_eq.C[i];
+ SS_ref_db.Comp[1][i] = spr5_eq.C[i];
+ SS_ref_db.Comp[2][i] = fspr_eq.C[i];
+ SS_ref_db.Comp[3][i] = 0.75*fspr_eq.C[i] + 0.25*spr4_eq.C[i];
+ SS_ref_db.Comp[4][i] = 0.5*andr_eq.C[i] - 0.5*gr_eq.C[i] + spr5_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[2][0] = 0.0+eps; SS_ref_db.bounds_ref[2][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[3][0] = -1.0+eps; SS_ref_db.bounds_ref[3][1] = 1.0-eps;
+
+ return SS_ref_db;
+}
+
+[docs]/**
+ retrieve reference thermodynamic data for mp_sp
+*/
+SS_ref G_SS_mp_sp_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"herc","sp","mt","usp"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = 16.;
+ SS_ref_db.W[1] = 2.;
+ SS_ref_db.W[2] = 20.;
+ SS_ref_db.W[3] = 18.;
+ SS_ref_db.W[4] = 36.;
+ SS_ref_db.W[5] = 30.;
+
+
+ em_data herc_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "herc",
+ "equilibrium" );
+
+ em_data sp_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "sp",
+ "equilibrium" );
+
+ em_data mt_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "mt",
+ "equilibrium" );
+
+ em_data usp_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "usp",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = herc_eq.gb;
+ SS_ref_db.gbase[1] = sp_eq.gb;
+ SS_ref_db.gbase[2] = mt_eq.gb;
+ SS_ref_db.gbase[3] = usp_eq.gb;
+
+ SS_ref_db.ElShearMod[0] = herc_eq.ElShearMod;
+ SS_ref_db.ElShearMod[1] = sp_eq.ElShearMod;
+ SS_ref_db.ElShearMod[2] = mt_eq.ElShearMod;
+ SS_ref_db.ElShearMod[3] = usp_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = herc_eq.C[i];
+ SS_ref_db.Comp[1][i] = sp_eq.C[i];
+ SS_ref_db.Comp[2][i] = mt_eq.C[i];
+ SS_ref_db.Comp[3][i] = usp_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[2][0] = 0.0+eps; SS_ref_db.bounds_ref[2][1] = 1.0-eps;
+
+ return SS_ref_db;
}
-
-/**
- function to easely get gb and comp in order to define solid solutions
+[docs]/**
+ retrieve reference thermodynamic data for mp_st
*/
-typedef struct em_datas{
- double C[15];
- double ElShearMod;
- double gb;
-} em_data;
-
-em_data get_em_data( int EM_database,
- int len_ox,
- bulk_info z_b,
- double P,
- double T,
- char *name,
- char *state ){
-
- em_data data;
- PP_ref PP_db = G_EM_function(EM_database, len_ox, z_b.bulk_rock, z_b.apo, P, T, name, state);
- data.ElShearMod = PP_db.phase_shearModulus;
- data.gb = PP_db.gbase;
-
- for (int i = 0; i < len_ox; i++){
- data.C[i] = PP_db.Comp[i];
- }
- return data;
+SS_ref G_SS_mp_st_function(SS_ref SS_ref_db, int EM_database, int len_ox, bulk_info z_b, double eps){
+
+ int i, j;
+ int n_em = SS_ref_db.n_em;
+
+ char *EM_tmp[] = {"mstm","fst","mnstm","msto","mstt"};
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ strcpy(SS_ref_db.EM_list[i],EM_tmp[i]);
+ };
+
+ SS_ref_db.W[0] = 16.;
+ SS_ref_db.W[1] = 12.;
+ SS_ref_db.W[2] = 2.;
+ SS_ref_db.W[3] = 20.;
+ SS_ref_db.W[4] = 8.;
+ SS_ref_db.W[5] = 18.;
+ SS_ref_db.W[6] = 36.;
+ SS_ref_db.W[7] = 14.;
+ SS_ref_db.W[8] = 32.;
+ SS_ref_db.W[9] = 30.;
+
+
+ em_data mst_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "mst",
+ "equilibrium" );
+
+ em_data fst_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "fst",
+ "equilibrium" );
+
+ em_data mnst_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "mnst",
+ "equilibrium" );
+
+ em_data andr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "andr",
+ "equilibrium" );
+
+ em_data gr_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "gr",
+ "equilibrium" );
+
+ em_data cor_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "cor",
+ "equilibrium" );
+
+ em_data ru_eq = get_em_data( EM_database,
+ len_ox,
+ z_b,
+ SS_ref_db.P,
+ SS_ref_db.T,
+ "ru",
+ "equilibrium" );
+
+ SS_ref_db.gbase[0] = mst_eq.gb - 8.0;
+ SS_ref_db.gbase[1] = fst_eq.gb;
+ SS_ref_db.gbase[2] = mnst_eq.gb - 0.19;
+ SS_ref_db.gbase[3] = andr_eq.gb - 1.0*gr_eq.gb + mst_eq.gb + 9.0;
+ SS_ref_db.gbase[4] = -1.0*cor_eq.gb + mst_eq.gb + 1.5*ru_eq.gb + 13.0;
+
+ SS_ref_db.ElShearMod[0] = mst_eq.ElShearMod;
+ SS_ref_db.ElShearMod[1] = fst_eq.ElShearMod;
+ SS_ref_db.ElShearMod[2] = mnst_eq.ElShearMod;
+ SS_ref_db.ElShearMod[3] = andr_eq.ElShearMod - 1.0*gr_eq.ElShearMod + mst_eq.ElShearMod;
+ SS_ref_db.ElShearMod[4] = -1.0*cor_eq.ElShearMod + mst_eq.ElShearMod + 1.5*ru_eq.ElShearMod;
+
+ for (i = 0; i < len_ox; i++){
+ SS_ref_db.Comp[0][i] = mst_eq.C[i];
+ SS_ref_db.Comp[1][i] = fst_eq.C[i];
+ SS_ref_db.Comp[2][i] = mnst_eq.C[i];
+ SS_ref_db.Comp[3][i] = andr_eq.C[i] - 1.0*gr_eq.C[i] + mst_eq.C[i];
+ SS_ref_db.Comp[4][i] = -1.0*cor_eq.C[i] + mst_eq.C[i] + 1.5*ru_eq.C[i];
+ }
+
+ for (i = 0; i < n_em; i++){
+ SS_ref_db.z_em[i] = 1.0;
+ };
+
+ SS_ref_db.bounds_ref[0][0] = 0.0+eps; SS_ref_db.bounds_ref[0][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[1][0] = 0.0+eps; SS_ref_db.bounds_ref[1][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[2][0] = 0.0+eps; SS_ref_db.bounds_ref[2][1] = 1.0-eps;
+ SS_ref_db.bounds_ref[3][0] = 0.0+eps; SS_ref_db.bounds_ref[3][1] = 1.0-eps;
+
+ return SS_ref_db;
}
@@ -2550,27 +4225,170 @@ Source code for gss_function.c
for (int j = 0; j < SS_ref_db.n_em; j++){
printf(" %+12.5f",SS_ref_db.gbase[j]);
}
- for (int j = SS_ref_db.n_em; j < gv.len_ox+1; j++){
- printf("%13s","-");
- }
printf("\n");
if (1 == 1){
/* display molar composition */
+ printf("\n S A C M F K N T O C H\n");
for (int i = 0; i < SS_ref_db.n_em; i++){
for (int j = 0; j < gv.len_ox; j++){
- printf(" %+10f",SS_ref_db.Comp[i][j]);
+ printf(" %.0f",SS_ref_db.Comp[i][j]);
}
printf("\n");
}
printf("\n");
}
-
}
return SS_ref_db;
};
+[docs]/**
+ checks if it can satisfy the mass constraint
+*/
+SS_ref G_SS_mp_EM_function( global_variable gv,
+ SS_ref SS_ref_db,
+ int EM_database,
+ bulk_info z_b,
+ char *name ){
+
+ double eps = gv.bnd_val;
+ double P = SS_ref_db.P;
+ double T = SS_ref_db.T;
+
+ SS_ref_db.ss_flags[0] = 1;
+
+ /* Associate the right solid-solution data */
+ for (int FD = 0; FD < gv.n_Diff; FD++){ /* cycle twice in order to get gb_P_eps to calculate densities later on */
+
+ if (FD == 8 || FD == 9){ // dG/dP0 to get Volume at P = 1bar
+ SS_ref_db.P = 1.+ gv.gb_P_eps*gv.pdev[0][FD];
+ SS_ref_db.T = T + gv.gb_T_eps*gv.pdev[1][FD];
+ }
+ else{
+ SS_ref_db.P = P + gv.gb_P_eps*gv.pdev[0][FD];
+ SS_ref_db.T = T + gv.gb_T_eps*gv.pdev[1][FD];
+ }
+
+ if (strcmp( name, "liq") == 0){
+ /* turn of liquid when T < 600°C) */
+ if ( T < gv.min_melt_T){
+ SS_ref_db.ss_flags[0] = 0;
+ }
+ SS_ref_db = G_SS_mp_liq_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else if (strcmp( name, "bi") == 0 ){
+ // if no H2O, deactivate
+ if (z_b.bulk_rock[10] == 0.){
+ SS_ref_db.ss_flags[0] = 0;
+ }
+ SS_ref_db = G_SS_mp_bi_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else if (strcmp( name, "pl4tr") == 0){
+ SS_ref_db = G_SS_mp_pl4tr_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else if (strcmp( name, "g") == 0){
+ SS_ref_db = G_SS_mp_g_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else if (strcmp( name, "ep") == 0 ){
+ // if no H2O, deactivate
+ if (z_b.bulk_rock[10] == 0.){
+ SS_ref_db.ss_flags[0] = 0;
+ }
+ SS_ref_db = G_SS_mp_ep_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else if (strcmp( name, "ma") == 0 ){
+ // if no H2O, deactivate
+ if (z_b.bulk_rock[10] == 0.){
+ SS_ref_db.ss_flags[0] = 0;
+ }
+ SS_ref_db = G_SS_mp_ma_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else if (strcmp( name, "mu") == 0 ){
+ // if no H2O, deactivate
+ if (z_b.bulk_rock[10] == 0.){
+ SS_ref_db.ss_flags[0] = 0;
+ }
+ SS_ref_db = G_SS_mp_mu_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else if (strcmp( name, "opx") == 0){
+ SS_ref_db = G_SS_mp_opx_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else if (strcmp( name, "sa") == 0){
+ SS_ref_db = G_SS_mp_sa_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else if (strcmp( name, "cd") == 0){
+ SS_ref_db = G_SS_mp_cd_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else if (strcmp( name, "st") == 0 ){
+ // if no H2O, deactivate
+ if (z_b.bulk_rock[10] == 0.){
+ SS_ref_db.ss_flags[0] = 0;
+ }
+ SS_ref_db = G_SS_mp_st_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else if (strcmp( name, "chl") == 0 ){
+ // if no H2O, deactivate
+ if (z_b.bulk_rock[10] == 0.){
+ SS_ref_db.ss_flags[0] = 0;
+ }
+ SS_ref_db = G_SS_mp_chl_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else if (strcmp( name, "ctd") == 0 ){
+ // if no H2O, deactivate
+ if (z_b.bulk_rock[10] == 0.){
+ SS_ref_db.ss_flags[0] = 0;
+ }
+ SS_ref_db = G_SS_mp_ctd_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else if (strcmp( name, "sp") == 0){
+ SS_ref_db = G_SS_mp_sp_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else if (strcmp( name, "ilm") == 0){
+ SS_ref_db = G_SS_mp_ilm_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else if (strcmp( name, "mt") == 0){
+ SS_ref_db = G_SS_mp_mt_function(SS_ref_db, EM_database, gv.len_ox, z_b, eps); }
+ else{
+ printf("\nsolid solution '%s' is not in the database\n",name); }
+ for (int j = 0; j < SS_ref_db.n_em; j++){
+ SS_ref_db.mu_array[FD][j] = SS_ref_db.gbase[j];
+ // printf(" %+10.10f",SS_ref_db.gbase[j]);
+ }
+ // printf("\n");
+ }
+
+ for (int j = 0; j < SS_ref_db.n_xeos; j++){
+ SS_ref_db.bounds[j][0] = SS_ref_db.bounds_ref[j][0];
+ SS_ref_db.bounds[j][1] = SS_ref_db.bounds_ref[j][1];
+ }
+
+ /* Calculate the number of atoms in the bulk-rock composition */
+ double fbc = 0.0;
+ for (int i = 0; i < gv.len_ox; i++){
+ fbc += z_b.bulk_rock[i]*z_b.apo[i];
+ }
+
+ /* get the numer of atoms per endmember, needed to update normalization factor for liquid */
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ SS_ref_db.ape[i] = 0.0;
+ for (int j = 0; j < gv.len_ox; j++){
+ SS_ref_db.ape[i] += SS_ref_db.Comp[i][j]*z_b.apo[j];
+ }
+ }
+
+ SS_ref_db.fbc = z_b.fbc;
+
+ if (gv.verbose == 1){
+ printf(" %4s:",name);
+
+ /* display Gibbs free energy of reference? */
+ for (int j = 0; j < SS_ref_db.n_em; j++){
+ printf(" %+12.5f",SS_ref_db.gbase[j]);
+ }
+
+ printf("\n");
+
+ if (1 == 1){
+ /* display molar composition */
+ printf("\n S A C M F K N T O M H\n");
+ for (int i = 0; i < SS_ref_db.n_em; i++){
+ for (int j = 0; j < gv.len_ox; j++){
+ printf(" %.0f",SS_ref_db.Comp[i][j]);
+ }
+ printf("\n");
+ }
+ printf("\n");
+ }
+ }
+
+ return SS_ref_db;
+};
diff --git a/docs/_modules/gss_init_function.c.html b/docs/_modules/gss_init_function.c.html
index 860b1736..60c0d0fc 100644
--- a/docs/_modules/gss_init_function.c.html
+++ b/docs/_modules/gss_init_function.c.html
@@ -137,11 +137,7 @@
Access output structure
-Provide custom bulk rock composition
-
+Provide custom bulk rock composition
@@ -407,9 +403,10 @@ Source code for gss_init_function.c
SS_ref G_SS_mp_pl4tr_init_function(SS_ref SS_ref_db, int EM_database, global_variable gv){
SS_ref_db.is_liq = 0;
- SS_ref_db.symmetry = 1;
+ SS_ref_db.symmetry = 0;
SS_ref_db.n_sf = 5;
SS_ref_db.n_em = 3;
+ SS_ref_db.n_v = 3;
SS_ref_db.n_w = 3;
SS_ref_db.n_xeos = 2;
SS_ref_db.CstFactor = 0;
@@ -572,7 +569,7 @@ Source code for gss_init_function.c
SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 1;
- SS_ref_db.n_sf = 13;
+ SS_ref_db.n_sf = 12;
SS_ref_db.n_em = 8;
SS_ref_db.n_w = 28;
SS_ref_db.n_xeos = 7;
@@ -620,7 +617,7 @@ Source code for gss_init_function.c
SS_ref_db.is_liq = 0;
SS_ref_db.symmetry = 1;
- SS_ref_db.n_sf = 8;
+ SS_ref_db.n_sf = 6;
SS_ref_db.n_em = 5;
SS_ref_db.n_w = 10;
SS_ref_db.n_xeos = 4;
@@ -909,6 +906,8 @@ Source code for gss_init_function.c
SS_ref_db = G_SS_mp_mu_init_function(SS_ref_db, EM_database, gv); }
else if (strcmp( name, "opx") == 0){
SS_ref_db = G_SS_mp_opx_init_function(SS_ref_db, EM_database, gv); }
+ else if (strcmp( name, "sa") == 0){
+ SS_ref_db = G_SS_mp_sa_init_function(SS_ref_db, EM_database, gv); }
else if (strcmp( name, "cd") == 0){
SS_ref_db = G_SS_mp_cd_init_function(SS_ref_db, EM_database, gv); }
else if (strcmp( name, "st") == 0){
diff --git a/docs/_modules/io_function.c.html b/docs/_modules/io_function.c.html
index 95240073..ba4f6455 100644
--- a/docs/_modules/io_function.c.html
+++ b/docs/_modules/io_function.c.html
@@ -137,11 +137,7 @@
Access output structure
-Provide custom bulk rock composition
-
+Provide custom bulk rock composition
diff --git a/docs/_modules/objective_functions.c.html b/docs/_modules/objective_functions.c.html
index c0f579c7..d0e410f8 100644
--- a/docs/_modules/objective_functions.c.html
+++ b/docs/_modules/objective_functions.c.html
@@ -137,11 +137,7 @@
Access output structure
-Provide custom bulk rock composition
-
+Provide custom bulk rock composition
@@ -266,14 +262,15 @@ Source code for objective_functions.c
dp_dx[0][0] = 1.0; dp_dx[0][1] = 0.0; dp_dx[0][2] = 0.0; dp_dx[0][3] = 0.0; dp_dx[0][4] = 0.0; dp_dx[0][5] = 0.0; dp_dx[0][6] = 0.0;
dp_dx[1][0] = 0.0; dp_dx[1][1] = x[2]; dp_dx[1][2] = x[1]; dp_dx[1][3] = 0.0; dp_dx[1][4] = 0.0; dp_dx[1][5] = 0.0; dp_dx[1][6] = 0.0;
- dp_dx[2][0] = 0.0; dp_dx[2][1] = 1.0 - 1.0*x[2]; dp_dx[2][2] = -1.0*x[1]; dp_dx[2][3] = 0.0; dp_dx[2][4] = 0.0; dp_dx[2][5] = 0.0; dp_dx[2][6] = 0.0;
+ dp_dx[2][0] = 0.0; dp_dx[2][1] = 1.0 - x[2]; dp_dx[2][2] = -x[1]; dp_dx[2][3] = 0.0; dp_dx[2][4] = 0.0; dp_dx[2][5] = 0.0; dp_dx[2][6] = 0.0;
dp_dx[3][0] = 0.0; dp_dx[3][1] = 0.0; dp_dx[3][2] = 0.0; dp_dx[3][3] = 1.0; dp_dx[3][4] = 0.0; dp_dx[3][5] = 0.0; dp_dx[3][6] = 0.0;
dp_dx[4][0] = -1.0; dp_dx[4][1] = -1.0; dp_dx[4][2] = 0.0; dp_dx[4][3] = -1.0; dp_dx[4][4] = -1.0; dp_dx[4][5] = 0.0; dp_dx[4][6] = -1.0;
- dp_dx[5][0] = 0.0; dp_dx[5][1] = 0.0; dp_dx[5][2] = 0.0; dp_dx[5][3] = 0.0; dp_dx[5][4] = 1.0 - 1.0*x[5]; dp_dx[5][5] = -1.0*x[4]; dp_dx[5][6] = 0.0;
+ dp_dx[5][0] = 0.0; dp_dx[5][1] = 0.0; dp_dx[5][2] = 0.0; dp_dx[5][3] = 0.0; dp_dx[5][4] = 1.0 - x[5]; dp_dx[5][5] = -x[4]; dp_dx[5][6] = 0.0;
dp_dx[6][0] = 0.0; dp_dx[6][1] = 0.0; dp_dx[6][2] = 0.0; dp_dx[6][3] = 0.0; dp_dx[6][4] = x[5]; dp_dx[6][5] = x[4]; dp_dx[6][6] = 0.0;
dp_dx[7][0] = 0.0; dp_dx[7][1] = 0.0; dp_dx[7][2] = 0.0; dp_dx[7][3] = 0.0; dp_dx[7][4] = 0.0; dp_dx[7][5] = 0.0; dp_dx[7][6] = 1.0;
}
+
[docs]/**
Update dpdx matrix of pl4tr_mp
*/
@@ -286,6 +283,7 @@ Source code for objective_functions.c
dp_dx[2][0] = 0.0; dp_dx[2][1] = 1.0;
}
+
[docs]/**
Update dpdx matrix of bi_mp
*/
@@ -295,13 +293,15 @@ Source code for objective_functions.c
dp_dx[0][0] = x[3] + 3.0*x[1] + x[4] + x[2] - 1.0; dp_dx[0][1] = 3.0*x[0] - 1.0; dp_dx[0][2] = x[0] - 1.0; dp_dx[0][3] = x[0] - 1.0; dp_dx[0][4] = x[0] - 1.0; dp_dx[0][5] = -2.0/3.0;
dp_dx[1][0] = 1.0; dp_dx[1][1] = 0.0; dp_dx[1][2] = 0.0; dp_dx[1][3] = 0.0; dp_dx[1][4] = 0.0; dp_dx[1][5] = -1.0/3.0;
- dp_dx[2][0] = -1.0*x[3] - 3.0*x[1] - 1.0*x[4] - 1.0*x[2]; dp_dx[2][1] = -3.0*x[0]; dp_dx[2][2] = -1.0*x[0]; dp_dx[2][3] = -1.0*x[0]; dp_dx[2][4] = -1.0*x[0]; dp_dx[2][5] = 1.0;
+ dp_dx[2][0] = -x[3] - 3.0*x[1] - x[4] - x[2]; dp_dx[2][1] = -3.0*x[0]; dp_dx[2][2] = -x[0]; dp_dx[2][3] = -x[0]; dp_dx[2][4] = -x[0]; dp_dx[2][5] = 1.0;
dp_dx[3][0] = 0.0; dp_dx[3][1] = 0.0; dp_dx[3][2] = 1.0; dp_dx[3][3] = 0.0; dp_dx[3][4] = 0.0; dp_dx[3][5] = 0.0;
dp_dx[4][0] = 0.0; dp_dx[4][1] = 0.0; dp_dx[4][2] = 0.0; dp_dx[4][3] = 0.0; dp_dx[4][4] = 1.0; dp_dx[4][5] = 0.0;
dp_dx[5][0] = 0.0; dp_dx[5][1] = 0.0; dp_dx[5][2] = 0.0; dp_dx[5][3] = 1.0; dp_dx[5][4] = 0.0; dp_dx[5][5] = 0.0;
dp_dx[6][0] = 0.0; dp_dx[6][1] = 1.0; dp_dx[6][2] = 0.0; dp_dx[6][3] = 0.0; dp_dx[6][4] = 0.0; dp_dx[6][5] = 0.0;
}
+
+
[docs]/**
Update dpdx matrix of g_mp
*/
@@ -309,13 +309,15 @@ Source code for objective_functions.c
SS_ref *d = (SS_ref *) SS_ref_db;
double **dp_dx = d->dp_dx;
- dp_dx[0][0] = x[2] + x[1] - 1.0; dp_dx[0][1] = x[0] - 1.0; dp_dx[0][2] = x[0] - 1.0; dp_dx[0][3] = 0.0;
- dp_dx[1][0] = -1.0*x[2] - 1.0*x[1] + 1.0; dp_dx[1][1] = -1.0*x[0]; dp_dx[1][2] = -1.0*x[0]; dp_dx[1][3] = 0.0;
+ dp_dx[0][0] = x[2] + x[1] - 1.0; dp_dx[0][1] = x[0] - 1.0; dp_dx[0][2] = x[0] - 1.0; dp_dx[0][3] = -1.0;
+ dp_dx[1][0] = -x[2] - x[1] + 1.0; dp_dx[1][1] = -x[0]; dp_dx[1][2] = -x[0]; dp_dx[1][3] = 0.0;
dp_dx[2][0] = 0.0; dp_dx[2][1] = 0.0; dp_dx[2][2] = 1.0; dp_dx[2][3] = 0.0;
dp_dx[3][0] = 0.0; dp_dx[3][1] = 1.0; dp_dx[3][2] = 0.0; dp_dx[3][3] = 0.0;
dp_dx[4][0] = 0.0; dp_dx[4][1] = 0.0; dp_dx[4][2] = 0.0; dp_dx[4][3] = 1.0;
}
+
+
[docs]/**
Update dpdx matrix of ep_mp
*/
@@ -337,7 +339,7 @@ Source code for objective_functions.c
dp_dx[0][0] = 0.0; dp_dx[0][1] = 1.0; dp_dx[0][2] = -1.0; dp_dx[0][3] = -1.0; dp_dx[0][4] = -1.0;
dp_dx[1][0] = x[1] - 1.0; dp_dx[1][1] = x[0] - 1.0; dp_dx[1][2] = 0.0; dp_dx[1][3] = 0.0; dp_dx[1][4] = 0.0;
- dp_dx[2][0] = 1.0 - 1.0*x[1]; dp_dx[2][1] = -1.0*x[0]; dp_dx[2][2] = 0.0; dp_dx[2][3] = 0.0; dp_dx[2][4] = 0.0;
+ dp_dx[2][0] = 1.0 - x[1]; dp_dx[2][1] = -x[0]; dp_dx[2][2] = 0.0; dp_dx[2][3] = 0.0; dp_dx[2][4] = 0.0;
dp_dx[3][0] = 0.0; dp_dx[3][1] = 0.0; dp_dx[3][2] = 0.0; dp_dx[3][3] = 1.0; dp_dx[3][4] = 0.0;
dp_dx[4][0] = 0.0; dp_dx[4][1] = 0.0; dp_dx[4][2] = 0.0; dp_dx[4][3] = 0.0; dp_dx[4][4] = 1.0;
dp_dx[5][0] = 0.0; dp_dx[5][1] = 0.0; dp_dx[5][2] = 1.0; dp_dx[5][3] = 0.0; dp_dx[5][4] = 0.0;
@@ -352,7 +354,7 @@ Source code for objective_functions.c
dp_dx[0][0] = 0.0; dp_dx[0][1] = 1.0; dp_dx[0][2] = -1.0; dp_dx[0][3] = -1.0; dp_dx[0][4] = -1.0;
dp_dx[1][0] = x[1] - 1.0; dp_dx[1][1] = x[0] - 1.0; dp_dx[1][2] = 0.0; dp_dx[1][3] = 0.0; dp_dx[1][4] = 0.0;
- dp_dx[2][0] = 1.0 - 1.0*x[1]; dp_dx[2][1] = -1.0*x[0]; dp_dx[2][2] = 0.0; dp_dx[2][3] = 0.0; dp_dx[2][4] = 0.0;
+ dp_dx[2][0] = 1.0 - x[1]; dp_dx[2][1] = -x[0]; dp_dx[2][2] = 0.0; dp_dx[2][3] = 0.0; dp_dx[2][4] = 0.0;
dp_dx[3][0] = 0.0; dp_dx[3][1] = 0.0; dp_dx[3][2] = 0.0; dp_dx[3][3] = 1.0; dp_dx[3][4] = 0.0;
dp_dx[4][0] = 0.0; dp_dx[4][1] = 0.0; dp_dx[4][2] = 0.0; dp_dx[4][3] = 0.0; dp_dx[4][4] = 1.0;
dp_dx[5][0] = 0.0; dp_dx[5][1] = 0.0; dp_dx[5][2] = 1.0; dp_dx[5][3] = 0.0; dp_dx[5][4] = 0.0;
@@ -366,8 +368,8 @@ Source code for objective_functions.c
double **dp_dx = d->dp_dx;
dp_dx[0][0] = x[4] + x[1] - 1.0; dp_dx[0][1] = 0.5*x[5] + x[0] - 1.0; dp_dx[0][2] = -1.0; dp_dx[0][3] = -1.0; dp_dx[0][4] = 0.5*x[5] + x[0] - 1.0; dp_dx[0][5] = 0.5*x[4] + 0.5*x[1] - 0.5;
- dp_dx[1][0] = -1.0*x[3] - 1.0*x[1] - 1.0*x[2] + 1.0; dp_dx[1][1] = 0.5*x[5] - 1.0*x[0]; dp_dx[1][2] = -1.0*x[0]; dp_dx[1][3] = -1.0*x[0]; dp_dx[1][4] = 0.5*x[5]; dp_dx[1][5] = 0.5*x[4] + 0.5*x[1] - 0.5;
- dp_dx[2][0] = -1.0*x[4] + x[3] + x[2]; dp_dx[2][1] = -1.0*x[5]; dp_dx[2][2] = x[0]; dp_dx[2][3] = x[0]; dp_dx[2][4] = -1.0*x[5] - 1.0*x[0]; dp_dx[2][5] = -1.0*x[4] - 1.0*x[1] + 1.0;
+ dp_dx[1][0] = -x[3] - x[1] - x[2] + 1.0; dp_dx[1][1] = 0.5*x[5] - x[0]; dp_dx[1][2] = -x[0]; dp_dx[1][3] = -x[0]; dp_dx[1][4] = 0.5*x[5]; dp_dx[1][5] = 0.5*x[4] + 0.5*x[1] - 0.5;
+ dp_dx[2][0] = -x[4] + x[3] + x[2]; dp_dx[2][1] = -x[5]; dp_dx[2][2] = x[0]; dp_dx[2][3] = x[0]; dp_dx[2][4] = -x[5] - x[0]; dp_dx[2][5] = -x[4] - x[1] + 1.0;
dp_dx[3][0] = 0.0; dp_dx[3][1] = 0.0; dp_dx[3][2] = 1.0; dp_dx[3][3] = 0.0; dp_dx[3][4] = 0.0; dp_dx[3][5] = 0.0;
dp_dx[4][0] = 0.0; dp_dx[4][1] = 0.0; dp_dx[4][2] = 0.0; dp_dx[4][3] = 1.0; dp_dx[4][4] = 0.0; dp_dx[4][5] = 0.0;
dp_dx[5][0] = 0.0; dp_dx[5][1] = 1.0; dp_dx[5][2] = 0.0; dp_dx[5][3] = 0.0; dp_dx[5][4] = 0.0; dp_dx[5][5] = 0.0;
@@ -383,7 +385,7 @@ Source code for objective_functions.c
dp_dx[0][0] = -1.0; dp_dx[0][1] = -1.0; dp_dx[0][2] = -1.0; dp_dx[0][3] = -0.25;
dp_dx[1][0] = 0.0; dp_dx[1][1] = 1.0; dp_dx[1][2] = 0.0; dp_dx[1][3] = 0.0;
- dp_dx[2][0] = -1.0*x[2] - 1.0*x[1] + 1.0; dp_dx[2][1] = -1.0*x[0]; dp_dx[2][2] = -1.0*x[0]; dp_dx[2][3] = -0.75;
+ dp_dx[2][0] = -x[2] - x[1] + 1.0; dp_dx[2][1] = -x[0]; dp_dx[2][2] = -x[0]; dp_dx[2][3] = -0.75;
dp_dx[3][0] = x[2] + x[1]; dp_dx[3][1] = x[0]; dp_dx[3][2] = x[0]; dp_dx[3][3] = 1.0;
dp_dx[4][0] = 0.0; dp_dx[4][1] = 0.0; dp_dx[4][2] = 1.0; dp_dx[4][3] = 0.0;
}
@@ -396,7 +398,7 @@ Source code for objective_functions.c
double **dp_dx = d->dp_dx;
dp_dx[0][0] = x[1] - 1.0; dp_dx[0][1] = x[0] - 1.0; dp_dx[0][2] = -1.0;
- dp_dx[1][0] = 1.0 - 1.0*x[1]; dp_dx[1][1] = -1.0*x[0]; dp_dx[1][2] = 0.0;
+ dp_dx[1][0] = 1.0 - x[1]; dp_dx[1][1] = -x[0]; dp_dx[1][2] = 0.0;
dp_dx[2][0] = 0.0; dp_dx[2][1] = 0.0; dp_dx[2][2] = 1.0;
dp_dx[3][0] = 0.0; dp_dx[3][1] = 1.0; dp_dx[3][2] = 0.0;
}
@@ -409,7 +411,7 @@ Source code for objective_functions.c
double **dp_dx = d->dp_dx;
dp_dx[0][0] = x[1] - 1.0; dp_dx[0][1] = x[0] - 1.0; dp_dx[0][2] = -1.0; dp_dx[0][3] = -4.0/3.0;
- dp_dx[1][0] = 1.0 - 1.0*x[1]; dp_dx[1][1] = -1.0*x[0]; dp_dx[1][2] = 0.0; dp_dx[1][3] = 0.0;
+ dp_dx[1][0] = 1.0 - x[1]; dp_dx[1][1] = -x[0]; dp_dx[1][2] = 0.0; dp_dx[1][3] = 0.0;
dp_dx[2][0] = 0.0; dp_dx[2][1] = 1.0; dp_dx[2][2] = 0.0; dp_dx[2][3] = 0.0;
dp_dx[3][0] = 0.0; dp_dx[3][1] = 0.0; dp_dx[3][2] = 1.0; dp_dx[3][3] = 0.0;
dp_dx[4][0] = 0.0; dp_dx[4][1] = 0.0; dp_dx[4][2] = 0.0; dp_dx[4][3] = 4.0/3.0;
@@ -422,16 +424,15 @@ Source code for objective_functions.c
SS_ref *d = (SS_ref *) SS_ref_db;
double **dp_dx = d->dp_dx;
- dp_dx[0][0] = -1.0*x[2] + x[3] - 1.0*x[4] - 1.0*x[1]; dp_dx[0][1] = 0.25*x[5] + 1.25*x[6] - 1.0*x[0]; dp_dx[0][2] = 1.25*x[6] - 1.0*x[0]; dp_dx[0][3] = 0.25*x[5] - 2.0*x[4] + x[0]; dp_dx[0][4] = -2.0*x[3] - 0.25*x[5] + 1.25*x[6] - 1.0*x[0]; dp_dx[0][5] = 0.25*x[3] - 0.25*x[4] + 0.25*x[1] - 0.25; dp_dx[0][6] = 1.25*x[2] + 1.25*x[4] + 1.25*x[1] - 1.25;
+ dp_dx[0][0] = -x[2] + x[3] - x[4] - x[1]; dp_dx[0][1] = 0.25*x[5] + 1.25*x[6] - x[0]; dp_dx[0][2] = 1.25*x[6] - x[0]; dp_dx[0][3] = 0.25*x[5] + x[0] - 1.0; dp_dx[0][4] = -0.25*x[5] + 1.25*x[6] - x[0] + 2.0; dp_dx[0][5] = 0.25*x[3] - 0.25*x[4] + 0.25*x[1] - 0.25; dp_dx[0][6] = 1.25*x[2] + 1.25*x[4] + 1.25*x[1] - 1.25;
dp_dx[1][0] = 2.0*x[2] + x[4] + 3.0*x[1] - 2.0; dp_dx[1][1] = -1.25*x[5] - 2.25*x[6] + 3.0*x[0] - 1.0; dp_dx[1][2] = -2.25*x[6] + 2.0*x[0] - 1.0; dp_dx[1][3] = -1.25*x[5]; dp_dx[1][4] = 1.25*x[5] - 2.25*x[6] + x[0] - 1.0; dp_dx[1][5] = -1.25*x[3] + 1.25*x[4] - 1.25*x[1] + 1.25; dp_dx[1][6] = -2.25*x[2] - 2.25*x[4] - 2.25*x[1] + 2.25;
dp_dx[2][0] = 0.0; dp_dx[2][1] = 1.0; dp_dx[2][2] = 0.0; dp_dx[2][3] = 0.0; dp_dx[2][4] = -1.0; dp_dx[2][5] = 0.0; dp_dx[2][6] = 0.0;
- dp_dx[3][0] = x[2] - 1.0*x[3] + x[4] + x[1]; dp_dx[3][1] = -0.25*x[5] - 1.25*x[6] + x[0]; dp_dx[3][2] = -1.25*x[6] + x[0]; dp_dx[3][3] = -0.25*x[5] - 1.0*x[0]; dp_dx[3][4] = 0.25*x[5] - 1.25*x[6] + x[0]; dp_dx[3][5] = -0.25*x[3] + 0.25*x[4] - 0.25*x[1] + 0.25; dp_dx[3][6] = -1.25*x[2] - 1.25*x[4] - 1.25*x[1] + 1.25;
- dp_dx[4][0] = -1.0*x[2] - 1.0*x[4] - 1.0*x[1] + 1.0; dp_dx[4][1] = x[6] - 1.0*x[0]; dp_dx[4][2] = x[6] - 1.0*x[0]; dp_dx[4][3] = 0.0; dp_dx[4][4] = x[6] - 1.0*x[0]; dp_dx[4][5] = 0.0; dp_dx[4][6] = x[2] + x[4] + x[1] - 1.0;
- dp_dx[5][0] = -1.0*x[2] - 2.0*x[1] + 1.0; dp_dx[5][1] = 1.25*x[5] + 1.25*x[6] - 2.0*x[0]; dp_dx[5][2] = 1.25*x[6] - 1.0*x[0]; dp_dx[5][3] = 1.25*x[5]; dp_dx[5][4] = -1.25*x[5] + 1.25*x[6]; dp_dx[5][5] = 1.25*x[3] - 1.25*x[4] + 1.25*x[1] - 1.25; dp_dx[5][6] = 1.25*x[2] + 1.25*x[4] + 1.25*x[1] - 1.25;
+ dp_dx[3][0] = x[2] - x[3] + x[4] + x[1]; dp_dx[3][1] = -0.25*x[5] - 1.25*x[6] + x[0]; dp_dx[3][2] = -1.25*x[6] + x[0]; dp_dx[3][3] = -0.25*x[5] - x[0]; dp_dx[3][4] = 0.25*x[5] - 1.25*x[6] + x[0]; dp_dx[3][5] = -0.25*x[3] + 0.25*x[4] - 0.25*x[1] + 0.25; dp_dx[3][6] = -1.25*x[2] - 1.25*x[4] - 1.25*x[1] + 1.25;
+ dp_dx[4][0] = -x[2] - x[4] - x[1] + 1.0; dp_dx[4][1] = x[6] - x[0]; dp_dx[4][2] = x[6] - x[0]; dp_dx[4][3] = 0.0; dp_dx[4][4] = x[6] - x[0]; dp_dx[4][5] = 0.0; dp_dx[4][6] = x[2] + x[4] + x[1] - 1.0;
+ dp_dx[5][0] = -x[2] - 2.0*x[1] + 1.0; dp_dx[5][1] = 1.25*x[5] + 1.25*x[6] - 2.0*x[0]; dp_dx[5][2] = 1.25*x[6] - x[0]; dp_dx[5][3] = 1.25*x[5]; dp_dx[5][4] = -1.25*x[5] + 1.25*x[6]; dp_dx[5][5] = 1.25*x[3] - 1.25*x[4] + 1.25*x[1] - 1.25; dp_dx[5][6] = 1.25*x[2] + 1.25*x[4] + 1.25*x[1] - 1.25;
dp_dx[6][0] = 0.0; dp_dx[6][1] = 0.0; dp_dx[6][2] = 1.0; dp_dx[6][3] = 0.0; dp_dx[6][4] = 0.0; dp_dx[6][5] = 0.0; dp_dx[6][6] = 0.0;
dp_dx[7][0] = 0.0; dp_dx[7][1] = 0.0; dp_dx[7][2] = 0.0; dp_dx[7][3] = 1.0; dp_dx[7][4] = 0.0; dp_dx[7][5] = 0.0; dp_dx[7][6] = 0.0;
}
-
[docs]/**
Update dpdx matrix of ctd_mp
*/
@@ -440,7 +441,7 @@ Source code for objective_functions.c
double **dp_dx = d->dp_dx;
dp_dx[0][0] = x[1] - 1.0; dp_dx[0][1] = x[0] - 1.0; dp_dx[0][2] = -1.0;
- dp_dx[1][0] = 1.0 - 1.0*x[1]; dp_dx[1][1] = -1.0*x[0]; dp_dx[1][2] = 0.0;
+ dp_dx[1][0] = 1.0 - x[1]; dp_dx[1][1] = -x[0]; dp_dx[1][2] = 0.0;
dp_dx[2][0] = 0.0; dp_dx[2][1] = 1.0; dp_dx[2][2] = 0.0;
dp_dx[3][0] = 0.0; dp_dx[3][1] = 0.0; dp_dx[3][2] = 1.0;
}
@@ -453,7 +454,7 @@ Source code for objective_functions.c
double **dp_dx = d->dp_dx;
dp_dx[0][0] = x[2] + 1.0; dp_dx[0][1] = 1.0; dp_dx[0][2] = x[0] - 1.0;
- dp_dx[1][0] = -1.0*x[2] - 1.0; dp_dx[1][1] = 0.0; dp_dx[1][2] = 1.0 - 1.0*x[0];
+ dp_dx[1][0] = -x[2] - 1.0; dp_dx[1][1] = 0.0; dp_dx[1][2] = 1.0 - x[0];
dp_dx[2][0] = 0.0; dp_dx[2][1] = -1.0; dp_dx[2][2] = -1.0;
dp_dx[3][0] = 0.0; dp_dx[3][1] = 0.0; dp_dx[3][2] = 1.0;
}
@@ -492,10 +493,10 @@ Source code for objective_functions.c
double *p = d->p;
p[0] = x[0];
p[1] = x[1]*x[2];
- p[2] = x[1]*(1.0 - 1.0*x[2]);
+ p[2] = x[1]*(1.0 - x[2]);
p[3] = x[3];
- p[4] = -1.0*x[3] - 1.0*x[1] - 1.0*x[6] - 1.0*x[4] - 1.0*x[0] + 1.0;
- p[5] = x[4]*(1.0 - 1.0*x[5]);
+ p[4] = -x[3] - x[1] - x[6] - x[4] - x[0] + 1.0;
+ p[5] = x[4]*(1.0 - x[5]);
p[6] = x[4]*x[5];
p[7] = x[6];
}
@@ -506,20 +507,19 @@ Source code for objective_functions.c
void px_mp_pl4tr(void *SS_ref_db, const double *x){
SS_ref *d = (SS_ref *) SS_ref_db;
double *p = d->p;
- p[0] = -1.0*x[0] - 1.0*x[1] + 1.0;
+ p[0] = -x[0] - x[1] + 1.0;
p[1] = x[0];
p[2] = x[1];
}
-
[docs]/**
Endmember fraction of bi_mp
*/
void px_mp_bi(void *SS_ref_db, const double *x){
SS_ref *d = (SS_ref *) SS_ref_db;
double *p = d->p;
- p[0] = x[3]*x[0] - 1.0*x[3] + 3.0*x[1]*x[0] - 1.0*x[1] - 2.0/3.0*x[5] + x[4]*x[0] - 1.0*x[4] + x[0]*x[2] - 1.0*x[0] - 1.0*x[2] + 1.0;
+ p[0] = x[3]*x[0] - x[3] + 3.0*x[1]*x[0] - x[1] - 2.0/3.0*x[5] + x[4]*x[0] - x[4] + x[0]*x[2] - x[0] - x[2] + 1.0;
p[1] = -1.0/3.0*x[5] + x[0];
- p[2] = -1.0*x[3]*x[0] - 3.0*x[1]*x[0] + x[5] - 1.0*x[4]*x[0] - 1.0*x[0]*x[2];
+ p[2] = -x[3]*x[0] - 3.0*x[1]*x[0] + x[5] - x[4]*x[0] - x[0]*x[2];
p[3] = x[2];
p[4] = x[4];
p[5] = x[3];
@@ -532,22 +532,22 @@ Source code for objective_functions.c
void px_mp_g(void *SS_ref_db, const double *x){
SS_ref *d = (SS_ref *) SS_ref_db;
double *p = d->p;
- p[0] = x[2]*x[0] - 1.0*x[2] + x[0]*x[1] - 1.0*x[0] - 1.0*x[1] + 1.0;
- p[1] = -1.0*x[2]*x[0] - 1.0*x[0]*x[1] + x[0];
+ p[0] = -x[3] + x[2]*x[0] - x[2] + x[0]*x[1] - x[0] - x[1] + 1.0;
+ p[1] = -x[2]*x[0] - x[0]*x[1] + x[0];
p[2] = x[2];
p[3] = x[1];
p[4] = x[3];
}
-
+
[docs]/**
Endmember fraction of ep_mp
*/
void px_mp_ep(void *SS_ref_db, const double *x){
SS_ref *d = (SS_ref *) SS_ref_db;
double *p = d->p;
- p[0] = -1.0*x[0] - 1.0*x[1] + 1.0;
+ p[0] = -x[0] - x[1] + 1.0;
p[1] = 2.0*x[1];
- p[2] = x[0] - 1.0*x[1];
+ p[2] = x[0] - x[1];
}
[docs]/**
@@ -556,9 +556,9 @@ Source code for objective_functions.c
void px_mp_ma(void *SS_ref_db, const double *x){
SS_ref *d = (SS_ref *) SS_ref_db;
double *p = d->p;
- p[0] = -1.0*x[4] - 1.0*x[2] - 1.0*x[3] + x[1];
- p[1] = x[0]*x[1] - 1.0*x[0] - 1.0*x[1] + 1.0;
- p[2] = -1.0*x[0]*x[1] + x[0];
+ p[0] = -x[4] - x[2] - x[3] + x[1];
+ p[1] = x[0]*x[1] - x[0] - x[1] + 1.0;
+ p[2] = -x[0]*x[1] + x[0];
p[3] = x[3];
p[4] = x[4];
p[5] = x[2];
@@ -570,9 +570,9 @@ Source code for objective_functions.c
void px_mp_mu(void *SS_ref_db, const double *x){
SS_ref *d = (SS_ref *) SS_ref_db;
double *p = d->p;
- p[0] = -1.0*x[4] - 1.0*x[2] - 1.0*x[3] + x[1];
- p[1] = x[0]*x[1] - 1.0*x[0] - 1.0*x[1] + 1.0;
- p[2] = -1.0*x[0]*x[1] + x[0];
+ p[0] = -x[4] - x[2] - x[3] + x[1];
+ p[1] = x[0]*x[1] - x[0] - x[1] + 1.0;
+ p[2] = -x[0]*x[1] + x[0];
p[3] = x[3];
p[4] = x[4];
p[5] = x[2];
@@ -584,9 +584,9 @@ Source code for objective_functions.c
void px_mp_opx(void *SS_ref_db, const double *x){
SS_ref *d = (SS_ref *) SS_ref_db;
double *p = d->p;
- p[0] = 0.5*x[4]*x[5] + x[4]*x[0] - 1.0*x[4] - 1.0*x[3] + 0.5*x[1]*x[5] + x[1]*x[0] - 1.0*x[1] - 0.5*x[5] - 1.0*x[0] - 1.0*x[2] + 1.0;
- p[1] = 0.5*x[4]*x[5] - 1.0*x[3]*x[0] + 0.5*x[1]*x[5] - 1.0*x[1]*x[0] - 0.5*x[5] - 1.0*x[0]*x[2] + x[0];
- p[2] = -1.0*x[4]*x[5] - 1.0*x[4]*x[0] + x[3]*x[0] - 1.0*x[1]*x[5] + x[5] + x[0]*x[2];
+ p[0] = 0.5*x[4]*x[5] + x[4]*x[0] - x[4] - x[3] + 0.5*x[1]*x[5] + x[1]*x[0] - x[1] - 0.5*x[5] - x[0] - x[2] + 1.0;
+ p[1] = 0.5*x[4]*x[5] - x[3]*x[0] + 0.5*x[1]*x[5] - x[1]*x[0] - 0.5*x[5] - x[0]*x[2] + x[0];
+ p[2] = -x[4]*x[5] - x[4]*x[0] + x[3]*x[0] - x[1]*x[5] + x[5] + x[0]*x[2];
p[3] = x[2];
p[4] = x[3];
p[5] = x[1];
@@ -599,9 +599,9 @@ Source code for objective_functions.c
void px_mp_sa(void *SS_ref_db, const double *x){
SS_ref *d = (SS_ref *) SS_ref_db;
double *p = d->p;
- p[0] = -1.0*x[2] - 0.25*x[3] - 1.0*x[0] - 1.0*x[1] + 1.0;
+ p[0] = -x[2] - 0.25*x[3] - x[0] - x[1] + 1.0;
p[1] = x[1];
- p[2] = -1.0*x[2]*x[0] - 0.75*x[3] - 1.0*x[0]*x[1] + x[0];
+ p[2] = -x[2]*x[0] - 0.75*x[3] - x[0]*x[1] + x[0];
p[3] = x[2]*x[0] + x[3] + x[0]*x[1];
p[4] = x[2];
}
@@ -612,8 +612,8 @@ Source code for objective_functions.c
void px_mp_cd(void *SS_ref_db, const double *x){
SS_ref *d = (SS_ref *) SS_ref_db;
double *p = d->p;
- p[0] = -1.0*x[2] + x[1]*x[0] - 1.0*x[1] - 1.0*x[0] + 1.0;
- p[1] = -1.0*x[1]*x[0] + x[0];
+ p[0] = -x[2] + x[1]*x[0] - x[1] - x[0] + 1.0;
+ p[1] = -x[1]*x[0] + x[0];
p[2] = x[2];
p[3] = x[1];
}
@@ -624,8 +624,8 @@ Source code for objective_functions.c
void px_mp_st(void *SS_ref_db, const double *x){
SS_ref *d = (SS_ref *) SS_ref_db;
double *p = d->p;
- p[0] = -1.0*x[2] + x[1]*x[0] - 1.0*x[1] - 4.0/3.0*x[3] - 1.0*x[0] + 1.0;
- p[1] = -1.0*x[1]*x[0] + x[0];
+ p[0] = -x[2] + x[1]*x[0] - x[1] - 4.0/3.0*x[3] - x[0] + 1.0;
+ p[1] = -x[1]*x[0] + x[0];
p[2] = x[1];
p[3] = x[2];
p[4] = 4.0/3.0*x[3];
@@ -637,12 +637,12 @@ Source code for objective_functions.c
void px_mp_chl(void *SS_ref_db, const double *x){
SS_ref *d = (SS_ref *) SS_ref_db;
double *p = d->p;
- p[0] = 1.25*x[2]*x[6] - 1.0*x[2]*x[0] + 0.25*x[3]*x[5] - 2.0*x[3]*x[4] + x[3]*x[0] - 0.25*x[5]*x[4] + 0.25*x[5]*x[1] - 0.25*x[5] + 1.25*x[6]*x[4] + 1.25*x[6]*x[1] - 1.25*x[6] - 1.0*x[4]*x[0] - 1.0*x[0]*x[1];
- p[1] = -2.25*x[2]*x[6] + 2.0*x[2]*x[0] - 1.0*x[2] - 1.25*x[3]*x[5] + 1.25*x[5]*x[4] - 1.25*x[5]*x[1] + 1.25*x[5] - 2.25*x[6]*x[4] - 2.25*x[6]*x[1] + 2.25*x[6] + x[4]*x[0] - 1.0*x[4] + 3.0*x[0]*x[1] - 2.0*x[0] - 1.0*x[1] + 1.0;
- p[2] = -1.0*x[4] + x[1];
- p[3] = -1.25*x[2]*x[6] + x[2]*x[0] - 0.25*x[3]*x[5] - 1.0*x[3]*x[0] + 0.25*x[5]*x[4] - 0.25*x[5]*x[1] + 0.25*x[5] - 1.25*x[6]*x[4] - 1.25*x[6]*x[1] + 1.25*x[6] + x[4]*x[0] + x[0]*x[1];
- p[4] = x[2]*x[6] - 1.0*x[2]*x[0] + x[6]*x[4] + x[6]*x[1] - 1.0*x[6] - 1.0*x[4]*x[0] - 1.0*x[0]*x[1] + x[0];
- p[5] = 1.25*x[2]*x[6] - 1.0*x[2]*x[0] + 1.25*x[3]*x[5] - 1.25*x[5]*x[4] + 1.25*x[5]*x[1] - 1.25*x[5] + 1.25*x[6]*x[4] + 1.25*x[6]*x[1] - 1.25*x[6] - 2.0*x[0]*x[1] + x[0];
+ p[0] = 1.25*x[2]*x[6] - x[2]*x[0] + 0.25*x[3]*x[5] + x[3]*x[0] - x[3] - 0.25*x[5]*x[4] + 0.25*x[5]*x[1] - 0.25*x[5] + 1.25*x[6]*x[4] + 1.25*x[6]*x[1] - 1.25*x[6] - x[4]*x[0] + 2.0*x[4] - x[0]*x[1];
+ p[1] = -2.25*x[2]*x[6] + 2.0*x[2]*x[0] - x[2] - 1.25*x[3]*x[5] + 1.25*x[5]*x[4] - 1.25*x[5]*x[1] + 1.25*x[5] - 2.25*x[6]*x[4] - 2.25*x[6]*x[1] + 2.25*x[6] + x[4]*x[0] - x[4] + 3.0*x[0]*x[1] - 2.0*x[0] - x[1] + 1.0;
+ p[2] = -x[4] + x[1];
+ p[3] = -1.25*x[2]*x[6] + x[2]*x[0] - 0.25*x[3]*x[5] - x[3]*x[0] + 0.25*x[5]*x[4] - 0.25*x[5]*x[1] + 0.25*x[5] - 1.25*x[6]*x[4] - 1.25*x[6]*x[1] + 1.25*x[6] + x[4]*x[0] + x[0]*x[1];
+ p[4] = x[2]*x[6] - x[2]*x[0] + x[6]*x[4] + x[6]*x[1] - x[6] - x[4]*x[0] - x[0]*x[1] + x[0];
+ p[5] = 1.25*x[2]*x[6] - x[2]*x[0] + 1.25*x[3]*x[5] - 1.25*x[5]*x[4] + 1.25*x[5]*x[1] - 1.25*x[5] + 1.25*x[6]*x[4] + 1.25*x[6]*x[1] - 1.25*x[6] - 2.0*x[0]*x[1] + x[0];
p[6] = x[2];
p[7] = x[3];
}
@@ -653,8 +653,8 @@ Source code for objective_functions.c
void px_mp_ctd(void *SS_ref_db, const double *x){
SS_ref *d = (SS_ref *) SS_ref_db;
double *p = d->p;
- p[0] = -1.0*x[2] + x[1]*x[0] - 1.0*x[1] - 1.0*x[0] + 1.0;
- p[1] = -1.0*x[1]*x[0] + x[0];
+ p[0] = -x[2] + x[1]*x[0] - x[1] - x[0] + 1.0;
+ p[1] = -x[1]*x[0] + x[0];
p[2] = x[1];
p[3] = x[2];
}
@@ -666,8 +666,8 @@ Source code for objective_functions.c
SS_ref *d = (SS_ref *) SS_ref_db;
double *p = d->p;
p[0] = x[1] + (x[0] - 1.0)*(x[2] + 1.0);
- p[1] = (1.0 - 1.0*x[0])*(x[2] + 1.0);
- p[2] = -1.0*x[1] - 1.0*x[2] + 1.0;
+ p[1] = (1.0 - x[0])*(x[2] + 1.0);
+ p[2] = -x[1] - x[2] + 1.0;
p[3] = x[2];
}
@@ -678,8 +678,8 @@ Source code for objective_functions.c
SS_ref *d = (SS_ref *) SS_ref_db;
double *p = d->p;
p[0] = x[3];
- p[1] = -1.0*x[1] + x[0] - 1.0*x[2] - 1.0*x[3];
- p[2] = 1.0 - 1.0*x[0];
+ p[1] = -x[1] + x[0] - x[2] - x[3];
+ p[2] = 1.0 - x[0];
p[3] = x[1];
p[4] = x[2];
}
@@ -692,7 +692,7 @@ Source code for objective_functions.c
double *p = d->p;
p[0] = 3.0*x[1] - 2.0*x[0];
p[1] = -3.0*x[1] + 3.0*x[0];
- p[2] = 1.0 - 1.0*x[0];
+ p[2] = 1.0 - x[0];
}
@@ -711,7 +711,6 @@ Source code for objective_functions.c
double *mu_Gex = d->mu_Gex;
double *sf = d->sf;
double *mu = d->mu;
- double *dfx = d->dfx;
px_mp_liq(SS_ref_db,x);
for (int i = 0; i < n_em; i++){
@@ -725,15 +724,15 @@ Source code for objective_functions.c
}
}
- sf[0] = 1.0 - 1.0*x[6];
+ sf[0] = 1.0 - x[6];
sf[1] = x[0];
sf[2] = x[1]*x[2];
- sf[3] = x[1]*(1.0 - 1.0*x[2]);
+ sf[3] = x[1]*(1.0 - x[2]);
sf[4] = x[3];
- sf[5] = -1.0*x[3] - 1.0*x[1] - 1.0*x[6] - 1.0*x[4] - 1.0*x[0] + 1.0;
+ sf[5] = -x[3] - x[1] - x[6] - x[4] - x[0] + 1.0;
sf[6] = x[4];
sf[7] = x[5];
- sf[8] = 1.0 - 1.0*x[5];
+ sf[8] = 1.0 - x[5];
sf[9] = x[6];
@@ -742,9 +741,9 @@ Source code for objective_functions.c
mu[2] = R*T*creal(clog(sf[0]*sf[3])) + gb[2] + mu_Gex[2];
mu[3] = R*T*creal(clog(sf[0]*sf[4])) + gb[3] + mu_Gex[3];
mu[4] = R*T*creal(clog(sf[0]*sf[5])) + gb[4] + mu_Gex[4];
- mu[5] = R*T*creal(clog(sf[0]*sf[6]*cpow(sf[8], 5.0))) + gb[5] + mu_Gex[5];
- mu[6] = R*T*creal(clog(sf[0]*sf[6]*cpow(sf[7], 5.0))) + gb[6] + mu_Gex[6];
- mu[7] = R*T*creal(clog(cpow(sf[9], 2.0))) + gb[7] + mu_Gex[7];
+ mu[5] = R*T*creal(clog(sf[0]*sf[6]*pow(sf[8], 5.0))) + gb[5] + mu_Gex[5];
+ mu[6] = R*T*creal(clog(sf[0]*sf[6]*pow(sf[7], 5.0))) + gb[6] + mu_Gex[6];
+ mu[7] = R*T*creal(clog(pow(sf[9], 2.0))) + gb[7] + mu_Gex[7];
d->sum_apep = 0.0;
for (int i = 0; i < n_em; i++){
@@ -778,68 +777,77 @@ Source code for objective_functions.c
Objective function of pl4tr_mp
*/
double obj_mp_pl4tr(unsigned n, const double *x, double *grad, void *SS_ref_db){
- SS_ref *d = (SS_ref *) SS_ref_db;
- int n_em = d->n_em;
- double P = d->P;
- double T = d->T;
- double R = d->R;
+ SS_ref *d = (SS_ref *) SS_ref_db;
- double *gb = d->gb_lvl;
- double *mu_Gex = d->mu_Gex;
- double *sf = d->sf;
- double *mu = d->mu;
- double *dfx = d->dfx;
- px_mp_pl4tr(SS_ref_db,x);
+ int n_em = d->n_em;
+ double P = d->P;
+ double T = d->T;
+ double R = d->R;
- for (int i = 0; i < n_em; i++){
- mu_Gex[i] = 0.0;
- int it = 0;
- for (int j = 0; j < d->n_xeos; j++){
- for (int k = j+1; k < n_em; k++){
- mu_Gex[i] -= (d->eye[i][j] - d->p[j])*(d->eye[i][k] - d->p[k])*(d->W[it]);
- it += 1;
- }
- }
- }
-
- sf[0] = -1.0*x[0] - 1.0*x[1] + 1.0;
- sf[1] = x[0];
- sf[2] = x[1];
- sf[3] = 0.25*x[0] + 0.25;
- sf[4] = 0.75 - 0.25*x[0];
-
-
- mu[0] = R*T*creal(clog(1.7547999999999999*cpow(sf[3], 0.25)*sf[0]*cpow(sf[4], 0.75))) + gb[0] + mu_Gex[0];
- mu[1] = R*T*creal(clog(2.0*sqrt(sf[3])*sf[1]*sqrt(sf[4]))) + gb[1] + mu_Gex[1];
- mu[2] = R*T*creal(clog(1.7547999999999999*cpow(sf[3], 0.25)*sf[2]*cpow(sf[4], 0.75))) + gb[2] + mu_Gex[2];
-
- d->sum_apep = 0.0;
- for (int i = 0; i < n_em; i++){
- d->sum_apep += d->ape[i]*d->p[i];
- }
- d->factor = d->fbc/d->sum_apep;
+ double *gb = d->gb_lvl;
+ double *mat_phi= d->mat_phi;
+ double *mu_Gex = d->mu_Gex;
+ double *sf = d->sf;
+ double *mu = d->mu;
- d->df_raw = 0.0;
- for (int i = 0; i < n_em; i++){
- d->df_raw += mu[i]*d->p[i];
- }
- d->df = d->df_raw * d->factor;
+ px_mp_pl4tr(SS_ref_db,x);
- if (grad){
- double *dfx = d->dfx;
- double **dp_dx = d->dp_dx;
- dpdx_mp_pl4tr(SS_ref_db,x);
- for (int i = 0; i < (d->n_xeos); i++){
- dfx[i] = 0.0;
- for (int j = 0; j < n_em; j++){
- dfx[i] += (mu[j] - (d->ape[j]/d->sum_apep)*d->df_raw)*d->factor*dp_dx[j][i];
- }
- grad[i] = creal(dfx[i]);
- }
- }
+ d->sum_v = 0.0;
+ for (int i = 0; i < d->n_em; i++){
+ d->sum_v += d->p[i]*d->v[i];
+ }
+ for (int i = 0; i < d->n_em; i++){
+ d->mat_phi[i] = (d->p[i]*d->v[i])/d->sum_v;
+ }
- return d->df;
+ for (int i = 0; i < d->n_em; i++){
+ mu_Gex[i] = 0.0;
+ int it = 0;
+ for (int j = 0; j < d->n_xeos; j++){
+ for (int k = j+1; k < d->n_em; k++){
+ mu_Gex[i] -= (d->eye[i][j] - d->mat_phi[j])*(d->eye[i][k] - d->mat_phi[k])*(d->W[it]*2.0*d->v[i]/(d->v[j]+d->v[k]));
+ it += 1;
+ }
+ }
+ }
+
+ sf[0] = -x[0] - x[1] + 1.0;
+ sf[1] = x[0];
+ sf[2] = x[1];
+ sf[3] = 0.25*x[0] + 0.25;
+ sf[4] = 0.75 - 0.25*x[0];
+
+ mu[0] = R*T*creal(clog(1.7548*sf[0]*cpow(sf[3], 0.25)*cpow(sf[4], 0.75))) + gb[0] + mu_Gex[0];
+ mu[1] = R*T*creal(clog(2.0*sf[1]*csqrt(sf[3])*csqrt(sf[4]))) + gb[1] + mu_Gex[1];
+ mu[2] = R*T*creal(clog(1.7548*sf[2]*cpow(sf[3], 0.25)*cpow(sf[4], 0.75))) + gb[2] + mu_Gex[2];
+
+ d->sum_apep = 0.0;
+ for (int i = 0; i < n_em; i++){
+ d->sum_apep += d->ape[i]*d->p[i];
+ }
+ d->factor = d->fbc/d->sum_apep;
+
+ d->df_raw = 0.0;
+ for (int i = 0; i < d->n_em; i++){
+ d->df_raw += mu[i]*d->p[i];
+ }
+ d->df = d->df_raw * d->factor;
+
+ if (grad){
+ double *dfx = d->dfx;
+ double **dp_dx = d->dp_dx;
+ dpdx_mp_pl4tr(SS_ref_db,x);
+ for (int i = 0; i < (d->n_xeos); i++){
+ dfx[i] = 0.0;
+ for (int j = 0; j < n_em; j++){
+ dfx[i] += (mu[j] - (d->ape[j]/d->sum_apep)*d->df_raw)*d->factor*dp_dx[j][i];
+ }
+ grad[i] = creal(dfx[i]);
+ }
+ }
+
+ return d->df;
}
[docs]/**
@@ -857,7 +865,6 @@ Source code for objective_functions.c
double *mu_Gex = d->mu_Gex;
double *sf = d->sf;
double *mu = d->mu;
- double *dfx = d->dfx;
px_mp_bi(SS_ref_db,x);
for (int i = 0; i < n_em; i++){
@@ -871,28 +878,28 @@ Source code for objective_functions.c
}
}
- sf[0] = x[3]*x[0] - 1.0*x[3] + 3.0*x[1]*x[0] - 1.0*x[1] - 0.666666666666667*x[5] + x[4]*x[0] - 1.0*x[4] + x[0]*x[2] - 1.0*x[0] - 1.0*x[2] + 1.0;
+ sf[0] = x[3]*x[0] - x[3] + 3.0*x[1]*x[0] - x[1] - 0.666666666666667*x[5] + x[4]*x[0] - x[4] + x[0]*x[2] - x[0] - x[2] + 1.0;
sf[1] = x[1];
- sf[2] = -1.0*x[3]*x[0] - 3.0*x[1]*x[0] + 0.666666666666667*x[5] - 1.0*x[4]*x[0] - 1.0*x[0]*x[2] + x[0];
+ sf[2] = -x[3]*x[0] - 3.0*x[1]*x[0] + 0.666666666666667*x[5] - x[4]*x[0] - x[0]*x[2] + x[0];
sf[3] = x[3];
sf[4] = x[4];
sf[5] = x[2];
- sf[6] = -1.0*x[1] + 0.333333333333333*x[5] - 1.0*x[0] + 1.0;
+ sf[6] = -x[1] + 0.333333333333333*x[5] - x[0] + 1.0;
sf[7] = x[1];
sf[8] = -0.333333333333333*x[5] + x[0];
sf[9] = -0.5*x[3] - 0.5*x[2] + 0.5;
sf[10] = 0.5*x[3] + 0.5*x[2] + 0.5;
- sf[11] = 1.0 - 1.0*x[4];
+ sf[11] = 1.0 - x[4];
sf[12] = x[4];
- mu[0] = R*T*creal(clog(4.0*sf[10]*cpow(sf[6], 2.0)*sf[0]*cpow(sf[11], 2.0)*sf[9])) + gb[0] + mu_Gex[0];
- mu[1] = R*T*creal(clog(4.0*sf[10]*cpow(sf[8], 2.0)*sf[2]*cpow(sf[11], 2.0)*sf[9])) + gb[1] + mu_Gex[1];
- mu[2] = R*T*creal(clog(4.0*sf[10]*sf[2]*cpow(sf[6], 2.0)*cpow(sf[11], 2.0)*sf[9])) + gb[2] + mu_Gex[2];
- mu[3] = R*T*creal(clog(sf[5]*cpow(sf[10], 2.0)*cpow(sf[6], 2.0)*cpow(sf[11], 2.0))) + gb[3] + mu_Gex[3];
- mu[4] = R*T*creal(clog(4.0*sf[10]*cpow(sf[6], 2.0)*cpow(sf[12], 2.0)*sf[9]*sf[4])) + gb[4] + mu_Gex[4];
- mu[5] = R*T*creal(clog(cpow(sf[10], 2.0)*sf[3]*cpow(sf[6], 2.0)*cpow(sf[11], 2.0))) + gb[5] + mu_Gex[5];
- mu[6] = R*T*creal(clog(4.0*sf[10]*cpow(sf[7], 2.0)*sf[1]*cpow(sf[11], 2.0)*sf[9])) + gb[6] + mu_Gex[6];
+ mu[0] = R*T*creal(clog(4.0*sf[10]*pow(sf[6], 2.0)*sf[0]*pow(sf[11], 2.0)*sf[9])) + gb[0] + mu_Gex[0];
+ mu[1] = R*T*creal(clog(4.0*sf[10]*pow(sf[8], 2.0)*sf[2]*pow(sf[11], 2.0)*sf[9])) + gb[1] + mu_Gex[1];
+ mu[2] = R*T*creal(clog(4.0*sf[10]*sf[2]*pow(sf[6], 2.0)*pow(sf[11], 2.0)*sf[9])) + gb[2] + mu_Gex[2];
+ mu[3] = R*T*creal(clog(sf[5]*pow(sf[10], 2.0)*pow(sf[6], 2.0)*pow(sf[11], 2.0))) + gb[3] + mu_Gex[3];
+ mu[4] = R*T*creal(clog(4.0*sf[10]*pow(sf[6], 2.0)*pow(sf[12], 2.0)*sf[9]*sf[4])) + gb[4] + mu_Gex[4];
+ mu[5] = R*T*creal(clog(pow(sf[10], 2.0)*sf[3]*pow(sf[6], 2.0)*pow(sf[11], 2.0))) + gb[5] + mu_Gex[5];
+ mu[6] = R*T*creal(clog(4.0*sf[10]*pow(sf[7], 2.0)*sf[1]*pow(sf[11], 2.0)*sf[9])) + gb[6] + mu_Gex[6];
d->sum_apep = 0.0;
for (int i = 0; i < n_em; i++){
@@ -922,6 +929,7 @@ Source code for objective_functions.c
return d->df;
}
+
[docs]/**
Objective function of g_mp
*/
@@ -938,7 +946,7 @@ Source code for objective_functions.c
double *mu_Gex = d->mu_Gex;
double *sf = d->sf;
double *mu = d->mu;
- double *dfx = d->dfx;
+
px_mp_g(SS_ref_db,x);
d->sum_v = 0.0;
@@ -960,32 +968,32 @@ Source code for objective_functions.c
}
}
- sf[0] = -1.0*x[3] + x[2]*x[0] - 1.0*x[2] + x[0]*x[1] - 1.0*x[0] - 1.0*x[1] + 1.0;
- sf[1] = -1.0*x[2]*x[0] - 1.0*x[0]*x[1] + x[0];
+ sf[0] = x[2]*x[0] - x[2] + x[0]*x[1] - x[0] - x[1] + 1.0;
+ sf[1] = -x[2]*x[0] - x[0]*x[1] + x[0];
sf[2] = x[2];
sf[3] = x[1];
- sf[4] = 1.0 - 1.0*x[3];
+ sf[4] = 1.0 - x[3];
sf[5] = x[3];
+ mu[0] = R*T*creal(clog(pow(sf[4], 2.0)*pow(sf[0], 3.0))) + gb[0] + mu_Gex[0];
+ mu[1] = R*T*creal(clog(pow(sf[4], 2.0)*pow(sf[1], 3.0))) + gb[1] + mu_Gex[1];
+ mu[2] = R*T*creal(clog(pow(sf[4], 2.0)*pow(sf[2], 3.0))) + gb[2] + mu_Gex[2];
+ mu[3] = R*T*creal(clog(pow(sf[4], 2.0)*pow(sf[3], 3.0))) + gb[3] + mu_Gex[3];
+ mu[4] = R*T*creal(clog(pow(sf[5], 2.0)*pow(sf[0], 3.0))) + gb[4] + mu_Gex[4];
- mu[0] = R*T*creal(clog(cpow(sf[4], 2.0)*cpow(sf[0], 3.0))) + gb[0] + mu_Gex[0];
- mu[1] = R*T*creal(clog(cpow(sf[4], 2.0)*cpow(sf[1], 3.0))) + gb[1] + mu_Gex[1];
- mu[2] = R*T*creal(clog(cpow(sf[4], 2.0)*cpow(sf[2], 3.0))) + gb[2] + mu_Gex[2];
- mu[3] = R*T*creal(clog(cpow(sf[4], 2.0)*cpow(sf[3], 3.0))) + gb[3] + mu_Gex[3];
- mu[4] = R*T*creal(clog(cpow(sf[5], 2.0)*cpow(sf[0], 3.0))) + gb[4] + mu_Gex[4];
-
- d->sum_apep = 0.0;
- for (int i = 0; i < n_em; i++){
- d->sum_apep += d->ape[i]*d->p[i];
- }
- d->factor = d->fbc/d->sum_apep;
- d->df_raw = 0.0;
- for (int i = 0; i < n_em; i++){
- d->df_raw += mu[i]*d->p[i];
- }
- d->df = d->df_raw * d->factor;
+ d->sum_apep = 0.0;
+ for (int i = 0; i < n_em; i++){
+ d->sum_apep += d->ape[i]*d->p[i];
+ }
+ d->factor = d->fbc/d->sum_apep;
+ d->df_raw = 0.0;
+ for (int i = 0; i < d->n_em; i++){
+ d->df_raw += mu[i]*d->p[i];
+ }
+ d->df = d->df_raw * d->factor;
+
if (grad){
double *dfx = d->dfx;
double **dp_dx = d->dp_dx;
@@ -997,8 +1005,21 @@ Source code for objective_functions.c
}
grad[i] = creal(dfx[i]);
}
+ // printf("grad \n");
+ // for (int i = 0; i < (d->n_xeos); i++){
+ // printf(" %+5f", grad[i]);
+ // }
}
+ // printf("d->df %+10f d->df_raw %+10f d->factor %+10f \n",d->df,d->df_raw,d->factor);
+
+ // printf("\n");
+ // printf(" %6s %6s %6s %6s %6s %6s\n","GB","MAT_PHI","MU_GEX","SF","MU","P");
+ // for (int i = 0; i < d->n_em; i++){
+ // printf(" %+5f %+5f %+5f %+5f %+5f %+5f\n",gb[i],mat_phi[i],mu_Gex[i],sf[i],mu[i],d->p[i]);
+ // }
+
+
return d->df;
}
@@ -1017,7 +1038,6 @@ Source code for objective_functions.c
double *mu_Gex = d->mu_Gex;
double *sf = d->sf;
double *mu = d->mu;
- double *dfx = d->dfx;
px_mp_ep(SS_ref_db,x);
for (int i = 0; i < n_em; i++){
@@ -1031,10 +1051,10 @@ Source code for objective_functions.c
}
}
- sf[0] = x[0] - 1.0*x[1];
- sf[1] = -1.0*x[0] + x[1] + 1.0;
+ sf[0] = x[0] - x[1];
+ sf[1] = -x[0] + x[1] + 1.0;
sf[2] = x[0] + x[1];
- sf[3] = -1.0*x[0] - 1.0*x[1] + 1.0;
+ sf[3] = -x[0] - x[1] + 1.0;
mu[0] = R*T*creal(clog(sf[1]*sf[3])) + gb[0] + mu_Gex[0];
@@ -1085,7 +1105,6 @@ Source code for objective_functions.c
double *mu_Gex = d->mu_Gex;
double *sf = d->sf;
double *mu = d->mu;
- double *dfx = d->dfx;
px_mp_ma(SS_ref_db,x);
d->sum_v = 0.0;
@@ -1107,13 +1126,13 @@ Source code for objective_functions.c
}
}
- sf[0] = -1.0*x[4] - 1.0*x[3] + 1.0;
+ sf[0] = -x[4] - x[3] + 1.0;
sf[1] = x[3];
sf[2] = x[4];
- sf[3] = x[0]*x[1] - 1.0*x[0] - 1.0*x[1] + 1.0;
- sf[4] = -1.0*x[0]*x[1] + x[0];
+ sf[3] = x[0]*x[1] - x[0] - x[1] + 1.0;
+ sf[4] = -x[0]*x[1] + x[0];
sf[5] = x[1];
- sf[6] = 1.0 - 1.0*x[2];
+ sf[6] = 1.0 - x[2];
sf[7] = x[2];
sf[8] = -0.5*x[4] - 0.5*x[1] + 1.0;
sf[9] = 0.5*x[4] + 0.5*x[1];
@@ -1170,7 +1189,6 @@ Source code for objective_functions.c
double *mu_Gex = d->mu_Gex;
double *sf = d->sf;
double *mu = d->mu;
- double *dfx = d->dfx;
px_mp_mu(SS_ref_db,x);
d->sum_v = 0.0;
@@ -1192,23 +1210,23 @@ Source code for objective_functions.c
}
}
- sf[0] = -1.0*x[4] - 1.0*x[3] + 1.0;
+ sf[0] = -x[4] - x[3] + 1.0;
sf[1] = x[3];
sf[2] = x[4];
- sf[3] = x[0]*x[1] - 1.0*x[0] - 1.0*x[1] + 1.0;
- sf[4] = -1.0*x[0]*x[1] + x[0];
+ sf[3] = x[0]*x[1] - x[0] - x[1] + 1.0;
+ sf[4] = -x[0]*x[1] + x[0];
sf[5] = x[1];
- sf[6] = 1.0 - 1.0*x[2];
+ sf[6] = 1.0 - x[2];
sf[7] = x[2];
sf[8] = -0.5*x[4] - 0.5*x[1] + 1.0;
sf[9] = 0.5*x[4] + 0.5*x[1];
mu[0] = R*T*creal(clog(4.0*sf[5]*sf[6]*sf[9]*sf[0]*sf[8])) + gb[0] + mu_Gex[0];
- mu[1] = R*T*creal(clog(sf[6]*sf[0]*sf[3]*cpow(sf[8], 2.0))) + gb[1] + mu_Gex[1];
- mu[2] = R*T*creal(clog(sf[6]*sf[4]*sf[0]*cpow(sf[8], 2.0))) + gb[2] + mu_Gex[2];
+ mu[1] = R*T*creal(clog(sf[6]*sf[0]*sf[3]*pow(sf[8], 2.0))) + gb[1] + mu_Gex[1];
+ mu[2] = R*T*creal(clog(sf[6]*sf[4]*sf[0]*pow(sf[8], 2.0))) + gb[2] + mu_Gex[2];
mu[3] = R*T*creal(clog(4.0*sf[5]*sf[6]*sf[9]*sf[1]*sf[8])) + gb[3] + mu_Gex[3];
- mu[4] = R*T*creal(clog(sf[5]*sf[6]*cpow(sf[9], 2.0)*sf[2])) + gb[4] + mu_Gex[4];
+ mu[4] = R*T*creal(clog(sf[5]*sf[6]*pow(sf[9], 2.0)*sf[2])) + gb[4] + mu_Gex[4];
mu[5] = R*T*creal(clog(4.0*sf[5]*sf[9]*sf[7]*sf[0]*sf[8])) + gb[5] + mu_Gex[5];
d->sum_apep = 0.0;
@@ -1255,7 +1273,6 @@ Source code for objective_functions.c
double *mu_Gex = d->mu_Gex;
double *sf = d->sf;
double *mu = d->mu;
- double *dfx = d->dfx;
px_mp_opx(SS_ref_db,x);
d->sum_v = 0.0;
@@ -1277,26 +1294,26 @@ Source code for objective_functions.c
}
}
- sf[0] = -0.5*x[4]*x[5] + x[3]*x[0] - 1.0*x[3] - 0.5*x[1]*x[5] + x[1]*x[0] - 1.0*x[1] + 0.5*x[5] + x[0]*x[2] - 1.0*x[0] - 1.0*x[2] + 1.0;
- sf[1] = 0.5*x[4]*x[5] - 1.0*x[3]*x[0] + 0.5*x[1]*x[5] - 1.0*x[1]*x[0] - 0.5*x[5] - 1.0*x[0]*x[2] + x[0];
+ sf[0] = -0.5*x[4]*x[5] + x[3]*x[0] - x[3] - 0.5*x[1]*x[5] + x[1]*x[0] - x[1] + 0.5*x[5] + x[0]*x[2] - x[0] - x[2] + 1.0;
+ sf[1] = 0.5*x[4]*x[5] - x[3]*x[0] + 0.5*x[1]*x[5] - x[1]*x[0] - 0.5*x[5] - x[0]*x[2] + x[0];
sf[2] = x[1];
sf[3] = x[3];
sf[4] = x[2];
- sf[5] = 0.5*x[4]*x[5] + x[4]*x[0] - 1.0*x[4] + 0.5*x[1]*x[5] + x[1]*x[0] - 1.0*x[1] - 0.5*x[5] - 1.0*x[0] + 1.0;
- sf[6] = -0.5*x[4]*x[5] - 1.0*x[4]*x[0] - 0.5*x[1]*x[5] - 1.0*x[1]*x[0] + 0.5*x[5] + x[0];
+ sf[5] = 0.5*x[4]*x[5] + x[4]*x[0] - x[4] + 0.5*x[1]*x[5] + x[1]*x[0] - x[1] - 0.5*x[5] - x[0] + 1.0;
+ sf[6] = -0.5*x[4]*x[5] - x[4]*x[0] - 0.5*x[1]*x[5] - x[1]*x[0] + 0.5*x[5] + x[0];
sf[7] = x[1];
sf[8] = x[4];
sf[9] = 0.5*x[3] + 0.5*x[2];
- sf[10] = -0.5*x[3] - 0.5*x[2] + 1.0;
+ sf[10] = -0.5*x[3] - 0.5*x[2] + 1.0;
- mu[0] = R*T*creal(clog(sf[0]*sf[5]*sqrt(sf[10]))) + gb[0] + mu_Gex[0];
- mu[1] = R*T*creal(clog(sf[1]*sf[6]*sqrt(sf[10]))) + gb[1] + mu_Gex[1];
- mu[2] = R*T*creal(clog(sf[6]*sf[0]*sqrt(sf[10]))) + gb[2] + mu_Gex[2];
- mu[3] = R*T*creal(clog(1.4141999999999999*sf[4]*cpow(sf[9], 0.25)*sf[5]*cpow(sf[10], 0.25))) + gb[3] + mu_Gex[3];
- mu[4] = R*T*creal(clog(1.4141999999999999*cpow(sf[9], 0.25)*sf[3]*sf[5]*cpow(sf[10], 0.25))) + gb[4] + mu_Gex[4];
- mu[5] = R*T*creal(clog(sf[2]*sf[7]*sqrt(sf[10]))) + gb[5] + mu_Gex[5];
- mu[6] = R*T*creal(clog(sf[8]*sf[0]*sqrt(sf[10]))) + gb[6] + mu_Gex[6];
+ mu[0] = R*T*creal(clog(sf[0]*sf[5]*csqrt(sf[10]))) + gb[0] + mu_Gex[0];
+ mu[1] = R*T*creal(clog(sf[1]*sf[6]*csqrt(sf[10]))) + gb[1] + mu_Gex[1];
+ mu[2] = R*T*creal(clog(sf[6]*sf[0]*csqrt(sf[10]))) + gb[2] + mu_Gex[2];
+ mu[3] = R*T*creal(clog(1.4142*sf[4]*cpow(sf[9], 0.25)*sf[5]*cpow(sf[10], 0.25))) + gb[3] + mu_Gex[3];
+ mu[4] = R*T*creal(clog(1.4142*cpow(sf[9], 0.25)*sf[3]*sf[5]*cpow(sf[10], 0.25))) + gb[4] + mu_Gex[4];
+ mu[5] = R*T*creal(clog(sf[2]*sf[7]*csqrt(sf[10]))) + gb[5] + mu_Gex[5];
+ mu[6] = R*T*creal(clog(sf[8]*sf[0]*csqrt(sf[10]))) + gb[6] + mu_Gex[6];
d->sum_apep = 0.0;
for (int i = 0; i < n_em; i++){
@@ -1341,7 +1358,6 @@ Source code for objective_functions.c
double *mu_Gex = d->mu_Gex;
double *sf = d->sf;
double *mu = d->mu;
- double *dfx = d->dfx;
px_mp_sa(SS_ref_db,x);
for (int i = 0; i < n_em; i++){
@@ -1355,21 +1371,21 @@ Source code for objective_functions.c
}
}
- sf[0] = x[2]*x[0] - 1.0*x[2] + 0.75*x[3] + x[0]*x[1] - 1.0*x[0] - 1.0*x[1] + 1.0;
- sf[1] = -1.0*x[2]*x[0] - 0.75*x[3] - 1.0*x[0]*x[1] + x[0];
+ sf[0] = x[2]*x[0] - x[2] + 0.75*x[3] + x[0]*x[1] - x[0] - x[1] + 1.0;
+ sf[1] = -x[2]*x[0] - 0.75*x[3] - x[0]*x[1] + x[0];
sf[2] = x[2];
sf[3] = x[1];
- sf[4] = -0.25*x[3] - 1.0*x[0] + 1.0;
+ sf[4] = -0.25*x[3] - x[0] + 1.0;
sf[5] = 0.25*x[3] + x[0];
- sf[6] = -1.0*x[2] - 1.0*x[1] + 1.0;
+ sf[6] = -x[2] - x[1] + 1.0;
sf[7] = x[2] + x[1];
- mu[0] = R*T*creal(clog(sf[0]*cpow(sf[4], 3.0)*sf[6])) + gb[0] + mu_Gex[0];
- mu[1] = R*T*creal(clog(sf[3]*sf[7]*cpow(sf[4], 3.0))) + gb[1] + mu_Gex[1];
- mu[2] = R*T*creal(clog(sf[1]*cpow(sf[5], 3.0)*sf[6])) + gb[2] + mu_Gex[2];
- mu[3] = R*T*creal(clog(cpow(sf[5], 3.0)*sf[0]*sf[6])) + gb[3] + mu_Gex[3];
- mu[4] = R*T*creal(clog(sf[7]*sf[2]*cpow(sf[4], 3.0))) + gb[4] + mu_Gex[4];
+ mu[0] = R*T*creal(clog(sf[0]*pow(sf[4], 3.0)*sf[6])) + gb[0] + mu_Gex[0];
+ mu[1] = R*T*creal(clog(sf[3]*sf[7]*pow(sf[4], 3.0))) + gb[1] + mu_Gex[1];
+ mu[2] = R*T*creal(clog(sf[1]*pow(sf[5], 3.0)*sf[6])) + gb[2] + mu_Gex[2];
+ mu[3] = R*T*creal(clog(pow(sf[5], 3.0)*sf[0]*sf[6])) + gb[3] + mu_Gex[3];
+ mu[4] = R*T*creal(clog(sf[7]*sf[2]*pow(sf[4], 3.0))) + gb[4] + mu_Gex[4];
d->sum_apep = 0.0;
for (int i = 0; i < n_em; i++){
@@ -1414,7 +1430,6 @@ Source code for objective_functions.c
double *mu_Gex = d->mu_Gex;
double *sf = d->sf;
double *mu = d->mu;
- double *dfx = d->dfx;
px_mp_cd(SS_ref_db,x);
for (int i = 0; i < n_em; i++){
@@ -1429,16 +1444,16 @@ Source code for objective_functions.c
}
sf[0] = x[0];
- sf[1] = 1.0 - 1.0*x[0];
+ sf[1] = 1.0 - x[0];
sf[2] = x[1];
sf[3] = x[2];
- sf[4] = 1.0 - 1.0*x[2];
+ sf[4] = 1.0 - x[2];
- mu[0] = R*T*creal(clog(cpow(sf[1], 2.0)*sf[4])) + gb[0] + mu_Gex[0];
- mu[1] = R*T*creal(clog(cpow(sf[0], 2.0)*sf[4])) + gb[1] + mu_Gex[1];
- mu[2] = R*T*creal(clog(sf[3]*cpow(sf[1], 2.0))) + gb[2] + mu_Gex[2];
- mu[3] = R*T*creal(clog(cpow(sf[2], 2.0)*sf[4])) + gb[3] + mu_Gex[3];
+ mu[0] = R*T*creal(clog(pow(sf[1], 2.0)*sf[4])) + gb[0] + mu_Gex[0];
+ mu[1] = R*T*creal(clog(pow(sf[0], 2.0)*sf[4])) + gb[1] + mu_Gex[1];
+ mu[2] = R*T*creal(clog(sf[3]*pow(sf[1], 2.0))) + gb[2] + mu_Gex[2];
+ mu[3] = R*T*creal(clog(pow(sf[2], 2.0)*sf[4])) + gb[3] + mu_Gex[3];
d->sum_apep = 0.0;
for (int i = 0; i < n_em; i++){
@@ -1483,7 +1498,6 @@ Source code for objective_functions.c
double *mu_Gex = d->mu_Gex;
double *sf = d->sf;
double *mu = d->mu;
- double *dfx = d->dfx;
px_mp_st(SS_ref_db,x);
for (int i = 0; i < n_em; i++){
@@ -1497,20 +1511,20 @@ Source code for objective_functions.c
}
}
- sf[0] = x[1]*x[0] - 1.0*x[1] - 1.0*x[0] + 1.0;
- sf[1] = -1.0*x[1]*x[0] + x[0];
+ sf[0] = x[1]*x[0] - x[1] - x[0] + 1.0;
+ sf[1] = -x[1]*x[0] + x[0];
sf[2] = x[1];
- sf[3] = -1.0*x[2] - 1.33333333333333*x[3] + 1.0;
+ sf[3] = -x[2] - 1.33333333333333*x[3] + 1.0;
sf[4] = x[2];
sf[5] = x[3];
sf[6] = 0.333333333333333*x[3];
- mu[0] = R*T*creal(clog(cpow(sf[3], 2.0)*cpow(sf[0], 4.0))) + gb[0] + mu_Gex[0];
- mu[1] = R*T*creal(clog(cpow(sf[3], 2.0)*cpow(sf[1], 4.0))) + gb[1] + mu_Gex[1];
- mu[2] = R*T*creal(clog(cpow(sf[3], 2.0)*cpow(sf[2], 4.0))) + gb[2] + mu_Gex[2];
- mu[3] = R*T*creal(clog(cpow(sf[4], 2.0)*cpow(sf[0], 4.0))) + gb[3] + mu_Gex[3];
- mu[4] = R*T*creal(clog(3.0792000000000002*cpow(sf[0], 4.0)*cpow(sf[5], 1.5)*sqrt(sf[6]))) + gb[4] + mu_Gex[4];
+ mu[0] = R*T*creal(clog(pow(sf[3], 2.0)*pow(sf[0], 4.0))) + gb[0] + mu_Gex[0];
+ mu[1] = R*T*creal(clog(pow(sf[3], 2.0)*pow(sf[1], 4.0))) + gb[1] + mu_Gex[1];
+ mu[2] = R*T*creal(clog(pow(sf[3], 2.0)*pow(sf[2], 4.0))) + gb[2] + mu_Gex[2];
+ mu[3] = R*T*creal(clog(pow(sf[4], 2.0)*pow(sf[0], 4.0))) + gb[3] + mu_Gex[3];
+ mu[4] = R*T*creal(clog(3.0792*pow(sf[0], 4.0)*pow(sf[5], 1.5)*csqrt(sf[6]))) + gb[4] + mu_Gex[4];
d->sum_apep = 0.0;
for (int i = 0; i < n_em; i++){
@@ -1555,7 +1569,6 @@ Source code for objective_functions.c
double *mu_Gex = d->mu_Gex;
double *sf = d->sf;
double *mu = d->mu;
- double *dfx = d->dfx;
px_mp_chl(SS_ref_db,x);
for (int i = 0; i < n_em; i++){
@@ -1569,29 +1582,28 @@ Source code for objective_functions.c
}
}
- sf[0] = -1.0*x[3]*x[5] + x[3]*x[0] - 1.0*x[3] + x[5]*x[4] - 1.0*x[5]*x[1] + x[5] - 1.0*x[4]*x[0] + x[4] + x[0]*x[1] - 1.0*x[0] - 1.0*x[1] + 1.0;
- sf[1] = x[3];
- sf[2] = x[3]*x[5] - 1.0*x[3]*x[0] - 1.0*x[5]*x[4] + x[5]*x[1] - 1.0*x[5] + x[4]*x[0] - 1.0*x[0]*x[1] + x[0];
- sf[3] = -1.0*x[4] + x[1];
- sf[4] = 0.25*x[2]*x[6] + 0.25*x[3]*x[5] + x[3]*x[0] - 1.0*x[3] - 0.25*x[5]*x[4] + 0.25*x[5]*x[1] - 0.25*x[5] + 0.25*x[6]*x[4] + 0.25*x[6]*x[1] - 0.25*x[6] - 1.0*x[0] + 1.0;
- sf[5] = x[3];
- sf[6] = -0.25*x[2]*x[6] - 0.25*x[3]*x[5] - 1.0*x[3]*x[0] + 0.25*x[5]*x[4] - 0.25*x[5]*x[1] + 0.25*x[5] - 0.25*x[6]*x[4] - 0.25*x[6]*x[1] + 0.25*x[6] + x[0];
- sf[7] = -1.0*x[2]*x[6] + x[2]*x[0] - 1.0*x[2] - 1.0*x[6]*x[4] - 1.0*x[6]*x[1] + x[6] + x[4]*x[0] - 1.0*x[4] + x[0]*x[1] - 1.0*x[0] - 1.0*x[1] + 1.0;
- sf[8] = x[2]*x[6] - 1.0*x[2]*x[0] + x[6]*x[4] + x[6]*x[1] - 1.0*x[6] - 1.0*x[4]*x[0] - 1.0*x[0]*x[1] + x[0];
- sf[9] = x[2];
- sf[10] = x[4] + x[1];
- sf[11] = -0.5*x[2] - 1.0*x[1] + 1.0;
- sf[12] = 0.5*x[2] + x[1];
-
-
- mu[0] = R*T*creal(clog(4.0*sf[10]*sf[12]*sf[0]*cpow(sf[4], 4.0)*sf[11])) + gb[0] + mu_Gex[0];
- mu[1] = R*T*creal(clog(sf[0]*cpow(sf[4], 4.0)*sf[7]*cpow(sf[11], 2.0))) + gb[1] + mu_Gex[1];
- mu[2] = R*T*creal(clog(sf[3]*sf[10]*cpow(sf[12], 2.0)*cpow(sf[4], 4.0))) + gb[2] + mu_Gex[2];
- mu[3] = R*T*creal(clog(4.0*sf[10]*sf[12]*sf[2]*cpow(sf[6], 4.0)*sf[11])) + gb[3] + mu_Gex[3];
- mu[4] = R*T*creal(clog(cpow(sf[6], 4.0)*sf[8]*sf[0]*cpow(sf[11], 2.0))) + gb[4] + mu_Gex[4];
- mu[5] = R*T*creal(clog(sf[2]*cpow(sf[4], 4.0)*sf[7]*cpow(sf[11], 2.0))) + gb[5] + mu_Gex[5];
- mu[6] = R*T*creal(clog(4.0*sf[12]*sf[9]*sf[0]*cpow(sf[4], 4.0)*sf[11])) + gb[6] + mu_Gex[6];
- mu[7] = R*T*creal(clog(4.0*sf[10]*sf[12]*sf[1]*cpow(sf[5], 4.0)*sf[11])) + gb[7] + mu_Gex[7];
+ sf[0] = -x[3]*x[5] + x[3]*x[0] - x[3] + x[5]*x[4] - x[5]*x[1] + x[5] - x[4]*x[0] + x[4] + x[0]*x[1] - x[0] - x[1] + 1.0;
+ sf[1] = x[3]*x[5] - x[3]*x[0] - x[5]*x[4] + x[5]*x[1] - x[5] + x[4]*x[0] - x[0]*x[1] + x[0];
+ sf[2] = -x[4] + x[1];
+ sf[3] = 0.25*x[2]*x[6] + 0.25*x[3]*x[5] + x[3]*x[0] - x[3] - 0.25*x[5]*x[4] + 0.25*x[5]*x[1] - 0.25*x[5] + 0.25*x[6]*x[4] + 0.25*x[6]*x[1] - 0.25*x[6] - x[0] + 1.0;
+ sf[4] = x[3];
+ sf[5] = -0.25*x[2]*x[6] - 0.25*x[3]*x[5] - x[3]*x[0] + 0.25*x[5]*x[4] - 0.25*x[5]*x[1] + 0.25*x[5] - 0.25*x[6]*x[4] - 0.25*x[6]*x[1] + 0.25*x[6] + x[0];
+ sf[6] = -x[2]*x[6] + x[2]*x[0] - x[2] - x[6]*x[4] - x[6]*x[1] + x[6] + x[4]*x[0] - x[4] + x[0]*x[1] - x[0] - x[1] + 1.0;
+ sf[7] = x[2]*x[6] - x[2]*x[0] + x[6]*x[4] + x[6]*x[1] - x[6] - x[4]*x[0] - x[0]*x[1] + x[0];
+ sf[8] = x[2];
+ sf[9] = x[4] + x[1];
+ sf[10] = -0.5*x[2] - x[1] + 1.0;
+ sf[11] = 0.5*x[2] + x[1];
+
+
+ mu[0] = R*T*creal(clog(4.0*sf[9]*sf[11]*sf[0]*pow(sf[3], 4.0)*sf[10])) + gb[0] + mu_Gex[0];
+ mu[1] = R*T*creal(clog(sf[0]*pow(sf[3], 4.0)*sf[6]*pow(sf[10], 2.0))) + gb[1] + mu_Gex[1];
+ mu[2] = R*T*creal(clog(sf[2]*sf[9]*pow(sf[11], 2.0)*pow(sf[3], 4.0))) + gb[2] + mu_Gex[2];
+ mu[3] = R*T*creal(clog(4.0*sf[9]*sf[11]*sf[1]*pow(sf[5], 4.0)*sf[10])) + gb[3] + mu_Gex[3];
+ mu[4] = R*T*creal(clog(pow(sf[5], 4.0)*sf[7]*sf[0]*pow(sf[10], 2.0))) + gb[4] + mu_Gex[4];
+ mu[5] = R*T*creal(clog(sf[1]*pow(sf[3], 4.0)*sf[6]*pow(sf[10], 2.0))) + gb[5] + mu_Gex[5];
+ mu[6] = R*T*creal(clog(4.0*sf[11]*sf[8]*sf[0]*pow(sf[3], 4.0)*sf[10])) + gb[6] + mu_Gex[6];
+ mu[7] = R*T*creal(clog(4.0*sf[9]*sf[11]*pow(sf[4], 5.0)*sf[10])) + gb[7] + mu_Gex[7];
d->sum_apep = 0.0;
for (int i = 0; i < n_em; i++){
@@ -1636,7 +1648,6 @@ Source code for objective_functions.c
double *mu_Gex = d->mu_Gex;
double *sf = d->sf;
double *mu = d->mu;
- double *dfx = d->dfx;
px_mp_ctd(SS_ref_db,x);
for (int i = 0; i < n_em; i++){
@@ -1650,10 +1661,10 @@ Source code for objective_functions.c
}
}
- sf[0] = 1.0 - 1.0*x[2];
+ sf[0] = 1.0 - x[2];
sf[1] = x[2];
- sf[2] = -1.0*x[1]*x[0] + x[0];
- sf[3] = x[1]*x[0] - 1.0*x[1] - 1.0*x[0] + 1.0;
+ sf[2] = -x[1]*x[0] + x[0];
+ sf[3] = x[1]*x[0] - x[1] - x[0] + 1.0;
sf[4] = x[1];
@@ -1705,7 +1716,6 @@ Source code for objective_functions.c
double *mu_Gex = d->mu_Gex;
double *sf = d->sf;
double *mu = d->mu;
- double *dfx = d->dfx;
px_mp_sp(SS_ref_db,x);
for (int i = 0; i < n_em; i++){
@@ -1720,9 +1730,9 @@ Source code for objective_functions.c
}
sf[0] = x[1];
- sf[1] = -1.0*x[1] - 1.0*x[2] + 1.0;
+ sf[1] = -x[1] - x[2] + 1.0;
sf[2] = x[2];
- sf[3] = 1.0 - 1.0*x[0];
+ sf[3] = 1.0 - x[0];
sf[4] = x[0];
@@ -1774,7 +1784,6 @@ Source code for objective_functions.c
double *mu_Gex = d->mu_Gex;
double *sf = d->sf;
double *mu = d->mu;
- double *dfx = d->dfx;
px_mp_ilm(SS_ref_db,x);
for (int i = 0; i < n_em; i++){
@@ -1788,21 +1797,19 @@ Source code for objective_functions.c
}
}
- sf[0] = -0.5*x[1] + 0.5*x[0] - 0.5*x[2] + 0.5*x[3];
- sf[1] = -0.5*x[1] + 0.5*x[0] - 0.5*x[2] - 0.5*x[3];
+ sf[0] = -0.5*x[2] + 0.5*x[3] + 0.5*x[0] - 0.5*x[1];
+ sf[1] = -0.5*x[2] - 0.5*x[3] + 0.5*x[0] - 0.5*x[1];
sf[2] = x[1];
sf[3] = x[2];
sf[4] = 1.0 - 1.0*x[0];
- sf[5] = -0.5*x[1] + 0.5*x[0] - 0.5*x[2] - 0.5*x[3];
- sf[6] = 0.5*x[1] + 0.5*x[0] + 0.5*x[2] + 0.5*x[3];
- sf[7] = 1.0 - 1.0*x[0];
+ sf[5] = 0.5*x[2] + 0.5*x[3] + 0.5*x[0] + 0.5*x[1];
- mu[0] = R*T*creal(clog(sf[0]*sf[6])) + gb[0] + mu_Gex[0];
- mu[1] = R*T*creal(clog(4.0*sqrt(sf[0])*sqrt(sf[5])*sqrt(sf[1])*sqrt(sf[6]))) + gb[1] + mu_Gex[1];
- mu[2] = R*T*creal(clog(sf[4]*sf[7])) + gb[2] + mu_Gex[2];
- mu[3] = R*T*creal(clog(sf[2]*sf[6])) + gb[3] + mu_Gex[3];
- mu[4] = R*T*creal(clog(sf[3]*sf[6])) + gb[4] + mu_Gex[4];
+ mu[0] = R*T*creal(clog(sf[0]*sf[5])) + gb[0] + mu_Gex[0];
+ mu[1] = R*T*creal(clog(4.0*sqrt(sf[0])*sf[1]*sqrt(sf[5]))) + gb[1] + mu_Gex[1];
+ mu[2] = R*T*creal(clog(pow(sf[4], 2.0))) + gb[2] + mu_Gex[2];
+ mu[3] = R*T*creal(clog(sf[2]*sf[5])) + gb[3] + mu_Gex[3];
+ mu[4] = R*T*creal(clog(sf[3]*sf[5])) + gb[4] + mu_Gex[4];
d->sum_apep = 0.0;
for (int i = 0; i < n_em; i++){
@@ -1847,7 +1854,6 @@ Source code for objective_functions.c
double *mu_Gex = d->mu_Gex;
double *sf = d->sf;
double *mu = d->mu;
- double *dfx = d->dfx;
px_mp_mt(SS_ref_db,x);
for (int i = 0; i < n_em; i++){
@@ -1865,11 +1871,11 @@ Source code for objective_functions.c
sf[1] = -0.5*x[1] + x[0];
sf[2] = 0.5*x[1] - 0.5*x[0] + 0.5;
sf[3] = x[1];
- sf[4] = 1.0 - 1.0*x[1];
+ sf[4] = 1.0 - x[1];
mu[0] = R*T*creal(clog(4.0*sf[1]*sf[3]*sf[2])) + gb[0] + mu_Gex[0];
- mu[1] = R*T*creal(clog(6.75*cpow(sf[1], 1.3333333333333333)*cpow(sf[3], 0.66666666666666663)*cpow(sf[2], 0.66666666666666663)*cpow(sf[4], 0.33333333333333331))) + gb[1] + mu_Gex[1];
+ mu[1] = R*T*creal(clog(6.75*pow(sf[1], 4.0/3.0)*cpow(sf[3], 2.0/3.0)*cpow(sf[2], 2.0/3.0)*cpow(sf[4], 1.0/3.0))) + gb[1] + mu_Gex[1];
mu[2] = R*T*creal(clog(4.0*sf[2]*sf[4]*sf[0])) + gb[2] + mu_Gex[2];
d->sum_apep = 0.0;
@@ -2214,7 +2220,6 @@ Source code for objective_functions.c
d->iguess[i] = d->bounds[i][1];
}
}
-
}
[docs]/**
@@ -2265,7 +2270,346 @@ Source code for objective_functions.c
d->iguess[i] = d->bounds[i][1];
}
}
+}
+
+[docs]/**
+ Endmember to xeos for bi_mp
+*/
+void p2x_mp_bi(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[1] = d->p[6];
+ d->iguess[3] = d->p[5];
+ d->iguess[4] = d->p[4];
+ d->iguess[2] = d->p[3];
+ d->iguess[5] = 3.0*(-d->iguess[3]*d->p[1] + d->iguess[3] - 3.0*d->iguess[1]*d->p[1] + d->iguess[1] + d->p[0] - d->p[1]*d->iguess[4] - d->p[1]*d->iguess[2] + d->p[1] + d->iguess[4] + d->iguess[2] - 1.0)/(d->iguess[3] + 3.0*d->iguess[1] + d->iguess[4] + d->iguess[2] - 3.0);
+ d->iguess[0] = (-d->p[2] + d->iguess[5])/(d->iguess[3] + 3.0*d->iguess[1] + d->iguess[4] + d->iguess[2]);
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
+}
+
+[docs]/**
+ Endmember to xeos for cd_mp
+*/
+void p2x_mp_cd(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[1] = d->p[3];
+ d->iguess[2] = d->p[2];
+ d->iguess[0] = d->p[1]/(1.0 - d->iguess[1]);
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
+}
+
+[docs]/**
+ Endmember to xeos for chl_mp
+*/
+void p2x_mp_chl(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[2] = d->p[6];
+ d->iguess[3] = d->p[7];
+ d->iguess[4] = (d->iguess[3] + 1.0 - d->iguess[2] -(d->p[1] - d->p[3]+d->p[5]-d->p[0] + d->p[2]+d->p[4]))/4.0;
+ d->iguess[1] = d->p[2] + d->iguess[4];
+ d->iguess[0] = (-2.0*d->iguess[4] + d->iguess[3] + d->p[0] - 4.0*d->p[3] - 5.0*d->p[4] - d->p[5])/(d->iguess[2] + 5.0*d->iguess[3] + 2.0*d->iguess[1] - 6.0);
+ d->iguess[6] = (-2.0*pow(d->iguess[4],2.0) - 2.0*d->iguess[4]*d->iguess[2] + d->iguess[4]*d->iguess[3] + d->iguess[4]*d->p[0] - 4.0*d->iguess[4]*d->p[3] - 5.0*d->iguess[4]*d->p[4] - d->iguess[4]*d->p[5] - 2.0*d->iguess[4]*d->iguess[1] + 2.0*d->iguess[4] + d->iguess[2]*d->iguess[3] + d->iguess[2]*d->p[0] - 4.0*d->iguess[2]*d->p[3] - 4.0*d->iguess[2]*d->p[4] - d->iguess[2]*d->p[5] + 5.0*d->iguess[3]*d->p[4] + d->iguess[3]*d->iguess[1] - d->iguess[3] + d->p[0]*d->iguess[1] - d->p[0] - 4.0*d->p[3]*d->iguess[1] + 4.0*d->p[3] - 3.0*d->p[4]*d->iguess[1] - d->p[4] - d->p[5]*d->iguess[1] + d->p[5])/(d->iguess[4]*d->iguess[2] + 5.0*d->iguess[4]*d->iguess[3] + 2.0*d->iguess[4]*d->iguess[1] - 6.0*d->iguess[4] + pow(d->iguess[2],2.0) + 5.0*d->iguess[2]*d->iguess[3] + 3.0*d->iguess[2]*d->iguess[1] - 7.0*d->iguess[2] + 5.0*d->iguess[3]*d->iguess[1] - 5.0*d->iguess[3] + 2.0*pow(d->iguess[1],2.0) - 8.0*d->iguess[1] + 6.0);
+ d->iguess[5] = (10.0*pow(d->iguess[4],2.0) - 2.0*d->iguess[4]*d->iguess[2] - 25.0*d->iguess[4]*d->iguess[3] - 5.0*d->iguess[4]*d->p[0] + 20.0*d->iguess[4]*d->p[3] + 25.0*d->iguess[4]*d->p[4] + 5.0*d->iguess[4]*d->p[5] - 14.0*d->iguess[4]*d->iguess[1] + 22.0*d->iguess[4] - 4.0*pow(d->iguess[2],2.0) - 21.0*d->iguess[2]*d->iguess[3] - d->iguess[2]*d->p[0] - 4.0*d->iguess[2]*d->p[1] + 4.0*d->iguess[2]*d->p[3] - 4.0*d->iguess[2]*d->p[4] + d->iguess[2]*d->p[5] - 12.0*d->iguess[2]*d->iguess[1] + 28.0*d->iguess[2] - 20.0*d->iguess[3]*d->p[1] - 45.0*d->iguess[3]*d->p[4] - 17.0*d->iguess[3]*d->iguess[1] + 21.0*d->iguess[3] + 3.0*d->p[0]*d->iguess[1] + d->p[0] - 8.0*d->p[1]*d->iguess[1] + 24.0*d->p[1] - 12.0*d->p[3]*d->iguess[1] - 4.0*d->p[3] - 33.0*d->p[4]*d->iguess[1] + 49.0*d->p[4] - 3.0*d->p[5]*d->iguess[1] - d->p[5] - 8.0*pow(d->iguess[1],2.0) + 32.0*d->iguess[1] - 24.0)/(5.0*(-d->iguess[4]*d->iguess[2] - 5.0*d->iguess[4]*d->iguess[3] - 2.0*d->iguess[4]*d->iguess[1] + 6.0*d->iguess[4] + d->iguess[2]*d->iguess[3] + d->iguess[2]*d->iguess[1] - d->iguess[2] + 5.0*pow(d->iguess[3],2.0) + 7.0*d->iguess[3]*d->iguess[1] - 11.0*d->iguess[3] + 2.0*pow(d->iguess[1],2.0) - 8.0*d->iguess[1] + 6.0));
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
+}
+
+[docs]/**
+ Endmember to xeos for ctd_mp
+*/
+void p2x_mp_ctd(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[2] = d->p[3];
+ d->iguess[1] = d->p[2];
+ d->iguess[0] = d->p[1]/(1.0 - d->iguess[1]);
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
+}
+
+[docs]/**
+ Endmember to xeos for ep_mp
+*/
+void p2x_mp_ep(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[1] = d->p[1]/2.0;
+ d->iguess[0] = d->p[2] + d->iguess[1];
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
+}
+
+[docs]/**
+ Endmember to xeos for g_mp
+*/
+void p2x_mp_g(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[3] = d->p[4];
+ d->iguess[1] = d->p[3];
+ d->iguess[2] = d->p[2];
+ d->iguess[0] = d->p[1]/(1.0 - d->iguess[2] - d->iguess[1]);
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
+}
+
+[docs]/**
+ Endmember to xeos for ilm_mp
+*/
+void p2x_mp_ilm(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[2] = d->p[4];
+ d->iguess[1] = d->p[3];
+ d->iguess[3] = d->p[0];
+ d->iguess[0] = 1.0 - d->p[2];
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
+}
+
+[docs]/**
+ Endmember to xeos for liq_mp
+*/
+void p2x_mp_liq(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[0] = d->p[0];
+ d->iguess[3] = d->p[3];
+ d->iguess[6] = d->p[7];
+ d->iguess[1] = d->p[1] + d->p[2];
+ d->iguess[2] = d->p[1]/d->iguess[1];
+ d->iguess[4] = 1.0 - d->iguess[0] - d->iguess[1] - d->iguess[3] - d->iguess[6] - d->p[4];
+ d->iguess[5] = d->p[6]/d->iguess[4];
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
+}
+
+[docs]/**
+ Endmember to xeos for ma_mp
+*/
+void p2x_mp_ma(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[2] = d->p[5];
+ d->iguess[4] = d->p[4];
+ d->iguess[3] = d->p[3];
+ d->iguess[1] = d->p[0] + d->iguess[4] + d->iguess[3] + d->iguess[2];
+ d->iguess[0] = d->p[2]/(1.0-d->iguess[1]);
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
+}
+
+[docs]/**
+ Endmember to xeos for mt_mp
+*/
+void p2x_mp_mt(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[0] = 1.0 - d->p[2];
+ d->iguess[1] = (3.0*d->iguess[0] - d->p[1])/3.0;
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
+}
+
+[docs]/**
+ Endmember to xeos for mu_mp
+*/
+void p2x_mp_mu(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[2] = d->p[5];
+ d->iguess[4] = d->p[4];
+ d->iguess[3] = d->p[3];
+ d->iguess[1] = d->p[0] + d->iguess[4] + d->iguess[3] + d->iguess[2];
+ d->iguess[0] = d->p[2]/(1.0-d->iguess[1]);
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
+}
+
+[docs]/**
+ Endmember to xeos for opx_mp
+*/
+void p2x_mp_opx(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[4] = d->p[6];
+ d->iguess[1] = d->p[5];
+ d->iguess[3] = d->p[4];
+ d->iguess[2] = d->p[3];
+ d->iguess[0] = (-2.0*d->p[1] - d->p[2])/(d->iguess[4] + d->iguess[3] + 2.0*d->iguess[1] + d->iguess[2] - 2.0);
+ d->iguess[5] = 2.0*(pow(d->iguess[4], 2) + 2.0*d->iguess[4]*d->iguess[3] + 3.0*d->iguess[4]*d->iguess[1] + d->iguess[4]*d->p[0] + 2.0*d->iguess[4]*d->p[1] + d->iguess[4]*d->p[2] + 2.0*d->iguess[4]*d->iguess[2] - 3.0*d->iguess[4] + pow(d->iguess[3], 2) + 3.0*d->iguess[3]*d->iguess[1] + d->iguess[3]*d->p[0] + 2.0*d->iguess[3]*d->iguess[2] - 3.0*d->iguess[3] + 2.0*pow(d->iguess[1], 2) + 2.0*d->iguess[1]*d->p[0] + 2.0*d->iguess[1]*d->p[1] + d->iguess[1]*d->p[2] + 3.0*d->iguess[1]*d->iguess[2] - 4.0*d->iguess[1] + d->p[0]*d->iguess[2] - 2.0*d->p[0] - 2.0*d->p[1] - d->p[2] + pow(d->iguess[2], 2) - 3.0*d->iguess[2] + 2.0)/(pow(d->iguess[4], 2) + d->iguess[4]*d->iguess[3] + 3.0*d->iguess[4]*d->iguess[1] + d->iguess[4]*d->iguess[2] - 3.0*d->iguess[4] + d->iguess[3]*d->iguess[1] - d->iguess[3] + 2.0*pow(d->iguess[1], 2) + d->iguess[1]*d->iguess[2] - 4.0*d->iguess[1] - d->iguess[2] + 2.0);
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
+}
+
+[docs]/**
+ Endmember to xeos for pl4tr_mp
+*/
+void p2x_mp_pl4tr(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[1] = d->p[2];
+ d->iguess[0] = d->p[1];
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
+}
+[docs]/**
+ Endmember to xeos for sa_mp
+*/
+void p2x_mp_sa(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[2] = d->p[4];
+ d->iguess[1] = d->p[1];
+ d->iguess[0] = (4.0*d->iguess[2] + 4.0*d->p[0] + d->p[3] + 4.0*d->iguess[1] - 4.0)/(d->iguess[2] + d->iguess[1] - 4.0);
+ d->iguess[3] = 4.0/3.0*(-4.0*pow(d->iguess[2], 2) - 4.0*d->iguess[2]*d->p[0] - d->iguess[2]*d->p[2] - d->iguess[2]*d->p[3] - 8.0*d->iguess[2]*d->iguess[1] + 8.0*d->iguess[2] - 4.0*d->p[0]*d->iguess[1] + 4.0*d->p[0] - d->p[2]*d->iguess[1] + 4.0*d->p[2] - d->p[3]*d->iguess[1] + d->p[3] - 4.0*pow(d->iguess[1], 2) + 8.0*d->iguess[1] - 4.0)/(d->iguess[2] + d->iguess[1] - 4.0);
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
+}
+
+
+[docs]/**
+ Endmember to xeos for sp_mp
+*/
+void p2x_mp_sp(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[2] = d->p[3];
+ d->iguess[1] = 1.0 - d->p[2] - d->iguess[2];
+ d->iguess[0] = (-d->p[1] + d->iguess[2] + 1.0)/(d->iguess[2] + 1.0);
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
+}
+
+[docs]/**
+ Endmember to xeos for st_mp
+*/
+void p2x_mp_st(void *SS_ref_db, double eps){
+ SS_ref *d = (SS_ref *) SS_ref_db;
+
+ d->iguess[3] = d->p[4]/(4.0/3.0);
+ d->iguess[2] = d->p[3];
+ d->iguess[1] = d->p[2];
+ d->iguess[0] = d->p[1]/(1.0 - d->iguess[1]);
+
+ for (int i = 0; i < d->n_xeos; i++){
+ if (d->iguess[i] < d->bounds[i][0]){
+ d->iguess[i] = d->bounds[i][0];
+ }
+ if (d->iguess[i] > d->bounds[i][1]){
+ d->iguess[i] = d->bounds[i][1];
+ }
+ }
}
[docs]/**
@@ -3809,7 +4153,7 @@ Source code for objective_functions.c
sf[3] = 2.0*x[6]/3.0 - 2.0*x[2]*x[1]/3.0 - 2.0*x[3]*x[1]/3.0 + 2.0*x[1]/3.0;
sf[4] = -x[4]/3.0 -x[3]*x[0]/3.0 +x[3]/3.0 -x[0]/3.0 + 1.0/3.0;
sf[5] = -x[5]/3.0 +x[3]*x[0]/3.0 +x[0]/3.0;
- sf[6] = 1.0*x[4]/3.0 +x[5]/3.0 +x[6]/3.0 + 2.0*x[2]*x[1]/3.0 -x[2] + 2.0*x[3]*x[1]/3.0 - 5.0*x[3]/6.0 - 2.0*x[1]/3.0 + 2.0/3.0;
+ sf[6] = x[4]/3.0 +x[5]/3.0 +x[6]/3.0 + 2.0*x[2]*x[1]/3.0 -x[2] + 2.0*x[3]*x[1]/3.0 - 5.0*x[3]/6.0 - 2.0*x[1]/3.0 + 2.0/3.0;
sf[7] = -x[6]/3.0 - 2.0*x[2]*x[1]/3.0 - 2.0*x[3]*x[1]/3.0 + 2.0*x[1]/3.0;
sf[8] = x[2];
sf[9] = 0.5*x[3];
@@ -3859,7 +4203,60 @@ Source code for objective_functions.c
double eps = gv.bnd_val;
/* Associate the right solid-solution data */
- if(gv.EM_database == 2){
+ if(gv.EM_database == 0){
+ if (strcmp( name, "liq") == 0 ){
+ p2x_mp_liq(&SS_ref_db, eps);
+ }
+ else if (strcmp( name, "pl4tr") == 0){
+ p2x_mp_pl4tr(&SS_ref_db, eps);
+ }
+ else if (strcmp( name, "bi") == 0){
+ p2x_mp_bi(&SS_ref_db, eps);
+ }
+ else if (strcmp( name, "g") == 0){
+ p2x_mp_g(&SS_ref_db, eps);
+ }
+ else if (strcmp( name, "ep") == 0){
+ p2x_mp_ep(&SS_ref_db, eps);
+ }
+ else if (strcmp( name, "ma") == 0){
+ p2x_mp_ma(&SS_ref_db, eps);
+ }
+ else if (strcmp( name, "mu") == 0){
+ p2x_mp_mu(&SS_ref_db, eps);
+ }
+ else if (strcmp( name, "opx") == 0){
+ p2x_mp_opx(&SS_ref_db, eps);
+ }
+ else if (strcmp( name, "sa") == 0){
+ p2x_mp_sa(&SS_ref_db, eps);
+ }
+ else if (strcmp( name, "cd") == 0){
+ p2x_mp_cd(&SS_ref_db, eps);
+ }
+ else if (strcmp( name, "st") == 0){
+ p2x_mp_st(&SS_ref_db, eps);
+ }
+ else if (strcmp( name, "chl") == 0){
+ p2x_mp_chl(&SS_ref_db, eps);
+ }
+ else if (strcmp( name, "ctd") == 0){
+ p2x_mp_ctd(&SS_ref_db, eps);
+ }
+ else if (strcmp( name, "sp") == 0){
+ p2x_mp_sp(&SS_ref_db, eps);
+ }
+ else if (strcmp( name, "ilm") == 0){
+ p2x_mp_ilm(&SS_ref_db, eps);
+ }
+ else if (strcmp( name, "mt") == 0){
+ p2x_mp_mt(&SS_ref_db, eps);
+ }
+ else{
+ printf("\nsolid solution '%s' is not in the database\n",name);
+ }
+ }
+ else if(gv.EM_database == 2){
if (strcmp( name, "bi") == 0 ){
p2x_ig_bi(&SS_ref_db, eps);
}
@@ -3919,7 +4316,60 @@ Source code for objective_functions.c
double G0 = 0.0;
/* Associate the right solid-solution data */
- if(gv.EM_database == 2){
+ if(gv.EM_database == 0){
+ if (strcmp( name, "liq") == 0 ){
+ G0 = obj_mp_liq(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else if (strcmp( name, "pl4tr") == 0){
+ G0 = obj_mp_pl4tr(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else if (strcmp( name, "bi") == 0){
+ G0 = obj_mp_bi(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else if (strcmp( name, "g") == 0){
+ G0 = obj_mp_g(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else if (strcmp( name, "ep") == 0){
+ G0 = obj_mp_ep(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else if (strcmp( name, "ma") == 0){
+ G0 = obj_mp_ma(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else if (strcmp( name, "mu") == 0){
+ G0 = obj_mp_mu(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else if (strcmp( name, "opx") == 0){
+ G0 = obj_mp_opx(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else if (strcmp( name, "sa") == 0){
+ G0 = obj_mp_sa(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else if (strcmp( name, "cd") == 0){
+ G0 = obj_mp_cd(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else if (strcmp( name, "st") == 0){
+ G0 = obj_mp_st(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else if (strcmp( name, "chl") == 0){
+ G0 = obj_mp_chl(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else if (strcmp( name, "ctd") == 0){
+ G0 = obj_mp_ctd(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else if (strcmp( name, "sp") == 0){
+ G0 = obj_mp_sp(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else if (strcmp( name, "ilm") == 0){
+ G0 = obj_mp_ilm(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else if (strcmp( name, "mt") == 0){
+ G0 = obj_mp_mt(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
+ }
+ else{
+ printf("\nsolid solution '%s' is not in the database\n",name);
+ }
+ }
+ else if(gv.EM_database == 2){
if (strcmp( name, "bi") == 0 ){
G0 = obj_ig_bi(SS_ref_db.n_xeos, SS_ref_db.iguess, SS_ref_db.dfx, &SS_ref_db);
}
diff --git a/docs/_modules/phase_update_function.c.html b/docs/_modules/phase_update_function.c.html
index 28c43e5d..9c9ff75f 100644
--- a/docs/_modules/phase_update_function.c.html
+++ b/docs/_modules/phase_update_function.c.html
@@ -137,11 +137,7 @@
Access output structure
-Provide custom bulk rock composition
-
+Provide custom bulk rock composition
@@ -758,22 +754,22 @@ Source code for phase_update_function.c
csd_phase_set *cp
){
- /** REMOVE AND DELETE PHASES FROM CONSIDERATION IF FRACTION < 0.0**/
- for (int i = 0; i < gv.len_pp; i++){
- if (gv.pp_flags[i][2] == 1){
- if (PP_ref_db[i].gb_lvl*PP_ref_db[i].factor > gv.bnd_filter_pc){
- gv.pp_flags[i][0] = 0;
- gv.pp_flags[i][1] = 0;
- gv.pp_flags[i][2] = 0;
- gv.pp_flags[i][3] = 1;
- gv.pp_n[i] = 0.0; /** put to 0 if you want to allow multiple phase removal on top of 1 phase addition */
- }
- }
- }
+ /** REMOVE AND DELETE PHASES FROM CONSIDERATION IF DELTA G IS GETTING TOO LARGE**/
+ // for (int i = 0; i < gv.len_pp; i++){
+ // if (gv.pp_flags[i][2] == 1){
+ // if (PP_ref_db[i].gb_lvl*PP_ref_db[i].factor > gv.bnd_filter_pc){
+ // gv.pp_flags[i][0] = 0;
+ // gv.pp_flags[i][1] = 0;
+ // gv.pp_flags[i][2] = 0;
+ // gv.pp_flags[i][3] = 1;
+ // gv.pp_n[i] = 0.0; /** put to 0 if you want to allow multiple phase removal on top of 1 phase addition */
+ // }
+ // }
+ // }
for (int i = 0; i < gv.len_cp; i++){
if (cp[i].ss_flags[2] == 1){
- if (cp[i].df*cp[i].factor > gv.bnd_filter_pc){
+ if (cp[i].df*cp[i].factor > gv.bnd_filter_pge){
cp[i].ss_flags[0] = 0;
cp[i].ss_flags[1] = 0;
cp[i].ss_flags[2] = 0;
diff --git a/docs/_modules/pp_min_function.c.html b/docs/_modules/pp_min_function.c.html
index 099186ce..02936b33 100644
--- a/docs/_modules/pp_min_function.c.html
+++ b/docs/_modules/pp_min_function.c.html
@@ -137,11 +137,7 @@
Access output structure
-Provide custom bulk rock composition
-
+Provide custom bulk rock composition
diff --git a/docs/_modules/simplex_levelling.c.html b/docs/_modules/simplex_levelling.c.html
index 646de5ba..256807a2 100644
--- a/docs/_modules/simplex_levelling.c.html
+++ b/docs/_modules/simplex_levelling.c.html
@@ -137,11 +137,7 @@
Access output structure
-Provide custom bulk rock composition
-
+Provide custom bulk rock composition
@@ -273,8 +269,8 @@ Source code for simplex_levelling.c
#include "nlopt.h"
#include "toolkit.h"
#include "PGE_function.h"
-#include "SS_xeos_PC.h"
-
+#include "SS_xeos_PC_mp.h" //mp is first, it contains the structure definition
+#include "SS_xeos_PC_ig.h"
[docs]/**
associate the array of pointer with the right solution phase
@@ -318,7 +314,48 @@ Source code for simplex_levelling.c
};
}
+void SS_mp_objective_init_function( obj_type *SS_objective,
+ global_variable gv ){
+
+ for (int iss = 0; iss < gv.len_ss; iss++){
+ if (strcmp( gv.SS_list[iss], "liq") == 0 ){
+ SS_objective[iss] = obj_mp_liq; }
+ else if (strcmp( gv.SS_list[iss], "pl4tr") == 0){
+ SS_objective[iss] = obj_mp_pl4tr; }
+ else if (strcmp( gv.SS_list[iss], "bi") == 0){
+ SS_objective[iss] = obj_mp_bi; }
+ else if (strcmp( gv.SS_list[iss], "g") == 0){
+ SS_objective[iss] = obj_mp_g; }
+ else if (strcmp( gv.SS_list[iss], "ep") == 0){
+ SS_objective[iss] = obj_mp_ep; }
+ else if (strcmp( gv.SS_list[iss], "ma") == 0){
+ SS_objective[iss] = obj_mp_ma; }
+ else if (strcmp( gv.SS_list[iss], "mu") == 0){
+ SS_objective[iss] = obj_mp_mu; }
+ else if (strcmp( gv.SS_list[iss], "opx") == 0){
+ SS_objective[iss] = obj_mp_opx; }
+ else if (strcmp( gv.SS_list[iss], "sa") == 0){
+ SS_objective[iss] = obj_mp_sa; }
+ else if (strcmp( gv.SS_list[iss], "cd") == 0){
+ SS_objective[iss] = obj_mp_cd; }
+ else if (strcmp( gv.SS_list[iss], "st") == 0){
+ SS_objective[iss] = obj_mp_st; }
+ else if (strcmp( gv.SS_list[iss], "chl") == 0){
+ SS_objective[iss] = obj_mp_chl; }
+ else if (strcmp( gv.SS_list[iss], "ctd") == 0){
+ SS_objective[iss] = obj_mp_ctd; }
+ else if (strcmp( gv.SS_list[iss], "sp") == 0){
+ SS_objective[iss] = obj_mp_sp; }
+ else if (strcmp( gv.SS_list[iss], "ilm") == 0){
+ SS_objective[iss] = obj_mp_ilm; }
+ else if (strcmp( gv.SS_list[iss], "mt") == 0){
+ SS_objective[iss] = obj_mp_mt; }
+ else{
+ printf("\nsolid solution '%s' is not in the database, cannot be initiated\n", gv.SS_list[iss]);
+ }
+ };
+}
[docs]/**
function to calculate delta G (position of potential phases with current G hyperplane*)
*/
@@ -1312,7 +1349,15 @@ Source code for simplex_levelling.c
PC_ref SS_pc_xeos[gv.len_ss];
- if (gv.EM_database == 2){
+
+ if (gv.EM_database == 0){
+ for (iss = 0; iss < gv.len_ss; iss++){
+ SS_mp_pc_init_function( SS_pc_xeos,
+ iss,
+ gv.SS_list[iss] );
+ }
+ }
+ else if (gv.EM_database == 2){
for (iss = 0; iss < gv.len_ss; iss++){
SS_ig_pc_init_function( SS_pc_xeos,
iss,
@@ -1384,7 +1429,14 @@ Source code for simplex_levelling.c
PC_ref SS_pc_xeos[gv.len_ss];
- if (gv.EM_database == 2){
+ if (gv.EM_database == 0){
+ for (ss = 0; ss < gv.len_ss; ss++){
+ SS_mp_pc_init_function( SS_pc_xeos,
+ ss,
+ gv.SS_list[ss] );
+ }
+ }
+ else if (gv.EM_database == 2){
for (ss = 0; ss < gv.len_ss; ss++){
SS_ig_pc_init_function( SS_pc_xeos,
ss,
diff --git a/docs/_modules/ss_min_function.c.html b/docs/_modules/ss_min_function.c.html
index 69e7d9a4..660ba541 100644
--- a/docs/_modules/ss_min_function.c.html
+++ b/docs/_modules/ss_min_function.c.html
@@ -137,11 +137,7 @@
Access output structure
-Provide custom bulk rock composition
-
+Provide custom bulk rock composition
@@ -610,7 +606,6 @@ Source code for ss_min_function.c
SS_ref *SS_ref_db,
csd_phase_set *cp
){
-
int ph_id;
for (int i = 0; i < gv.len_cp; i++){
if (cp[i].ss_flags[0] == 1){
@@ -640,7 +635,7 @@ Source code for ss_min_function.c
SS_ref_db[ph_id] = restrict_SS_HyperVolume( gv,
SS_ref_db[ph_id],
gv.box_size_mode_1 );
-
+
/**
call to NLopt for non-linear + inequality constraints optimization
*/
@@ -697,7 +692,26 @@ Source code for ss_min_function.c
){
- if (EM_database == 2){
+ if (EM_database == 0){
+ for (int i = 0; i < gv.len_ss; i++){
+ SS_ref_db[i].P = z_b.P; /** needed to pass to local minimizer, allows for P variation for liq/sol */
+ SS_ref_db[i].T = z_b.T;
+ SS_ref_db[i].R = 0.0083144;
+
+ // if (SS_ref_db[i].is_liq == 1){
+ // SS_ref_db[i].P = z_b.P + gv.melt_pressure;
+ // }
+
+ SS_ref_db[i] = G_SS_mp_EM_function( gv,
+ SS_ref_db[i],
+ EM_database,
+ z_b,
+ gv.SS_list[i] );
+
+ /** can become a global variable instead */
+ }
+ }
+ else if (EM_database == 2){
for (int i = 0; i < gv.len_ss; i++){
SS_ref_db[i].P = z_b.P; /** needed to pass to local minimizer, allows for P variation for liq/sol */
SS_ref_db[i].T = z_b.T;
diff --git a/docs/_modules/toolkit.c.html b/docs/_modules/toolkit.c.html
index 3c8c2f26..3437d8f2 100644
--- a/docs/_modules/toolkit.c.html
+++ b/docs/_modules/toolkit.c.html
@@ -137,11 +137,7 @@
Access output structure
-Provide custom bulk rock composition
-
+Provide custom bulk rock composition
@@ -285,7 +281,7 @@ Source code for toolkit.c
printf(" --solver= [int] : solver: 0 for legacy and 1 for PGE (default)\n");
printf(" --out_matlab= [int] : Matlab text file output, 0. inactive, 1. active\n");
printf("\n");
- printf(" *the list of oxides must be given as follow:\n");
+ printf(" *the list of oxides must be provided as follow:\n");
printf(" SiO2, Al2O3, CaO, MgO, FeOt, K2O, Na2O, TiO2, O, Cr2O3, H2O\n");
printf("\n");
printf(" Note that FeOt (total iron) is used here!\n");
@@ -387,17 +383,25 @@ Source code for toolkit.c
}
+
if (gv.verbose == 1){
+
+ if (gv.EM_database == 0){
+ printf(" - Database : Metapelite (White et al., 2014)\n" );
+ }
+ else if (gv.EM_database == 2){
+ printf(" - Database : Igneous (Holland et al., 2018)\n" );
+ }
+
if (strcmp( gv.sys_in, "mol") == 0){
- printf(" - input system composition : mol fraction\n" );
+ printf(" - input system composition : mol fraction\n" );
}
else if (strcmp( gv.sys_in, "wt") == 0){
- printf(" - input system composition : wt fraction\n" );
+ printf(" - input system composition : wt fraction\n" );
}
else{
- printf(" - input system composition : unknown! [has to be mol or wt]\n");
+ printf(" - input system composition : unknown! [has to be mol or wt]\n");
}
- printf("\n");
}
/** Normalize composition to sum to 1. */
@@ -412,10 +416,13 @@ Source code for toolkit.c
gv.bulk_rock[i] = 1.0e-4;
renorm = 1;
if (gv.verbose == 1){
- printf(" - mol fraction of %4s is < 1e-4 -> set back to 1e-4 to avoid minimization issues\n\n",gv.ox[i] );
+ printf(" - mol of %4s = %+.5f < 1e-4 : set back to 1e-4 to avoid minimization issues\n",gv.ox[i],gv.bulk_rock[i]);
}
}
}
+ if (gv.verbose == 1){
+ printf("\n");
+ }
if (renorm == 1){
norm_array( gv.bulk_rock,
gv.len_ox );
diff --git a/docs/_sources/ckbk/Commands.rst.txt b/docs/_sources/ckbk/Commands.rst.txt
index 4583ee4c..4d2ea08c 100644
--- a/docs/_sources/ckbk/Commands.rst.txt
+++ b/docs/_sources/ckbk/Commands.rst.txt
@@ -32,6 +32,8 @@ The list of valid command line arguments is the following
+-----------------+-----------------------------------------------+
| -\-solver=x | Legacy, 0. PGE, 1 (default) |
+-----------------+-----------------------------------------------+
+| -\-db="" | database, "ig" or "mp", default is ig |
++-----------------+-----------------------------------------------+
| -\-sys_in="" | system comp "mol" or "wt", default is "mol" |
+-----------------+-----------------------------------------------+
| -\-out_matlab=x | Matlab output, 0. inactive, 1. active |
@@ -56,15 +58,15 @@ Using previously defined arguments, a valid command to run a single point calcul
.. code-block:: shell
- ./MAGEMin --Verb=1 --Temp=718.750 --Pres=30.5000 --test=0 >&log.txt
+ ./MAGEMin --Verb=1 --Temp=718.750 --Pres=30.5000 --db=ig --test=0 >&log.txt
-Here, the verbose is active and the bulk rock composition of *test 0* is selected. The output of the verbose is saved as a log file *log.txt*.
+Here, the verbose is active, the selected database is "ig" (Igneous) and the bulk rock composition of *test 0* is selected. The output of the verbose is saved as a log file *log.txt*.
If you want to do a computation using a different bulk rock composition you can pass the custom bulk such as:
.. code-block:: shell
- ./MAGEMin --Verb=1 --Temp=488.750 --Pres=3.5000 --Bulk=41.49,1.57,3.824,50.56,5.88,0.01,0.25,0.10,0.1,0.0 --sys_in=mol
+ ./MAGEMin --Verb=1 --Temp=488.750 --Pres=3.5000 --db=ig --Bulk=41.49,1.57,3.824,50.56,5.88,0.01,0.25,0.10,0.1,0.0 --sys_in=mol
|
@@ -75,7 +77,7 @@ To run multiple points at once you can pass an input file containing the list of
.. code-block:: shell
- ./MAGEMin --Verb=1 --File=path_to_file --n_points=x
+ ./MAGEMin --Verb=1 --File=path_to_file --n_points=x --db=ig
where "path_to_file" is the location of the file and "x" is an integer corresponding to the total number of points contained in the file. The file must have one point per line using the following structure
@@ -102,7 +104,7 @@ You can compute the list of points using:
.. code-block:: shell
- ./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --test=0
+ ./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --test=0 --db=ig
Note that verbose should be deactivated in parallel (--Verb=0 or --Verb=-1), however matlab output can be generated in parallel (--out_matlab=1). To compute a custom list of bulk-rock compositions you have to provide the oxide composition and replace the "0.0" such as:
@@ -120,7 +122,7 @@ Then compute the list of points while indicating the system composition unit (:l
.. code-block:: shell
- ./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --sys_in=mol
+ ./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --sys_in=mol --db=ig
|
Multiple points in parallel
@@ -130,8 +132,8 @@ To run a list of points in parallel, you simply need to call "MPI" before MAGEMi
.. code-block:: shell
- mpirun -np 8 ./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --test=0 --out_matlab=1
- mpiexec -n 8 ./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --test=0 --out_matlab=1
+ mpirun -np 8 ./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --db=ig --test=0 --out_matlab=1
+ mpiexec -n 8 ./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --db=ig --test=0 --out_matlab=1
where 8 is the desired number of cores. Here the results will be stored in an output file gathering the results of all points (see :ref:`MATLAB output `).
diff --git a/docs/_sources/index.rst.txt b/docs/_sources/index.rst.txt
index dc501aeb..51d86e71 100644
--- a/docs/_sources/index.rst.txt
+++ b/docs/_sources/index.rst.txt
@@ -10,7 +10,7 @@
|
-**MAGEMin v1.2.8**
+**MAGEMin v1.3.0**
==================
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
@@ -32,7 +32,18 @@ Igneous thermodynamic dataset
- Equations of state for
- Pure stoichiometric phases quartz (q), cristobalite (crst), tridymite (trd), coesite (coe), stishovite (stv), kyanite (ky), sillimanite (sill), andalusite (and), rutile (ru) and sphene (sph).
- Solution phases spinel (spn), biotite (bi), cordierite (cd), clinopyroxene (cpx), orthopyroxene (opx), epidote (ep), garnet (g), hornblende (hb), ilmenite (ilm), silicate melt (liq), muscovite (mu), olivine (ol), ternary feldspar (pl4T), and aqueous fluid (fl).
-
+
+Metapelite thermodynamic dataset
+********************************
+
+- White et al., 2014a, 2014b (see http://hpxeosandthermocalc.org)
+- K2O-Na2O-CaO-FeO-MgO-Al2O3-SiO2-H2O-TiO2-O-MnO chemical system
+- Equations of state for
+ - Pure stoichiometric phases quartz (q), cristobalite (crst), tridymite (trd), coesite (coe), stishovite (stv), kyanite (ky), sillimanite (sill), andalusite (and), rutile (ru) and sphene (sph).
+ - Solution phases spinel (spn), biotite (bi), cordierite (cd), orthopyroxene (opx), epidote (ep), garnet (g), ilmenite (ilm), silicate melt (liq), muscovite (mu), ternary feldspar (pl4T), sapphirine (sa), staurolite (st), magnetite (mt), chlorite (chl), chloritoid (ctd) and margarite (ma).
+- added March 2023
+
+
Imported libraries
==================
diff --git a/docs/_sources/issues.rst.txt b/docs/_sources/issues.rst.txt
index d490cff1..85d21d4b 100644
--- a/docs/_sources/issues.rst.txt
+++ b/docs/_sources/issues.rst.txt
@@ -56,9 +56,11 @@ Reduced chemical systems
Low temperature stabilization
******************************
-* In a number of cases, mainly water under-saturated cases, and at temperature below 600-650°C, the current version of the solver fails to provide consistent minimizations. We are working on an algorithm upgrade in order to fix this issue.
+* In a number of cases using the Igneous database, mainly water under-saturated cases, and at temperature below 600-650°C, the PGE solver fails to provide consistent minimizations.
-* While a working alternative approach is already being tested, we are further improving the performances before releasing it.
+* In nearly all of these cases, the Gibbs-Duhem constraint cannot be enforced by the PGE (which relies on being able to enforce it), and an alternative "legacy" has now been added. The "legacy" solver uses the approach presented by de Capitani & Brown (1987). This approach enforces the Gibbs-Duhem constraint only on the effective composition of the solution phase and not on each constitutive endmember of the solution phase such as in the PGE. When the PGE method fails the "legacy" solution can be seen as a relaxed Gibbs-Duhem constraint solution.
+
+* Note that in the cases of non PGE failure, the PGE and the "legacy" solvers yield identical results, which points out to thermodynamic database limitation outside calibration range.
HP-LT melt prediction
@@ -66,4 +68,4 @@ HP-LT melt prediction
* For water-saturated composition, we found that at pressure > 20 kbar and temperature < 650°C melt is predicted to be stable.
-* This is a known problem from the THERMOCALC developer community, and a fix should be provided in the following versions of the igenous thermodynamic dataset.
\ No newline at end of file
+* This is a known problem from the THERMOCALC developer community, and a fix should be provided in a future version of the igneous thermodynamic dataset.
\ No newline at end of file
diff --git a/docs/_sources/julia/Run.rst.txt b/docs/_sources/julia/Run.rst.txt
index 0580f175..e0ce3751 100644
--- a/docs/_sources/julia/Run.rst.txt
+++ b/docs/_sources/julia/Run.rst.txt
@@ -12,7 +12,8 @@ Initialize database
*******************
.. code-block:: shell
- gv, z_b, DB, splx_data = init_MAGEMin();
+ db = "ig" # database: ig, igneous (Holland et al., 2018); mp, metapelite (White et al 2014b)
+ gv, z_b, DB, splx_data = init_MAGEMin(db);
This initiatizes the global variables and the Database.
@@ -24,7 +25,7 @@ Set P-T-(pressure temperature)
T = 800.
sys_in = "mol" # wt or mol, default is mol
test = 0;
- gv = use_predefined_bulk_rock(gv, test)
+ gv = use_predefined_bulk_rock(gv, test, db)
:literal:`get_bulk_rock` retrieves the saved bulk-rock composition 0, which corresponds to KLB-1 peridotite.
@@ -38,7 +39,7 @@ Use a pre-defined bulk-rock "test" composition
.. code-block:: shell
test = 0;
- gv = use_predefined_bulk_rock(gv, test)
+ gv = use_predefined_bulk_rock(gv, test, db)
|
@@ -106,46 +107,35 @@ The full description of what contains the output structure is given in the CookB
Provide custom bulk rock composition
====================================
-Bulk-rock composition can be provided either by using the system unit of MAGEMin or by using other system unit and converting them.
-MAGEMin system unit
-*******************
-
-To define and use your own bulk rock composition you can provide it directly in the format used in MAGEMin: :literal:`[mol,wt]` fraction using the following chemical system i.e.
-
-+-------+--------+-------+-------+-------+------+------+------+------+-------+-------+
-| SiO2 | Al2O3 | CaO | MgO | FeOt | K2O | Na2O | TiO2 | O | Cr2O3 | H2O |
-+-------+--------+-------+-------+-------+------+------+------+------+-------+-------+
+To define and use your own bulk rock composition we provide a routine that converts bulk-rock composition into the right MAGEMin format.
-For instance:
+* For the igneous database:
.. code-block:: shell
- bulk_rock = [0.38451319035870185, 0.017740308257833806, 0.028208688355924924, 0.5050993397328966, 0.0587947378409965, 9.988912307338855e-5, 0.0024972280768347137, 0.0009988912307338856, 0.0009589355815045301, 0.0010887914414999351, 0.0]
- gv = define_bulk_rock(gv, bulk_rock)
-
+ bulk_in_ox = ["SiO2"; "Al2O3"; "CaO"; "MgO"; "FeO"; "Fe2O3"; "K2O"; "Na2O"; "TiO2"; "Cr2O3"; "H2O"]
+ bulk_in = [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"
+ db = "ig" # database: ig, igneous (Holland et al., 2018); mp, metapelite (White et al 2014b)
-Variable system unit
-********************
+ gv = define_bulk_rock(gv, bulk_in, bulk_in_ox, sys_in, db);
-However, measured bulk-rock compositions usually provide :literal:`FeO` and :literal:`Fe2O3` instead of :literal:`FeOt` and :literal:`O`. Therefore, we provide an additional routine that convert bulk-rock composition into the right MAGEMin format:
+* For the metapelite database
.. code-block:: shell
- bulk_in_ox = ["SiO2"; "Al2O3"; "CaO"; "MgO"; "FeO"; "Fe2O3"; "K2O"; "Na2O"; "TiO2"; "Cr2O3"; "H2O"]
- bulk_in = [48.43; 15.19; 11.57; 10.13; 6.65; 1.64; 0.59; 1.87; 0.68; 0.0; 3.0]
+ bulk_in_ox = ["SiO2"; "Al2O3"; "CaO"; "MgO"; "FeO"; "Fe2O3"; "K2O"; "Na2O"; "TiO2"; "MnO"; "H2O"]
+ bulk_in = [69.64; 13.76; 1.77; 1.73; 4.32; 0.4; 2.61; 2.41; 0.80; 0.07; 10.0]
sys_in = "wt"
+ db = "mp" # database: ig, igneous (Holland et al., 2018); mp, metapelite (White et al 2014b)
- bulk_rock = convertBulk4MAGEMin(bulk_in,bulk_in_ox,sys_in)
- gv = define_bulk_rock(gv, bulk_rock)
-
-where :literal:`bulk_in_ox` is a :literal:`Vector(String)` containing the oxide names and :literal:`bulk_in` is a :literal:`Vector(Float)` of the :literal:`[mol,wt]` fraction of the bulk-rock composition. The function
+ gv = define_bulk_rock(gv, bulk_in, bulk_in_ox, sys_in, db);
-.. code-block:: shell
- bulk_rock = convertBulk4MAGEMin(bulk_in,bulk_in_ox,sys_in)`
-converts
+where :literal:`bulk_in_ox` is a :literal:`Vector(String)` containing the oxide names and :literal:`bulk_in` is a :literal:`Vector(Float)` of the :literal:`[mol,wt]` fraction of the bulk-rock composition.
+The function converts
:literal:`SiO2`, ..., :literal:`FeO` and :literal:`Fe2O3` in system unit :literal:`[mol,wt]`
@@ -163,22 +153,53 @@ A full Julia script demonstrating how to use this function is provided below:
using MAGEMin_C
#initialize
- gv, z_b, DB, splx_data = init_MAGEMin();
+ db = "ig" # database: ig, igneous (Holland et al., 2018); mp, metapelite (White et al 2014b)
+ gv, z_b, DB, splx_data = init_MAGEMin(db);
# provide bulk-rock composition
- bulk_in_ox = ["SiO2"; "Al2O3"; "CaO"; "MgO"; "FeO"; "Fe2O3"; "K2O"; "Na2O"; "TiO2"; "Cr2O3"; "H2O"]
- bulk_in = [48.43; 15.19; 11.57; 10.13; 6.65; 1.64; 0.59; 1.87; 0.68; 0.0; 3.0]
+ bulk_in_ox = ["SiO2"; "Al2O3"; "CaO"; "MgO"; "FeO"; "Fe2O3"; "K2O"; "Na2O"; "TiO2"; "Cr2O3"; "H2O"];
+ bulk_in = [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"
# convert bulk rock
- bulk_rock = convertBulk4MAGEMin(bulk_in,bulk_in_ox,sys_in)
+ gv = define_bulk_rock(gv, bulk_in, bulk_in_ox, sys_in, db);
+
+ # provide pressure and temperature conditions
+ P,T = 10.0, 1100.0;
- # send bulk-rock to MAGEMin
- gv = define_bulk_rock(gv, bulk_rock)
+ # switch off any verbose
+ gv.verbose = -1
+
+ # perform minimization
+ out = point_wise_minimization(P,T, gv, z_b, DB, splx_data, sys_in)
+
+ # print output
+ print_info(out)
+
+ # free memory
+ finalize_MAGEMin(gv,DB)
+
+of for the metapelite database:
+
+.. code-block:: shell
+
+ #load MAGEMin
+ using MAGEMin_C
+
+ #initialize
+ db = "mp" # database: ig, igneous (Holland et al., 2018); mp, metapelite (White et al 2014b)
+ gv, z_b, DB, splx_data = init_MAGEMin(db);
+
+ # provide bulk-rock composition
+ bulk_in_ox = ["SiO2"; "Al2O3"; "CaO"; "MgO"; "FeO"; "Fe2O3"; "K2O"; "Na2O"; "TiO2"; "MnO"; "H2O"]
+ bulk_in = [69.64; 13.76; 1.77; 1.73; 4.32; 0.4; 2.61; 2.41; 0.80; 0.07; 10.0]
+ sys_in = "wt"
+
+ # convert bulk rock
+ gv = define_bulk_rock(gv, bulk_in, bulk_in_ox, sys_in, db);
# provide pressure and temperature conditions
- P = 10.0
- T = 1100.0
+ P,T = 4.0, 800.0;
# switch off any verbose
gv.verbose = -1
diff --git a/docs/ckbk.html b/docs/ckbk.html
index 984cb218..9b0e0419 100644
--- a/docs/ckbk.html
+++ b/docs/ckbk.html
@@ -130,15 +130,17 @@
Use MAGEMin_C
@@ -153,7 +155,7 @@
Known problems
diff --git a/docs/ckbk/Commands.html b/docs/ckbk/Commands.html
index b454c237..f9465119 100644
--- a/docs/ckbk/Commands.html
+++ b/docs/ckbk/Commands.html
@@ -130,15 +130,17 @@
Use MAGEMin_C
@@ -153,7 +155,7 @@
Known problems
@@ -285,10 +287,13 @@ List of arguments--solver=x
Legacy, 0. PGE, 1 (default)
---sys_in=””
+--db=””
+database, “ig” or “mp”, default is ig
+
+--sys_in=””
system comp “mol” or “wt”, default is “mol”
---out_matlab=x
+--out_matlab=x
Matlab output, 0. inactive, 1. active
@@ -332,12 +337,12 @@ List of arguments
Single point calculation
Using previously defined arguments, a valid command to run a single point calculation with MAGEMin is for instance:
-./MAGEMin --Verb=1 --Temp=718.750 --Pres=30.5000 --test=0 >&log.txt
+./MAGEMin --Verb=1 --Temp=718.750 --Pres=30.5000 --db=ig --test=0 >&log.txt
-Here, the verbose is active and the bulk rock composition of test 0 is selected. The output of the verbose is saved as a log file log.txt.
+Here, the verbose is active, the selected database is “ig” (Igneous) and the bulk rock composition of test 0 is selected. The output of the verbose is saved as a log file log.txt.
If you want to do a computation using a different bulk rock composition you can pass the custom bulk such as:
-./MAGEMin --Verb=1 --Temp=488.750 --Pres=3.5000 --Bulk=41.49,1.57,3.824,50.56,5.88,0.01,0.25,0.10,0.1,0.0 --sys_in=mol
+./MAGEMin --Verb=1 --Temp=488.750 --Pres=3.5000 --db=ig --Bulk=41.49,1.57,3.824,50.56,5.88,0.01,0.25,0.10,0.1,0.0 --sys_in=mol
@@ -347,7 +352,7 @@ Single point calculation
Multiple points calculation
To run multiple points at once you can pass an input file containing the list of points such as
-./MAGEMin --Verb=1 --File=path_to_file --n_points=x
+./MAGEMin --Verb=1 --File=path_to_file --n_points=x --db=ig
where “path_to_file” is the location of the file and “x” is an integer corresponding to the total number of points contained in the file. The file must have one point per line using the following structure
@@ -387,7 +392,7 @@ Multiple points calculation./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --test=0
+./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --test=0 --db=ig
Note that verbose should be deactivated in parallel (–Verb=0 or –Verb=-1), however matlab output can be generated in parallel (–out_matlab=1). To compute a custom list of bulk-rock compositions you have to provide the oxide composition and replace the “0.0” such as:
@@ -401,7 +406,7 @@ Multiple points calculationmol or wt
fraction):
-./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --sys_in=mol
+./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --sys_in=mol --db=ig
@@ -411,8 +416,8 @@ Multiple points calculation
Multiple points in parallel
To run a list of points in parallel, you simply need to call “MPI” before MAGEMin and give the number of cores you want to use. Valid calls using previously defined input file are for instance:
-mpirun -np 8 ./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --test=0 --out_matlab=1
-mpiexec -n 8 ./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --test=0 --out_matlab=1
+mpirun -np 8 ./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --db=ig --test=0 --out_matlab=1
+mpiexec -n 8 ./MAGEMin --File=/path_to_file/MAGEMin_input.dat --n_points=4 --db=ig --test=0 --out_matlab=1
where 8 is the desired number of cores. Here the results will be stored in an output file gathering the results of all points (see MATLAB output).
diff --git a/docs/ckbk/gui.html b/docs/ckbk/gui.html
index cec8b94f..25780ec6 100644
--- a/docs/ckbk/gui.html
+++ b/docs/ckbk/gui.html
@@ -130,15 +130,17 @@
Use MAGEMin_C
@@ -153,7 +155,7 @@
Known problems
diff --git a/docs/ckbk/out_struct.html b/docs/ckbk/out_struct.html
index c2c620f2..3db6ae85 100644
--- a/docs/ckbk/out_struct.html
+++ b/docs/ckbk/out_struct.html
@@ -130,15 +130,17 @@
Use MAGEMin_C
@@ -153,7 +155,7 @@
Known problems
diff --git a/docs/dev.html b/docs/dev.html
index 65cac6fc..b09f7642 100644
--- a/docs/dev.html
+++ b/docs/dev.html
@@ -130,15 +130,17 @@
Use MAGEMin_C
@@ -153,7 +155,7 @@
Known problems
diff --git a/docs/dev/Dev.html b/docs/dev/Dev.html
index 3416a9ba..16f72152 100644
--- a/docs/dev/Dev.html
+++ b/docs/dev/Dev.html
@@ -130,15 +130,17 @@
Use MAGEMin_C
@@ -153,7 +155,7 @@
Known problems
diff --git a/docs/faq.html b/docs/faq.html
index f2ff49d3..9018eec5 100644
--- a/docs/faq.html
+++ b/docs/faq.html
@@ -130,15 +130,17 @@
Use MAGEMin_C
@@ -153,7 +155,7 @@
Known problems
diff --git a/docs/genindex.html b/docs/genindex.html
index 94d9b70f..5adf5cf7 100644
--- a/docs/genindex.html
+++ b/docs/genindex.html
@@ -137,11 +137,7 @@
Access output structure
-Provide custom bulk rock composition
-
+Provide custom bulk rock composition
@@ -282,6 +278,8 @@ B
@@ -291,6 +289,8 @@ C
@@ -410,6 +414,8 @@ E
+ - ep_mp_c (C function)
+
- euclidean_distance (C function)
- exchangeRows (C function)
@@ -439,6 +445,8 @@
G
- G_EM_function (C function)
- g_ig_c (C function)
+
+ - g_mp_c (C function)
- G_SS_ig_bi_function (C function)
@@ -490,8 +498,6 @@ G
- G_SS_ig_opx_init_function (C function)
-
-
+
- G_SS_mp_cd_init_function (C function)
+
+ - G_SS_mp_chl_function (C function)
- G_SS_mp_chl_init_function (C function)
+
+ - G_SS_mp_ctd_function (C function)
- G_SS_mp_ctd_init_function (C function)
+
+ - G_SS_mp_EM_function (C function)
+
+ - G_SS_mp_ep_function (C function)
- G_SS_mp_ep_init_function (C function)
+
+ - G_SS_mp_g_function (C function)
- G_SS_mp_g_init_function (C function)
+
+ - G_SS_mp_ilm_function (C function)
- G_SS_mp_ilm_init_function (C function)
+
+ - G_SS_mp_liq_function (C function)
- G_SS_mp_liq_init_function (C function)
+
+ - G_SS_mp_ma_function (C function)
- G_SS_mp_ma_init_function (C function)
+
+ - G_SS_mp_mt_function (C function)
- G_SS_mp_mt_init_function (C function)
+
+ - G_SS_mp_mu_function (C function)
- G_SS_mp_mu_init_function (C function)
+
+ - G_SS_mp_opx_function (C function)
- G_SS_mp_opx_init_function (C function)
+
+ - G_SS_mp_pl4tr_function (C function)
- G_SS_mp_pl4tr_init_function (C function)
+
+ - G_SS_mp_sa_function (C function)
- G_SS_mp_sa_init_function (C function)
+
+ - G_SS_mp_sp_function (C function)
- G_SS_mp_sp_init_function (C function)
+
+ - G_SS_mp_st_function (C function)
- G_SS_mp_st_init_function (C function)
@@ -563,6 +605,8 @@ I