hpjeonGIT / nonlinear_solver

Sample/example of nonlinear solvers for flow in porous media

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sample nonlinear solvers

  • MATLAB/Octave sample codes for flow in porous media
  • Python code might be provided

Newton Raphson

  • Ref: http://www.mj-oystein.no/index_htm_files/ResSimNotes.pdf
  • Solve f(x) = 0
  • Fig 31. of the reference
  • x1 = x0 - f(x0)/f'(x0)
  • f'(x0)*(x1-x0) + f(x0) => f'(x_k) dx_k + f(x_k) = 0 : Eqn(44)
  • In matrix form: A = df1/dx1 df1/dx2 ... df1/dxN df2/dx1 df2/dx2 ... df2/dxN ... dfN/dx1 dfN/dx2 ... dfN/dxN x = dx1, dx2, ... dxN b = -f1, -f2, ... -fsN Solve Ax=b
  • Then update: x = x + alpha *dx. Alpha would be 1 for non-damping cases

Inexact Newton

ASPIN

Sample example

  • F1(x1,x2) = x1 + 0.1 * x1x2 + 0.2x2*x2 - 0.17975 = 0
  • F2(x1,x2) = x1x1 + 1.5x1*x2 - 0.7 *x2 + 0.41125 = 0
  • Let F1(x1-T1,x2) = (x1-T1) + 0.1 * (x1-T1)x2 + 0.2x2*x2 - 0.17975 = 0
    • T1 = (x1 + 0.1x1x2 + 0.2x2x2 -0.17975)/(1 + 0.1*x2)
  • Let F2(x1,x2-T2) = x1x1 + 1.5x1*(x2-T2) - 0.7 * (x2-T2) + 0.41125 =0
    • T2 = (x1x1 + 1.5x1x2 - 0.7x2 + 0.41125)/(1.5*x1 -0.7)
  • Ref: https://icerm.brown.edu/materials/Slides/tw-15-5

Sample2

  • Ref: Nonlinear_Schwarz_Preconditioning_]_David_Keyes,King_Abdullah_University_of_Science&_Technology.pdf
  • ASPIN reduces NR steps as a half
  • Inexact NT is 2x faster than exact NR
    • The key of inexact NT is two fold loops
    • First loop is for the convergence. Residual check might be done
    • Second loop is for the the condition of inequality |f + df dx | <= eta |f|
    • Iterating until the inequality, find the dx. When dx is found, check if the convergence is met. If not, iterate the first loop
    • The key of inexact NT is that the total cost of the dual loop might be cheaper than the exact NT.

In reservoir simulator

T= t0, t1, t2, ... t_f At t_i,

  1. Configure nonlinear system
  2. differentiate
  3. loop over linear solver
  4. when converged, exit linear loop
  5. update nonlinear system
  6. If not converged, time step cut

HO expansion

  • y = f + f' dx + f''dx*dx/2 = 0
  • dx = -f'/f'' +- \sqrt( f'f' - 2f''*f)/f''

About

Sample/example of nonlinear solvers for flow in porous media


Languages

Language:MATLAB 99.5%Language:M 0.5%