<jupyter_start><jupyter_text>Issue 320: append Triangle Boundary effect in ERT sensistivity https://github.com/gimli-org/gimli/issues/320  Import pyGIMLi and the needed modules<jupyter_code>import pygimli as pg
from pygimli.physics import ert  # the module
import pygimli.meshtools as mt<jupyter_output><empty_output><jupyter_text>Load the data and create a world containing the electrodes as nodes.<jupyter_code>data = ert.load("simple.dat")
world2 = mt.createWorld(start=[-30, -20], end=[30, 0], marker=2, worldMarker=True)
for pos in data.sensorPositions():
    world2.createNode(pos)<jupyter_output><empty_output><jupyter_text>Standard modelling with the small meshCreate a mesh and map the resistivity to it (or take a constant vector instead).Set up a forward operator and compute forward response and Jacobian.<jupyter_code>mesh = mt.createMesh(world2, area=.2, quality=33, marker=2)
rhomap = [[2, 100]]
rhomodel = pg.solver.parseArgToArray(rhomap, mesh.cellCount(), mesh)
fop = ert.ERTModelling()
fop.setData(data)
fop.setMesh(mesh)
dr = fop.response(rhomodel)
ert.showData(data, vals=dr)
fop.createJacobian(rhomodel)
J = pg.utils.gmat2numpy(fop.jacobian())
ax, cb = pg.show(fop.paraDomain, J[0,:], cMin=-0.01, cMax=0.01, cMap="bwr");
ax.set_xlim([-30, 0])
ax.set_ylim([-10, 0])<jupyter_output><empty_output><jupyter_text>Generate a bigger mesh by appending a boundary that is triangulated.<jupyter_code>print(mesh)
bigMesh = pg.meshtools.appendTriangleBoundary(mesh, marker=1, xbound=250, ybound=250)
print(bigMesh)
pg.show(bigMesh, markers=True, showMesh=True)<jupyter_output>Mesh: Nodes: 5321 Cells: 10358 Boundaries: 15678
Mesh: Nodes: 5967 Cells: 11808 Boundaries: 17774<jupyter_text>Variant 1: use the boundary part as background(not part of model vector)<jupyter_code>fop1 = ert.ERTModelling()
fop1.setData(data)
fop1.setMesh(bigMesh)
fop1.setRegionProperties(1, background=True)
dr = fop1.response(rhomodel)
ert.showERTData(data, vals=dr)
fop1.createJacobian(rhomodel)
J1 = fop1.jacobian()
ax, cb = pg.show(fop1.paraDomain, J1[0,:], cMin=-0.01, cMax=0.01, cMap="bwr");
ax.set_xlim([-30, 0])
ax.set_ylim([-10, 0])<jupyter_output><empty_output><jupyter_text>Variant 2: include the boundary mesh into inversion<jupyter_code>fop2 = ert.ERTModelling()
fop2.setData(data)
fop2.setMesh(bigMesh)
rhomap2 = [[1, 100],[2, 100]]
rhomodel2 = pg.solver.parseArgToArray(rhomap2, bigMesh.cellCount(), bigMesh)
fop2.setRegionProperties(1, background=False)
dr = fop2.response(rhomodel2)
# ert.showERTData(data, vals=dr)
fop2.createJacobian(rhomodel2)
J2 = fop2.jacobian()
ax, cb = pg.show(fop2.paraDomain, J2[0,:], cMin=-0.01, cMax=0.01, cMap="bwr");
ax.set_xlim([-30, 0])
ax.set_ylim([-10, 0])<jupyter_output>06/08/21 - 09:22:28 - pyGIMLi - [0;32;49mINFO[0m - Found 2 regions.
06/08/21 - 09:22:28 - pyGIMLi - [0;32;49mINFO[0m - Region with smallest marker (1) set to background
06/08/21 - 09:22:28 - pyGIMLi - [0;32;49mINFO[0m - Creating forward mesh from region infos.
06/08/21 - 09:22:29 - pyGIMLi - [0;32;49mINFO[0m - Creating refined mesh (H2) to solve forward task.<jupyter_text>Variant 3: use the same marker for inner and outer mesh<jupyter_code>bigMesh3 = pg.meshtools.appendTriangleBoundary(mesh, marker=2, xbound=250, ybound=250)
fop3 = ert.ERTModelling()
fop3.setData(data)
fop3.setMesh(bigMesh3)
rhomodel3 = pg.Vector(bigMesh3.cellCount(), 100)
dr = fop3.response(rhomodel3)
# ert.showERTData(data, vals=dr)
fop3.createJacobian(rhomodel3)
J3 = pg.utils.gmat2numpy(fop3.jacobian())
ax, cb = pg.show(fop3.paraDomain, J3[0,:], cMin=-0.01, cMax=0.01, cMap="bwr")
ax.set_xlim([-30, 0])
ax.set_ylim([-10, 0])<jupyter_output>06/08/21 - 09:20:08 - pyGIMLi - [0;32;49mINFO[0m - Found 1 regions.
06/08/21 - 09:20:08 - pyGIMLi - [0;32;49mINFO[0m - Creating forward mesh from region infos.
06/08/21 - 09:20:08 - pyGIMLi - [0;32;49mINFO[0m - Creating refined mesh (H2) to solve forward task.
{'fraction_non_alphanumeric': 0.1500640204865557, 'fraction_numerical': 0.07887323943661972, 'mean_word_length': 6.193370165745856, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '629430', 'license': 'Apache-2.0', 'n_tokens_mistral': 1808, 'n_tokens_neox': 1607, 'n_words': 326, 'path': 'issues/320/issue320.ipynb', 'repo_name': 'gimli-org/notebooks', 'size': '3905'}