Retrieving soil layer info from boreholes using Python

03 March 2019

PLAXIS 2019, CONNECT Edition and later

Since PLAXIS 2D 2019, the Input program has an improved way of modelling soil layers. As an addition to the “Modify Soil Layers” window, the soil stratigraphy is now also available in the model explorer under “Stratigraphy”. The “Boreholes” group is now also moved here. Users can, for example, change the layer thickness or top and bottom depths directly via the Model explorer, instead of only relying on the “Modify Soil Layers” window. The changes are also reflected in the command line, giving users who use Python scripting a better structure to access the soil layers information in the model.

With the new PLAXIS 2019 implementation, we have introduced a new item called Stratigraphy which is split into two parts: Boreholes and Soil layers:

Stratigraphy in the Model Explorer

  • Under the Borehole group, all the different boreholes are stored with some relevant information (e.g. location of the borehole, water head etc).
  • Under the Soil layers group, the horizontal soil layers are stored with their height for the different boreholes.

The Python script below shows how to return a list of dictionaries with the following relevant info: soil layer's name, top, bottom and thickness.

def get_borehole_layers(borehole):
    """ reads the borehole information to collect soillayer thickness
        information and returns a dictionary per layer top-down """
    borehole_layers = []
    for soillayer in g_i.Soillayers:
        for zone in soillayer.Zones:
            if (zone.Borehole.value) == borehole:
                borehole_layers.append({"name": soillayer.Name.value,
                                        "top": zone.Top.value,
                                        "bottom": zone.Bottom.value,
                                        "thickness": zone.Thickness.value
                                        }
                                       )
    return borehole_layers

boreholelayers = get_borehole_layers(g_i.Borehole_1)

for boreholelayer in boreholelayers:
    print(boreholelayer)

When using this code for 2D's Tutorial Lesson 2, this will be the result:

  Python response in interpreter 


>>> 
{'name': 'Soillayer_1', 'bottom': 0, 'thickness': 20, 'top': 20}
{'name': 'Soillayer_2', 'bottom': -30, 'thickness': 30, 'top': 0}
>>>

Soil layer in previous PLAXIS versions

In older versions (e.g. PLAXIS 2D 2018, 3D 2018) the information was only stored in the
Borehole object.

In each borehole, the information is stored for the different soil layers and their height. The Python script below returns a list of dictionaries with the relevant info: the soil layer's name, top, bottomand thickness.
The Soillayers will be sorted top-down.

import re

def get_borehole_layers(borehole):
    results = []
    for line in borehole.echo().splitlines():
        # Try to match something like:
        # "Layer 4: From -19 to -21 (thickness = 2)"
        m = re.search('(Layer .*): From (.*) to (.*) \(thickness = (.*)\)',
                      line)
        if m is not None:
            results.append({'name': m.group(1),
                            'top': float(m.group(2)),
                            'bottom': float(m.group(3)),
                            'thickness': float(m.group(4))})
    return results


# for a model with at least two soil layers
print(get_borehole_layers(g_i.Borehole_1)[1]) # prints the dict
print(get_borehole_layers(g_i.Borehole_1)[1]["top"]) # prints the top level value

The script uses the re module for regular expressions.

Version

The first example was made with PLAXIS 2D 2019.00 using Python 3.4.x.

The above examples are made with PLAXIS 2D 2017.00 and PLAXIS 3D 2016.02 using Python 3.4.x.

Related posts

Privacy Preference Center

Necessary

The Cookies are necessary for the site to function

CONSENT, NID, _cfduid, wp-settings-time-16, wp-setting-16, wordpress_test_cookie, gdpr[allowed_cookies], gdpr[consent_types], wp_woocommerce_session, wordpress_logged_in, wordpress_sec, PHPSESSID

Advertising

These Cookies are used to provide you with useful information based on recent browser data

_gads
UserMatchHistory, lang, BizoID
IDE
fr
NID
lidc, bcookie

Analytics

These are used to track user interaction and detect potential problems. These help us improve our services by providing analytical data on how users use this site

_ga, _gid

Other