mirror of
https://github.com/wassname/simpeg.git
synced 2026-07-27 11:27:23 +08:00
Merge branch 'Dom' of https://github.com/simpeg/simpegpf into Dom
Conflicts: simpegPF/Magnetics.py
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import os
|
||||
|
||||
home_dir = 'C:\Users\dominiquef.MIRAGEOSCIENCE\Documents\GIT\SimPEG\simpegpf\simpegPF\Dev'
|
||||
# home_dir = 'C:\Users\dominiquef.MIRAGEOSCIENCE\Documents\GIT\SimPEG\simpegpf\simpegPF\Dev'
|
||||
|
||||
os.chdir(home_dir)
|
||||
# os.chdir(home_dir)
|
||||
|
||||
#%%
|
||||
from SimPEG import *
|
||||
@@ -16,12 +16,12 @@ plt.close('all')
|
||||
#%% Create survey
|
||||
|
||||
B = np.array(([-45.,315.,50000.]))
|
||||
|
||||
|
||||
M = np.array(([-45.,315.]))
|
||||
|
||||
|
||||
# Sphere radius
|
||||
R = 0.25
|
||||
|
||||
|
||||
# # Or create juste a plane grid
|
||||
xr = np.linspace(-2., 2., 5)
|
||||
yr = np.linspace(-2., 2., 5)
|
||||
@@ -37,67 +37,67 @@ lrl = np.zeros(d_iter)
|
||||
# Create mesh using simpeg and write out in GIF format
|
||||
|
||||
for ii in range(d_iter):
|
||||
|
||||
|
||||
nc = 3**(ii+1)
|
||||
|
||||
|
||||
hxind = [(1./nc, nc)]
|
||||
hyind = [(1./nc, nc)]
|
||||
hzind = [(1./nc, nc)]
|
||||
|
||||
|
||||
mesh = Mesh.TensorMesh([hxind, hyind, hzind], 'CCC')
|
||||
|
||||
|
||||
xn = mesh.vectorNx
|
||||
yn = mesh.vectorNy
|
||||
zn = mesh.vectorNz
|
||||
|
||||
|
||||
mcell = mesh.nC
|
||||
|
||||
|
||||
print 'Mesh size: ' + str(mcell)
|
||||
|
||||
|
||||
sph_ind = PF.MagAnalytics.spheremodel(mesh, 0, 0, 0, R)
|
||||
|
||||
|
||||
chibkg = 0.
|
||||
chiblk = 0.01
|
||||
model = np.ones(mcell)*chibkg
|
||||
model[sph_ind] = chiblk
|
||||
|
||||
|
||||
actv = np.ones(mcell)
|
||||
|
||||
|
||||
#%% Forward mode ldata
|
||||
d = PF.Magnetics.Intgrl_Fwr_Data(mesh,B,M,rxLoc,model,actv,'xyz')
|
||||
fwr_x = d[0:ndata]
|
||||
fwr_y = d[ndata:2*ndata]
|
||||
fwr_z = d[2*ndata:]
|
||||
|
||||
|
||||
#%% Get the analystical answer and compute the residual
|
||||
bxa,bya,bza = PF.MagAnalytics.MagSphereAnaFunA(rxLoc[:,0],rxLoc[:,1],rxLoc[:,2],R,0.,0.,0.,chiblk, np.array(([0.,0.,B[2]])),'secondary')
|
||||
Bd = (450.-float(B[1]))%360.
|
||||
Bi = B[0]; # Convert dip to horizontal to cartesian
|
||||
|
||||
Bx = np.cos(np.deg2rad(Bi)) * np.cos(np.deg2rad(Bd)) * B[2]
|
||||
By = np.cos(np.deg2rad(Bi)) * np.sin(np.deg2rad(Bd)) * B[2]
|
||||
Bz = np.sin(np.deg2rad(Bi)) * B[2]
|
||||
|
||||
Bi = B[0]; # Convert dip to horizontal to cartesian
|
||||
|
||||
Bx = np.cos(np.deg2rad(Bi)) * np.cos(np.deg2rad(Bd)) * B[2]
|
||||
By = np.cos(np.deg2rad(Bi)) * np.sin(np.deg2rad(Bd)) * B[2]
|
||||
Bz = np.sin(np.deg2rad(Bi)) * B[2]
|
||||
|
||||
Bo = np.c_[Bx, By, Bz]
|
||||
|
||||
|
||||
bxa,bya,bza = PF.MagAnalytics.MagSphereFreeSpace(rxLoc[:,0],rxLoc[:,1],rxLoc[:,2],R,0.,0.,0.,chiblk, Bo)
|
||||
#bxa,bya,bza = PF.MagAnalytics.MagSphereAnaFunA(rxLoc[:,0],rxLoc[:,1],rxLoc[:,2],R,0.,0.,0.,chiblk, np.array(([0.,0.,B[2]])),'secondary')
|
||||
|
||||
|
||||
r_Bx = fwr_x - bxa
|
||||
r_By = fwr_y - bya
|
||||
r_Bz = fwr_z - bza
|
||||
|
||||
lrl[ii] = sum( r_Bx**2 + r_By**2 + r_Bz**2 ) **0.5
|
||||
|
||||
|
||||
|
||||
lrl[ii] = sum( r_Bx**2 + r_By**2 + r_Bz**2 ) **0.5
|
||||
|
||||
|
||||
|
||||
#%% Plot results
|
||||
print 'Residual between analytical sphere and integral forward'
|
||||
print 'Residual between analytical sphere and integral forward'
|
||||
for ii in range(d_iter):
|
||||
nc = 3**(ii+1)
|
||||
|
||||
print "||r||= " + str(lrl[ii]) + "\t dx= " + str(1./nc)
|
||||
|
||||
|
||||
#%% Plot fields
|
||||
|
||||
plt.figure(1)
|
||||
@@ -168,4 +168,6 @@ plt.imshow(np.reshape(r_Bz,X.shape).T, interpolation="bicubic", extent=[xr.min()
|
||||
plt.colorbar(fraction=0.04)
|
||||
plt.contour(X,Y, np.reshape(r_Bz,X.shape).T,10)
|
||||
plt.scatter(X,Y, c=np.reshape(r_Bz,X.shape).T, s=20)
|
||||
ax.set_title('Sphere Ana Bz')
|
||||
ax.set_title('Sphere Ana Bz')
|
||||
|
||||
plt.show()
|
||||
|
||||
Reference in New Issue
Block a user