Soil layer material assignment using Python


ApplicationPLAXIS 2D
PLAXIS 3D
VersionPLAXIS 2D 2017
PLAXIS 3D 2016
Date created21 August 2017
Date modified21 August 2017

When using boreholes in PLAXIS to define soil layers, Plaxis automatically creates soil polygons (2D) and soil volumes (3D) for these soil layers. When assigning materials to these soils, normally you would use a command in PLAXIS 2D like this:

Plaxis command
setmaterial Polygon_1.Soil Sand
Python equivalent
g_i.setmaterial(g_i.Polygon_1.Soil, g_i.Sand)

or

Plaxis command
set Polygon_1.Soil.Material Sand
Python equivalent
g_i.Polygon_1.Soil.Material = g_i.Sand

However, any soil layer might consist of any number of soil polygons, depending on the soil layer configuration (e.g. when a soil layer has zero thickness).
For this, you can also assign the material to the Soillayer objects. The Soillayers object is a listable that is updated after any change to the borehole soil layer settings and lists the Soillayer objects top-down.

Soil layer configuration in borehole

0010> echo Soillayers
    SoilLayerList named "Soillayers"
    Count: 5
    0/-5. Soillayer named "Soillayer_1"
    1/-4. Soillayer named "Soillayer_2"
    2/-3. Soillayer named "Soillayer_3"
    3/-2. Soillayer named "Soillayer_4"
    4/-1. Soillayer named "Soillayer_5"
    

To assign a new material to a newly added soil layer (not an inserted soil layer) you can use:

Plaxis command
setmaterial Soillayers[-1] Sand
Python equivalent
g_i.setmaterial(g_i.Soillayers[-1], g_i.Sand)

For more complex geometries, you can for example do this:

  1. Create a borehole
  2. Add all soil layers
  3. Then assign soil materials to each layer top-down

Example commands in PLAXIS 2D

borehole 0
soillayer 1  # add a soil layer with 1 m thickness 
soillayer 1
soillayer 1
soillayer 1
soillayer 1
set Soillayer_1.Soil.Material SoilMat_1  # assign material to the top soil layer 
set Soillayer_2.Soil.Material SoilMat_2  # assign material to the second layer 
set Soillayer_3.Soil.Material SoilMat_3  # assign material to the third layer 
set Soillayer_4.Soil.Material SoilMat_4  # assign material to the fourth layer 
set Soillayer_5.Soil.Material SoilMat_5  # assign material to the fifth and final layer 

Python solution

g_i.borehole(0)
# add soil layers, each 1 m thick:
g_i.soillayer(1)
g_i.soillayer(1)
g_i.soillayer(1)
g_i.soillayer(1)
g_i.soillayer(1)
# assign materials to the current configured soil layers
g_i.Soillayers[0].Soil.Material = g_i.SoilMat_1
g_i.Soillayers[1].Soil.Material = g_i.SoilMat_2
g_i.Soillayers[2].Soil.Material = g_i.SoilMat_3
g_i.Soillayers[3].Soil.Material = g_i.SoilMat_4
g_i.Soillayers[4].Soil.Material = g_i.SoilMat_5

This Python script can also be nicely written as:

g_i.borehole(0)
# add soil layers, each 1 m thick:
for i in range(5):
     g_i.soillayer(1)
# material list:
materials = [g_i.SoilMat_1, 
             g_i.SoilMat_2,
             g_i.SoilMat_3,
             g_i.SoilMat_4,
             g_i.SoilMat_5]
# assign materials to the current configured soil layers
for layer, material in zip(g_i.Soillayers, materials):
    layer.Soil.Material = material

Version

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

See also