1.3. First modelling#

This first modeling tutorial solves the stationary heat equation in 2D, an example from the pyGIMLi paper [Rücker et al., 2017], Examples here.

import pygimli as pg
import pygimli.meshtools as mt

Create geometry definition for the modelling domain.

world = mt.createWorld(start=[-20, 0], end=[20, -16], layers=[-2, -8],
                       worldMarker=False)
# Create a heterogeneous block
block = mt.createRectangle(start=[-6, -3.5], end=[6, -6.0],
                           marker=4,  boundaryMarker=10, area=0.1)
# Merge geometrical entities
geom = world + block
ax, cb = pg.show(geom, markers=True)
../../../_images/78e587eb0efc7beb9b9ddd913ce7e6e0d568a08beb8c1fda01356ce040922ee3.png

Create a mesh from based on the geometry definition. When calling the pg.meshtools.createMesh() function, a quality parameter can be forwarded to Triangle, which prescribes the minimum angle allowed in the final mesh.

mesh = mt.createMesh(geom, quality=33, area=0.2, smooth=[1, 10])
ax, _ = pg.show(mesh)
../../../_images/ba427aab12114a0e18221cbb72cef7282fc1bc66e285fc353ce6ec8979c5c839.png

Call pygimli.solver.solveFiniteElements() to solve the heat diffusion equation \(\nabla\cdot(a\nabla T)=0\) with \(T(bottom)=0\) (boundary marker 4) and \(T(top)=1\) (boundary marker 8), where \(a\) is the thermal diffusivity and \(T\) is the temperature distribution. We assign thermal diffusivities to the four # regions using their marker numbers in a dictionary (a) and the fixed temperatures at the boundaries using Dirichlet boundary conditions with the respective markers in another dictionary (bc)

T = pg.solver.solveFiniteElements(mesh,
                                  a={1: 1.0, 2: 2.0, 3: 3.0, 4:0.1},
                                  bc={'Dirichlet': {8: 1.0, 4: 0.0}}, verbose=True)
ax, _ = pg.show(mesh, data=T, label='Temperature $T$',
                cMap="hot_r", nCols=8, contourLines=False)

ax, _ = pg.show(geom, ax=ax, fillRegion=False)
Mesh:  Mesh: Nodes: 3011 Cells: 5832 Boundaries: 8842
Assembling time:  0.039613328
Solving time:  0.012903979
../../../_images/6da5b2f52461b37beed2ecd07d5afc3370154e338a831541362569f5550c9baa.png