Numerical solution scheme Directory UMM :Data Elmu:jurnal:A:Advances In Water Resources:Vol21.Issue8.1998:

conditions of local non-equilibrium, a fine grid spacing is required to capture many of the physical processes occurring during the flood. In other words, numerical dispersion as a result of upstream weighting of the advection terms is likely to be of less significance than hydrodynamic dispersion, therefore making it unnecessary to use a more complex spatial weighting scheme for one-dimensional simulations. Due to computer memory and speed limitations, higher order weighting schemes andor flux limiting may be required for two- or three-dimensional simulations.

3.2 Numerical solution scheme

Due to the highly non-linear nature of the governing equations, full Newton–Raphson iteration is used to solve the discretized equations. The resulting sparse Jacobian matrix is solved using a direct tri-diagonal block solver. The presence of either a single phase or two phases at a node will dictate its nodal state. For nodes containing only wetting phase state 1, the primary variables at that node are the wetting phase pressure, P w , the mole fraction of organic in the wetting phase, x 2w , and the mole fraction of alcohol in the wetting phase, x 3w . For nodes containing two phases state 2, the primary variables are P w , x 2w , x 3w , the wetting phase saturation, S w , the mole fraction of water in the non-wetting phase, x 1nw , and the mole fraction of alcohol in the non-wetting phase, x 3nw . For one-phase nodes that are adjacent to nodes containing two phases, a check is made at the beginning of an iteration to determine if the wetting phase at the single phase node is miscible with the non-wetting phase at the two-phase node. If these phases are immiscible, the single-phase node is given a state of 2 and the wetting phase saturation is set equal to 1.0. If, at the end of an iteration, the wetting phase saturation remains equal to 1.0 at that node, i.e. no non- wetting phase has entered that cell from an adjacent two- phase cell, the state at that node is reset to 1. The mass balance equations for the three components in the non- wetting phase are not independent if inter-phase mass transfer, at the node being invaded by the non-wetting phase, is equal to zero. Invoking the assumption that inter-phase mass transfer is zero at the node being invaded by the non-wetting phase allows for a simplifi- cation of the mass balance equations at that node. The three mass balance equations for the components in the non-wetting phase are summed together. The primary variables at the node being invaded by non-wetting phase then become P w , x 2w , x 3w , and S w . If no inter- phase mass transfer occurs at the node being invaded, the composition of the non-wetting phase at that node will be equivalent to the non-wetting phase composition at the upstream node. The mass conservation equations for each component in each phase eqn 2 can be rewritten as a series of equations in the form F x ¼ 0 to given n c 3 n p 3 n n independent equations note exception above R b i , I ; fS b c tb x ib N þ 1 I ¹ fS b c tb x ib N I n o V I Dt ¹ X J[h c w N þ 1 bJ ¹ w N þ 1 bI c tb x ib k rb m b N þ 1 ups I , J g IJ ¹ X J[h c c tb N þ 1 IJ þ 1 2 g IJ 9 b x ibJ ¹ x ibI N þ 1 2 6 4 3 7 5 ¹ q ib þ I ib N þ 1 V I ¼ b ¼ 1 , 2 i ¼ 1 , 2 , 3 I ¼ 1 , ::: , n n ð 11Þ The independent equations are ordered into a vector of functions F as follows: F T ¼ R w 1 , 1 , R w 2 , 1 , R w 3 , 1 , R nw 1 , 1 , R nw 2 , 1 , R nw 3 , 1 , ::: , R w 1 , n n , R w 2 , n n , R w 3 , n n , R nw 1 , n n , R nw 2 , n n , R nw 3 , n n ð 12Þ The unknown variables corresponding to this set of equations are ordered into a vector x as follows x T ¼ P w , 1 , x w2 , 1 , x w3 , 1 , x nw1 , 1 , S w , 1 , x nw3 , 1 , ::: , P w , n n , x w2 , n n , x w3 , n n , x nw1 , n n , S w , n n , x nw3 , n n ð 13Þ The ordering of the primary variables in x is done in such a way as to maximize diagonal dominance in the Jacobian matrix. If the nodal state is equal to 2, all Jacobian terms must be calculated by finding the partial derivatives of R b i , I with respect to each primary variable. However, if the nodal state is equal to 1, only the partial derivatives of R w i , I with respect P w , x w2 , and x w3 are required, since R nw i , I ¼ 0 at these nodes. When the nodal state is equal to 1, the main diagonal values in the Jacobian matrix associated with the mass conservation equations of each component in the non-wetting phase are set equal to 1.0. This enables simple utilization of the tri-diagonal block solver since, regardless of nodal state, a 6 3 6 block structure is maintained throughout the Jacobian matrix with non-zero values on the main diagonal. Numerical differentiation is used to calculate the Jacobian terms. Due to the nature of the constitutive equations used in the governing equations, the partial derivative terms are not easily determined and may require more computational time than would be required for numerical differentiation. 19,56 It is necessary to choose the correct incremental change in primary variable size for cal- culation of the Jacobian terms for two reasons. Firstly, too small an increment may lead to large numerical error which is especially important when certain secondary variables are calculated using iterative techniques such as the inter-phase mass transfer terms. Secondly, if a change in the primary variable causes a change in state at a particular cell, con- vergence will likely not occur. 19 It was found that absolute values of DP w ¼ 10 ¹ 4 , DS w ¼ 10 ¹ 5 , and Dx ib ¼ 10 ¹ 6 for calculation of Jacobian terms worked well. The sign assigned to DP w could be either positive or negative, and 666 S. Reitsma, B. H. Kueper to DS w was always negative so that S w þ DS w a 1.0. The sign assigned to Dx ib was positive unless the mole fraction of either the organic or the alcohol in the wetting phase, or the water or the alcohol in the non-wetting phase, approached the plait point. This would ensure that the algorithms for calculating the equations of state received appropriate input compositions. At the completion of each Newton iteration, the state of each cell is determined. To switch from a state of 1 to a state of 2, either the composition of the single phase at that node must fall below the binodal curve and a second phase is precipitated or, as mentioned above, the non-wetting phase invades that node from neighboring nodes. If the switch is made due to precipitation of a second phase, the two new phases are assumed to be in equilibrium with an overall composition equivalent to that of the original single phase. To switch from a state of 2 to a state of 1 at a particular node, either the composition of the two bulk phases at that node are miscible, or the wetting phase saturation is greater than 1 at the end of an iteration. If the switch is made due to miscibility of the two phases, the composition of the new single phase is equal to the overall composition of the two original phases. If the switch is made due to S w Nþ1 s 1.0, the composition remains equal to the composition of wetting phase found at the end of the iteration, and the wetting phase saturation is set equal to 1.0. Adaptive time stepping in a formulation similar to Ref. 56 is used for calculation of the time increment at the present time step, Dt Nþ1 , given by Dt N þ 1 ¼ Min Dt N DS T w DS max w , Dt N Dx T Dx max b , C 1 Dt N 14 where Dt N is the previous time step increment, DS w T is the target change in wetting phase saturation, DS w max is the maximum change in wetting phase saturation in the entire domain from time step N ¹ 1 to time step N, Dx T is the target change in composition, Dx b max is the maximum change in composition in the entire domain from time step N ¹ 1 to time step N expressed as a mole fraction, and C 1 is a constant greater than 1.0 that dictates the rate of time increment increase. Input target changes in saturation and composition represent the desired maximum changes of these variables in the entire domain from one time step to the next.

3.3 Boundary conditions