In [1]:
%pylab inline
In [3]:
from scipy.special import erfc
In [37]:
def dsig(eta, tau, t):
b = 1./(1.-eta)/np.sqrt(tau)
a = eta*b
return a*(1./np.sqrt(np.pi*t) - b*np.exp(b**2*t)*erfc(b*np.sqrt(t)))
In [90]:
dsig(0.1, 0.01, t)
Out[90]:
In [91]:
t = np.logspace(-5, 0., 41)
plt.loglog(t, dsig(0.1, 0.01, t))
plt.loglog(t, dsig(0.1, 0.1, t))
plt.loglog(t, dsig(0.1, 1, t))
Out[91]:
In [92]:
# def petaconvfun(a, b, we, time, P):
def petaconvfun(m, time=t):
a, b = m[0], m[1]
kernel = lambda t: a*(1./np.sqrt(np.pi*t) - b*np.exp(b**2*t)*erfc(b*np.sqrt(t)))
temp = kernel(time)
# temp = Convolution.CausalConvIntSingle(we, time, kernel)
# out = P*temp
out = temp.copy()
return out
# def petaJconvfun(a, b, we, time, P):
def petaJconvfun(m, time=t):
a, b = m[0], m[1]
kernela = lambda x: 1./np.sqrt(np.pi*t) - b*np.exp(b**2*t)*erfc(b*np.sqrt(t))
kernelb = lambda x: a*(2*b*np.sqrt(t)/np.sqrt(np.pi) \
- 2*b**2*t*np.exp(b**2*t)*erfc(b*np.sqrt(t))\
- np.exp(b**2*t)*erfc(b*np.sqrt(t)))
tempa = kernela(time)
tempb = kernelb(time)
# tempa = Convolution.CausalConvIntSingle(we, time, kernela)
# tempb = Convolution.CausalConvIntSingle(we, time, kernelb)
# J = np.c_[P*tempeta, P*temptau]
J = np.c_[tempa, tempb]
return J
In [93]:
from SimPEG import Tests
In [94]:
eta, tau = 0.1, 0.1
b = 1./(1.-eta)/np.sqrt(tau)
a = eta*b
m0 = np.r_[a, b]
J = petaJconvfun(m0)
dobs = petaconvfun(m0)
In [95]:
def Jvec(m, mx):
J = petaJconvfun(m)
return np.dot(J, mx)
In [96]:
derChk = lambda m: [petaconvfun(m), lambda mx: Jvec(m0, mx)]
passed = Tests.checkDerivative(derChk, m0, plotIt=False)