PLAXIS 2D + Python Scripting Tutorial 4

Stabilisation of a rock slope with fault discontinuities, cable reinforcement elements, retaining wall, backfill, and safety factor calculation.

⬇️ PDF

1️⃣ Introduction

This tutorial covers the stability analysis and stabilization of a rock slope containing a fault plane (discontinuity). It demonstrates how to model rock mass behaviour, ground reinforcement using cables, progressive road-cut excavation, retaining wall construction, backfilling, and safety factor (ΣMsf) evaluations.

Learning Objectives:

  • Construct complex rock slope model geometry.
  • Define Hoek–Brown rock mass and fault discontinuity elements (`discontinuitymat`).
  • Model elastoplastic pre-tensioned cable reinforcement elements (`cablemat`).
  • Simulate staged road-cut excavation, wall placement, and backfilling.
  • Perform safety factor analysis (ΣMsf) for intermediate excavation and final backfill stages.

2️⃣ Connect to the Remote Scripting Server

Ensure PLAXIS Input and Output servers are running on ports 10000 and 10001. Password is read from environment variable PLAXIS_PASSWORD for security.

import os
from pathlib import Path
from plxscripting.easy import *

PLAXIS_PASSWORD = os.getenv("PLAXIS_PASSWORD")
if not PLAXIS_PASSWORD:
    raise RuntimeError("Environment variable PLAXIS_PASSWORD is not set")

s_i, g_i = new_server('localhost', 10000, password=PLAXIS_PASSWORD)
s_o, g_o = new_server('localhost', 10001, password=PLAXIS_PASSWORD)

print("✅ Connected to PLAXIS Remote Scripting Server")

Use s_i/g_i for Input; s_o/g_o for Output program commands.

3️⃣ Start a New Project

Initialize a fresh model and set the project save path.

filepath = r"C:\Users\opengti\Plaxis_playground\tutorial_4"
s_i.new()
g_i.save(filepath)

Saving frequently preserves staged-construction states during iterative design.

4️⃣ Set Project Properties

Configure project title, comments, model type (Plane strain), and element type (15-Noded).

g_i.Project.Title.set("Lesson 4")
g_i.Project.Comments.set("Stabilisation of a rock slope")
g_i.Project.ModelType.set("plane strain")
g_i.Project.ElementType = "15-Noded"

5️⃣ Define Soil Contour

Set model boundaries: xmin = 0 m, xmax = 45 m, ymin = -13 m, ymax = 15 m.

g_i.SoilContour.initializerectangular(0, -13, 45, 15)

The bottom-left point is (0, -13) and top-right is (45, 15), forming the computational domain.

6️⃣ Create Soil & Rock Slope Polygons

Switch to Structures mode and create the main rock slope domain polygon.

g_i.gotostructures()

slope_polygon = g_i.polygon(
    (0, -13), (0, 15), (20, 15), (23.5, 13), (27, 10.5), (29, 8.5),
    (32, 6), (35, 4), (37, 2.5), (40, 0), (42.5, -1), (45, -2), (45, -13)
)[0]

The vertex coordinates define the realistic surface topography of the rock slope.

7️⃣ Define Materials (Hoek–Brown Rock & Fault Discontinuity)

Define the Hoek–Brown material model for the rock mass and a discontinuity material model for the geological fault.

# Hoek-Brown Rock Material
material_rock = g_i.soilmat("SoilModel", "Hoek-Brown")
rock_properties = [
    ("Identification", "Rock"),
    ("DrainageType", "Drained"), 
    ("gammaUnsat", 24), 
    ("gammaSat", 24), 
    ("Erm", 1_000_000), 
    ("nu", 0.25),
    ("AbsSigmaCI", 25_000),
    ("mi", 10),
    ("GSI", 39),
    ("Disturbance", 0),
    ("TensionCutOff", True),
    ("TensileStrength", 30),
    ("psiMax", 10),
    ("sigmaPsi", 0.50)
]
material_rock.setproperties(*rock_properties)
slope_polygon.Soil.setproperties("Material", material_rock)

# Discontinuity Fault Material
material_fault = g_i.discontinuitymat()
material_fault.setproperties(
    "Identification", "Fault",
    "MaterialType", "Mohr-Coulomb",
    "StrengthMethod", "Peak",
    "GapClosure", True,
    "NormalStiffness", 1.0e6,
    "ShearStiffness", 1.0e5,
    "cRef", 8.0,
    "phi", 25.0,
    "psi", 0.0
)

# Draw fault line and create discontinuity element
line_g = g_i.line((8, 15), (42, -13))[-1]
discontinuity_g = g_i.discontinuity(line_g, "Material", material_fault)

Discontinuities model plane joint sliding using normal stiffness, shear stiffness, cohesion, and friction angle.

8️⃣ Define Road-Cut Excavation Geometry

Define cutting lines for progressive multi-stage road excavation.

# 1. Slope face cut: from (20, 15) to (25, 0)
slope_face = g_i.line((20, 15), (25, 0))

# 2. Roadway bottom: from (25, 0) to (40, 0)
roadway = g_i.line((25, 0), (40, 0))

# 3. Stage boundary: horizontal line from (23, 6) to (32, 6)
stage_boundary = g_i.line((23, 6), (32, 6))

These geometry lines slice the rock mass polygon into staged excavation clusters.

9️⃣ Define Cable Reinforcement (Rock Bolts)

Define elastoplastic cable material with grout bond strength parameters and install 3 rock bolt cables.

# Cable material definition
material_cable = g_i.cablemat(
    "Identification", "Cable", 
    "MaterialType", "Elastoplastic",
    "LSpacing", 3.0,
    "CrossSectionType", "Predefined",
    "PredefinedCrossSectionType", "Solid circular beam",
    "Diameter", 0.0254, 
    "E", 98600000,
    "NpComp", 0.0,
    "Nptens", 548, 
    "KsBond", 15000000,
    "BondStrengthDistribution", "Uniform",
    "CohesiveStrengthBond", 800,
    "PhiBond", 20,
    "FailureSurfacePerimeter", "Predefined"
)

# Draw cable lines into stable rock mass
cable1 = g_i.line((21.5, 10.5), (11.5, 7))[-1]
cable2 = g_i.line((22.5, 7.5), (12.5, 4))[-1]
cable3 = g_i.line((23.5, 4.5), (13.5, 1))[-1]

cables_g = g_i.cable((cable1, cable2, cable3), "Material", material_cable)

Cables model rock bolts with tensile yield capacity (`Nptens`) and skin resistance along the grout-rock interface (`KsBond`, `CohesiveStrengthBond`).

🔟 Retaining Wall & Backfill Geometries

Create materials and soil polygons for the concrete retaining wall and engineered backfill.

# Retaining wall material (Mohr-Coulomb Non-porous)
material_wall = g_i.soilmat("SoilModel", "Mohr-Coulomb")
wall_properties = [
    ("Identification", "Retaining wall"),
    ("DrainageType", "Non-porous"), 
    ("gammaUnsat", 24), 
    ("ERef", 27_000_000), 
    ("nu", 0.15),
    ("cRef", 500),
    ("phi", 35),
    ("psi", 5),
    ("TensionCutOff", True),
    ("TensileStrength", 750), 
]
material_wall.setproperties(*wall_properties)

# Backfill material (Mohr-Coulomb Drained)
material_backfill = g_i.soilmat("SoilModel", "Mohr-Coulomb")
backfill_properties = [
    ("Identification", "Backfill"),
    ("DrainageType", "Drained"), 
    ("gammaUnsat", 20),
    ("gammaSat", 20), 
    ("ERef", 100_000), 
    ("nu", 0.3),
    ("cRef", 5),
    ("phi", 45),
    ("psi", 15),
]
material_backfill.setproperties(*backfill_properties)

# Wall and Backfill Polygons
polygon_wall = g_i.polygon((25.5, 0), (25.5, 3), (26.5, 3), (26.5, 0))[0]
polygon_wall.Soil.setproperties("Material", material_rock)

polygon_fill = g_i.polygon((25.5, 0), (25.5, 3), (24, 3), (25, 0))[0]
polygon_fill.Soil.setproperties("Material", material_rock)

Polygons are initially assigned initial rock properties and later activated with wall and backfill materials during staged construction.

1️⃣1️⃣ Finite Element Mesh & Output Selection

Generate finite element mesh and select monitoring curve points.

g_i.gotomesh()
g_i.mesh(0.06)  # medium coarseness factor
print("✅ Mesh generated successfully")

output_port = g_i.selectmeshpoints()
g_o.addcurvepoint('node', (23, 6))
g_o.update()

The monitoring node at (23, 6) tracks deformation near the slope face across all stages.

1️⃣2️⃣ Staged Construction & Safety Analysis

Setup initial state, 6 construction stages, and 2 safety factor (ΣMsf) calculations.

g_i.gotostages()

# Initial Phase: activate all polygons & discontinuities
phase0_s = g_i.InitialPhase
for polygon in g_i.Polygons:
    polygon.activate(phase0_s)
for item in g_i.Discontinuities:
    item.activate(phase0_s)

# Phase 1: First Excavation Stage (top 9m)
phase1_excavation = g_i.phase(phase0_s)
phase1_excavation.Name.set("First_excavation_stage")
phase1_excavation.Identification.set("Phase 1: First excavation stage")
g_i.Polygon_1_2.deactivate(phase1_excavation)

# Phase 2: Installation & Prestressing of First 2 Cables
phase2_cables = g_i.phase(phase1_excavation)
phase2_cables.Name.set("Installation_of_first_two_rows_of_cables")
phase2_cables.Identification.set("Phase 2: Installation of first two rows of cables")
g_i.Cable_1_1.activate(phase2_cables)
g_i.Cable_2_1.activate(phase2_cables)
g_i.Cable_1_1.AdjustPrestress.set(phase2_cables, True)
g_i.Cable_1_1.PrestressForce.set(phase2_cables, 200)
g_i.Cable_2_1.AdjustPrestress.set(phase2_cables, True)
g_i.Cable_2_1.PrestressForce.set(phase2_cables, 200)

# Phase 3: Second Excavation Stage (down to 0m)
phase3_excavation = g_i.phase(phase2_cables)
phase3_excavation.Identification.set("Phase 3: Second excavation stage")
g_i.Polygon_1_6.deactivate(phase3_excavation)
g_i.Polygon_2.deactivate(phase3_excavation)
g_i.Polygon_3.deactivate(phase3_excavation)

# Phase 4: Installation of Third Cable
current_phase = g_i.phase(phase3_excavation)
current_phase.Identification.set("Phase 4: Installation of third cable")
g_i.Cable_3_1.activate(current_phase)
g_i.Cable_3_1.AdjustPrestress.set(current_phase, True)
g_i.Cable_3_1.PrestressForce.set(current_phase, 200)

# Phase 5: Construction of Retaining Wall
current_phase = g_i.phase(current_phase)
current_phase.Identification.set("Phase 5: Construction of retaining wall")
g_i.Polygon_2.activate(current_phase)
g_i.Polygon_2.setmaterial(current_phase, material_wall)

# Phase 6: Backfilling
phase6 = g_i.phase(current_phase)
phase6.Identification.set("Phase 6: Backfilling")
g_i.Polygon_3.activate(phase6)
g_i.Polygon_3.setmaterial(phase6, material_backfill)

# Phase 7: Safety Analysis after 2nd Excavation
phase7 = g_i.phase(phase3_excavation)
phase7.Identification.set("Phase 7: Safety analysis after second excavation")
phase7.DeformCalcType = "safety"
phase7.Deform.UseDefaultIterationParams = False
phase7.Deform.MaxSteps = 180

# Phase 8: Safety Analysis after Backfilling
phase8 = g_i.phase(phase6)
phase8.Identification.set("Safety analysis after backfilling")
phase8.DeformCalcType = "safety"
phase8.Deform.UseDefaultIterationParams = False
phase8.Deform.MaxSteps = 180

# Calculate & Save Project
g_i.calculate()
g_i.save(filepath)

Safety calculation (`DeformCalcType = "safety"`) reduces soil/rock shear strength parameters c and tan(φ) until failure to compute the safety factor.

🔧 Summary

This tutorial demonstrated key rock engineering features in PLAXIS 2D:

  • Hoek–Brown constitutive rock mass model parameterization.
  • Geological fault joint modeling using `discontinuitymat` elements.
  • Elastoplastic rock bolts using `cablemat` with pre-tensioning force (200 kN).
  • Staged excavation sequence combined with retaining wall construction and engineered backfill.
  • Strength reduction safety factor calculation (ΣMsf) for intermediate excavation and final completed slope states.
Next-step idea
# Inspect safety factor results (SumMsf) in Output
print(f"Safety factor after 2nd excavation: {g_o.Phases[7].Result.SumMsf}")
print(f"Safety factor after backfilling: {g_o.Phases[8].Result.SumMsf}")