32 #define CONSTANT_MW 18.015 // molar mass of water molecular 33 #define CONSTANT_pi 3.1415926 // value of constant pai 34 #define CONSTANT_NA 6.02214129E+23 // value of constant Avogadro constant 35 #define CONSTANT_k 1.3806448E-16 // unit in esu 36 #define CONSTANT_e 4.8024E-10 // unit in esu 37 #define CONSTANT_pc 0.322 // critical pressure 38 #define CONSTANT_Tc 647.096 // critical temperature 40 #define CONSTANT_b1 1.99274064 41 #define CONSTANT_b2 1.09965342 42 #define CONSTANT_b3 -0.510839303 43 #define CONSTANT_b4 -1.75493479 44 #define CONSTANT_b5 -45.5170352 45 #define CONSTANT_b6 -6.74694450E+5 47 #define tao_T (1.0 - T/CONSTANT_Tc) 48 #define p_T (CONSTANT_pc)*(1 + CONSTANT_b1 * pow (tao_T, 1.0/3.0) + CONSTANT_b2 * pow (tao_T, 2.0/3.0) \ 49 + CONSTANT_b3 * pow (tao_T, 5.0/3.0) + CONSTANT_b4 * pow (tao_T, 16.0/3.0) \ 50 + CONSTANT_b5 * pow (tao_T, 43.0/3.0) + CONSTANT_b6 * pow (tao_T, 110.0/3.0)) // g.cm3 52 #define CONSTANT_U1 3.4279E+2 53 #define CONSTANT_U2 -5.0866E-3 54 #define CONSTANT_U3 9.4690E-7 55 #define CONSTANT_U4 -2.0525 56 #define CONSTANT_U5 3.1159E+3 57 #define CONSTANT_U6 -1.8289E+2 58 #define CONSTANT_U7 -8.0325E+3 59 #define CONSTANT_U8 4.2142E+6 60 #define CONSTANT_U9 2.1417 62 #define D1000_T (CONSTANT_U1 * exp (CONSTANT_U2 * T + CONSTANT_U3 * T * T)) 63 #define C_T (CONSTANT_U4 + CONSTANT_U5/(CONSTANT_U6 + T)) 64 #define B_T (CONSTANT_U7 + CONSTANT_U8/T + CONSTANT_U9 * T) 65 #define D_T (D1000_T + C_T * log ((B_T + P)/(B_T + 1000))) 67 #define dp_T -(CONSTANT_pc/CONSTANT_Tc)*(CONSTANT_b1/3.0 * pow (tao_T, -2.0/3.0) \ 68 + 2.0 * CONSTANT_b2/3.0 * pow (tao_T, -1.0/3.0) \ 69 + 5.0 * CONSTANT_b3/3.0 * pow (tao_T, 2.0/3.0) \ 70 + 16.0 * CONSTANT_b4/3.0 * pow (tao_T, 13/3.0) \ 71 + 43.0 * CONSTANT_b5/3.0 * pow (tao_T, 40.0/3.0) \ 72 + 110.0 * CONSTANT_b6/3.0 * pow (tao_T, 107/3.0)) 74 #define aw_T -(1/(p_T))*dp_T 75 #define dD1000_T CONSTANT_U1*exp(CONSTANT_U2*T + CONSTANT_U3*T*T)*(CONSTANT_U2 + 2*CONSTANT_U3*T) 76 #define dC_T -CONSTANT_U5/pow(CONSTANT_U6 + T, 2) 77 #define dB_T (-CONSTANT_U8/(T * T) + CONSTANT_U9) 78 #define dBP1000_T ((B_T + 1000)*dB_T - (B_T + P)*dB_T)/pow(B_T + 1000, 2) 79 #define dB1000P_T ((B_T + P)*dB_T - (B_T + 1000)*dB_T)/pow(B_T + P, 2) 80 #define dD_T (dD1000_T + dC_T * log ((B_T + P)/(B_T + 1000)) + C_T * (B_T + 1000)/(B_T + P)*dBP1000_T) 81 #define dlnD_T (1/D_T)*dD_T 82 #define d2D1000_T CONSTANT_U1*exp(CONSTANT_U2*T + CONSTANT_U3*T*T)*(pow(CONSTANT_U2 + 2*CONSTANT_U3*T, 2) + 2*CONSTANT_U3) 83 #define d2C_T 2*CONSTANT_U5/pow(CONSTANT_U6 + T, 3) 84 #define d2B_T 2*CONSTANT_U8/pow(T, 3) 85 #define d2BP1000_T (((B_T + 1000) * d2B_T - d2B_T * (B_T + P)) * (B_T + 1000) * (B_T + 1000) \ 86 - 2 * (B_T + 1000) * dB_T * \ 87 ((B_T + 1000) * dB_T - (B_T + P) * dB_T))/pow(B_T + 1000, 4) 88 #define d2D_T (d2D1000_T + d2C_T * log ((B_T + P)/(B_T + 1000)) \ 89 + dC_T*(B_T+1000)/(B_T+P)*dBP1000_T + (dC_T * (B_T + 1000)/(B_T + P) \ 90 + C_T * dB1000P_T) * dBP1000_T + C_T * (B_T+1000)/(B_T + P) * d2BP1000_T) 91 #define d2p_T (CONSTANT_pc/(CONSTANT_Tc * CONSTANT_Tc)) * ((-2.0*CONSTANT_b1/9.0)* pow (tao_T, -5.0/3.0) + \ 92 (-2.0*CONSTANT_b2/9.0)* pow (tao_T, -4.0/3.0) + \ 93 (10.0*CONSTANT_b3/9.0)* pow (tao_T, -1.0/3.0) + \ 94 (208.0*CONSTANT_b4/9.0)* pow (tao_T, 10.0/3.0) + \ 95 (1720.0*CONSTANT_b5/9.0)* pow (tao_T, 37.0/3.0) + \ 96 (11770.0*CONSTANT_b6/9.0)* pow (tao_T, 104.0/3.0)) 98 #define ROU 13.0 // here used a constant p = 13.0 instead of (2150*sqrt(p_T/D_T/T)) 101 static double aphi (
double T,
double P)
106 static double ax (
double T,
double P)
111 static double ah (
double T,
double P)
113 return -6.0 *
R * T * aphi (T, P) * (1.0 + T *
dlnD_T + T *
aw_T/3.0);
116 static double ahx (
double T,
double P)
121 static double aj (
double T,
double P)
123 return 3 * aphi (T, P) *
R * T * (1.0/T + 2 *
dlnD_T 129 static double ajx (
double T,
double P)
135 static double g(
double x)
139 return 2 * (1 - (1 + x) * exp(-x) ) / pow (x, 2);
148 static double gp(
double x)
152 return -2 * (1 - (1 + x + pow (x, 2) / 2.0) * exp (-x)) / pow (x, 2);
160 static double jj (
double x)
162 return x * pow ( (4.0 +
C1 * pow (x, -
C2) * exp (-
C3 * pow (x,
C4))), -1.0);
165 static double jp (
double x)
167 return pow ( (4.0 +
C1 * pow (x, -
C2) * exp (-
C3 * pow (x,
C4))), -1.0) +
168 pow (4.0 +
C1 * pow (x, -
C2) * exp (-
C3 * pow (x,
C4)), -2.0) *
169 ( (
C1 * x * exp (-
C3 * pow (x,
C4))) * (
C2 * pow (x, -
C2-1.0) +
170 C3 *
C4 * pow (x,
C4-1.0) * pow (x, -
C2)));
173 static double psc_rn (
AQUEOUS_PHASE aq,
int index,
double *n,
double T,
double P)
177 printf (
"The species is not a neutral species!!!\n");
183 printf (
"The species dose not existed!!!\n");
191 int i, j, k, l, m, s;
210 double Bii_a, Bii_b, Bii_c, Bii_d, Bii_e, Bii_f, \
211 B1ii_a, B1ii_b, B1ii_c, B1ii_d, B1ii_e, B1ii_f, \
212 Wnn_a, Wnn_b, Wnn_c, Wnn_d, Wnn_e, Wnn_f, \
213 Unn_a, Unn_b, Unn_c, Unn_d, Unn_e, Unn_f, \
214 Wnii_a, Wnii_b, Wnii_c, Wnii_d, Wnii_e, Wnii_f, \
215 Unii_a, Unii_b, Unii_c, Unii_d, Unii_e, Unii_f, \
216 Vnii_a, Vnii_b, Vnii_c, Vnii_d, Vnii_e, Vnii_f, \
217 Wiii_a, Wiii_b, Wiii_c, Wiii_d, Wiii_e, Wiii_f, \
218 Qniii_a, Qniii_b, Qniii_c, Qniii_d, Qniii_e, Qniii_f, \
219 Yniii_a, Yniii_b, Yniii_c, Yniii_d, Yniii_e, Yniii_f, \
220 Ynnii_a, Ynnii_b, Ynnii_c, Ynnii_d, Ynnii_e, Ynnii_f;
243 F += 0.5 * x[k] * fabs(Z[k]);
250 Ix += 0.5 * (x[k] * Z[k] * Z[k]);
296 Qniii[i][j][l][m] = 0;
297 Yniii[i][j][l][m] = 0;
298 Ynnii[i][j][l][m] = 0;
338 double Bii_value = Bii_a + Bii_b * T + Bii_c * T * log(T) + Bii_d * T * T + Bii_e * T * T * T + Bii_f/T;
339 double B1ii_value = B1ii_a + B1ii_b * T + B1ii_c * T * log(T) + B1ii_d * T * T + B1ii_e * T * T * T + B1ii_f/T;
341 aii[i][j] = aii_value; aii[j][i] = aii[i][j];
342 a1ii[i][j] = a1ii_value; a1ii[j][i] = a1ii[i][j];
343 Bii[i][j] = Bii_value; Bii[j][i] = Bii[i][j];
344 B1ii[i][j] = B1ii_value; B1ii[j][i] = B1ii[i][j];
378 double Wnn_value = Wnn_a + Wnn_b * T + Wnn_c * T * log(T) + Wnn_d * T * T + Wnn_e * T * T * T + Wnn_f/T;
379 double Unn_value = Unn_a + Unn_b * T + Unn_c * T * log(T) + Unn_d * T * T + Unn_e * T * T * T + Unn_f/T;
381 Wnn[i][j] = Wnn_value; Wnn[j][i] = Wnn[i][j];
382 Unn[i][j] = Unn_value; Unn[j][i] = Unn[i][j];
430 double Wnii_value = Wnii_a + Wnii_b * T + Wnii_c * T * log(T) + Wnii_d * T * T + Wnii_e * T * T * T + Wnii_f/T;
431 double Unii_value = Unii_a + Unii_b * T + Unii_c * T * log(T) + Unii_d * T * T + Unii_e * T * T * T + Unii_f/T;
432 double Vnii_value = Vnii_a + Vnii_b * T + Vnii_c * T * log(T) + Vnii_d * T * T + Vnii_e * T * T * T + Vnii_f/T;
434 Wnii[i][j][l] = Wnii_value;
435 Wnii[i][l][j] = Wnii[i][j][l];
436 Wnii[j][i][l] = Wnii[i][j][l];
437 Wnii[j][l][i] = Wnii[i][j][l];
438 Wnii[l][i][j] = Wnii[i][j][l];
439 Wnii[l][j][i] = Wnii[i][j][l];
441 Unii[i][j][l] = Unii_value;
442 Unii[i][l][j] = Unii[i][j][l];
443 Unii[j][i][l] = Unii[i][j][l];
444 Unii[j][l][i] = Unii[i][j][l];
445 Unii[l][i][j] = Unii[i][j][l];
446 Unii[l][j][i] = Unii[i][j][l];
448 Vnii[i][j][l] = Vnii_value;
449 Vnii[i][l][j] = Vnii[i][j][l];
450 Vnii[j][i][l] = Vnii[i][j][l];
451 Vnii[j][l][i] = Vnii[i][j][l];
452 Vnii[l][i][j] = Vnii[i][j][l];
453 Vnii[l][j][i] = Vnii[i][j][l];
489 double Wiii_value = Wiii_a + Wiii_b * T + Wiii_c * T * log(T) + Wiii_d * T * T + Wiii_e * T * T * T + Wiii_f/T;
491 Wiii[i][j][l] = Wiii_value;
492 Wiii[i][l][j] = Wiii[i][j][l];
493 Wiii[j][i][l] = Wiii[i][j][l];
494 Wiii[j][l][i] = Wiii[i][j][l];
495 Wiii[l][i][j] = Wiii[i][j][l];
496 Wiii[l][j][i] = Wiii[i][j][l];
545 double Qniii_value = Qniii_a + Qniii_b * T + Qniii_c * T * log(T) + Qniii_d * T * T + Qniii_e * T * T * T + Qniii_f/T;
546 double Yniii_value = Yniii_a + Yniii_b * T + Yniii_c * T * log(T) + Yniii_d * T * T + Yniii_e * T * T * T + Yniii_f/T;
548 Qniii[i][j][l][s] = Qniii_value;
549 Qniii[i][j][s][l] = Qniii[i][j][l][s];
550 Qniii[i][l][j][s] = Qniii[i][j][l][s];
551 Qniii[i][l][s][j] = Qniii[i][j][l][s];
552 Qniii[i][s][j][l] = Qniii[i][j][l][s];
553 Qniii[i][s][l][j] = Qniii[i][j][l][s];
555 Qniii[j][i][l][s] = Qniii[i][j][l][s];
556 Qniii[j][i][s][l] = Qniii[i][j][l][s];
557 Qniii[j][l][i][s] = Qniii[i][j][l][s];
558 Qniii[j][l][s][i] = Qniii[i][j][l][s];
559 Qniii[j][s][i][l] = Qniii[i][j][l][s];
560 Qniii[j][s][l][i] = Qniii[i][j][l][s];
562 Qniii[l][i][j][s] = Qniii[i][j][l][s];
563 Qniii[l][i][s][j] = Qniii[i][j][l][s];
564 Qniii[l][j][i][s] = Qniii[i][j][l][s];
565 Qniii[l][j][s][i] = Qniii[i][j][l][s];
566 Qniii[l][s][i][j] = Qniii[i][j][l][s];
567 Qniii[l][s][j][i] = Qniii[i][j][l][s];
569 Qniii[s][i][j][l] = Qniii[i][j][l][s];
570 Qniii[s][i][l][j] = Qniii[i][j][l][s];
571 Qniii[s][j][l][i] = Qniii[i][j][l][s];
572 Qniii[s][j][i][l] = Qniii[i][j][l][s];
573 Qniii[s][l][i][j] = Qniii[i][j][l][s];
574 Qniii[s][l][j][i] = Qniii[i][j][l][s];
576 Yniii[i][j][l][s] = Yniii_value;
577 Yniii[i][j][s][l] = Yniii[i][j][l][s];
578 Yniii[i][l][j][s] = Yniii[i][j][l][s];
579 Yniii[i][l][s][j] = Yniii[i][j][l][s];
580 Yniii[i][s][j][l] = Yniii[i][j][l][s];
581 Yniii[i][s][l][j] = Yniii[i][j][l][s];
583 Yniii[j][i][l][s] = Yniii[i][j][l][s];
584 Yniii[j][i][s][l] = Yniii[i][j][l][s];
585 Yniii[j][l][i][s] = Yniii[i][j][l][s];
586 Yniii[j][l][s][i] = Yniii[i][j][l][s];
587 Yniii[j][s][i][l] = Yniii[i][j][l][s];
588 Yniii[j][s][l][i] = Yniii[i][j][l][s];
590 Yniii[l][i][j][s] = Yniii[i][j][l][s];
591 Yniii[l][i][s][j] = Yniii[i][j][l][s];
592 Yniii[l][j][i][s] = Yniii[i][j][l][s];
593 Yniii[l][j][s][i] = Yniii[i][j][l][s];
594 Yniii[l][s][i][j] = Yniii[i][j][l][s];
595 Yniii[l][s][j][i] = Yniii[i][j][l][s];
597 Yniii[s][i][j][l] = Yniii[i][j][l][s];
598 Yniii[s][i][l][j] = Yniii[i][j][l][s];
599 Yniii[s][j][l][i] = Yniii[i][j][l][s];
600 Yniii[s][j][i][l] = Yniii[i][j][l][s];
601 Yniii[s][l][i][j] = Yniii[i][j][l][s];
602 Yniii[s][l][j][i] = Yniii[i][j][l][s];
646 double Ynnii_value = Ynnii_a + Ynnii_b * T + Ynnii_c * T * log(T) + Ynnii_d * T * T + Ynnii_e * T * T * T + Ynnii_f/T;
648 Ynnii[i][j][l][s] = Ynnii_value;
649 Ynnii[i][j][s][l] = Ynnii[i][j][l][s];
650 Ynnii[i][l][j][s] = Ynnii[i][j][l][s];
651 Ynnii[i][l][s][j] = Ynnii[i][j][l][s];
652 Ynnii[i][s][j][l] = Ynnii[i][j][l][s];
653 Ynnii[i][s][l][j] = Ynnii[i][j][l][s];
655 Ynnii[j][i][l][s] = Ynnii[i][j][l][s];
656 Ynnii[j][i][s][l] = Ynnii[i][j][l][s];
657 Ynnii[j][l][i][s] = Ynnii[i][j][l][s];
658 Ynnii[j][l][s][i] = Ynnii[i][j][l][s];
659 Ynnii[j][s][i][l] = Ynnii[i][j][l][s];
660 Ynnii[j][s][l][i] = Ynnii[i][j][l][s];
662 Ynnii[l][i][j][s] = Ynnii[i][j][l][s];
663 Ynnii[l][i][s][j] = Ynnii[i][j][l][s];
664 Ynnii[l][j][i][s] = Ynnii[i][j][l][s];
665 Ynnii[l][j][s][i] = Ynnii[i][j][l][s];
666 Ynnii[l][s][i][j] = Ynnii[i][j][l][s];
667 Ynnii[l][s][j][i] = Ynnii[i][j][l][s];
669 Ynnii[s][i][j][l] = Ynnii[i][j][l][s];
670 Ynnii[s][i][l][j] = Ynnii[i][j][l][s];
671 Ynnii[s][j][l][i] = Ynnii[i][j][l][s];
672 Ynnii[s][j][i][l] = Ynnii[i][j][l][s];
673 Ynnii[s][l][i][j] = Ynnii[i][j][l][s];
674 Ynnii[s][l][j][i] = Ynnii[i][j][l][s];
679 E[i] = x[i] * fabs (Z[i]);
684 if (Z[i] * Z[k] > 0) {sum = sum + x[k] * fabs (Z[k]);}
687 if (sum != 0) {E[i] = E[i] / sum;}
691 lnfn = 2.0 * Ax * Ix * sqrt (Ix) / (1.0 +
ROU * sqrt (Ix));
701 lnfn = lnfn - 0.5 * (x[i] * x[j] * Bii[i][j] * exp (-aii[i][j] * sqrt (Ix)) + x[i] * x[j] * B1ii[i][j] * exp (-a1ii[i][j] * sqrt (Ix)));
711 if (Z[i] * Z[j] > 0 && i != j && Ix != 0)
713 double xij = 6.0 * Z[i] * Z[j] * Ax * sqrt (Ix);
714 double xii = 6.0 * Z[i] * Z[i] * Ax * sqrt (Ix);
715 double xjj = 6.0 * Z[j] * Z[j] * Ax * sqrt (Ix);
717 double vij = Z[i] * Z[j] / (4.0 * Ix) * (jj(xij) - 0.5 * jj(xii) - 0.5 * jj(xjj));
718 double vpij = - vij/Ix + (Z[i]*Z[j]/(8.0 * Ix * Ix)) * (xij * jp(xij) - 0.5 * xii * jp(xii) - 0.5 * xjj * jp(xjj));
720 lnfn = lnfn + 0.5 * (-2.0 * x[i] * x[j] * (vij + Ix * vpij));
742 Wnii_sum += x[k] * Wnii[i][j][k];
743 Unii_sum += 2 * x[k] * Unii[i][j][k];
744 Vnii_sum += 3 * x[k]* x[k] * Vnii[i][j][k];
748 lnfn = lnfn + 0.5 * ((1/F) * E[i] * E[j] * (fabs(Z[i]) + fabs(Z[j])) / (fabs(Z[i]) * fabs(Z[j])) * (Wnii[index][i][j] - Wnii_sum) +
749 x[i] * x[j] * pow (fabs(Z[i]) + fabs(Z[j]), 2) / (fabs(Z[i]) * fabs(Z[j])) * (Unii[index][i][j] - Unii_sum) +
750 4 * x[i] * x[j] * (2 * x[index] * Vnii[index][i][j] - Vnii_sum));
764 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
766 lnfn = lnfn + (- 2 * E[i] * x[j] * x[l] * Wiii[i][j][l]) * 0.5;
781 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
783 double Qniii_sum = 0;
784 double Yniii_sum = 0;
790 Qniii_sum += 2 * x[k] * Qniii[i][j][l][k];
791 Yniii_sum += 3 * x[k] * x[k] * Yniii[i][j][l][k];
795 lnfn = lnfn + 0.5 * (4 * E[i] * x[j] * x[l] * (Qniii[index][i][j][l] - Qniii_sum)
796 + 4 * E[i] * x[j] * x[l] * (2 * x[index] * Yniii[index][i][j][l] - Yniii_sum));
805 if (Z[i] == 0 && i != index)
807 lnfn = lnfn + x[i] * ((1 - x[index]) * Wnn[index][i] + (2 * (x[index] - x[i]) * (1 - x[index]) + x[i]) * Unn[index][i]);
813 for (j = 0; j < i; j ++)
815 if (Z[i] == 0 && Z[j] == 0 && i != index && j != index && i != j)
817 lnfn = lnfn - x[i] * x[j] * (Wnn[i][j] + 2 * (x[i] - x[j]) * Unn[i][j]);
831 if (Z[i] * Z[j] < 0 && Z[k] == 0 && k != index)
833 sum1 += x[k] * Ynnii[index][i][j][k];
841 if (Z[i] * Z[j] < 0 && Z[k] == 0 && Z[l] == 0 && k != l)
843 sum2 += 2.0 * 0.5 * x[k] * x[l] * Ynnii[i][j][k][l];
850 lnfn = lnfn + 0.5 * (1/F) * E[i] * E[j] * (fabs(Z[i]) + fabs(Z[j]))/(fabs(Z[i]) * fabs(Z[j])) * (sum1 - sum2);
863 lnfn = lnfn - (Wnn[index][k] - Unn[index][k]);
865 if (index != k) {
return exp(lnfn) * x[k];}
870 static double psc_an (
AQUEOUS_PHASE aq,
int index,
double *n,
double T,
double P)
874 printf (
"The species is not a neutral species!!!\n");
880 printf (
"The species dose not existed!!!\n");
889 int i, j, k, l, m, s;
908 double Bii_a, Bii_b, Bii_c, Bii_d, Bii_e, Bii_f, \
909 B1ii_a, B1ii_b, B1ii_c, B1ii_d, B1ii_e, B1ii_f, \
910 Wnn_a, Wnn_b, Wnn_c, Wnn_d, Wnn_e, Wnn_f, \
911 Unn_a, Unn_b, Unn_c, Unn_d, Unn_e, Unn_f, \
912 Wnii_a, Wnii_b, Wnii_c, Wnii_d, Wnii_e, Wnii_f, \
913 Unii_a, Unii_b, Unii_c, Unii_d, Unii_e, Unii_f, \
914 Vnii_a, Vnii_b, Vnii_c, Vnii_d, Vnii_e, Vnii_f, \
915 Wiii_a, Wiii_b, Wiii_c, Wiii_d, Wiii_e, Wiii_f, \
916 Qniii_a, Qniii_b, Qniii_c, Qniii_d, Qniii_e, Qniii_f, \
917 Yniii_a, Yniii_b, Yniii_c, Yniii_d, Yniii_e, Yniii_f, \
918 Ynnii_a, Ynnii_b, Ynnii_c, Ynnii_d, Ynnii_e, Ynnii_f;
941 F += 0.5 * x[k] * fabs(Z[k]);
948 Ix += 0.5 * (x[k] * Z[k] * Z[k]);
994 Qniii[i][j][l][m] = 0;
995 Yniii[i][j][l][m] = 0;
996 Ynnii[i][j][l][m] = 0;
1036 double Bii_value = Bii_a + Bii_b * T + Bii_c * T * log(T) + Bii_d * T * T + Bii_e * T * T * T + Bii_f/T;
1037 double B1ii_value = B1ii_a + B1ii_b * T + B1ii_c * T * log(T) + B1ii_d * T * T + B1ii_e * T * T * T + B1ii_f/T;
1039 aii[i][j] = aii_value; aii[j][i] = aii[i][j];
1040 a1ii[i][j] = a1ii_value; a1ii[j][i] = a1ii[i][j];
1041 Bii[i][j] = Bii_value; Bii[j][i] = Bii[i][j];
1042 B1ii[i][j] = B1ii_value; B1ii[j][i] = B1ii[i][j];
1076 double Wnn_value = Wnn_a + Wnn_b * T + Wnn_c * T * log(T) + Wnn_d * T * T + Wnn_e * T * T * T + Wnn_f/T;
1077 double Unn_value = Unn_a + Unn_b * T + Unn_c * T * log(T) + Unn_d * T * T + Unn_e * T * T * T + Unn_f/T;
1079 Wnn[i][j] = Wnn_value; Wnn[j][i] = Wnn[i][j];
1080 Unn[i][j] = Unn_value; Unn[j][i] = Unn[i][j];
1128 double Wnii_value = Wnii_a + Wnii_b * T + Wnii_c * T * log(T) + Wnii_d * T * T + Wnii_e * T * T * T + Wnii_f/T;
1129 double Unii_value = Unii_a + Unii_b * T + Unii_c * T * log(T) + Unii_d * T * T + Unii_e * T * T * T + Unii_f/T;
1130 double Vnii_value = Vnii_a + Vnii_b * T + Vnii_c * T * log(T) + Vnii_d * T * T + Vnii_e * T * T * T + Vnii_f/T;
1132 Wnii[i][j][l] = Wnii_value;
1133 Wnii[i][l][j] = Wnii[i][j][l];
1134 Wnii[j][i][l] = Wnii[i][j][l];
1135 Wnii[j][l][i] = Wnii[i][j][l];
1136 Wnii[l][i][j] = Wnii[i][j][l];
1137 Wnii[l][j][i] = Wnii[i][j][l];
1139 Unii[i][j][l] = Unii_value;
1140 Unii[i][l][j] = Unii[i][j][l];
1141 Unii[j][i][l] = Unii[i][j][l];
1142 Unii[j][l][i] = Unii[i][j][l];
1143 Unii[l][i][j] = Unii[i][j][l];
1144 Unii[l][j][i] = Unii[i][j][l];
1146 Vnii[i][j][l] = Vnii_value;
1147 Vnii[i][l][j] = Vnii[i][j][l];
1148 Vnii[j][i][l] = Vnii[i][j][l];
1149 Vnii[j][l][i] = Vnii[i][j][l];
1150 Vnii[l][i][j] = Vnii[i][j][l];
1151 Vnii[l][j][i] = Vnii[i][j][l];
1187 double Wiii_value = Wiii_a + Wiii_b * T + Wiii_c * T * log(T) + Wiii_d * T * T + Wiii_e * T * T * T + Wiii_f/T;
1189 Wiii[i][j][l] = Wiii_value;
1190 Wiii[i][l][j] = Wiii[i][j][l];
1191 Wiii[j][i][l] = Wiii[i][j][l];
1192 Wiii[j][l][i] = Wiii[i][j][l];
1193 Wiii[l][i][j] = Wiii[i][j][l];
1194 Wiii[l][j][i] = Wiii[i][j][l];
1243 double Qniii_value = Qniii_a + Qniii_b * T + Qniii_c * T * log(T) + Qniii_d * T * T + Qniii_e * T * T * T + Qniii_f/T;
1244 double Yniii_value = Yniii_a + Yniii_b * T + Yniii_c * T * log(T) + Yniii_d * T * T + Yniii_e * T * T * T + Yniii_f/T;
1246 Qniii[i][j][l][s] = Qniii_value;
1247 Qniii[i][j][s][l] = Qniii[i][j][l][s];
1248 Qniii[i][l][j][s] = Qniii[i][j][l][s];
1249 Qniii[i][l][s][j] = Qniii[i][j][l][s];
1250 Qniii[i][s][j][l] = Qniii[i][j][l][s];
1251 Qniii[i][s][l][j] = Qniii[i][j][l][s];
1253 Qniii[j][i][l][s] = Qniii[i][j][l][s];
1254 Qniii[j][i][s][l] = Qniii[i][j][l][s];
1255 Qniii[j][l][i][s] = Qniii[i][j][l][s];
1256 Qniii[j][l][s][i] = Qniii[i][j][l][s];
1257 Qniii[j][s][i][l] = Qniii[i][j][l][s];
1258 Qniii[j][s][l][i] = Qniii[i][j][l][s];
1260 Qniii[l][i][j][s] = Qniii[i][j][l][s];
1261 Qniii[l][i][s][j] = Qniii[i][j][l][s];
1262 Qniii[l][j][i][s] = Qniii[i][j][l][s];
1263 Qniii[l][j][s][i] = Qniii[i][j][l][s];
1264 Qniii[l][s][i][j] = Qniii[i][j][l][s];
1265 Qniii[l][s][j][i] = Qniii[i][j][l][s];
1267 Qniii[s][i][j][l] = Qniii[i][j][l][s];
1268 Qniii[s][i][l][j] = Qniii[i][j][l][s];
1269 Qniii[s][j][l][i] = Qniii[i][j][l][s];
1270 Qniii[s][j][i][l] = Qniii[i][j][l][s];
1271 Qniii[s][l][i][j] = Qniii[i][j][l][s];
1272 Qniii[s][l][j][i] = Qniii[i][j][l][s];
1274 Yniii[i][j][l][s] = Yniii_value;
1275 Yniii[i][j][s][l] = Yniii[i][j][l][s];
1276 Yniii[i][l][j][s] = Yniii[i][j][l][s];
1277 Yniii[i][l][s][j] = Yniii[i][j][l][s];
1278 Yniii[i][s][j][l] = Yniii[i][j][l][s];
1279 Yniii[i][s][l][j] = Yniii[i][j][l][s];
1281 Yniii[j][i][l][s] = Yniii[i][j][l][s];
1282 Yniii[j][i][s][l] = Yniii[i][j][l][s];
1283 Yniii[j][l][i][s] = Yniii[i][j][l][s];
1284 Yniii[j][l][s][i] = Yniii[i][j][l][s];
1285 Yniii[j][s][i][l] = Yniii[i][j][l][s];
1286 Yniii[j][s][l][i] = Yniii[i][j][l][s];
1288 Yniii[l][i][j][s] = Yniii[i][j][l][s];
1289 Yniii[l][i][s][j] = Yniii[i][j][l][s];
1290 Yniii[l][j][i][s] = Yniii[i][j][l][s];
1291 Yniii[l][j][s][i] = Yniii[i][j][l][s];
1292 Yniii[l][s][i][j] = Yniii[i][j][l][s];
1293 Yniii[l][s][j][i] = Yniii[i][j][l][s];
1295 Yniii[s][i][j][l] = Yniii[i][j][l][s];
1296 Yniii[s][i][l][j] = Yniii[i][j][l][s];
1297 Yniii[s][j][l][i] = Yniii[i][j][l][s];
1298 Yniii[s][j][i][l] = Yniii[i][j][l][s];
1299 Yniii[s][l][i][j] = Yniii[i][j][l][s];
1300 Yniii[s][l][j][i] = Yniii[i][j][l][s];
1344 double Ynnii_value = Ynnii_a + Ynnii_b * T + Ynnii_c * T * log(T) + Ynnii_d * T * T + Ynnii_e * T * T * T + Ynnii_f/T;
1346 Ynnii[i][j][l][s] = Ynnii_value;
1347 Ynnii[i][j][s][l] = Ynnii[i][j][l][s];
1348 Ynnii[i][l][j][s] = Ynnii[i][j][l][s];
1349 Ynnii[i][l][s][j] = Ynnii[i][j][l][s];
1350 Ynnii[i][s][j][l] = Ynnii[i][j][l][s];
1351 Ynnii[i][s][l][j] = Ynnii[i][j][l][s];
1353 Ynnii[j][i][l][s] = Ynnii[i][j][l][s];
1354 Ynnii[j][i][s][l] = Ynnii[i][j][l][s];
1355 Ynnii[j][l][i][s] = Ynnii[i][j][l][s];
1356 Ynnii[j][l][s][i] = Ynnii[i][j][l][s];
1357 Ynnii[j][s][i][l] = Ynnii[i][j][l][s];
1358 Ynnii[j][s][l][i] = Ynnii[i][j][l][s];
1360 Ynnii[l][i][j][s] = Ynnii[i][j][l][s];
1361 Ynnii[l][i][s][j] = Ynnii[i][j][l][s];
1362 Ynnii[l][j][i][s] = Ynnii[i][j][l][s];
1363 Ynnii[l][j][s][i] = Ynnii[i][j][l][s];
1364 Ynnii[l][s][i][j] = Ynnii[i][j][l][s];
1365 Ynnii[l][s][j][i] = Ynnii[i][j][l][s];
1367 Ynnii[s][i][j][l] = Ynnii[i][j][l][s];
1368 Ynnii[s][i][l][j] = Ynnii[i][j][l][s];
1369 Ynnii[s][j][l][i] = Ynnii[i][j][l][s];
1370 Ynnii[s][j][i][l] = Ynnii[i][j][l][s];
1371 Ynnii[s][l][i][j] = Ynnii[i][j][l][s];
1372 Ynnii[s][l][j][i] = Ynnii[i][j][l][s];
1377 E[i] = x[i] * fabs (Z[i]);
1382 if (Z[i] * Z[k] > 0) {sum = sum + x[k] * fabs (Z[k]);}
1385 if (sum != 0) {E[i] = E[i] / sum;}
1389 lnfn = 2.0 * Ax * Ix * sqrt (Ix) / (1.0 +
ROU * sqrt (Ix));
1399 lnfn = lnfn - 0.5 * (x[i] * x[j] * Bii[i][j] * exp (-aii[i][j] * sqrt (Ix)) + x[i] * x[j] * B1ii[i][j] * exp (-a1ii[i][j] * sqrt (Ix)));
1409 if (Z[i] * Z[j] > 0 && i != j && Ix != 0)
1411 double xij = 6.0 * Z[i] * Z[j] * Ax * sqrt (Ix);
1412 double xii = 6.0 * Z[i] * Z[i] * Ax * sqrt (Ix);
1413 double xjj = 6.0 * Z[j] * Z[j] * Ax * sqrt (Ix);
1415 double vij = Z[i] * Z[j] / (4.0 * Ix) * (jj(xij) - 0.5 * jj(xii) - 0.5 * jj(xjj));
1416 double vpij = - vij/Ix + (Z[i]*Z[j]/(8.0 * Ix * Ix)) * (xij * jp(xij) - 0.5 * xii * jp(xii) - 0.5 * xjj * jp(xjj));
1418 lnfn = lnfn + 0.5 * (-2.0 * x[i] * x[j] * (vij + Ix * vpij));
1432 double Wnii_sum = 0;
1433 double Unii_sum = 0;
1434 double Vnii_sum = 0;
1440 Wnii_sum += x[k] * Wnii[i][j][k];
1441 Unii_sum += 2 * x[k] * Unii[i][j][k];
1442 Vnii_sum += 3 * x[k]* x[k] * Vnii[i][j][k];
1446 lnfn = lnfn + 0.5 * ((1/F) * E[i] * E[j] * (fabs(Z[i]) + fabs(Z[j])) / (fabs(Z[i]) * fabs(Z[j])) * (Wnii[index][i][j] - Wnii_sum) +
1447 x[i] * x[j] * pow (fabs(Z[i]) + fabs(Z[j]), 2) / (fabs(Z[i]) * fabs(Z[j])) * (Unii[index][i][j] - Unii_sum) +
1448 4 * x[i] * x[j] * (2 * x[index] * Vnii[index][i][j] - Vnii_sum));
1462 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
1464 lnfn = lnfn + (- 2 * E[i] * x[j] * x[l] * Wiii[i][j][l]) * 0.5;
1479 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
1481 double Qniii_sum = 0;
1482 double Yniii_sum = 0;
1488 Qniii_sum += 2 * x[k] * Qniii[i][j][l][k];
1489 Yniii_sum += 3 * x[k] * x[k] * Yniii[i][j][l][k];
1493 lnfn = lnfn + 0.5 * (4 * E[i] * x[j] * x[l] * (Qniii[index][i][j][l] - Qniii_sum)
1494 + 4 * E[i] * x[j] * x[l] * (2 * x[index] * Yniii[index][i][j][l] - Yniii_sum));
1503 if (Z[i] == 0 && i != index)
1505 lnfn = lnfn + x[i] * ((1 - x[index]) * Wnn[index][i] + (2 * (x[index] - x[i]) * (1 - x[index]) + x[i]) * Unn[index][i]);
1511 for (j = 0; j < i; j ++)
1513 if (Z[i] == 0 && Z[j] == 0 && i != index && j != index && i != j)
1515 lnfn = lnfn - x[i] * x[j] * (Wnn[i][j] + 2 * (x[i] - x[j]) * Unn[i][j]);
1529 if (Z[i] * Z[j] < 0 && Z[k] == 0 && k != index)
1531 sum1 += x[k] * Ynnii[index][i][j][k];
1539 if (Z[i] * Z[j] < 0 && Z[k] == 0 && Z[l] == 0 && k != l)
1541 sum2 += 2.0 * 0.5 * x[k] * x[l] * Ynnii[i][j][k][l];
1546 if (Z[i] * Z[j] < 0)
1548 lnfn = lnfn + 0.5 * (1/F) * E[i] * E[j] * (fabs(Z[i]) + fabs(Z[j]))/(fabs(Z[i]) * fabs(Z[j])) * (sum1 - sum2);
1561 lnfn = lnfn - (Wnn[index][k] - Unn[index][k]);
1563 if (index != k) {
return exp(lnfn) * x[k] * (n[index] / n[k] * 1000/
CONSTANT_MW);}
1565 return exp(lnfn) * x[index];
1568 static double psc_ri (
AQUEOUS_PHASE aq,
int index,
double *n,
double T,
double P)
1572 printf (
"The species is not a ion species!!!\n");
1578 printf (
"The species dose not existed!!!\n");
1587 int i, j, k, l, m, s;
1606 double Bii_a, Bii_b, Bii_c, Bii_d, Bii_e, Bii_f, \
1607 B1ii_a, B1ii_b, B1ii_c, B1ii_d, B1ii_e, B1ii_f, \
1608 Wnn_a, Wnn_b, Wnn_c, Wnn_d, Wnn_e, Wnn_f, \
1609 Unn_a, Unn_b, Unn_c, Unn_d, Unn_e, Unn_f, \
1610 Wnii_a, Wnii_b, Wnii_c, Wnii_d, Wnii_e, Wnii_f, \
1611 Unii_a, Unii_b, Unii_c, Unii_d, Unii_e, Unii_f, \
1612 Vnii_a, Vnii_b, Vnii_c, Vnii_d, Vnii_e, Vnii_f, \
1613 Wiii_a, Wiii_b, Wiii_c, Wiii_d, Wiii_e, Wiii_f, \
1614 Qniii_a, Qniii_b, Qniii_c, Qniii_d, Qniii_e, Qniii_f, \
1615 Yniii_a, Yniii_b, Yniii_c, Yniii_d, Yniii_e, Yniii_f, \
1616 Ynnii_a, Ynnii_b, Ynnii_c, Ynnii_d, Ynnii_e, Ynnii_f;
1639 F += 0.5 * x[k] * fabs(Z[k]);
1646 Ix += 0.5 * (x[k] * Z[k] * Z[k]);
1692 Qniii[i][j][l][m] = 0;
1693 Yniii[i][j][l][m] = 0;
1694 Ynnii[i][j][l][m] = 0;
1734 double Bii_value = Bii_a + Bii_b * T + Bii_c * T * log(T) + Bii_d * T * T + Bii_e * T * T * T + Bii_f/T;
1735 double B1ii_value = B1ii_a + B1ii_b * T + B1ii_c * T * log(T) + B1ii_d * T * T + B1ii_e * T * T * T + B1ii_f/T;
1737 aii[i][j] = aii_value; aii[j][i] = aii[i][j];
1738 a1ii[i][j] = a1ii_value; a1ii[j][i] = a1ii[i][j];
1739 Bii[i][j] = Bii_value; Bii[j][i] = Bii[i][j];
1740 B1ii[i][j] = B1ii_value; B1ii[j][i] = B1ii[i][j];
1774 double Wnn_value = Wnn_a + Wnn_b * T + Wnn_c * T * log(T) + Wnn_d * T * T + Wnn_e * T * T * T + Wnn_f/T;
1775 double Unn_value = Unn_a + Unn_b * T + Unn_c * T * log(T) + Unn_d * T * T + Unn_e * T * T * T + Unn_f/T;
1777 Wnn[i][j] = Wnn_value; Wnn[j][i] = Wnn[i][j];
1778 Unn[i][j] = Unn_value; Unn[j][i] = Unn[i][j];
1826 double Wnii_value = Wnii_a + Wnii_b * T + Wnii_c * T * log(T) + Wnii_d * T * T + Wnii_e * T * T * T + Wnii_f/T;
1827 double Unii_value = Unii_a + Unii_b * T + Unii_c * T * log(T) + Unii_d * T * T + Unii_e * T * T * T + Unii_f/T;
1828 double Vnii_value = Vnii_a + Vnii_b * T + Vnii_c * T * log(T) + Vnii_d * T * T + Vnii_e * T * T * T + Vnii_f/T;
1830 Wnii[i][j][l] = Wnii_value;
1831 Wnii[i][l][j] = Wnii[i][j][l];
1832 Wnii[j][i][l] = Wnii[i][j][l];
1833 Wnii[j][l][i] = Wnii[i][j][l];
1834 Wnii[l][i][j] = Wnii[i][j][l];
1835 Wnii[l][j][i] = Wnii[i][j][l];
1837 Unii[i][j][l] = Unii_value;
1838 Unii[i][l][j] = Unii[i][j][l];
1839 Unii[j][i][l] = Unii[i][j][l];
1840 Unii[j][l][i] = Unii[i][j][l];
1841 Unii[l][i][j] = Unii[i][j][l];
1842 Unii[l][j][i] = Unii[i][j][l];
1844 Vnii[i][j][l] = Vnii_value;
1845 Vnii[i][l][j] = Vnii[i][j][l];
1846 Vnii[j][i][l] = Vnii[i][j][l];
1847 Vnii[j][l][i] = Vnii[i][j][l];
1848 Vnii[l][i][j] = Vnii[i][j][l];
1849 Vnii[l][j][i] = Vnii[i][j][l];
1885 double Wiii_value = Wiii_a + Wiii_b * T + Wiii_c * T * log(T) + Wiii_d * T * T + Wiii_e * T * T * T + Wiii_f/T;
1887 Wiii[i][j][l] = Wiii_value;
1888 Wiii[i][l][j] = Wiii[i][j][l];
1889 Wiii[j][i][l] = Wiii[i][j][l];
1890 Wiii[j][l][i] = Wiii[i][j][l];
1891 Wiii[l][i][j] = Wiii[i][j][l];
1892 Wiii[l][j][i] = Wiii[i][j][l];
1941 double Qniii_value = Qniii_a + Qniii_b * T + Qniii_c * T * log(T) + Qniii_d * T * T + Qniii_e * T * T * T + Qniii_f/T;
1942 double Yniii_value = Yniii_a + Yniii_b * T + Yniii_c * T * log(T) + Yniii_d * T * T + Yniii_e * T * T * T + Yniii_f/T;
1944 Qniii[i][j][l][s] = Qniii_value;
1945 Qniii[i][j][s][l] = Qniii[i][j][l][s];
1946 Qniii[i][l][j][s] = Qniii[i][j][l][s];
1947 Qniii[i][l][s][j] = Qniii[i][j][l][s];
1948 Qniii[i][s][j][l] = Qniii[i][j][l][s];
1949 Qniii[i][s][l][j] = Qniii[i][j][l][s];
1951 Qniii[j][i][l][s] = Qniii[i][j][l][s];
1952 Qniii[j][i][s][l] = Qniii[i][j][l][s];
1953 Qniii[j][l][i][s] = Qniii[i][j][l][s];
1954 Qniii[j][l][s][i] = Qniii[i][j][l][s];
1955 Qniii[j][s][i][l] = Qniii[i][j][l][s];
1956 Qniii[j][s][l][i] = Qniii[i][j][l][s];
1958 Qniii[l][i][j][s] = Qniii[i][j][l][s];
1959 Qniii[l][i][s][j] = Qniii[i][j][l][s];
1960 Qniii[l][j][i][s] = Qniii[i][j][l][s];
1961 Qniii[l][j][s][i] = Qniii[i][j][l][s];
1962 Qniii[l][s][i][j] = Qniii[i][j][l][s];
1963 Qniii[l][s][j][i] = Qniii[i][j][l][s];
1965 Qniii[s][i][j][l] = Qniii[i][j][l][s];
1966 Qniii[s][i][l][j] = Qniii[i][j][l][s];
1967 Qniii[s][j][l][i] = Qniii[i][j][l][s];
1968 Qniii[s][j][i][l] = Qniii[i][j][l][s];
1969 Qniii[s][l][i][j] = Qniii[i][j][l][s];
1970 Qniii[s][l][j][i] = Qniii[i][j][l][s];
1972 Yniii[i][j][l][s] = Yniii_value;
1973 Yniii[i][j][s][l] = Yniii[i][j][l][s];
1974 Yniii[i][l][j][s] = Yniii[i][j][l][s];
1975 Yniii[i][l][s][j] = Yniii[i][j][l][s];
1976 Yniii[i][s][j][l] = Yniii[i][j][l][s];
1977 Yniii[i][s][l][j] = Yniii[i][j][l][s];
1979 Yniii[j][i][l][s] = Yniii[i][j][l][s];
1980 Yniii[j][i][s][l] = Yniii[i][j][l][s];
1981 Yniii[j][l][i][s] = Yniii[i][j][l][s];
1982 Yniii[j][l][s][i] = Yniii[i][j][l][s];
1983 Yniii[j][s][i][l] = Yniii[i][j][l][s];
1984 Yniii[j][s][l][i] = Yniii[i][j][l][s];
1986 Yniii[l][i][j][s] = Yniii[i][j][l][s];
1987 Yniii[l][i][s][j] = Yniii[i][j][l][s];
1988 Yniii[l][j][i][s] = Yniii[i][j][l][s];
1989 Yniii[l][j][s][i] = Yniii[i][j][l][s];
1990 Yniii[l][s][i][j] = Yniii[i][j][l][s];
1991 Yniii[l][s][j][i] = Yniii[i][j][l][s];
1993 Yniii[s][i][j][l] = Yniii[i][j][l][s];
1994 Yniii[s][i][l][j] = Yniii[i][j][l][s];
1995 Yniii[s][j][l][i] = Yniii[i][j][l][s];
1996 Yniii[s][j][i][l] = Yniii[i][j][l][s];
1997 Yniii[s][l][i][j] = Yniii[i][j][l][s];
1998 Yniii[s][l][j][i] = Yniii[i][j][l][s];
2042 double Ynnii_value = Ynnii_a + Ynnii_b * T + Ynnii_c * T * log(T) + Ynnii_d * T * T + Ynnii_e * T * T * T + Ynnii_f/T;
2044 Ynnii[i][j][l][s] = Ynnii_value;
2045 Ynnii[i][j][s][l] = Ynnii[i][j][l][s];
2046 Ynnii[i][l][j][s] = Ynnii[i][j][l][s];
2047 Ynnii[i][l][s][j] = Ynnii[i][j][l][s];
2048 Ynnii[i][s][j][l] = Ynnii[i][j][l][s];
2049 Ynnii[i][s][l][j] = Ynnii[i][j][l][s];
2051 Ynnii[j][i][l][s] = Ynnii[i][j][l][s];
2052 Ynnii[j][i][s][l] = Ynnii[i][j][l][s];
2053 Ynnii[j][l][i][s] = Ynnii[i][j][l][s];
2054 Ynnii[j][l][s][i] = Ynnii[i][j][l][s];
2055 Ynnii[j][s][i][l] = Ynnii[i][j][l][s];
2056 Ynnii[j][s][l][i] = Ynnii[i][j][l][s];
2058 Ynnii[l][i][j][s] = Ynnii[i][j][l][s];
2059 Ynnii[l][i][s][j] = Ynnii[i][j][l][s];
2060 Ynnii[l][j][i][s] = Ynnii[i][j][l][s];
2061 Ynnii[l][j][s][i] = Ynnii[i][j][l][s];
2062 Ynnii[l][s][i][j] = Ynnii[i][j][l][s];
2063 Ynnii[l][s][j][i] = Ynnii[i][j][l][s];
2065 Ynnii[s][i][j][l] = Ynnii[i][j][l][s];
2066 Ynnii[s][i][l][j] = Ynnii[i][j][l][s];
2067 Ynnii[s][j][l][i] = Ynnii[i][j][l][s];
2068 Ynnii[s][j][i][l] = Ynnii[i][j][l][s];
2069 Ynnii[s][l][i][j] = Ynnii[i][j][l][s];
2070 Ynnii[s][l][j][i] = Ynnii[i][j][l][s];
2075 E[i] = x[i] * fabs (Z[i]);
2080 if (Z[i] * Z[k] > 0) {sum = sum + x[k] * fabs (Z[k]);}
2086 double sumc = 0, suma = 0;
2089 if (Z[i] > 0) {sumc += x[i] * fabs (Z[i]);}
2090 if (Z[i] < 0) {suma += x[i] * fabs (Z[i]);}
2097 if (Z[i] * Z[j] > 0)
2099 if (i == j && Z[i] > 0) {iEj[i][j] = fabs (Z[i]) / (sumc) * (1.0 - E[i]);}
2100 if (i != j && Z[i] > 0) {iEj[i][j] = -fabs (Z[i]) * E[j] / (sumc);}
2101 if (i == j && Z[i] < 0) {iEj[i][j] = fabs (Z[i]) / (suma) * (1.0 - E[i]);}
2102 if (i != j && Z[i] < 0) {iEj[i][j] = -fabs (Z[i]) * E[j] / (suma);}
2108 lnfi = -Z[index] * Z[index] * Ax * ((2.0 /
ROU) * log (1.0 +
ROU * sqrt (Ix)) +
2109 sqrt (Ix) * (1.0 - 2.0 * Ix / (Z[index] * Z[index])) / (1.0 +
ROU * sqrt (Ix)));
2114 if (Z[i]*Z[index] != 0)
2116 lnfi = lnfi + (x[i] * Bii[i][index] * g (aii[i][index] * sqrt (Ix)) + x[i] * B1ii[i][index] * g (a1ii[i][index] * sqrt (Ix)));
2124 if (Z[i] * Z[j] < 0)
2126 lnfi = lnfi - 0.5 * (x[i] * x[j] * Bii[i][j] * (Z[index] * Z[index] * g (aii[i][j] * sqrt (Ix)) / (2.0 * Ix) +
2127 (1.0 - Z[index] * Z[index] / (2.0 * Ix)) * exp (-aii[i][j] * sqrt (Ix))) +
2128 x[i] * x[j] * B1ii[i][j] * (Z[index] * Z[index] * g (a1ii[i][j] * sqrt (Ix)) / (2.0 * Ix) +
2129 (1.0 - Z[index] * Z[index] / (2.0 * Ix)) * exp (-a1ii[i][j] * sqrt (Ix))));
2137 if (Z[i] * Z[index] > 0 && i != index && Ix != 0)
2139 double xij = 6.0 * Z[i] * Z[index] * Ax * sqrt (Ix);
2140 double xii = 6.0 * Z[i] * Z[i] * Ax * sqrt (Ix);
2141 double xjj = 6.0 * Z[index] * Z[index] * Ax * sqrt (Ix);
2143 double vij = Z[i] * Z[index] / (4.0 * Ix) * (jj(xij) - 0.5 * jj(xii) - 0.5 * jj(xjj));
2144 double vpij = - vij/Ix + (Z[i]*Z[index]/(8.0 * Ix * Ix)) * (xij * jp(xij) - 0.5 * xii * jp(xii) - 0.5 * xjj * jp(xjj));
2146 lnfi = lnfi + (2.0 * x[i] * (vij - x[index] * (vij + vpij * (Ix - Z[index] * Z[index] / 2.0))));
2154 if (Z[i] * Z[j] > 0 && i != j && i != index && j != index && Ix != 0)
2156 double xij = 6.0 * Z[i] * Z[j] * Ax * sqrt (Ix);
2157 double xii = 6.0 * Z[i] * Z[i] * Ax * sqrt (Ix);
2158 double xjj = 6.0 * Z[j] * Z[j] * Ax * sqrt (Ix);
2160 double vij = Z[i] * Z[j] / (4.0 * Ix) * (jj(xij) - 0.5 * jj(xii) - 0.5 * jj(xjj));
2161 double vpij = - vij/Ix + (Z[i]*Z[j]/(8.0 * Ix * Ix)) * (xij * jp(xij) - 0.5 * xii * jp(xii) - 0.5 * xjj * jp(xjj));
2163 lnfi = lnfi - 0.5 * (2.0 * x[i] * x[j] * (vij + vpij * (Ix - Z[index] * Z[index] / 2.0)));
2175 if (Z[i] * Z[index] < 0 && Z[k] == 0)
2183 sum += E[j] * (fabs (Z[i]) + fabs (Z[j])) / (fabs (Z[i]) * fabs (Z[j])) * Wnii[k][i][j];
2187 sum1 = sum1 + E[i] * ((fabs (Z[index]) + fabs (Z[i])) / fabs (Z[i]) * Wnii[k][i][index] - (fabs (Z[index]) / 2.0 + 1.0 / F) * sum);
2193 lnfi = lnfi + x[k] * sum1;
2203 if (Z[i] * Z[index] < 0 && Z[k] == 0)
2211 sum += 2.0 * x[j] * pow(fabs (Z[i]) + fabs (Z[j]), 2) / (fabs (Z[i]) * fabs (Z[j])) * Unii[k][i][j];
2215 sum1 = sum1 + x[i] * (pow (fabs (Z[index]) + fabs (Z[i]), 2) / (fabs (Z[i]) * fabs (Z[index])) * Unii[k][i][index] - sum);
2221 lnfi = lnfi + x[k] * sum1;
2231 if (Z[i] * Z[index] < 0 && Z[k] == 0)
2239 sum += 3.0 * x[j] * Vnii[k][i][j];
2243 sum1 = sum1 + x[i] * (Vnii[k][i][index] - sum);
2249 lnfi = lnfi + 4.0 * x[k] * x[k] * sum1;
2263 if (Z[i] * Z[index] < 0)
2273 sum += E[j] * (fabs (Z[i]) + fabs (Z[j])) / (fabs (Z[i]) * fabs (Z[j])) * Wnii[k][i][j];
2277 lnfi = lnfi - E[i] * ((1.0 - E[index] / 2.0) * (fabs (Z[index]) + fabs (Z[i])) / (fabs (Z[i])) * Wnii[k][i][index] - (fabs(Z[index]) / 2.0) * sum);
2288 if (Z[j] * Z[index] > 0) {sum += x[j] * Wiii[index][i][j];}
2295 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
2297 sum = sum - 0.5 * x[j] * x[l] * Wiii[i][j][l];
2302 if (Z[i] * Z[index] < 0)
2304 lnfi = lnfi + 2.0 * E[i] * sum;
2316 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
2318 sum = sum + 0.5 * x[j] * x[l] * Wiii[i][j][l];
2323 if (Z[i] * Z[index] > 0)
2325 lnfi = lnfi - 2.0 * (E[i] - iEj[index][i]) * sum;
2340 if (Z[j] * Z[index] > 0 && Z[i] * Z[index] < 0 && j != index)
2342 sum += x[j] * Qniii[k][index][i][j];
2350 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
2352 sum = sum - 0.5 * 2.0 * x[j] * x[l] * Qniii[k][i][j][l];
2357 if (Z[i] * Z[index] < 0)
2359 sum1 = sum1 + E[i] * sum;
2365 lnfi = lnfi + 4.0 * x[k] * sum1;
2381 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
2383 sum = sum + 0.5 * x[j] * x[l] * Qniii[k][i][j][l];
2388 if (Z[i] * Z[index] > 0)
2390 sum1 = sum1 + (2.0 * E[i] - iEj[index][i]) * sum;
2396 lnfi = lnfi - 4.0 * x[k] * sum1;
2411 if (Z[j] * Z[index] > 0 && j != index)
2413 sum += x[j] * Yniii[k][index][i][j];
2421 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
2423 sum = sum - 0.5 * 3.0 * x[j] * x[l] * Yniii[k][i][j][l];
2428 if (Z[i] * Z[index] < 0)
2430 sum1 = sum1 + E[i] * sum;
2436 lnfi = lnfi + 4.0 * x[k] * x[k] * sum1;
2452 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
2454 sum = sum + 0.5 * x[j] * x[l] * Yniii[k][i][j][l];
2459 if (Z[i] * Z[index] > 0)
2461 sum1 = sum1 + (3.0 * E[i] - iEj[index][i]) * sum;
2467 lnfi = lnfi - 4.0 * x[k] * x[k] * sum1;
2483 if (Z[k] * Z[l] < 0 && Z[i] == 0 && Z[j] == 0)
2485 sum += E[k] * (fabs (Z[l]) + fabs (Z[k])) / (fabs (Z[l]) * fabs (Z[k])) * Ynnii[i][j][k][l];
2489 if (Z[k] * Z[index] < 0)
2491 sum1 += E[k] * ((fabs (Z[index]) + fabs (Z[k])) / fabs (Z[k]) * Ynnii[index][i][j][k] - (fabs (Z[index])/2 + 2/F) * sum);
2495 if (Z[i] == 0 && Z[j] == 0 && i != j)
2497 lnfi = lnfi + 0.5 * x[i] * x[j] * sum1;
2505 for (j = 0; j < i; j ++)
2507 if (Z[i] == 0 && Z[j] == 0 && i != j)
2509 lnfi = lnfi - 2.0 * x[i] * x[j] * (Wnn[i][j] + 2.0 * (x[i] - x[j]) * Unn[i][j]);
2522 return exp(lnfi) * x[k];
2525 static double psc_ai (
AQUEOUS_PHASE aq,
int index,
double *n,
double T,
double P)
2529 printf (
"The species is not a ion species!!!\n");
2535 printf (
"The species dose not existed!!!\n");
2544 int i, j, k, l, m, s;
2563 double Bii_a, Bii_b, Bii_c, Bii_d, Bii_e, Bii_f, \
2564 B1ii_a, B1ii_b, B1ii_c, B1ii_d, B1ii_e, B1ii_f, \
2565 Wnn_a, Wnn_b, Wnn_c, Wnn_d, Wnn_e, Wnn_f, \
2566 Unn_a, Unn_b, Unn_c, Unn_d, Unn_e, Unn_f, \
2567 Wnii_a, Wnii_b, Wnii_c, Wnii_d, Wnii_e, Wnii_f, \
2568 Unii_a, Unii_b, Unii_c, Unii_d, Unii_e, Unii_f, \
2569 Vnii_a, Vnii_b, Vnii_c, Vnii_d, Vnii_e, Vnii_f, \
2570 Wiii_a, Wiii_b, Wiii_c, Wiii_d, Wiii_e, Wiii_f, \
2571 Qniii_a, Qniii_b, Qniii_c, Qniii_d, Qniii_e, Qniii_f, \
2572 Yniii_a, Yniii_b, Yniii_c, Yniii_d, Yniii_e, Yniii_f, \
2573 Ynnii_a, Ynnii_b, Ynnii_c, Ynnii_d, Ynnii_e, Ynnii_f;
2596 F += 0.5 * x[k] * fabs(Z[k]);
2603 Ix += 0.5 * (x[k] * Z[k] * Z[k]);
2649 Qniii[i][j][l][m] = 0;
2650 Yniii[i][j][l][m] = 0;
2651 Ynnii[i][j][l][m] = 0;
2691 double Bii_value = Bii_a + Bii_b * T + Bii_c * T * log(T) + Bii_d * T * T + Bii_e * T * T * T + Bii_f/T;
2692 double B1ii_value = B1ii_a + B1ii_b * T + B1ii_c * T * log(T) + B1ii_d * T * T + B1ii_e * T * T * T + B1ii_f/T;
2694 aii[i][j] = aii_value; aii[j][i] = aii[i][j];
2695 a1ii[i][j] = a1ii_value; a1ii[j][i] = a1ii[i][j];
2696 Bii[i][j] = Bii_value; Bii[j][i] = Bii[i][j];
2697 B1ii[i][j] = B1ii_value; B1ii[j][i] = B1ii[i][j];
2731 double Wnn_value = Wnn_a + Wnn_b * T + Wnn_c * T * log(T) + Wnn_d * T * T + Wnn_e * T * T * T + Wnn_f/T;
2732 double Unn_value = Unn_a + Unn_b * T + Unn_c * T * log(T) + Unn_d * T * T + Unn_e * T * T * T + Unn_f/T;
2734 Wnn[i][j] = Wnn_value; Wnn[j][i] = Wnn[i][j];
2735 Unn[i][j] = Unn_value; Unn[j][i] = Unn[i][j];
2783 double Wnii_value = Wnii_a + Wnii_b * T + Wnii_c * T * log(T) + Wnii_d * T * T + Wnii_e * T * T * T + Wnii_f/T;
2784 double Unii_value = Unii_a + Unii_b * T + Unii_c * T * log(T) + Unii_d * T * T + Unii_e * T * T * T + Unii_f/T;
2785 double Vnii_value = Vnii_a + Vnii_b * T + Vnii_c * T * log(T) + Vnii_d * T * T + Vnii_e * T * T * T + Vnii_f/T;
2787 Wnii[i][j][l] = Wnii_value;
2788 Wnii[i][l][j] = Wnii[i][j][l];
2789 Wnii[j][i][l] = Wnii[i][j][l];
2790 Wnii[j][l][i] = Wnii[i][j][l];
2791 Wnii[l][i][j] = Wnii[i][j][l];
2792 Wnii[l][j][i] = Wnii[i][j][l];
2794 Unii[i][j][l] = Unii_value;
2795 Unii[i][l][j] = Unii[i][j][l];
2796 Unii[j][i][l] = Unii[i][j][l];
2797 Unii[j][l][i] = Unii[i][j][l];
2798 Unii[l][i][j] = Unii[i][j][l];
2799 Unii[l][j][i] = Unii[i][j][l];
2801 Vnii[i][j][l] = Vnii_value;
2802 Vnii[i][l][j] = Vnii[i][j][l];
2803 Vnii[j][i][l] = Vnii[i][j][l];
2804 Vnii[j][l][i] = Vnii[i][j][l];
2805 Vnii[l][i][j] = Vnii[i][j][l];
2806 Vnii[l][j][i] = Vnii[i][j][l];
2842 double Wiii_value = Wiii_a + Wiii_b * T + Wiii_c * T * log(T) + Wiii_d * T * T + Wiii_e * T * T * T + Wiii_f/T;
2844 Wiii[i][j][l] = Wiii_value;
2845 Wiii[i][l][j] = Wiii[i][j][l];
2846 Wiii[j][i][l] = Wiii[i][j][l];
2847 Wiii[j][l][i] = Wiii[i][j][l];
2848 Wiii[l][i][j] = Wiii[i][j][l];
2849 Wiii[l][j][i] = Wiii[i][j][l];
2898 double Qniii_value = Qniii_a + Qniii_b * T + Qniii_c * T * log(T) + Qniii_d * T * T + Qniii_e * T * T * T + Qniii_f/T;
2899 double Yniii_value = Yniii_a + Yniii_b * T + Yniii_c * T * log(T) + Yniii_d * T * T + Yniii_e * T * T * T + Yniii_f/T;
2901 Qniii[i][j][l][s] = Qniii_value;
2902 Qniii[i][j][s][l] = Qniii[i][j][l][s];
2903 Qniii[i][l][j][s] = Qniii[i][j][l][s];
2904 Qniii[i][l][s][j] = Qniii[i][j][l][s];
2905 Qniii[i][s][j][l] = Qniii[i][j][l][s];
2906 Qniii[i][s][l][j] = Qniii[i][j][l][s];
2908 Qniii[j][i][l][s] = Qniii[i][j][l][s];
2909 Qniii[j][i][s][l] = Qniii[i][j][l][s];
2910 Qniii[j][l][i][s] = Qniii[i][j][l][s];
2911 Qniii[j][l][s][i] = Qniii[i][j][l][s];
2912 Qniii[j][s][i][l] = Qniii[i][j][l][s];
2913 Qniii[j][s][l][i] = Qniii[i][j][l][s];
2915 Qniii[l][i][j][s] = Qniii[i][j][l][s];
2916 Qniii[l][i][s][j] = Qniii[i][j][l][s];
2917 Qniii[l][j][i][s] = Qniii[i][j][l][s];
2918 Qniii[l][j][s][i] = Qniii[i][j][l][s];
2919 Qniii[l][s][i][j] = Qniii[i][j][l][s];
2920 Qniii[l][s][j][i] = Qniii[i][j][l][s];
2922 Qniii[s][i][j][l] = Qniii[i][j][l][s];
2923 Qniii[s][i][l][j] = Qniii[i][j][l][s];
2924 Qniii[s][j][l][i] = Qniii[i][j][l][s];
2925 Qniii[s][j][i][l] = Qniii[i][j][l][s];
2926 Qniii[s][l][i][j] = Qniii[i][j][l][s];
2927 Qniii[s][l][j][i] = Qniii[i][j][l][s];
2929 Yniii[i][j][l][s] = Yniii_value;
2930 Yniii[i][j][s][l] = Yniii[i][j][l][s];
2931 Yniii[i][l][j][s] = Yniii[i][j][l][s];
2932 Yniii[i][l][s][j] = Yniii[i][j][l][s];
2933 Yniii[i][s][j][l] = Yniii[i][j][l][s];
2934 Yniii[i][s][l][j] = Yniii[i][j][l][s];
2936 Yniii[j][i][l][s] = Yniii[i][j][l][s];
2937 Yniii[j][i][s][l] = Yniii[i][j][l][s];
2938 Yniii[j][l][i][s] = Yniii[i][j][l][s];
2939 Yniii[j][l][s][i] = Yniii[i][j][l][s];
2940 Yniii[j][s][i][l] = Yniii[i][j][l][s];
2941 Yniii[j][s][l][i] = Yniii[i][j][l][s];
2943 Yniii[l][i][j][s] = Yniii[i][j][l][s];
2944 Yniii[l][i][s][j] = Yniii[i][j][l][s];
2945 Yniii[l][j][i][s] = Yniii[i][j][l][s];
2946 Yniii[l][j][s][i] = Yniii[i][j][l][s];
2947 Yniii[l][s][i][j] = Yniii[i][j][l][s];
2948 Yniii[l][s][j][i] = Yniii[i][j][l][s];
2950 Yniii[s][i][j][l] = Yniii[i][j][l][s];
2951 Yniii[s][i][l][j] = Yniii[i][j][l][s];
2952 Yniii[s][j][l][i] = Yniii[i][j][l][s];
2953 Yniii[s][j][i][l] = Yniii[i][j][l][s];
2954 Yniii[s][l][i][j] = Yniii[i][j][l][s];
2955 Yniii[s][l][j][i] = Yniii[i][j][l][s];
2999 double Ynnii_value = Ynnii_a + Ynnii_b * T + Ynnii_c * T * log(T) + Ynnii_d * T * T + Ynnii_e * T * T * T + Ynnii_f/T;
3001 Ynnii[i][j][l][s] = Ynnii_value;
3002 Ynnii[i][j][s][l] = Ynnii[i][j][l][s];
3003 Ynnii[i][l][j][s] = Ynnii[i][j][l][s];
3004 Ynnii[i][l][s][j] = Ynnii[i][j][l][s];
3005 Ynnii[i][s][j][l] = Ynnii[i][j][l][s];
3006 Ynnii[i][s][l][j] = Ynnii[i][j][l][s];
3008 Ynnii[j][i][l][s] = Ynnii[i][j][l][s];
3009 Ynnii[j][i][s][l] = Ynnii[i][j][l][s];
3010 Ynnii[j][l][i][s] = Ynnii[i][j][l][s];
3011 Ynnii[j][l][s][i] = Ynnii[i][j][l][s];
3012 Ynnii[j][s][i][l] = Ynnii[i][j][l][s];
3013 Ynnii[j][s][l][i] = Ynnii[i][j][l][s];
3015 Ynnii[l][i][j][s] = Ynnii[i][j][l][s];
3016 Ynnii[l][i][s][j] = Ynnii[i][j][l][s];
3017 Ynnii[l][j][i][s] = Ynnii[i][j][l][s];
3018 Ynnii[l][j][s][i] = Ynnii[i][j][l][s];
3019 Ynnii[l][s][i][j] = Ynnii[i][j][l][s];
3020 Ynnii[l][s][j][i] = Ynnii[i][j][l][s];
3022 Ynnii[s][i][j][l] = Ynnii[i][j][l][s];
3023 Ynnii[s][i][l][j] = Ynnii[i][j][l][s];
3024 Ynnii[s][j][l][i] = Ynnii[i][j][l][s];
3025 Ynnii[s][j][i][l] = Ynnii[i][j][l][s];
3026 Ynnii[s][l][i][j] = Ynnii[i][j][l][s];
3027 Ynnii[s][l][j][i] = Ynnii[i][j][l][s];
3032 E[i] = x[i] * fabs (Z[i]);
3037 if (Z[i] * Z[k] > 0) {sum = sum + x[k] * fabs (Z[k]);}
3043 double sumc = 0, suma = 0;
3046 if (Z[i] > 0) {sumc += x[i] * fabs (Z[i]);}
3047 if (Z[i] < 0) {suma += x[i] * fabs (Z[i]);}
3054 if (Z[i] * Z[j] > 0)
3056 if (i == j && Z[i] > 0) {iEj[i][j] = fabs (Z[i]) / (sumc) * (1.0 - E[i]);}
3057 if (i != j && Z[i] > 0) {iEj[i][j] = -fabs (Z[i]) * E[j] / (sumc);}
3058 if (i == j && Z[i] < 0) {iEj[i][j] = fabs (Z[i]) / (suma) * (1.0 - E[i]);}
3059 if (i != j && Z[i] < 0) {iEj[i][j] = -fabs (Z[i]) * E[j] / (suma);}
3065 lnfi = -Z[index] * Z[index] * Ax * ((2.0 /
ROU) * log (1.0 +
ROU * sqrt (Ix)) +
3066 sqrt (Ix) * (1.0 - 2.0 * Ix / (Z[index] * Z[index])) / (1.0 +
ROU * sqrt (Ix)));
3071 if (Z[i]*Z[index] != 0)
3073 lnfi = lnfi + (x[i] * Bii[i][index] * g (aii[i][index] * sqrt (Ix)) + x[i] * B1ii[i][index] * g (a1ii[i][index] * sqrt (Ix)));
3081 if (Z[i] * Z[j] < 0)
3083 lnfi = lnfi - 0.5 * (x[i] * x[j] * Bii[i][j] * (Z[index] * Z[index] * g (aii[i][j] * sqrt (Ix)) / (2.0 * Ix) +
3084 (1.0 - Z[index] * Z[index] / (2.0 * Ix)) * exp (-aii[i][j] * sqrt (Ix))) +
3085 x[i] * x[j] * B1ii[i][j] * (Z[index] * Z[index] * g (a1ii[i][j] * sqrt (Ix)) / (2.0 * Ix) +
3086 (1.0 - Z[index] * Z[index] / (2.0 * Ix)) * exp (-a1ii[i][j] * sqrt (Ix))));
3094 if (Z[i] * Z[index] > 0 && i != index && Ix != 0)
3096 double xij = 6.0 * Z[i] * Z[index] * Ax * sqrt (Ix);
3097 double xii = 6.0 * Z[i] * Z[i] * Ax * sqrt (Ix);
3098 double xjj = 6.0 * Z[index] * Z[index] * Ax * sqrt (Ix);
3100 double vij = Z[i] * Z[index] / (4.0 * Ix) * (jj(xij) - 0.5 * jj(xii) - 0.5 * jj(xjj));
3101 double vpij = - vij/Ix + (Z[i]*Z[index]/(8.0 * Ix * Ix)) * (xij * jp(xij) - 0.5 * xii * jp(xii) - 0.5 * xjj * jp(xjj));
3103 lnfi = lnfi + (2.0 * x[i] * (vij - x[index] * (vij + vpij * (Ix - Z[index] * Z[index] / 2.0))));
3111 if (Z[i] * Z[j] > 0 && i != j && i != index && j != index && Ix != 0)
3113 double xij = 6.0 * Z[i] * Z[j] * Ax * sqrt (Ix);
3114 double xii = 6.0 * Z[i] * Z[i] * Ax * sqrt (Ix);
3115 double xjj = 6.0 * Z[j] * Z[j] * Ax * sqrt (Ix);
3117 double vij = Z[i] * Z[j] / (4.0 * Ix) * (jj(xij) - 0.5 * jj(xii) - 0.5 * jj(xjj));
3118 double vpij = - vij/Ix + (Z[i]*Z[j]/(8.0 * Ix * Ix)) * (xij * jp(xij) - 0.5 * xii * jp(xii) - 0.5 * xjj * jp(xjj));
3120 lnfi = lnfi - 0.5 * (2.0 * x[i] * x[j] * (vij + vpij * (Ix - Z[index] * Z[index] / 2.0)));
3132 if (Z[i] * Z[index] < 0 && Z[k] == 0)
3140 sum += E[j] * (fabs (Z[i]) + fabs (Z[j])) / (fabs (Z[i]) * fabs (Z[j])) * Wnii[k][i][j];
3144 sum1 = sum1 + E[i] * ((fabs (Z[index]) + fabs (Z[i])) / fabs (Z[i]) * Wnii[k][i][index] - (fabs (Z[index]) / 2.0 + 1.0 / F) * sum);
3150 lnfi = lnfi + x[k] * sum1;
3160 if (Z[i] * Z[index] < 0 && Z[k] == 0)
3168 sum += 2.0 * x[j] * pow(fabs (Z[i]) + fabs (Z[j]), 2) / (fabs (Z[i]) * fabs (Z[j])) * Unii[k][i][j];
3172 sum1 = sum1 + x[i] * (pow (fabs (Z[index]) + fabs (Z[i]), 2) / (fabs (Z[i]) * fabs (Z[index])) * Unii[k][i][index] - sum);
3178 lnfi = lnfi + x[k] * sum1;
3188 if (Z[i] * Z[index] < 0 && Z[k] == 0)
3196 sum += 3.0 * x[j] * Vnii[k][i][j];
3200 sum1 = sum1 + x[i] * (Vnii[k][i][index] - sum);
3206 lnfi = lnfi + 4.0 * x[k] * x[k] * sum1;
3220 if (Z[i] * Z[index] < 0)
3230 sum += E[j] * (fabs (Z[i]) + fabs (Z[j])) / (fabs (Z[i]) * fabs (Z[j])) * Wnii[k][i][j];
3234 lnfi = lnfi - E[i] * ((1.0 - E[index] / 2.0) * (fabs (Z[index]) + fabs (Z[i])) / (fabs (Z[i])) * Wnii[k][i][index] - (fabs(Z[index]) / 2.0) * sum);
3245 if (Z[j] * Z[index] > 0) {sum += x[j] * Wiii[index][i][j];}
3252 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
3254 sum = sum - 0.5 * x[j] * x[l] * Wiii[i][j][l];
3259 if (Z[i] * Z[index] < 0)
3261 lnfi = lnfi + 2.0 * E[i] * sum;
3273 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
3275 sum = sum + 0.5 * x[j] * x[l] * Wiii[i][j][l];
3280 if (Z[i] * Z[index] > 0)
3282 lnfi = lnfi - 2.0 * (E[i] - iEj[index][i]) * sum;
3297 if (Z[j] * Z[index] > 0 && Z[i] * Z[index] < 0 && j != index)
3299 sum += x[j] * Qniii[k][index][i][j];
3307 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
3309 sum = sum - 0.5 * 2.0 * x[j] * x[l] * Qniii[k][i][j][l];
3314 if (Z[i] * Z[index] < 0)
3316 sum1 = sum1 + E[i] * sum;
3322 lnfi = lnfi + 4.0 * x[k] * sum1;
3338 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
3340 sum = sum + 0.5 * x[j] * x[l] * Qniii[k][i][j][l];
3345 if (Z[i] * Z[index] > 0)
3347 sum1 = sum1 + (2.0 * E[i] - iEj[index][i]) * sum;
3353 lnfi = lnfi - 4.0 * x[k] * sum1;
3368 if (Z[j] * Z[index] > 0 && j != index)
3370 sum += x[j] * Yniii[k][index][i][j];
3378 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
3380 sum = sum - 0.5 * 3.0 * x[j] * x[l] * Yniii[k][i][j][l];
3385 if (Z[i] * Z[index] < 0)
3387 sum1 = sum1 + E[i] * sum;
3393 lnfi = lnfi + 4.0 * x[k] * x[k] * sum1;
3409 if ((Z[j] * Z[l] > 0) && (Z[j] * Z[i] < 0))
3411 sum = sum + 0.5 * x[j] * x[l] * Yniii[k][i][j][l];
3416 if (Z[i] * Z[index] > 0)
3418 sum1 = sum1 + (3.0 * E[i] - iEj[index][i]) * sum;
3424 lnfi = lnfi - 4.0 * x[k] * x[k] * sum1;
3440 if (Z[k] * Z[l] < 0 && Z[i] == 0 && Z[j] == 0)
3442 sum += E[k] * (fabs (Z[l]) + fabs (Z[k])) / (fabs (Z[l]) * fabs (Z[k])) * Ynnii[i][j][k][l];
3446 if (Z[k] * Z[index] < 0)
3448 sum1 += E[k] * ((fabs (Z[index]) + fabs (Z[k])) / fabs (Z[k]) * Ynnii[index][i][j][k] - (fabs (Z[index])/2 + 2/F) * sum);
3452 if (Z[i] == 0 && Z[j] == 0 && i != j)
3454 lnfi = lnfi + 0.5 * x[i] * x[j] * sum1;
3462 for (j = 0; j < i; j ++)
3464 if (Z[i] == 0 && Z[j] == 0 && i != j)
3466 lnfi = lnfi - 2.0 * x[i] * x[j] * (Wnn[i][j] + 2.0 * (x[i] - x[j]) * Unn[i][j]);
3480 return exp(lnfi) * x[k] * (n[index] / n[k] * 1000/
CONSTANT_MW);
3487 return psc_rn (aq, index, n, T, P);
3491 return psc_ri (aq, index, n, T, P);
3500 return psc_an (aq, index, n, T, P);
3504 return psc_ai (aq, index, n, T, P);
IIBINPARAM * ii_bin_params
double psc_a(AQUEOUS_PHASE aq, int index, double *n, double T, double P)
SPECIES * aqueous_species
NNBINPARAM * nn_bin_params
NIITERPARAM * nii_ter_params
IIITERPARAM * iii_ter_params
NNIIQUAPARAM * nnii_qua_params
double psc_r(AQUEOUS_PHASE aq, int index, double *n, double T, double P)
NIIIQUAPARAM * niii_qua_params