def test_createMesh2D(self): mesh = pg.createMesh2D(xDim=5, yDim=2) self.assertEqual(mesh.cellCount(), 10.0) mesh = pg.createMesh2D(5, 2) self.assertEqual(mesh.cellCount(), 10.0) mesh = pg.createMesh2D(np.linspace(0, 1, 6),np.linspace(0, 1, 3)) self.assertEqual(mesh.cellCount(), 10.0)
def test_createMesh2D(self): mesh = pg.createMesh2D(xDim=5, yDim=2) self.assertEqual(mesh.cellCount(), 10.0) mesh = pg.createMesh2D(5, 2) self.assertEqual(mesh.cellCount(), 10.0) mesh = pg.createMesh2D(np.linspace(0, 1, 6), np.linspace(0, 1, 3)) self.assertEqual(mesh.cellCount(), 10.0)
def create_mesh_and_data(n): nc = np.linspace(-2.0, 0.0, n) mesh = pg.createMesh2D(nc, nc) mcx = pg.x(mesh.cellCenter()) mcy = pg.y(mesh.cellCenter()) data = np.cos(1.5 * mcx) * np.sin(1.5 * mcy) return mesh, data
def __init__(self, data, nlay=2, verbose=False, f=None, r=None): """Parameters: FDEM data class and number of layers.""" super(FDEMLCIFOP, self).__init__(verbose) self.nlay = nlay self.FOP = data.FOP(nlay) self.nx = len(data.x) self.nf = len(data.freq()) self.np = 2 * nlay - 1 self.mesh2d = pg.createMesh2D(self.np, self.nx) self.mesh2d.rotate(pg.RVector3(0, 0, -np.pi / 2)) self.setMesh(self.mesh2d) self.J = pg.RBlockMatrix() self.FOP1d = [] for i in range(self.nx): self.FOP1d.append(HEMmodelling(nlay, data.z[i], f, r)) n = self.J.addMatrix(self.FOP1d[-1].jacobian()) self.J.addMatrixEntry(n, self.nf * 2 * i, self.np * i) self.setJacobian(self.J)
def __init__(self, data, nlay=2, verbose=False, f=None, r=None): """ Parameters: FDEM data class and number of layers """ super(FDEMLCIFOP, self).__init__(verbose) self.nlay = nlay self.FOP = data.FOP(nlay) self.nx = len(data.x) self.nf = len(data.freq()) self.np = 2 * nlay - 1 self.mesh2d = pg.createMesh2D(self.np, self.nx) self.mesh2d.rotate(pg.RVector3(0, 0, -np.pi/2)) self.setMesh(self.mesh2d) self.J = pg.RBlockMatrix() self.FOP1d = [] for i in range(self.nx): self.FOP1d.append(HEMmodelling(nlay, data.z[i], f, r)) n = self.J.addMatrix(self.FOP1d[-1].jacobian()) self.J.addMatrixEntry(n, self.nf*2*i, self.np*i) self.setJacobian(self.J)
def __init__(self, profile, nlay=2, verbose=False): """Parameters: FDEM data class and number of layers""" super(MRSLCI, self).__init__(verbose) self.nlay = nlay self.nx = len(profile) self.np = 3 * nlay - 1 # self.mesh2d = pg.createMesh2D(npar, self.nx) # self.mesh2d = pg.createMesh2D(self.nx, self.np) self.mesh2d = pg.createMesh2D(range(self.np+1), range(self.nx+1)) self.mesh2d.rotate(pg.RVector3(0, 0, -np.pi/2)) self.setMesh(self.mesh2d) self.J = pg.RBlockMatrix() self.FOP1d = [] ipos = 0 for i, mrs in enumerate(profile): mrs.createFOP(nlay, verbose=False) self.FOP1d.append(mrs.f) n = self.J.addMatrix(self.FOP1d[-1].jacobian()) self.J.addMatrixEntry(n, ipos, self.np * i) ipos += len(mrs.data) self.J.recalcMatrixSize() print(self.J.rows(), self.J.cols()) self.setJacobian(self.J)
def __init__(self, profile, nlay=2, verbose=False): """Parameters: FDEM data class and number of layers""" super(MRSLCI, self).__init__(verbose) self.nlay = nlay self.nx = len(profile) self.np = 3 * nlay - 1 # self.mesh2d = pg.createMesh2D(npar, self.nx) # self.mesh2d = pg.createMesh2D(self.nx, self.np) self.mesh2d = pg.createMesh2D(range(self.np + 1), range(self.nx + 1)) self.mesh2d.rotate(pg.RVector3(0, 0, -np.pi / 2)) self.setMesh(self.mesh2d) self.J = pg.RBlockMatrix() self.FOP1d = [] ipos = 0 for i, mrs in enumerate(profile): mrs.createFOP(nlay, verbose=False) self.FOP1d.append(mrs.f) n = self.J.addMatrix(self.FOP1d[-1].jacobian()) self.J.addMatrixEntry(n, ipos, self.np * i) ipos += len(mrs.data) self.J.recalcMatrixSize() print(self.J.rows(), self.J.cols()) self.setJacobian(self.J)
c0 = mt.createCircle(pos=(7.0, -10.0), radius=3, segments=25, marker=1) c1 = mt.createCircle(pos=(12.0, -18.0), radius=4, segments=25, marker=2) geom = mt.mergePLC([world, c0, c1]) for sen in sensors: geom.createNode(sen) mesh_fwd = mt.createMesh(geom, quality=34, area=.25) model = np.array([2000., 2300, 1700])[mesh_fwd.cellMarkers()] pg.show(mesh_fwd, model, label="Velocity (m/s)", nLevs=3, logScale=False) ################################################################################ # Create inversion mesh refinement = 0.25 x = np.arange(0, bh_spacing + refinement, sensor_spacing * refinement) y = -np.arange(0.0, bh_length + 3, sensor_spacing * refinement) mesh = pg.createMesh2D(x, y) ax, _ = pg.show(mesh, hold=True) ax.plot(sensors[:, 0], sensors[:, 1], "ro") ################################################################################ # Next, we create an empty DataContainer and fill it with sensor positions and # all possible shot-recevier pairs for the two-borehole scenario using the # product funtion in the itertools module (Python standard library). from itertools import product numbers = np.arange(len(depth)) rays = list(product(numbers, numbers + len(numbers))) # Empty container scheme = pg.DataContainer()
end=2 * math.pi, isClosed=False) left = plc.createLine(start=(-20, 0.0), end=(-5.1, 0.0), segments=10) left.node(8).setMarker(1) mid = plc.createLine(start=(-4.9, 0.0), end=(4.9, 0.0), segments=20) right = plc.createLine(start=(5.1, 0.0), end=(20, 0.0), segments=10) left.node(2).setMarker(1) border = plc.mergePLC([left, c1, mid, c2, right]) depth = 20 nz = 15 newNodes = [] y = pg.increasingRange(0.2, depth, nz) surface = pg.createMesh2D(border, y, 0, 0, False) #for n in surface.nodes(): #yNodes = pg.increasingRange(yDefault[1], depth+n.y(), nz) #for y in yNodes[0:]: #newNodes.append([n.x(), n.y() -y]) #surface = pg.createGrid(x=yDefault, y=pg.sort(pg.x(surface.positions()))) #for i, n in enumerate(surface.nodes()): #n.setPos(newNodes[i]) #surface.smooth(1, 1, 1, 10) ax, _ = pg.show(surface) #showBoundaryNorm(surface, axes=ax)
c2 = plc.createCircle(pos=( 5.0, 0.0), radius=0.1, segments=5, start=math.pi, end=2*math.pi, isClosed=False) left = plc.createLine(start=(-20, 0.0), end=(-5.1, 0.0), segments=10) left.node(8).setMarker(1) mid = plc.createLine(start=(-4.9, 0.0), end=(4.9, 0.0), segments=20) right= plc.createLine(start=(5.1, 0.0), end=(20, 0.0), segments=10) left.node(2).setMarker(1) border = mergePLC([left, c1, mid, c2, right]) depth = 20 nz = 15 newNodes = [] y = pg.increasingRange(0.2, depth, nz) surface = pg.createMesh2D(border, y, 0, 0, False) #for n in surface.nodes(): #yNodes = pg.increasingRange(yDefault[1], depth+n.y(), nz) #for y in yNodes[0:]: #newNodes.append([n.x(), n.y() -y]) #surface = pg.createGrid(x=yDefault, y=pg.sort(pg.x(surface.positions()))) #for i, n in enumerate(surface.nodes()): #n.setPos(newNodes[i]) #surface.smooth(1, 1, 1, 10) ax, _ = pg.show(surface) #showBoundaryNorm(surface, axes=ax)
c0 = mt.createCircle(pos=(7.0, -10.0), radius=3, segments=25, marker=1) c1 = mt.createCircle(pos=(12.0, -18.0), radius=4, segments=25, marker=2) geom = mt.mergePLC([world, c0, c1]) for sen in sensors: geom.createNode(sen) mesh_fwd = mt.createMesh(geom, quality=34, area=.25) model = np.array([2000., 2300, 1700])[mesh_fwd.cellMarkers()] pg.show(mesh_fwd, model, label="Velocity (m/s)", nLevs=3, logScale=False) ################################################################################ # Create inversion mesh refinement = 0.25 x = np.arange(0, bh_spacing + refinement, sensor_spacing * refinement) y = -np.arange(0.0, bh_length + 3, sensor_spacing * refinement) mesh = pg.createMesh2D(x, y) ax, _ = pg.show(mesh, hold=True) ax.plot(sensors[:, 0], sensors[:, 1], "ro") ################################################################################ # Next, we create an empty DataContainer and fill it with sensor positions and # all possible shot-recevier pairs for the two-borehole scenario using the # product function in the itertools module (Python standard library). from itertools import product numbers = np.arange(len(depth)) rays = list(product(numbers, numbers + len(numbers))) # Empty container scheme = pg.DataContainer()