SoilTest - configure and run a soil test


 

Application PLAXIS 2D
PLAXIS 3D
Version PLAXIS 2D 2024.1 and later
PLAXIS 3D 2024.1 and later
Date created 09 September 2024
Date modified 09 September 2024
Original author Stefanos Papavasileiou - Technical Support Group
Keywords PLAXIS, SoilTest, soil, test, lab test, virtual lab, Python, API, py, cookbook

The SoilTest option is a quick and convenient procedure to simulate basic soil lab tests on the basis of a single-point algorithm, i.e., without the need to create a complete finite element model.

Using Python, the SoilTest facility can be utilized to run most of the types of laboratory tests and allow  the retrieval of results, which can be post-processed by any script used for automation.

In this article you will learn:

Python solution

Initialise PLAXIS Input with Python scripting

For SoilTest to run a virtual laboratory test, a material needs to be provided. In this case, PLAXIS Input should provide the material.

To create a material in PLAXIS via Python scripting, the Remote Scripting Server needs to be initialised for the PLAXIS Input program.

See also: Using PLAXIS Remote scripting with the Python wrapper in order to correctly set up the reference to Plaxis Input (s_i, g_i) using the boilerplate code.

In the code below, the following happens:

  1. The boilerplate for PLAXIS is used;
  2. a new project is started;
  3. the parameters of a Hardening Soil material are stored in a list;
  4. a material data set is created using the previously created list of parameters;
  5. PLAXIS SoilTest is launched with the created material.
    Notice the boilerplate for SoilTest is using the local variables s_t and g_t, and the soiltest command will return the port number used by SoilTest.
# 1.   PLAXIS boilerplate
from plxscripting.easy import *
s_i, g_i = new_server('localhost', 10000, password="your_password")

# 2. Start a new PLAXIS project
s_i.new()

# 3. Define Sand material as Hardening Soil
sand_properties = ["Identification", "Sand", "SoilModel", "Hardening Soil", "gammaUnsat", 17, "gammaSat", 20,
                   "E50Ref", 40000, "EOedRef", 40000, "cRef", 5, "phi", 32,
                   "PermHorizontalPrimary", 1, "PermVertical", 1,
                   "InterfaceStrengthDetermination", "Manual", "Rinter", 0.67]

# 4. Create the material object
g_i.soilmat(*sand_properties)

# 5. Start SoilTest from Input
localhostport_t = g_i.soiltest(g_i.Sand)
s_t, g_t = new_server('localhost', localhostport_t, password=s_i.connection._password)

Configure a triaxial test

In the code below, the configuration of a triaxial test is set:

  1. Store the Triaxial test object to a variable as a quick reference;
  2. configure various input settings for the test;
  3. calculate the Triaxial test.
# 1. Define the laboratory test
lab_test = g_t.Triaxial

# 2. Configure the Triaxial test
lab_test.CellPressure = 100
lab_test.MaximumStrain = 10
lab_test.Steps = 500

# 3. Calculate the test
g_t.calculate(lab_test)

1.png

Retrieve results from a test

In the code provided, various calculation results are retrieved and printed to the Python console:

  1. Store the various result types as variables for quick references;
  2. use the print statement to show results in the console;
  3. use a for-loop to print individual results to the console.    
# Various results from Triaxial test
# 1a. Retrieve the Deviatoric Stresses
deviatoric_stresses = lab_test.Results.DeviatoricStressT.value
# 1b. Retrieve the Cartesian Y-direction Strains
epsyys = lab_test.Results.Epsyy.value
# 1c. Retrieve the Total Volumetric Strains
vol_strains = lab_test.Results.TotalVolumetricStrain.value

# 2. Print maximum and minimum values for some results
print(f"Maximum value for {deviatoric_stresses.Name} is: {max(deviatoric_stresses)}")
print(f"Minimum value for {vol_strains.Name} is: {(min(vol_strains)):.2%}")

# 3. Print some results in console
for dev_stress in deviatoric_stresses:
    print(dev_stress)

Plot a graph of results

In the last part of the code, the matplotlib module is used to create a plot:

  1. Import the necessary Python module.
    Note that it is recommended to add this code at the start of the script (following the suggested PEP8 coding style).
  2. Configure the plot and show it.
# 1. Import a Python module for the script
import matplotlib.pyplot as plt

# 2. Create a plot with Deviatoric Stresses and Cartesian Y-direction Strains results
print("Plot created. Click the X on Figure 1 to close it.")
plt.plot(epsyys, deviatoric_stresses)
plt.xlabel(r'$\varepsilon_{yy}$')
plt.ylabel(r'$|\sigma_1 - \sigma_2|$ [kN/m$^2$]')
plt.gca().invert_xaxis()  # Invert the x-axis
plt.show()

2.png

For further information on commands and objects in SoilTest, go to Help > Command reference menu option.

Version

This script has been tested with PLAXIS 2024.1 and Python 3.8.18, and with PLAXIS 2024.2 and Python 3.12.3.

 

Downloads

See also