def load_grav_pygimli_cylinder(): #!/usr/bin/env python # -*- coding: utf-8 -*- r""" Semianalytical Gravimetry and Geomagnetics in 2D ------------------------------------------------ Simple gravimetric and magnetostatic field caluculation using integration approach after :cite:`WonBev1987`. """ radius = 2. depth = 5. rho = 1000.0 x = np.arange(-20, 20, 1) pnts = np.zeros((len(x), 2)) pnts[:, 0] = x pos = [0, -depth] fig, ax = pg.plt.subplots(nrows=3, ncols=1, figsize=(12, 8), sharex=True) # Horizontal cylinder circ = createCircle([0, -depth], radius=radius, marker=2, area=0.1, segments=32) pg.show(circ, ax=ax[0], fillRegion=False) ga = gradUCylinderHoriz(pnts, radius, rho, pos=pos) gza = gradGZCylinderHoriz(pnts, radius, rho, pos=pos) g, gz = solveGravimetry(circ, rho, pnts, complete=True) plot(x, ax[1], ga, gza, ax[2], g, gz, legend=False) # ax[0].set_ylim(bottom=-depth*2, top=1) labels = ["Horizontal cylinder", "Half plate"] for ax, label in zip(ax[:], labels): ax.set_title(label) ax.set_aspect("equal") ax.set_xlim(left=x[0], right=x[-1]) ax.set_ylim(bottom=-depth * 2, top=1) # pg.wait() return ga, gza
import pygimli as pg from pygimli.meshtools import createCircle, createWorld, createMesh from pygimli.physics.gravimetry import gradUCylinderHoriz, solveGravimetry radius = 2. # [m] depth = 5. # [m] pos = [0., -depth] dRho = 100 x = np.arange(-20, 20.1, .5) pnts = np.array([x, np.zeros(len(x))]).T ############################################################################### # Analytical solution first gz_a = gradUCylinderHoriz(pnts, radius, dRho, pos)[:, 1] ############################################################################### # Integration for a 2D polygon after :cite:`WonBev1987` circ = createCircle([0, -depth], radius=radius, marker=2, area=0.1, nSegments=16) gz_p = solveGravimetry(circ, dRho, pnts, complete=False) ############################################################################### # Integration for complete 2D mesh after :cite:`WonBev1987` world = createWorld(start=[-20, 0], end=[20, -10], marker=1) mesh = createMesh([world, circ]) dRhoC = pg.solver.parseMapToCellArray([[1, 0.0], [2, dRho]], mesh)
linestyle='', label=r'Won & Bevis: $\frac{\partial^2 u}{\partial z,z}$') a1.set_xlabel('$x$-coordinate [m]') a1.set_ylabel(r'$\frac{\partial u}{\partial (x,z)}$ [mGal]') a1.legend(loc='best') a2.set_xlabel('$x$-coordinate [m]') a2.legend(loc='best') fig = pg.plt.figure(figsize=(8, 8)) ax = [fig.add_subplot(2, 2, i) for i in range(1, 5)] # Horizontal cylinder ga = gradUCylinderHoriz(pnts, radius, rho, pos=pos) gza = gradGZCylinderHoriz(pnts, radius, rho, pos=pos) circ = createCircle([0, -depth], radius=radius, marker=2, area=0.1, segments=32) g, gz = solveGravimetry(circ, rho, pnts, complete=True) plot(x, ax[0], ga, gza, ax[1], g, gz) # Half plate thickness = 0.1
a2.plot(x, gz[:, 2], marker='o', linestyle='', label=r'Won & Bevis: $\frac{\partial^2 u}{\partial z,z}$') a1.set_xlabel('$x$-coordinate [m]') a1.set_ylabel(r'$\frac{\partial u}{\partial (x,z)}$ [mGal]') a1.legend(loc='best') a2.set_xlabel('$x$-coordinate [m]') a2.legend(loc='best') fig = pg.plt.figure(figsize=(8,8)) ax = [fig.add_subplot(2, 2, i) for i in range(1, 5)] # Horizontal cylinder ga = gradUCylinderHoriz(pnts, radius, rho, pos=pos) gza = gradGZCylinderHoriz(pnts, radius, rho, pos=pos) circ = createCircle([0, -depth], radius=radius, marker=2, area=0.1, segments=32) g, gz = solveGravimetry(circ, rho, pnts, complete=True) plot(x, ax[0], ga, gza, ax[1], g, gz) # Half plate thickness = 0.1 # mesh = pg.createGrid(x=[-2,2], y=[-2,2], z=[-3,-7]) mesh = pg.createGrid(x=np.linspace(0, 5000, 2), y=[-depth-thickness/2.0, -depth+thickness/2.0])
import pygimli as pg from pygimli.meshtools import createCircle, createWorld, createMesh, mergePLC from pygimli.physics.gravimetry import gradUCylinderHoriz, solveGravimetry radius = 2. # [m] depth = 5. # [m] pos = [0., -depth] dRho = 100 x = np.arange(-20, 20.1, .5) pnts = np.array([x, np.zeros(len(x))]).T ############################################################################### # Analytical solution first gz_a = gradUCylinderHoriz(pnts, radius, dRho, pos)[:, 1] ############################################################################### # Integration for a 2D polygon after :cite:`WonBev1987` circ = createCircle([0, -depth], radius=radius, marker=2, area=0.1, segments=16) gz_p = solveGravimetry(circ, dRho, pnts, complete=False) ############################################################################### # Integration for complete 2D mesh after :cite:`WonBev1987` world = createWorld(start=[-20, 0], end=[20, -10], marker=1) mesh = createMesh([world, circ]) dRhoC = pg.solver.parseMapToCellArray([[1, 0.0], [2, dRho]], mesh) gc_m = solveGravimetry(mesh, dRhoC, pnts) ###############################################################################
from pygimli.meshtools import * from pygimli.physics.gravimetry import gradUCylinderHoriz, solveGravimetry radius = 2 # [m] depth = 5 # [m] x = np.arange(-20, 20.1, 1) pnts = np.array([x, np.zeros(len(x))]).T pos = [0, -depth] dRho = 100 ax1 = pg.plt.subplot(2,1,1) ax2 = pg.plt.subplot(2,1,2) # analytical first ax1.plot(x, gradUCylinderHoriz(pnts, radius, dRho, pos)[:,1], label='Analytical') # polygon circ = createCircle([0, -depth], radius=radius, marker=2, segments=16) ax1.plot(x, solveGravimetry(circ, dRho, pnts, complete=False), label='Poly') # complete cell based mesh world = createWorld(start=[-20, 0], end=[20, -10], marker=1) mesh = createMesh([world, circ]) dRhoC = pg.solver.parseMapToCellArray([[1, 0.0], [2, dRho]], mesh) ax1.plot(x, solveGravimetry(mesh, dRhoC, pnts), label='Mesh') pg.show([world, circ], axes=ax2) # Finite Element way world = createWorld(start=[-200, 200], end=[200, -200], marker=1)