mirror of
https://github.com/wassname/simpeg.git
synced 2026-07-15 11:26:09 +08:00
Working codes
This commit is contained in:
+3
-2
@@ -136,15 +136,16 @@ class BaseDepthModel(Model.BaseModel):
|
||||
Model.BaseModel.__init__(self, mesh)
|
||||
self.mesh = mesh
|
||||
self.active_ind = kwargs['active_ind']
|
||||
self.c = kwargs['c']
|
||||
|
||||
def transform(self, m):
|
||||
weight = abs(self.mesh.gridCC[:,2])**1.0
|
||||
weight = abs(self.mesh.gridCC[:,2])**self.c
|
||||
weight = weight/weight.max()
|
||||
weight[~self.active_ind] = 1.
|
||||
return m*weight
|
||||
|
||||
def transformDeriv(self, m):
|
||||
weight = abs(self.mesh.gridCC[:,2])**1.0
|
||||
weight = abs(self.mesh.gridCC[:,2])**self.c
|
||||
weight = weight/weight.max()
|
||||
weight[~self.active_ind] = 1.
|
||||
return Utils.sdiag(weight)
|
||||
|
||||
@@ -215,10 +215,10 @@ if __name__ == '__main__':
|
||||
Bbczx, Bbczy, Bbczz = MagSphereAnalFun(M3.gridFz[(indzd|indzu),0], M3.gridFz[(indzd|indzu),1], M3.gridFz[(indzd|indzu),2], 100, 0., 0., 0., mu_0, mu_0*(1+chiblk), H0, flag)
|
||||
Bbc_anal = np.r_[Bbcxx, Bbcyy, Bbczz]
|
||||
|
||||
fig, ax = plt.subplots(1,1, figsize = (10, 10))
|
||||
ax.plot(Bbc_anal)
|
||||
ax.plot(Bbc)
|
||||
plt.show()
|
||||
# fig, ax = plt.subplots(1,1, figsize = (10, 10))
|
||||
# ax.plot(Bbc_anal)
|
||||
# ax.plot(Bbc)
|
||||
# plt.show()
|
||||
err = np.linalg.norm(Bbc-Bbc_anal)/np.linalg.norm(Bbc_anal)
|
||||
|
||||
if err < 0.1:
|
||||
|
||||
@@ -332,6 +332,8 @@ def MagneticsDiffSecondaryInv(mesh, model, data, **kwargs):
|
||||
from SimPEG import Optimization, Regularization, Parameters, ObjFunction, Inversion
|
||||
prob = MagneticsDiffSecondary(mesh, model)
|
||||
|
||||
miter = kwargs.get('maxIter', 10)
|
||||
|
||||
if prob.ispaired:
|
||||
prob.unpair()
|
||||
if data.ispaired:
|
||||
@@ -339,7 +341,7 @@ def MagneticsDiffSecondaryInv(mesh, model, data, **kwargs):
|
||||
prob.pair(data)
|
||||
|
||||
# Create an optimization program
|
||||
opt = Optimization.InexactGaussNewton(maxIter=5)
|
||||
opt = Optimization.InexactGaussNewton(maxIter=miter)
|
||||
opt.bfgsH0 = Solver(sp.identity(model.nP),flag='D')
|
||||
# Create a regularization program
|
||||
reg = Regularization.Tikhonov(model)
|
||||
@@ -387,11 +389,12 @@ if __name__ == '__main__':
|
||||
prob.pair(data)
|
||||
|
||||
dpred = data.dpred(chi)
|
||||
fig = plt.figure( figsize = (8,5) )
|
||||
ax = plt.subplot(111)
|
||||
dat = plt.imshow(np.reshape(dpred, (xr.size, yr.size), order='F'), extent=[min(xr), max(xr), min(yr), max(yr)])
|
||||
plt.colorbar(dat, ax = ax)
|
||||
plt.show()
|
||||
|
||||
# fig = plt.figure( figsize = (8,5) )
|
||||
# ax = plt.subplot(111)
|
||||
# dat = plt.imshow(np.reshape(dpred, (xr.size, yr.size), order='F'), extent=[min(xr), max(xr), min(yr), max(yr)])
|
||||
# plt.colorbar(dat, ax = ax)
|
||||
# plt.show()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -52,9 +52,9 @@ class MagFwdProblemTests(unittest.TestCase):
|
||||
dpred = data.projectFieldsAsVector(B)
|
||||
err = np.linalg.norm(dpred-np.r_[bxa, bya, bza])/np.linalg.norm(np.r_[bxa, bya, bza])
|
||||
|
||||
plt.plot(dpred)
|
||||
plt.plot(np.r_[bxa, bya, bza])
|
||||
plt.show()
|
||||
# plt.plot(dpred)
|
||||
# plt.plot(np.r_[bxa, bya, bza])
|
||||
# plt.show()
|
||||
|
||||
if err > 0.05:
|
||||
raise Exception('Anaytic test is failed T.T')
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user