PLAXIS 2D + Python Scripting Tutorial 1

Automating a circular footing settlement analysis using the PLAXIS Remote Scripting API.

⬇️ PDF

1️⃣ Introduction

This tutorial shows how to control PLAXIS 2D using Python via the Remote Scripting API, inside a Jupyter Notebook.

When you create a notebook from PLAXIS Input, two key objects are available:

  • s_i – the Input server object (sends commands to PLAXIS Input).
  • g_i – the global Input object (access to project data: geometry, materials, etc.).

Similarly, for PLAXIS Output you have s_o and g_o.

from plxscripting.easy import *
user_password = "input your own password"

# Connect to PLAXIS Input (port 10000) and Output (port 10001)
s_i, g_i = new_server('localhost', 10000, password=user_password)
s_o, g_o = new_server('localhost', 10001, password=user_password)

Make sure PLAXIS Input and Output are running with Remote Scripting enabled on ports 10000 and 10001 before running this cell.

2️⃣ Start a New Project

We start with a clean model by telling PLAXIS Input to create a new project, then saving it to disk.

# Start a new project
s_i.new()

# Save the project to disk
g_i.save(r'C:\Users\opengti\Plaxis_playground\tutorial_1')

Regular saving is good practice, especially when scripting, to avoid losing a working state.

3️⃣ Set Project Properties

PLAXIS stores metadata such as title, comments, and model type in the Project object. For a circular footing, an axisymmetric model is appropriate.

# Inspect project if needed:
# print(g_i.Project.echo())
# dir(g_i.Project)

g_i.Project.Title.set("Lesson 1")
g_i.Project.Comments.set("Settlement of a circular footing")
g_i.Project.ModelType.set("axisymmetry")

# Define soil contour (model boundaries)
g_i.SoilContour.initializerectangular(0, 0, 5, 4)

The soil contour sets the computational domain (here: x from 0 to 5 m, y from 0 to 4 m). In axisymmetry, the line at x = 0 represents the axis of rotation; a line from (0, 4) to (1, 4) is a radius of 1 m in 3D.

4️⃣ Create Boreholes & Soil Layers

Boreholes define vertical reference lines where soil layer elevations and groundwater levels are specified.

# Add a borehole at x = 0
borehole_g = g_i.borehole(0)

# Define a soil layer boundary at y = 4 m
layer_g = g_i.soillayer(4)
layer_g.y = 4

# Set groundwater head (water table) at 2 m
borehole_g.Head = 2

The borehole and layer definition control how soil layers are distributed across the soil contour and how groundwater is applied in the model.

5️⃣ Define Soil Material (Sand)

Soil materials are created with soilmat(). Here we define a drained Mohr–Coulomb sand and assign it to the soil cluster.

# Create a new soil material (SoilModel = 2 → Mohr-Coulomb)
material_sand = g_i.soilmat("SoilModel", 2)

# Define properties using a list of (name, value) pairs
sand_properties = [
    ("Identification", "Sand"),
    ("SoilModel", 2),
    ("DrainageType", 0),   # drained
    ("gammaUnsat", 17),
    ("gammaSat", 20),
    ("ERef", 13000),
    ("nu", 0.3),
    ("cRef", 1),
    ("phi", 30),
]

material_sand.setproperties(*sand_properties)

# Assign this material to the first soil cluster
g_i.Soils[0].Material = material_sand

Using setproperties(*sand_properties) is a clean way to pass many parameters at once and makes it easier to reuse or modify later.

6️⃣ Create Structural Elements (Footing Plate)

Footings can be modelled as plate elements. We first define a plate material, then draw a line at the surface and convert it into a plate.

# Switch to Structures mode
g_i.gotostructures()

# Create a plate material for the footing
material_footing = g_i.platemat("MaterialType", 1)

footing_parameters = [
    ("Identification", "Footing"),
    ("MaterialType", 1),
    ("PreventPunching", False),
    ("Isotropic", True),
    ("EA1", 500000),
    ("EI", 8500),
    ("StructNu", 0),
]
material_footing.setproperties(*footing_parameters)

# Draw a line at ground level (y = 4 m)
# Use [-1] to select the most recently created line
line_g = g_i.line((0, 4), (1, 4))[-1]

# Create a plate element on the line and assign material
plate_g = g_i.plate(line_g)
plate_g.Material = material_footing

The line between (0, 4) and (1, 4) represents the footing radius in an axisymmetric model. The plate carries the footing stiffness and load.

7️⃣ Apply Line Load on the Footing

A line load is used to represent the vertical pressure applied by the footing.

# Create a line load on the footing line
lineloads_g = g_i.lineload(line_g)

# Set the vertical load (negative = downward)
lineloads_g.qy_start = -188

In PLAXIS convention, downward vertical loads are negative (qy_start < 0), so a negative value represents compression on the footing.

8️⃣ Generate the Mesh & Select Output Point

Before running calculations, the model must be meshed. We then specify a point in Output where we want to monitor results (e.g. footing settlement).

# Go to Mesh mode and generate the mesh
g_i.gotomesh()
g_i.mesh()

# Select a monitoring point in Output (e.g. at footing centre)
g_o.addcurvepoint('node', g_o.Soil_1_1, (0, 4))
g_o.update()

The curve point at (0, 4) will allow you to extract settlement vs. load or vs. time in PLAXIS Output.

9️⃣ Define Calculation Phase & Run Analysis

Calculations in PLAXIS are organised into phases. Here we create a new phase based on the initial one, activate the footing and load, and run the analysis.

# Switch to Staged Construction mode
g_i.gotostages()

# Create a new phase based on the initial phase
phase1 = g_i.phase(g_i.Phases[0])

# Activate the line load and plate in this phase
g_i.LineLoads[0].Active[phase1] = True
g_i.Plates[0].Active[phase1] = True

# Run the calculation
g_i.calculate()

# Save final project
g_i.save(r'C:\Users\opengti\Plaxis_playground\tutorial_1')

After calculation, you can switch to PLAXIS Output to plot deformations or settlement curves at the selected node or export results via the scripting API.

🔟 Summary of the Workflow

This tutorial demonstrated how to:

  • Connect Python to PLAXIS 2D Input and Output using the Remote Scripting API.
  • Set project metadata and choose an axisymmetric model type.
  • Create a soil domain, borehole, and soil layer with groundwater level.
  • Define and assign a Mohr–Coulomb sand material.
  • Create a footing plate and apply a vertical line load.
  • Generate the finite element mesh.
  • Define a calculation phase, activate load and plate, and run the analysis.
  • Add a curve point in Output to monitor footing settlement.

This forms a foundation for more advanced automation such as:

  • Parametric studies (looping over material properties or loads).
  • Automated reporting and result extraction with Python.
  • Coupling PLAXIS with optimisation or AI workflows.
Next-step idea
# Example of inspecting curve points in Output
for curve in g_o.CurvePoints:
    print(curve.Name, curve.y)