OpenCAEPoro  v0.5.0
A simulator for multicomponent porous media flow
AcceleratePVT.cpp
Go to the documentation of this file.
1 
12 #include "AcceleratePVT.hpp"
13 
15 // Skip Stability Analysis
17 
18 void SkipStaAnaly::Setup(const OCP_USI& numBulk, const USI& np, const USI& nc)
19 {
20  if (!ifSetup) {
21  ifSetup = OCP_TRUE;
22 
23  numPhase = np;
24  numCom = nc;
25 
26  flag.resize(numBulk);
27  P.resize(numBulk);
28  T.resize(numBulk);
29  minEigen.resize(numBulk);
30  zi.resize(numBulk * numCom);
31 
32  lflag.resize(numBulk);
33  lP.resize(numBulk);
34  lT.resize(numBulk);
35  lminEigen.resize(numBulk);
36  lzi.resize(numBulk * numCom);
37  }
38 }
39 
41  const OCP_DBL& minEigenSkip,
42  const OCP_DBL& PSkip,
43  const OCP_DBL& TSkip,
44  const vector<OCP_DBL>& ziSkip)
45 {
46  minEigen[n] = minEigenSkip;
47  P[n] = PSkip;
48  T[n] = TSkip;
49  for (USI i = 0; i < numCom; i++) {
50  zi[n * numCom + i] = ziSkip[i];
51  }
52 }
53 
55  const OCP_DBL& Tin,
56  const OCP_DBL& Ntin,
57  const vector<OCP_DBL>& Niin,
58  const OCP_USI& n) const
59 {
60  if (flag[n]) {
61  if (fabs(1 - P[n] / Pin) >= minEigen[n] / 10) {
62  return OCP_FALSE;
63  }
64  if (fabs(T[n] - Tin) >= minEigen[n] * 10) {
65  return OCP_FALSE;
66  }
67  // OCP_DBL Nt_w = Ntin - Niin[numCom];
68  for (USI i = 0; i < numCom; i++) {
69  if (fabs(Niin[i] / Ntin - zi[n * numCom + i]) >= minEigen[n] / 10) {
70  return OCP_FALSE;
71  }
72  }
73  return OCP_TRUE;
74  } else {
75  return OCP_FALSE;
76  }
77 }
78 
80  const OCP_DBL& Tin,
81  const OCP_DBL& Ntin,
82  const vector<OCP_DBL>& Niin,
83  const OCP_USI& n)
84 {
85  if (ifUseSkip) {
86  if (IfSkip(Pin, Tin, Ntin, Niin, n)) {
87  return 1;
88  } else {
89  return 0;
90  }
91  } else {
92  return 0;
93  }
94 }
95 
97  const OCP_DBL& Tin,
98  const OCP_DBL& Ntin,
99  const vector<OCP_DBL>& Niin,
100  const OCP_DBL* S,
101  const USI& np,
102  const OCP_USI& n) const
103 {
104  if (ifUseSkip) {
105  if (IfSkip(Pin, Tin, Ntin, Niin, n)) {
106  return 1;
107  } else if (np >= 2) {
108  for (USI j = 0; j < numPhase; j++) {
109  if (S[j] < 1E-4) {
110  return 0; // phases change (predicted)
111  }
112  }
113  return 2;
114  } else {
115  return 0;
116  }
117  } else {
118  return 0;
119  }
120 }
121 
123 {
124  flag = lflag;
126  P = lP;
127  T = lT;
128  zi = lzi;
129 }
130 
132 {
133  lflag = flag;
135  lP = P;
136  lT = T;
137  lzi = zi;
138 }
139 
140 /*----------------------------------------------------------------------------*/
141 /* Brief Change History of This File */
142 /*----------------------------------------------------------------------------*/
143 /* Author Date Actions */
144 /*----------------------------------------------------------------------------*/
145 /* Shizhe Li Dec/25/2022 Create file */
146 /*----------------------------------------------------------------------------*/
AcceleratePVT class declaration.
unsigned int USI
Generic unsigned integer.
Definition: OCPConst.hpp:23
double OCP_DBL
Double precision.
Definition: OCPConst.hpp:27
unsigned int OCP_USI
Long unsigned integer.
Definition: OCPConst.hpp:25
unsigned int OCP_BOOL
OCP_BOOL in OCP.
Definition: OCPConst.hpp:29
OCP_BOOL ifSetup
Only one setup is needed.
vector< OCP_DBL > lminEigen
Last min eigenvalue.
USI numCom
Num of components used in phase equilibrium calculation.
USI CalFtypeFIM(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL &Ntin, const vector< OCP_DBL > &Niin, const OCP_DBL *S, const USI &np, const OCP_USI &n) const
Calculate the ftype for FIM.
vector< OCP_DBL > P
Pressure at last step.
void UpdateLastTimeStep()
Update SkipStaAnaly term at last time step.
USI CalFtypeIMPEC(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL &Ntin, const vector< OCP_DBL > &Niin, const OCP_USI &n)
Calculate the ftype for IMPEC.
vector< OCP_DBL > lT
Last T.
vector< OCP_BOOL > lflag
Last flag.
void Setup(const OCP_USI &numBulk, const USI &np, const USI &nc)
Allocate memory for SkipStaAnaly term.
vector< OCP_BOOL > flag
If true, skip will be test.
vector< OCP_DBL > zi
Mole fraction of components(for test) at last step.
OCP_BOOL ifUseSkip
If true, then Skip option will be used.
vector< OCP_DBL > minEigen
minimum eigenvalue used for testing skipping
USI numPhase
Num of phase used in phase equilibrium calculation.
vector< OCP_DBL > lP
Last P.
vector< OCP_DBL > lzi
Last zi.
void ResetToLastTimeStep()
Reset SkipStaAnaly term to last time step.
vector< OCP_DBL > T
Temperature at last step.
void AssignValue(const OCP_USI &n, const OCP_DBL &minEigenSkip, const OCP_DBL &PSkip, const OCP_DBL &TSkip, const vector< OCP_DBL > &ziSkip)
Update variables used for determine if skipping will happen.
OCP_BOOL IfSkip(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL &Ntin, const vector< OCP_DBL > &Niin, const OCP_USI &n) const
Determine if skipping will happen.