Modeling of geochemical processes Numeric Mathematics Refreshment J. Faimon Modeling of geochemical processes Numeric mathematics Numeric mathematics Search of solution by a substitution of exact numerals for variables. Large number of repeated numeric operation Personal computers Iterations and algorithms * algorithm -- an instruction how to solve the given task * iteration algorithm -- technique of calculation in the repetitious steps, at which the result from the previous step is input into next step[1]. * iteration -- the step in the iteration algorithm [1] Algorithm should "converge" (it should approach solution). Modeling of geochemical processes Numeric mathematics Example: Calculation of square root It is a solution of the equation , for x We have to find, e.g., square root of 16, N = 16. The arrangement of the definitional equation gives . Let us calculate x. At first (zero step), we substitute for x on the right hand of the equation its estimation (arbitrary number), e.g., x[0] = 2, and calculate new value of x, i.e., x[1]. We substitute the found solution for x and repeat the calculation till the solution is not constant. The solution procedure (algorithm) can be written as where k is step number; iteration number (we start by zero step) Modeling of geochemical processes Numeric mathematics Calculation: As can be seen, the algorithm does not converge. It must be revised! Modeling of geochemical processes Numeric mathematics Algorithm formulation Solution of non-linear equations: Newton method Modeling of geochemical processes Numeric mathematics Example: Find the roots of the equation x^3 -- 4x^2 + 5x -- 2 = 0. The derivation of f(x) for x is 3x^2 - 8x + 5 The roots are x[1] = 2, x[2,3] = 1 Modeling of geochemical processes Numeric mathematics Example: Equilibrium in the open system calcite-H[2]O-CO[2 ]system: CaCO[3(s)], CO[2], H[2]O, Ca^2+, HCO[3]^-, CO[3]^2-, OH^-, H^+, H[2]CO[3] (9 components) activity coefficient ~ 1, a ~ mol/l, 4 components are given: activity of CaCO[3(s)] and H[2]O, p[CO2] = const = 3.10^-4 atm and [H[2]CO[3]] = const = K[H] p[CO2 ]5 variables: x[1] = [H^+], x[2] = [OH^-], x[3] = [Ca^2+], x[4] = [HCO[3]^-], x[5] = [CO[3]^2-] 5 equations: (1) electro-neutrality and equilibrium equations for: (2) H[2]O, (3) calcite-H[2]O system, carbonate dissociation into (4) first and (5) second stage! 5 variables in 5 functions: f[1](x) = x[1] - x[2] + 2 x[3] - x[4] -- 2 x[5] = 0 (electro-neutrality) f[2](x) = x[1] x[2] -- K[w] = 0 (water ion product) f[3](x) = x[1] x[5]/x[4] -- K[2] = 0 (dissociation constant K[2]) f[4](x) = x[1] x[4] -- K[1] K[H] p[CO2] = 0 (dissociation constant K[1]) f[5](x) = x[3] x[5] -- K[s] = 0 (calcite dissolution product)