PLAXIS 2D + Python Scripting Tutorial 3

Submerged excavation with diaphragm wall, interfaces, anchors, and staged construction.

⬇️ PDF

1️⃣ Introduction

This tutorial walks through a submerged excavation using a diaphragm wall, interfaces, and a fixed-end anchor. It reuses concepts from Tutorial 1 and adds staged excavation, anchor activation, and water pressures.

Objectives:

  • Model soil–structure interaction with interfaces.
  • Use the Hardening Soil model with drained sand and undrained clay.
  • Define a fixed-end anchor and strut material.
  • Simulate staged excavation with multiple phases.

2️⃣ Connect to the Remote Scripting Server

Ensure PLAXIS Input and Output servers run on ports 10000 and 10001. Store the password in an environment variable 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.

3️⃣ Start a New Project

Clear the model and save a new project.

s_i.new()
g_i.save(r'C:\\Users\\username\\Desktop\\software playground\\Plaxis_playground\\tutorials\\tutorial_3')

Save often to preserve staged-construction states.

4️⃣ Set Project Properties

Set title, comments, model type, and element type.

g_i.Project.Title.set("Lesson 3")
g_i.Project.Comments.set("Submerged construction of an excavation")
g_i.Project.ModelType.set("plane strain")
g_i.Project.ElementType = "15-Noded"

5️⃣ Define Soil Contour

Set model boundaries: xmin = 0, xmax = 65 m, ymin = -30 m, ymax = 20 m.

g_i.SoilContour.initializerectangular(0, -30, 65, 20)

This rectangle bounds the computational domain.

6️⃣ Create Boreholes & Soil Layers

Create a borehole at x = 0 m and define stratigraphy.

borehole_BH_1 = g_i.borehole(0)

# First layer: top 20 m (20 to 0)
g_i.soillayer(20)
g_i.setsoillayerlevel(borehole_BH_1, 0, 20)
g_i.setsoillayerlevel(borehole_BH_1, 1, 0)

# Second layer: 30 m thickness
g_i.soillayer(30)

# Groundwater head
borehole_BH_1.Head = 18

Use echo() to inspect borehole attributes when needed.

7️⃣ Define Materials (Hardening Soil)

Create drained sand and undrained clay materials using the Hardening Soil model.

material_sand = g_i.soilmat("SoilModel", "Hardening Soil")
sand_properties = [
    ("Identification", "Sand"),
    ("DrainageType", "Drained"),
    ("gammaUnsat", 17),
    ("gammaSat", 20),
    ("E50Ref", 40_000),
    ("EOedRef", 40_000),
    ("EURRef", 120_000),
    ("nuUR", 0.2),
    ("PowerM", 0.5),
    ("cRef", 0),
    ("phi", 32),
    ("psi", 2),
    ("UseDefaults", False),
    ("K0NC", 0.4701),
]
material_sand.setproperties(*sand_properties)

material_clay = g_i.soilmat("SoilModel", "Hardening Soil")
clay_properties = [
    ("Identification", "Clay"),
    ("DrainageType", "Undrained A"),
    ("gammaUnsat", 16),
    ("gammaSat", 18),
    ("E50Ref", 4_000),
    ("EOedRef", 3_300),
    ("EURRef", 12_000),
    ("nuUR", 0.15),
    ("PowerM", 1),
    ("cRef", 1),
    ("phi", 25),
    ("psi", 0),
    ("UseDefaults", False),
    ("K0NC", 0.5774),
]
material_clay.setproperties(*clay_properties)

# Assign to soil clusters
g_i.Soils[0].Material = material_clay
g_i.Soils[1].Material = material_sand

Hardening Soil captures stress-dependent stiffness; Undrained A uses total-stress strength with undrained stiffness.

8️⃣ Structural Elements: Diaphragm Wall, Interfaces, Anchor

Switch to Structures mode, create a wall plate with interfaces, and add a fixed-end anchor.

g_i.gotostructures()

# Plate material for diaphragm wall
material_wall = g_i.platemat("MaterialType", "elastic")
d_wall_parameters = [
    ("Identification", "Diaphragm Wall"),
    ("w", 10),
    ("PreventPunching", False),
    ("Isotropic", True),
    ("EA1", 7_500_000),
    ("EI", 1_000_000),
    ("StructNu", 0),
]
material_wall.setproperties(*d_wall_parameters)

# Draw wall line and create plate
line_g = g_i.line((50, 20), (50, -10))[-1]
plate_g = g_i.plate(line_g)
plate_g.Material = material_wall

# Interfaces on both sides
pos_interface = g_i.posinterface(line_g)
neg_interface = g_i.neginterface(line_g)

# Excavation reference lines
exc_level_1 = g_i.line((50, 18), (65, 18))[-1]
exc_level_2 = g_i.line((50, 10), (65, 10))[-1]

# Fixed-end anchor and strut material
point_g = g_i.point(50, 19)
fixedendanchor_g = g_i.fixedendanchor(point_g)
fixedendanchor_g.Direction_x = 15
strut_material = g_i.anchormat(
    "Identification", "Strut",
    "MaterialType", "Elastic",
    "EA", 2_000_000,
    "LSpacing", 5
)
fixedendanchor_g.Material = strut_material
fixedendanchor_g.Material.Colour = 16210946

Interfaces allow relative slip between soil and structure; anchors add horizontal support above the excavation.

9️⃣ Apply Line Load

Create a surface line load acting downward.

line_load_ref = g_i.line((43, 20), (48, 20))[-1]
lineloads_g = g_i.lineload(line_load_ref)
lineloads_g.qy_start = -5  # negative = downward

Only qy_start is set, so the load is uniform along the line.

🔟 Mesh & Output Points

Generate the mesh and add a monitoring point in Output.

g_i.gotomesh()
g_i.mesh(0.06)  # optional global coarseness
print("✅ Mesh generated successfully")

output_port = g_i.selectmeshpoints()
g_o.addcurvepoint('node', g_o.Soil_1_3, (50, 10))
g_o.update()

Curve points let you track settlement or forces at specific locations.

1️⃣1️⃣ Staged Construction & Calculation

Create phases for loading, excavation, and anchor activation, then run the analysis.

g_i.gotostages()

# Phase 1: load + wall
phase1 = g_i.phase(g_i.Phases[0])
phase1.Identification = "Phase 1 - External Load"
g_i.LineLoads[0].Active[phase1] = True
for plate in g_i.Plates:
    plate.Active[phase1] = True
for interface in g_i.Interfaces:
    interface.Active[g_i.Phases[1]] = True

# Phase 2: first excavation
phase2 = g_i.phase(g_i.Phases[1])
phase2.Identification = "Phase 2 - First Excavation Stage"
g_i.BoreholePolygon_1_1.deactivate(g_i.Phases[2])

# Phase 3: install strut
phase3 = g_i.phase(g_i.Phases[2])
phase3.Identification = "Phase 3 - Installation of a strut"
g_i.FixedEndAnchors[0].activate(g_i.Phases[3])

# Phase 4: submerged excavation
phase4 = g_i.phase(g_i.Phases[3])
phase4.Identification = "Phase 4 - Second (submerged) excavation stage"
g_i.BoreholePolygon_1_2.deactivate(g_i.Phases[4])

# Phase 5: third excavation
phase5 = g_i.phase(g_i.Phases[4])
phase5.Identification = "Phase 5 - Third excavation stage"
g_i.BoreholePolygon_1_4.deactivate(g_i.Phases[5])

# Solve and save
g_i.calculate()
from pathlib import Path
project_path = Path.cwd() / "tutorial_3"
g_i.save(str(project_path))

Adjust phase sequence or deactivations to match your geometry and excavation plan.

🔧 Summary

This tutorial covered:

  • Connecting securely to PLAXIS via the Remote Scripting API.
  • Setting up plane-strain model bounds and groundwater head.
  • Building stratigraphy and assigning Hardening Soil materials.
  • Creating a diaphragm wall with interfaces and a fixed-end anchor.
  • Applying line loads, meshing, and selecting output points.
  • Running multi-stage excavation with phased activation/deactivation.
Next-step idea
# Inspect available curve points in Output
for curve in g_o.CurvePoints:
    print(curve.Name, curve.y)