ISLEC  Version 4.2
islec.h
Go to the documentation of this file.
1 /* src/islec.h
2  *
3  * Copyright (C) 2011-2018 Dongdong Li
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundataion; either version 3 of the License, or (at
8  * your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABLITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
30 #define PROGRAM_NAME "ISLEC" // program name
31 #define PROGRAM_COMMAND "islec" // command name
32 #define PROGRAM_SITE "http://www.islec.net" // program website
33 #define COPYRIGHT "2011-2018" // copyright year
34 #define AUTHOR "Dongdong Li" // author
35 #define AUTHOR_EMAIL "ddong_li@hotmail.com" // author email
36 
37 #define R 8.314
38 #define PRESSURE 1.0
39 #define TEMP_FILE "temp.db"
40 
41 /* higer order electrostatic term constants C1 to C3 */
42 #define C1 4.5810
43 #define C2 0.7237
44 #define C3 0.0120
45 #define C4 0.5280
46 
47 #define WATER_SYMBOL "H2O(aq)"
48 
49 char BLOCK_KEYWORDS[2][64] = {"COMPONENTS",
50  "PHASES"};
51 
52 char PHASE_KEYWORDS[4][64] = {"GAS",
53  "LIQUID",
54  "SOLID",
55  "SOLIDSOLUTION"};
56 
57 char PROCESS[5][64] = {"EQUILIBRIUM",
58  "EVAPORATION",
59  "FREEZING",
60  "HEATING",
61  "MIXING"};
62 
63 char PROPERTY[6][64] = {"AW",
64  "GAMMA",
65  "LPHI",
66  "HDIL",
67  "CPHI",
68  "LNK"};
69 
70 typedef struct ELEMENT
71 {
72  char element_symbol[2];
74  double element_mass;
75 }ELEMENT;
76 
77 typedef struct SPECIES
78 {
79  char species_symbol[64];
80  int charge;
81  double *elements;
82  double thermo_coeff[7];
83 }SPECIES;
84 
85 typedef struct IIBINPARAM
86 {
87  char species_s1[64];
88  char species_s2[64];
89  double alpha;
90  double alpha1;
91  double B0ss[6];
92  double B1ss[6];
93 }IIBINPARAM;
94 
95 typedef struct NNBINPARAM
96 {
97  char species_s1[64];
98  char species_s2[64];
99  double Wss[6];
100  double Uss[6];
101 }NNBINPARAM;
102 
103 typedef struct NIITERPARAM
104 {
105  char species_s1[64];
106  char species_s2[64];
107  char species_s3[64];
108  double Wsss[6];
109  double Usss[6];
110  double Vsss[6];
111 }NIITERPARAM;
112 
113 typedef struct IIITERPARAM
114 {
115  char species_s1[64];
116  char species_s2[64];
117  char species_s3[64];
118  double Wsss[6];
119 }IIITERPARAM;
120 
121 typedef struct NIIIQUAPARAM
122 {
123  char species_s1[64];
124  char species_s2[64];
125  char species_s3[64];
126  char species_s4[64];
127  double Qssss[6];
128  double Yssss[6];
129 }NIIIQUAPARAM;
130 
131 typedef struct NNIIQUAPARAM
132 {
133  char species_s1[64];
134  char species_s2[64];
135  char species_s3[64];
136  char species_s4[64];
137  double Yssss[6];
138 }NNIIQUAPARAM;
139 
140 typedef struct SUBRPARAM
141 {
142  char species_a[64];
143  char species_b[64];
144  double A0;
145  double A1;
146 }SUBRPARAM;
147 
148 typedef struct GAS_PHASE
149 {
152 }GAS_PHASE;
153 
154 typedef struct AQUEOUS_PHASE
155 {
171 
172 typedef struct SOLID_PHASE
173 {
176 }SOLID_PHASE;
177 
178 typedef struct SOLIDSOLUTION_PHASE
179 {
185 
186 typedef struct PHASES
187 {
192 }PHASES;
193 
194 int total_comp_num; // component number
198 int solidsolution_phase_num; // solid solution phase number
199 int total_phase_num; // solid phase number
200 int total_species_num; // total species number
201 
202 char block_keyword[32]; //
203 char phase_keyword[32]; //
204 
205 ELEMENT *components; // element component array
206 PHASES phases; // phase object
207 
208 double **coeff_matrix; // coeffcients matrix
209 
210 double system_T; // temperature system
211 double system_P; // system pressure
212 double system_charge; // system total charge
213 double *total_components; // total components given initally
214 
215 double *n_eq; // molal number of species in equilibrium
216 double gibbs_eq; // Total Gibbs energy of the whole system in equilibrium
217 bool successed; // Gibbs energy minimization successed flag
218 
219 /*
220  * load databank
221  * input: databank file name
222  * temp: temp file name
223  */
224 extern bool load_db (char *input, char *temp);
225 
226 extern bool test_load ();
227 
228 extern bool test_models ();
229 
230 extern double psc_r (AQUEOUS_PHASE aq, int index, double *n, double T, double P);
231 
232 extern double psc_a (AQUEOUS_PHASE aq, int index, double *n, double T, double P);
233 
234 extern double rkg_a (SOLIDSOLUTION_PHASE ss, int index, double *n, double T, double P);
235 
243 extern int gem_ipopt ();
double rkg_a(SOLIDSOLUTION_PHASE ss, int index, double *n, double T, double P)
Definition: rkg_model.c:99
int ii_bin_param_num
Definition: islec.h:158
struct SOLID_PHASE SOLID_PHASE
AQUEOUS_PHASE * aqueous
Definition: islec.h:189
int solidsolution_phase_num
Definition: islec.h:198
struct NIITERPARAM NIITERPARAM
int species_num
Definition: islec.h:150
struct AQUEOUS_PHASE AQUEOUS_PHASE
IIBINPARAM * ii_bin_params
Definition: islec.h:159
struct IIITERPARAM IIITERPARAM
struct IIBINPARAM IIBINPARAM
int species_num
Definition: islec.h:156
struct NNBINPARAM NNBINPARAM
double * total_components
Definition: islec.h:213
SPECIES * gas_species
Definition: islec.h:151
int element_number
Definition: islec.h:73
double A0
Definition: islec.h:144
double psc_a(AQUEOUS_PHASE aq, int index, double *n, double T, double P)
Definition: psc_model.c:3496
double ** coeff_matrix
Definition: islec.h:208
bool successed
Definition: islec.h:217
SPECIES * aqueous_species
Definition: islec.h:157
int species_num
Definition: islec.h:174
int niii_qua_param_num
Definition: islec.h:166
double alpha
Definition: islec.h:89
struct GAS_PHASE GAS_PHASE
double system_T
Definition: islec.h:210
NNBINPARAM * nn_bin_params
Definition: islec.h:161
struct ELEMENT ELEMENT
double psc_r(AQUEOUS_PHASE aq, int index, double *n, double T, double P)
Definition: psc_model.c:3483
char BLOCK_KEYWORDS[2][64]
Definition: islec.h:49
int charge
Definition: islec.h:80
double A1
Definition: islec.h:145
NIITERPARAM * nii_ter_params
Definition: islec.h:163
int total_phase_num
Definition: islec.h:199
SOLIDSOLUTION_PHASE * solidsolution
Definition: islec.h:191
bool test_models()
Definition: test_models.c:30
double * n_eq
Definition: islec.h:215
GAS_PHASE * gas
Definition: islec.h:188
int nn_bin_param_num
Definition: islec.h:160
struct NNIIQUAPARAM NNIIQUAPARAM
double system_P
Definition: islec.h:211
bool test_load()
Definition: test_load.c:31
Definition: islec.h:186
bool load_db(char *input, char *temp)
Definition: load_db.c:718
Definition: islec.h:77
struct PHASES PHASES
int aqueous_phase_num
Definition: islec.h:196
SOLID_PHASE * solids
Definition: islec.h:190
SPECIES * solid_species
Definition: islec.h:175
double element_mass
Definition: islec.h:74
Definition: islec.h:70
double * elements
Definition: islec.h:81
char element_symbol[2]
Definition: islec.h:72
int total_species_num
Definition: islec.h:200
char PHASE_KEYWORDS[4][64]
Definition: islec.h:52
char phase_keyword[32]
Definition: islec.h:203
char PROPERTY[6][64]
Definition: islec.h:63
char PROCESS[5][64]
Definition: islec.h:57
char block_keyword[32]
Definition: islec.h:202
int nii_ter_param_num
Definition: islec.h:162
IIITERPARAM * iii_ter_params
Definition: islec.h:165
SUBRPARAM * params
Definition: islec.h:183
double gibbs_eq
Definition: islec.h:216
struct SPECIES SPECIES
NNIIQUAPARAM * nnii_qua_params
Definition: islec.h:169
int gem_ipopt()
Perform Gibbs energy minimization (GEM) using the IPOPT algrithium.
Definition: gem_ipopt.c:180
PHASES phases
Definition: islec.h:206
int total_comp_num
Definition: islec.h:194
double alpha1
Definition: islec.h:90
double system_charge
Definition: islec.h:212
int solid_phase_num
Definition: islec.h:197
struct NIIIQUAPARAM NIIIQUAPARAM
NIIIQUAPARAM * niii_qua_params
Definition: islec.h:167
int iii_ter_param_num
Definition: islec.h:164
int gas_phase_num
Definition: islec.h:195
int nnii_qua_param_num
Definition: islec.h:168
struct SOLIDSOLUTION_PHASE SOLIDSOLUTION_PHASE
struct SUBRPARAM SUBRPARAM
SPECIES * solidsolution_species
Definition: islec.h:181
ELEMENT * components
Definition: islec.h:205