ISLEC  Version 4.2
print_results.c
Go to the documentation of this file.
1 /* src/print_results.c
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 
33 {
34  printf ("System Initial Information\n");
35  printf (" System temperature (K) : %lf\n", system_T);
36  printf (" System pressure (Kpa): %lf\n", system_P);
37  printf (" Total components (mol):\n");
38 
39  int i;
40  for (i = 0; i < total_comp_num; i ++)
41  {
42  printf (" %s\t%e\n", components[i].element_symbol, total_components[i]);
43  }
44 
45  printf (" Total phase number : %d\n\n", total_phase_num);
46 }
47 
49 {
50  printf ("System Equilibrium Information\n");
51 
52  double T = system_T;
53  double P = system_P;
54  int species_num_index = 0;
55 
56  int i;
57  for (i = 0; i < gas_phase_num; i ++)
58  {
59  printf (" GAS %d\n", i+1);
60  printf (" %-16s\t%s\t%s\n", "S", "Z", "n(mol)");
61 
62  int j;
63  double ngi[phases.gas[i].species_num];
64 
65  for (j = 0; j < phases.gas[i].species_num; j++)
66  {
67  ngi[j] = n_eq[j + species_num_index];
68  }
69 
70  for (j = 0; j < phases.gas[i].species_num; j ++)
71  {
72  printf (" %-16s\t%-+d\t%e\n",
75  ngi[j]);
76 
77  species_num_index ++;
78  }
79  }
80 
81  for (i = 0; i < aqueous_phase_num; i ++)
82  {
83  printf (" LIQUID %d\n", i+1);
84  printf (" %-16s\t%s\t%s\t\t%s\t%s\t\t%s\t\t%s\n",
85  "S", "Z", "n(mol)", "m(mol/kgw)", "x", "a", "r");
86 
87  int j, k;
88  double naqi[phases.aqueous[i].species_num];
89  double sum_naqi = 0;
90 
91  for (k = 0; k < phases.aqueous[i].species_num; k ++)
92  {
93  if (phases.aqueous[i].aqueous_species[k].charge == 0 &&
95  {
96  break;
97  }
98  }
99 
100  for (j = 0; j < phases.aqueous[i].species_num; j++)
101  {
102  naqi[j] = n_eq[j + species_num_index];
103  sum_naqi += naqi[j];
104  }
105 
106  for (j = 0; j < phases.aqueous[i].species_num; j ++)
107  {
108  double aj = psc_a (phases.aqueous[i], j, naqi, T, P);
109  double rj = psc_r (phases.aqueous[i], j, naqi, T, P);
110 
111  printf (" %-16s\t%-+d\t%e\t%e\t%e\t%e\t%e\n",
114  naqi[j], naqi[j]/naqi[k]*55.51, naqi[j]/sum_naqi, aj, rj);
115 
116  species_num_index ++;
117  }
118  }
119 
120  for (i = 0; i < solid_phase_num; i ++)
121  {
122  printf (" SOLID %d\n", i+1);
123  printf (" %-30s\t%s\t%s\n", "S", "Z", "n(mol)");
124 
125  int j;
126  double nsi[phases.solids[i].species_num];
127 
128  for (j = 0; j < phases.solids[i].species_num; j++)
129  {
130  nsi[j] = n_eq[j + species_num_index];
131  }
132 
133  for (j = 0; j < phases.solids[i].species_num; j ++)
134  {
135  printf (" %-30s\t%-+d\t%e\n",
138  nsi[j]);
139 
140  species_num_index ++;
141  }
142  }
143 
144  for (i = 0; i < solidsolution_phase_num; i ++)
145  {
146  printf (" SOLIDSOLUTION %d\n", i+1);
147  printf (" %-30s\t%s\t%s\t\t%s\n", "S", "Z", "n(mol)", "a");
148 
149  int j;
150  double nssi[phases.solidsolution[i].species_num];
151 
152  for (j = 0; j < phases.solidsolution[i].species_num; j++)
153  {
154  nssi[j] = n_eq[j + species_num_index];
155  }
156 
157  for (j = 0; j < phases.solidsolution[i].species_num; j ++)
158  {
159  double aj = rkg_ai (phases.solidsolution[i], j, nssi, T, P);
160 
161  printf (" %-30s\t%-+d\t%e\t%e\n",
164  nssi[j], aj);
165 
166  species_num_index ++;
167  }
168  }
169 }
170 
172 {
173  printf ("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
174 
177 
178  printf("\n Total Gibbs energy in equilibrium (kJ): %e\n", gibbs_eq);
179 
180  printf ("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
181 }
AQUEOUS_PHASE * aqueous
Definition: islec.h:189
int solidsolution_phase_num
Definition: islec.h:198
int species_num
Definition: islec.h:150
int species_num
Definition: islec.h:156
double * total_components
Definition: islec.h:213
SPECIES * gas_species
Definition: islec.h:151
double psc_a(AQUEOUS_PHASE aq, int index, double *n, double T, double P)
Definition: psc_model.c:3496
SPECIES * aqueous_species
Definition: islec.h:157
int species_num
Definition: islec.h:174
double system_T
Definition: islec.h:210
double psc_r(AQUEOUS_PHASE aq, int index, double *n, double T, double P)
Definition: psc_model.c:3483
int charge
Definition: islec.h:80
#define WATER_SYMBOL
Definition: islec.h:47
int total_phase_num
Definition: islec.h:199
SOLIDSOLUTION_PHASE * solidsolution
Definition: islec.h:191
double * n_eq
Definition: islec.h:215
GAS_PHASE * gas
Definition: islec.h:188
double system_P
Definition: islec.h:211
int aqueous_phase_num
Definition: islec.h:196
SOLID_PHASE * solids
Definition: islec.h:190
SPECIES * solid_species
Definition: islec.h:175
double gibbs_eq
Definition: islec.h:216
PHASES phases
Definition: islec.h:206
char species_symbol[64]
Definition: islec.h:79
int total_comp_num
Definition: islec.h:194
int solid_phase_num
Definition: islec.h:197
int gas_phase_num
Definition: islec.h:195
SPECIES * solidsolution_species
Definition: islec.h:181
ELEMENT * components
Definition: islec.h:205