In [1]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from ttim import *
Load data of two observation wells
In [2]:
drawdown = np.loadtxt('data/oudekorendijk_h30.dat')
to1 = drawdown[:,0] / 60 / 24
ho1 = -drawdown[:,1]
ro1 = 30
drawdown = np.loadtxt('data/oudekorendijk_h90.dat')
to2 = drawdown[:,0] / 60 / 24
ho2 = -drawdown[:,1]
ro2 = 90
Pumping discharge
In [3]:
Qo = 788
Create model
In [4]:
ml = ModelMaq(kaq=60, z=(-18, -25), Saq=1e-4, tmin=1e-5, tmax=1)
w = Well(ml, xw=0, yw=0, rw=0.1, tsandQ=[(0, 788)], layers=0)
ml.solve()
Create calibration object, add parameters and first series. Fit the model. The chi-square value is the mean of the squared residuals at the optimum.
In [5]:
cal = Calibrate(ml)
cal.set_parameter(name='kaq0', initial=10)
cal.set_parameter(name='Saq0', initial=1e-4)
cal.series(name='obs1', x=ro1, y=0, layer=0, t=to1, h=ho1)
cal.fit(report=True)
display(cal.parameters)
print('rmse:', cal.rmse())
print('mse:', cal.rmse() ** 2 * len(ho1))
h1a = ml.head(ro1, 0, to1, 0) # simulated head
h2a = ml.head(ro2, 0, to2, 0) # simulated head
In [6]:
# second observation well
cal = Calibrate(ml)
cal.set_parameter(name='kaq0', initial=50)
cal.set_parameter(name='Saq0', initial=1.5e-5)
cal.series(name='obs1', x=ro2, y=0, layer=0, t=to2, h=ho2)
cal.fit(report=False)
display(cal.parameters)
h1b = ml.head(ro1, 0, to1, 0) # simulated head
h2b = ml.head(ro2, 0, to2, 0) # simulated head
In [7]:
plt.figure(figsize=(12, 4))
plt.subplot(121)
plt.semilogx(to1, ho1, 'C0.', label='observed 1')
plt.semilogx(to1, h1a[0], 'C0', label='model 1')
plt.semilogx(to2, ho2, 'C1.', label='observed 2')
plt.semilogx(to2, h2a[0], 'C1', label='model 2')
plt.title('calibrated well 1')
plt.xlabel('time (d)')
plt.ylabel('head (m)')
plt.legend()
plt.subplot(122)
plt.semilogx(to1, ho1, 'C0.', label='observed 1')
plt.semilogx(to1, h1b[0], 'C0', label='model 1')
plt.semilogx(to2, ho2, 'C1.', label='observed 2')
plt.semilogx(to2, h2b[0], 'C1', label='model 2')
plt.title('calibrated well 2')
plt.xlabel('time (d)')
plt.ylabel('head (m)')
plt.legend();
In [8]:
ml = ModelMaq(kaq=60, z=(-18, -25), Saq=1e-4, tmin=1e-5, tmax=1)
w = Well(ml, xw=0, yw=0, rw=0.1, rc=0.2, tsandQ=[(0, 788)], layers=0)
ml.solve()
In [9]:
cal = Calibrate(ml)
cal.set_parameter(name='kaq0', initial=10)
cal.set_parameter(name='Saq0', initial=1e-5)
cal.set_parameter_by_reference(name='rc', parameter=w.rc[:], initial=0.2, pmin=0.01, pmax=1)
cal.series(name='obs1', x=ro1, y=0, layer=0, t=to1, h=ho1)
cal.fit(report=False)
display(cal.parameters)
h1a = ml.head(ro1, 0, to1, 0) # simulated head
h2a = ml.head(ro2, 0, to2, 0) # simulated head
In [10]:
cal = Calibrate(ml)
cal.set_parameter(name='kaq0', initial=10)
cal.set_parameter(name='Saq0', initial=1e-5)
cal.set_parameter_by_reference(name='rc', parameter=w.rc[:], initial=0.2, pmin=0.01, pmax=1)
cal.series(name='obs2', x=ro2, y=0, layer=0, t=to2, h=ho2)
cal.fit(report=False)
display(cal.parameters)
h1b = ml.head(ro1, 0, to1, 0) # simulated head
h2b = ml.head(ro2, 0, to2, 0) # simulated head
In [11]:
plt.figure(figsize=(12, 4))
plt.subplot(121)
plt.semilogx(to1, ho1, 'C0.', label='observed 1')
plt.semilogx(to1, h1a[0], 'C0', label='model 1')
plt.semilogx(to2, ho2, 'C1.', label='observed 2')
plt.semilogx(to2, h2a[0], 'C1', label='model 2')
plt.title('calibrated well 1')
plt.xlabel('time (d)')
plt.ylabel('head (m)')
plt.legend()
plt.subplot(122)
plt.semilogx(to1, ho1, 'C0.', label='observed 1')
plt.semilogx(to1, h1b[0], 'C0', label='model 1')
plt.semilogx(to2, ho2, 'C1.', label='observed 2')
plt.semilogx(to2, h2b[0], 'C1', label='model 2')
plt.title('calibrated well 2')
plt.xlabel('time (d)')
plt.ylabel('head (m)')
plt.legend();
In [12]:
cal = Calibrate(ml)
cal.set_parameter(name='kaq0', initial=10)
cal.set_parameter(name='Saq0', initial=1e-5)
cal.set_parameter_by_reference(name='rc', parameter=w.rc[:], initial=0.2, pmin=0.01, pmax=1)
cal.series(name='obs1', x=ro1, y=0, layer=0, t=to1, h=ho1)
cal.series(name='obs2', x=ro2, y=0, layer=0, t=to2, h=ho2)
cal.fit(report=False)
display(cal.parameters)
In [13]:
h1 = ml.head(ro1, 0, to1, 0)
plt.semilogx(to1, ho1, '.', label='obs1')
plt.semilogx(to1, h1[0], label='model')
h2 = ml.head(ro2, 0, to2, 0)
plt.semilogx(to2, ho2, '.', label='obs2')
plt.semilogx(to2, h2[0], label='model')
plt.title('two wells simulaneously')
plt.xlabel('time (d)')
plt.ylabel('head (m)')
plt.legend();