Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERT forward problem with topographic effect #797

Open
dhhien1503 opened this issue Dec 9, 2024 · 3 comments
Open

ERT forward problem with topographic effect #797

dhhien1503 opened this issue Dec 9, 2024 · 3 comments

Comments

@dhhien1503
Copy link

Problem description

Hi developer,

Thank you for very useful package on the ERT inversion. I have a geomodel which I interpreted it from geotechnical drilling data. I would like to do ERT forward modeling in order to do design the electric imaging survey for further field implementation. I create the FEM grid as suggested from the tutorial for each block of geobody, and assign resistivity values for each block. However at the end of simulation, it failed. Here I attached the notebook together of data for each geobody in zip file.
issues.zip

Your helps to figure out the errors of this procedure are sincerely apprecicated.

Kind regards,
Hien

Your environment

Please provide the output of print(pygimli.Report()) here. If that does not
work, please give provide some additional information on your:

Operating system: e.g. Windows, Linux or Mac?
Python version: e.g. 3.9, 3.10, etc.?
pyGIMLi version: Output of print(pygimli.__version__)
Way of installation: e.g. Conda package, manual compilation from source, etc.

Steps to reproduce

Tell us how to reproduce this issue. Ideally, you could paste the code that produces the error:

import pygimli as pg
...

Expected behavior

Tell us what should happen or what you want to achieve.

Actual behavior

Tell us what happens instead and/or provide the output of your script.

Paste your script output here.

If possible, please add one or more labels to your issue, e.g. if you expect that your issue is rather a question than a problem with the code, please add the label "question".

@halbmy
Copy link
Contributor

halbmy commented Dec 9, 2024

Dear user, this is not a helpdesk to drop the own work without but an issue tracker where users and developers help each other. Therefore we provided a mask about general points (What you intend to do, what you expect, what happens or what exactly the error is, which version you're using etc.). By filling this information others can learn from it and people find the problem and its solution. So, please, fill out the form, insert codes, images, error messages that makes it a story and you'll have the chance to find people helping you.

@dhhien1503
Copy link
Author

dhhien1503 commented Dec 9, 2024

Dear Thomas,

Thank you for clarification.

The main purpose this job is that I would like to make a forward modeling for the EI survey with the topographic effect.

The following is my procedure:

  1. Create a grid using the topographic data (define the region of simulation)
  2. Define some geobody within that region using meshtool (mt.createPolygon)
  3. Fill the resistivity values for each geobody and do simulation with given electrode configuration (say dd or wn)

Once the forward modeling finish, I would like to do inversion to see whether with the given configuration I would detect the thin week soil beneath a depth of 15 to 20m. If it can I can go to the field to do the survey with the planned configuration.

Here is step by step of code to do that:

# 1 import neccessary package 
import numpy as np
import pygimli as pg
import pygimli.meshtools as mt
from pygimli.physics import ert
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# 2 read the geobody polygon point for setting up
reg1 = pd.read_csv('regions12.dat', header=None, names=["X", "Z", "LogRho"])
reg2 = pd.read_csv('regions2.dat', header=None, names=["X", "Z", "LogRho"])
reg3 = pd.read_csv('regions3.dat', header=None, names=["X", "Z", "LogRho"])
reg4 = pd.read_csv('regions4.txt', header=None, names=["X", "Z", "LogRho"])
reg5 = pd.read_csv('regions5.dat', header=None, names=["X", "Z", "LogRho"])
reg6 = pd.read_csv('regions6.dat', header=None, names=["X", "Z", "LogRho"])
xz1=reg1[['X','Z']].values
xz2=reg2[['X','Z']][:-2].values
xz3=reg3[['X','Z']].values
xz4=reg4[['X','Z']].values
xz5=reg5[['X','Z']].values
xz6=reg6[['X','Z']].values
#3 Create the computing grid within above geobody 
plc1 = mt.createPolygon(xz1, isClosed=True,
                       addNodes=3,interpolate='spline',marker=1,)
plc2 = mt.createPolygon(xz2, isClosed=True,
                       addNodes=3, interpolate='spline',marker=2,)
plc3 = mt.createPolygon(xz3, isClosed=True,
                       addNodes=3, interpolate='spline',marker=3,)
plc4 = mt.createPolygon(xz4, isClosed=True,
                       addNodes=3, interpolate='spline',marker=4,)
plc5 = mt.createPolygon(xz5, isClosed=True,
                       addNodes=3, interpolate='spline',marker=5,)
plc6 = mt.createPolygon(xz6, isClosed=True,
                       addNodes=3, interpolate='spline',marker=6,)
geom = plc1 + plc2 + plc3 + plc4+ plc5 + plc6 

ax, cb = pg.show(geom)

Geomodel

#4. fill the resistivity for each geobody
rhomap = [[0, 2000],
          [1, 2000],
          [2, 90],
          [3, 50],
          [4, 100],
          [5, 300],
         [6, 30]]

# Take a look at the mesh and the resistivity distribution
pg.show(mesh, data=rhomap, label=pg.unit('res'), showMesh=True)
#5. Read the electrode position (x,z) and define the scheme accordingly 
topo=pd.read_excel('Line1_electrode_pos.xlsx')
scheme = ert.DataContainer()
x=topo['X-location'].values
z=topo['Z-location'].values
for i,xi in enumerate(x):
    scheme.createSensor([xi, z[i]])
scheme.name='dd'
for p in scheme.sensors():
    geom.createNode(p)
    geom.createNode(p - [0, 0.1])
#6. do EI simulation as
data = ert.simulate(mesh, scheme=scheme, res=rhomap, noiseLevel=1,
                    noiseAbs=1e-6, seed=1337)

However the errors happened as follows:

RuntimeError Traceback (most recent call last)
Cell In[7], line 1
----> 1 data = ert.simulate(mesh, scheme=scheme, res=rhomap, noiseLevel=1,
2 noiseAbs=1e-6, seed=1337)

File ~\AppData\Roaming\Python\Python311\site-packages\pygimli\physics\ert\ert.py:124, in simulate(mesh, scheme, res, **kwargs)
122 # fop = self.createForwardOperator(useBert=True, sr=sr, verbose=verbose)
123 fop.data = scheme
--> 124 fop.setMesh(mesh, ignoreRegionManager=True)
125 cI = kwargs.pop("contactImpedances", None)
126 if cI is not None:

File ~\AppData\Roaming\Python\Python311\site-packages\pygimli\frameworks\modelling.py:747, in MeshModelling.setMesh(self, mesh, ignoreRegionManager)
744 super(Modelling, self).setMesh(mesh, ignoreRegionManager=True)
745 pass
--> 747 self.setMeshPost(mesh)
748 return
750 # copy the mesh to the region manager who renumber cell markers

File ~\AppData\Roaming\Python\Python311\site-packages\pygimli\physics\ert\ertModelling.py:231, in ERTModelling.setMeshPost(self, mesh)
229 def setMeshPost(self, mesh):
230 """Set mesh (at a later stage)."""
--> 231 self._core.setMesh(mesh, ignoreRegionManager=True)

RuntimeError: ./core/src/mesh.cpp:928 GIMLI::Cell* GIMLI::Mesh::findCell(const GIMLI::RVector3&, size_t&, bool) const no cells or boundaries for this node. This may be a corrupt mesh

I attached the input file for above code here, and please help me to figure out the errors that I have made.

Line1_electrode_pos.xlsx
regions4.txt
regions2.txt
regions3.txt
regions6.txt
regions5.txt
regions12.txt

@halbmy
Copy link
Contributor

halbmy commented Dec 13, 2024

In your code you use mesh before creating it:

pg.show(mesh, data=rhomap, label=pg.unit('res'), showMesh=True)

I guess there is some mesh.createMesh(geom) missing. But you show the mesh and then you still add the electrodes.

From the message I can hardly deduce the problem, but I guess the electrodes are (slightly) outside the mesh. Can you plot them and zoom in or use mesh.findCell(data.sensor(i)). I suggest using the electrode positions to create the mesh topography.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants