-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheqbrm.h
100 lines (85 loc) · 2.84 KB
/
eqbrm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* \copyright
* Copyright (c) 2015, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <string>
#include <fstream>
#include <sstream>
#include <vector>
#include <ctype.h>
// using namespace std;
class EQ
{
private:
public:
EQ(void);
~EQ(void);
static std::vector<std::string> species; // name of species in the last line of input file (eqbrm.in)
static double T, P;
/* Data */
typedef struct
{
std::vector<std::string> species_name;
std::vector<std::string> species_formula;
std::vector<double> species_stoi;
double logK;
double stoi_water;
} ReactionData;
static std::vector<ReactionData> eq_reactions;
typedef struct
{
std::string name;
std::string formula;
double charge;
int idx_phase;
std::vector<int> idx_element;
std::vector<double> stoi_element;
} SpeciesData;
static std::vector<SpeciesData> eq_species;
// set chemical system for eqbrm input value
int NN, MM;
double** VV; // mass action submatrix
double** GG; // mass balance submatrix --> chemical element
double* ZZ; // charge vector
std::vector<std::string> chemical_species, chemical_element; // name and index of species and element
// pass parameters
double* LOGKK;
double* BB; // mass amount --> chemical element
int* xidx_phase; // phase index vector
double *AA, *GAMMAA; // concentration and activity coefficent
double AAW;
double* xstoi_water; // check "H2O" in reactions, 0 no water, 1 or -1 water stoi number
int activity_model; // 0-9
/* Method */
void eqbrm(int N, int M, double** V, double* B, double** G, double* LOGK, double* Z, double* A, double* GAMMA,
double& AW);
void eqbrm_multiphases(int N, int M, double** V, double* B, double** G, double* LOGK, double* VW, double* Z, int* P,
double* A, double* GAMMA, double& AW);
void actcof(double N, double* Z, double* A, double* GAMMA, double& AW);
void actcofWATEQ(double N, double* Z, double* A, double* GAMMA, double& AW);
void ludcmp(double** a, int n, int* indx, double* d);
void lubksb(double** a, int n, int* indx, double b[]);
double** matrix(int row, int col);
static double** matrix_new(int row, int col);
void matrixdel(double** data);
void entrance(void);
void load_chemical_system(void);
void show_chemical_system(void);
void calc_chemical_system(void);
void reset_estimated_value(void);
void calc_activity(double* A, double* GAMMA, double& AW);
void batch_calc(void);
void batch_calc_pH(void);
void single_calc(void);
static void mainentrance(void);
};