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

**URL:** <https://simpeg.discourse.group/t/gravity-is-it-possible-to-do-the-simulation-for-2d-model-by-setting-y-axis-as-a-single-value/255>\
**Category:** Getting Started\
**Created:** [September 2, 2021, 9:30pm UTC](https://simpeg.discourse.group/t/gravity-is-it-possible-to-do-the-simulation-for-2d-model-by-setting-y-axis-as-a-single-value/255 "2021-09-02T21:30:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Astor](https://yyz2.discourse-cdn.com/free1/user_avatar/simpeg.discourse.group/astor/32/189_2.png) [@Astor](https://simpeg.discourse.group/u/Astor)\
**Post date:** [September 2, 2021, 9:30pm UTC](https://simpeg.discourse.group/t/gravity-is-it-possible-to-do-the-simulation-for-2d-model-by-setting-y-axis-as-a-single-value/255/1 "2021-09-02T21:30:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![thibaut.astic](https://yyz2.discourse-cdn.com/free1/user_avatar/simpeg.discourse.group/thibaut.astic/32/109_2.png) [@thibaut.astic](https://simpeg.discourse.group/u/thibaut.astic)\
**Post date:** [September 28, 2021, 3:44pm UTC](https://simpeg.discourse.group/t/gravity-is-it-possible-to-do-the-simulation-for-2d-model-by-setting-y-axis-as-a-single-value/255/2 "2021-09-28T15:44:50Z")

</div>

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:

```auto
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)

```

 ![image](https://global.discourse-cdn.com/free1/uploads/simpeg/original/1X/d23216a6d605f689910f6c24cae808019a93a0ac.png)

Maybe @domfournier would have more insights as well.

---

<div class="post-metadata">

**Author:** ![Astor](https://yyz2.discourse-cdn.com/free1/user_avatar/simpeg.discourse.group/astor/32/189_2.png) [@Astor](https://simpeg.discourse.group/u/Astor)\
**Post date:** [February 21, 2022, 3:22am UTC](https://simpeg.discourse.group/t/gravity-is-it-possible-to-do-the-simulation-for-2d-model-by-setting-y-axis-as-a-single-value/255/4 "2022-02-21T03:22:36Z")

</div>

Hi Thibaut,

Thank you so much for your reply and the example. It works. 😄

---

<div class="post-metadata">

**Author:** ![Astor](https://yyz2.discourse-cdn.com/free1/user_avatar/simpeg.discourse.group/astor/32/189_2.png) [@Astor](https://simpeg.discourse.group/u/Astor)\
**Post date:** [February 24, 2022, 11:55pm UTC](https://simpeg.discourse.group/t/gravity-is-it-possible-to-do-the-simulation-for-2d-model-by-setting-y-axis-as-a-single-value/255/5 "2022-02-24T23:55:02Z")

</div>

Hi @Thibaut,

I found that the 2D mesh can be equivalent by using one wide cell in the Y direction. However, it looks like the observation locations must be an (N, 3) Numpy array, and Y can not be set as a single value. If I set the Y location as a single value, I encountered the `QhullError: QH6154 Qhull precision error: Initial simplex is flat (facet 1 is coplanar with the interior point)`. Does that mean the survey still needs to be 3D? I was intended to simulate a 2D cross-well case. It seems that the 3D Gravity can not be modified directly. Thank you in advance for any responses!

---

<div class="post-metadata">

**Author:** ![daz](https://avatars.discourse-cdn.com/v4/letter/d/87869e/32.png) [@daz](https://simpeg.discourse.group/u/daz)\
**Post date:** [November 26, 2024, 4:11am UTC](https://simpeg.discourse.group/t/gravity-is-it-possible-to-do-the-simulation-for-2d-model-by-setting-y-axis-as-a-single-value/255/6 "2024-11-26T04:11:58Z")

</div>

Have you tried to make a duplicate of your observation data then shift the location just a few units? I’m not sure, but this could modify your data to be (N, 3) Numpy array.

PS. I also looking the way to do 2D simulation.
