 # Gravity: is it possible to do the simulation for 2D model by setting y axis as a single value?

Hi,

I saw there are forward and inversion examples for gravity based on a 3D model. I need to do some verification on a 2D model. So I would like to know how can I do the simulation based on a 2D model. Is it possible by setting the x- or y-axis as only a single value? It seems that only defining a 2D model is not correct because the surface topography is required to be an (N,3) NumPy array. Any response would be highly appreciated.

Hi @Astor,
Sorry for the delay.
I never tried it myself, but I believe you should be able to simulate a 2D gravity survey by using a 3D mesh with only one very wide cell in the Y-axis direction. The survey would then have to be centred in the middle of those very long Y-axis cells. Here is an example script to create such mesh:

``````import numpy as np
import discretize
import matplotlib.pyplot as plt

ncx = 16  # number of cells in the x-direction
ncy = 1 # number of cells in the y-direction
ncz = 4  # number of cells in the z-direction

dx = 5  # base cell width x
dy = 1e5  # base cell width y
dz = 5 # base cell width z

hx = dx * np.ones(ncx)
hy = dy * np.ones(ncy)
hz = dz * np.ones(ncz)

# create a tensor mesh
tensor_mesh = discretize.TensorMesh([hx, hy, hz],x0="CCN")

print(tensor_mesh)

fig, ax = plt.subplots(1,1,figsize=(10,20),subplot_kw={"projection": "3d"})
tensor_mesh.plot_grid(ax=ax)
``````

Maybe @domfournier would have more insights as well.