Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
  • Welcome
  • Products
  • Support
  • About
  • More
  • Cancel
GeoStudio | PLAXIS
  • Product Communities
GeoStudio | PLAXIS
GeoStudio | PLAXIS Wiki Retrieving soil layer info from boreholes using Python
    • Sign In
    • -Geotechnical Analysis Wiki
      • +GeoStudio
      • -PLAXIS
        • +Software and License - PLAXIS
        • +Documentation - PLAXIS
        • -API / Python scripting - PLAXIS
          • Access to Staged Construction settings using Python
          • Adding functionality to PLAXIS Calculation Manager: pre- and post-processing
          • Automatic line cross-section chart generation using Python
          • Automatically generated cross-sections of embankments
          • Changing the material colour using Python scripting
          • Combined plate results in one chart using Python
          • Create custom connection with selection API
          • Damage assessment of adjacent buildings caused by excavations using the Burland's chart
          • Export and format plots from PLAXIS Output using Python
          • How to create a tunnel using Python
          • How to get a load - displacement curve using Scripting interface
          • How to identify the material name of an object in Output using Python scripting
          • How to install additional Python modules in PLAXIS
          • How to open and close a PLAXIS project with Python
          • How to retrieve results from PLAXIS Output by the node number
          • Identify Python commands from Plaxis command line
          • Material lists in PLAXIS – Python
          • Material Property changes for Python scripting
          • Optimize excavation calculation time for wall horizontal displacement criteria
          • Output scripting example: create curve data
          • Output scripting example: get anchor force
          • Output scripting example: get heave of excavation bottom
          • Output scripting example: get maximum bending moment
          • Polycurves to Polygons in PLAXIS 2D using Python
          • Receive instant notifications for finished calculations on your phone
          • Remove invalid custom connections for PLAXIS 3D
          • Retrieve coordinates of a Polygon in PLAXIS 2D using Python
          • Retrieving soil layer info from boreholes using Python
          • Scripting reference and how to use it
          • Selection API for PLAXIS Input
          • Soil layer material assignment using Python
          • Support capacity evaluation of a tunnel lining in PLAXIS 2D
          • Tunnel advancement script for PLAXIS 3D
          • User defined Python script (3D): Extract displacements by coordinates
        • +Known issues - PLAXIS
        • +Models - PLAXIS
        • +Tips and Tricks
        • +Publications
        • +Videos - PLAXIS
      • +PLAXIS Monopile Designer
      • +PLAXIS LE
      • +SOILVISION
      • +Geotechnical SELECT Entitlements [GSE]
      • +Subscription Entitlement Service

     
     Questions about this article, topic, or product? Click here. 

    Retrieving soil layer info from boreholes using Python

    Application PLAXIS 2D
    PLAXIS 3D
    Version PLAXIS 2D 2017
    PLAXIS 3D 2016
    Date created 03 March 2019
    Date modified 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.

    See also

    Using PLAXIS Remote scripting with the Python wrapper

    [Tips and Tricks]


    Identify Python commands from Plaxis command line

    [Python Scripts]


    Plaxis Soil model numbers in command line

    [Tips and Tricks]


    Soil layer material assignment using Python

    [Python Scripts]

    • PLAXIS 3D
    • python
    • API
    • py cookbook
    • soil layers
    • Automation
    • Scripting
    • PLAXIS
    • Remote scripting
    • cookbook
    • Borehole
    • python cookbook
    • soil layer
    • stratigraphy
    • PLAXIS 2D
    • Share
    • History
    • More
    • Cancel
    • Micha van der Sloot Created by Bentley Colleague Micha van der Sloot
    • When: Wed, Dec 18 2019 9:33 AM
    • Stefanos Papavasileiou Last revision by Bentley Colleague Stefanos Papavasileiou
    • When: Tue, Feb 15 2022 6:10 AM
    • Revisions: 3
    • Comments: 0
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies