FLOW: Richards: 1D: InversionΒΆ

The example shows an inversion of Richards equation in 1D with a heterogeneous hydraulic conductivity function.

The haverkamp model is used with the same parameters as Celia1990 the boundary and initial conditions are also the same. The simulation domain is 40cm deep and is run for an hour with an exponentially increasing time step that has a maximum of one minute. The general setup of the experiment is an infiltration front that advances downward through the model over time.

The model chosen is the saturated hydraulic conductivity inside the hydraulic conductivity function (using haverkamp). The initial model is chosen to be the background (1e-3 cm/s). The saturation data has 2% random Gaussian noise added.

The figure shows the recovered saturated hydraulic conductivity next to the true model. The other two figures show the saturation field for the entire simulation for the true and recovered models.

Rowan Cockett - 21/12/2016



SimPEG.InvProblem will set Regularization.mref to m0.
SimPEG.InvProblem is setting bfgsH0 to the inverse of the eval2Deriv.
                    ***Done using same Solver and solverOpts as the problem***
SimPEG.DataMisfit.l2_DataMisfit assigning default eps of 1e-5 * ||dobs||
model has any nan: 0
============================ Inexact Gauss Newton ============================
  #     beta     phi_d     phi_m       f      |proj(x-g)-x|  LS    Comment
x0 has any nan: 0
   0  2.44e+05  9.63e+04  0.00e+00  9.63e+04    1.44e+04      0
   1  2.44e+05  9.12e+04  7.92e-03  9.32e+04    3.75e+03      0
   2  2.44e+05  8.99e+04  1.26e-02  9.30e+04    9.72e+02      0   Skip BFGS
   3  6.10e+04  8.97e+04  1.33e-02  9.05e+04    1.11e+04      1   Skip BFGS
   4  6.10e+04  8.11e+04  7.12e-02  8.54e+04    6.47e+03      0
   5  6.10e+04  7.56e+04  1.27e-01  8.34e+04    5.04e+03      0   Skip BFGS
   6  1.53e+04  7.16e+04  1.75e-01  7.42e+04    1.22e+04      0   Skip BFGS
   7  1.53e+04  5.90e+04  3.86e-01  6.49e+04    1.16e+04      0
   8  1.53e+04  4.79e+04  6.10e-01  5.72e+04    1.01e+04      0
   9  3.82e+03  3.81e+04  8.48e-01  4.13e+04    1.47e+04      0   Skip BFGS
  10  3.82e+03  2.56e+04  1.25e+00  3.03e+04    1.47e+04      0
  11  3.82e+03  1.46e+04  1.59e+00  2.07e+04    1.39e+04      0
NewtonRoot stopped by maxIters (30). norm: 8.3554e-04
  12  9.54e+02  6.72e+03  1.90e+00  8.53e+03    1.52e+04      0   Skip BFGS
  13  9.54e+02  1.86e+03  2.33e+00  4.08e+03    7.07e+03      0
  14  9.54e+02  8.58e+02  2.54e+00  3.28e+03    1.36e+03      0   Skip BFGS
  15  2.38e+02  7.36e+02  2.59e+00  1.35e+03    1.41e+03      0   Skip BFGS
  16  2.38e+02  3.82e+02  3.27e+00  1.16e+03    1.13e+03      0
  17  2.38e+02  3.52e+02  3.35e+00  1.15e+03    3.40e+02      0   Skip BFGS
  18  5.96e+01  3.46e+02  3.37e+00  5.47e+02    4.07e+02      0
  19  5.96e+01  2.96e+02  3.96e+00  5.32e+02    1.53e+03      0
  20  5.96e+01  2.81e+02  3.95e+00  5.17e+02    1.32e+03      1
------------------------- STOP! -------------------------
1 : |fc-fOld| = 1.5126e+01 <= tolF*(1+|f0|) = 9.6302e+03
1 : |xc-x_last| = 2.8241e-01 <= tolX*(1+|x0|) = 4.4688e+00
0 : |proj(x-g)-x|    = 1.3209e+03 <= tolG          = 1.0000e-01
0 : |proj(x-g)-x|    = 1.3209e+03 <= 1e3*eps       = 1.0000e-02
1 : maxIter   =      20    <= iter          =     20
------------------------- DONE! -------------------------

import matplotlib
import matplotlib.pyplot as plt
import numpy as np

from SimPEG import Mesh
from SimPEG import Maps
from SimPEG import Regularization
from SimPEG import DataMisfit
from SimPEG import Optimization
from SimPEG import InvProblem
from SimPEG import Directives
from SimPEG import Inversion

from SimPEG.FLOW import Richards

def run(plotIt=True):

    M = Mesh.TensorMesh([np.ones(40)], x0='N')
    # We will use the haverkamp empirical model with parameters from Celia1990
    k_fun, theta_fun = Richards.Empirical.haverkamp(
        M, A=1.1750e+06, gamma=4.74, alpha=1.6110e+06,
        theta_s=0.287, theta_r=0.075, beta=3.96

    # Here we are making saturated hydraulic conductivity
    # an exponential mapping to the model (defined below)
    k_fun.KsMap = Maps.ExpMap(nP=M.nC)

    # Setup the boundary and initial conditions
    bc = np.array([-61.5, -20.7])
    h = np.zeros(M.nC) + bc[0]
    prob = Richards.RichardsProblem(
        boundary_conditions=bc, initial_conditions=h,
        do_newton=False, method='mixed', debug=False
    prob.timeSteps = [(5, 25, 1.1), (60, 40)]

    # Create the survey
    locs = -np.arange(2, 38, 4.)
    times = np.arange(30, prob.timeMesh.vectorCCx[-1], 60)
    rxSat = Richards.SaturationRx(locs, times)
    survey = Richards.RichardsSurvey([rxSat])

    # Create a simple model for Ks
    Ks = 1e-3
    mtrue = np.ones(M.nC)*np.log(Ks)
    mtrue[15:20] = np.log(5e-2)
    mtrue[20:35] = np.log(3e-3)
    mtrue[35:40] = np.log(1e-2)
    m0 = np.ones(M.nC)*np.log(Ks)

    # Create some synthetic data and fields
    stdev = 0.02  # The standard deviation for the noise
    Hs = prob.fields(mtrue)
    survey.makeSyntheticData(mtrue, std=stdev, f=Hs, force=True)

    # Setup a pretty standard inversion
    reg = Regularization.Tikhonov(M, alpha_s=1e-1)
    dmis = DataMisfit.l2_DataMisfit(survey)
    opt = Optimization.InexactGaussNewton(maxIter=20, maxIterCG=10)
    invProb = InvProblem.BaseInvProblem(dmis, reg, opt)
    beta = Directives.BetaSchedule(coolingFactor=4)
    betaest = Directives.BetaEstimate_ByEig(beta0_ratio=1e2)
    target = Directives.TargetMisfit()
    dir_list = [beta, betaest, target]
    inv = Inversion.BaseInversion(invProb, directiveList=dir_list)

    mopt = inv.run(m0)

    Hs_opt = prob.fields(mopt)

    if plotIt:
        plt.figure(figsize=(14, 9))

        ax = plt.subplot(121)
        plt.semilogx(np.exp(np.c_[mopt, mtrue]), M.gridCC)
        plt.xlabel('Saturated Hydraulic Conductivity, $K_s$')
        plt.ylabel('Depth, cm')
        plt.semilogx([10**-3.9]*len(locs), locs, 'ro')
        plt.legend(('$m_{rec}$', '$m_{true}$', 'Data locations'), loc=4)

        ax = plt.subplot(222)
        mesh2d = Mesh.TensorMesh([prob.timeMesh.hx/60, prob.mesh.hx], '0N')
        sats = [theta_fun(_) for _ in Hs]
        clr = mesh2d.plotImage(np.c_[sats][1:, :], ax=ax)
        cmap0 = matplotlib.cm.RdYlBu_r
        c = plt.colorbar(clr[0])
        c.set_label('Saturation $\\theta$')
        plt.xlabel('Time, minutes')
        plt.ylabel('Depth, cm')
        plt.title('True saturation over time')

        ax = plt.subplot(224)
        mesh2d = Mesh.TensorMesh([prob.timeMesh.hx/60, prob.mesh.hx], '0N')
        sats = [theta_fun(_) for _ in Hs_opt]
        clr = mesh2d.plotImage(np.c_[sats][1:, :], ax=ax)
        cmap0 = matplotlib.cm.RdYlBu_r
        c = plt.colorbar(clr[0])
        c.set_label('Saturation $\\theta$')
        plt.xlabel('Time, minutes')
        plt.ylabel('Depth, cm')
        plt.title('Recovered saturation over time')


if __name__ == '__main__':

Total running time of the script: ( 4 minutes 27.784 seconds)

Generated by Sphinx-Gallery