Article

Why Engineers Use Python to Automate Geotechnical Engineering in RS2

Published on: Mar 21, 2025 Updated on: Mar 27, 2025 Read: 5 minutes

A small change in material properties, slope geometry, or support placement can mean running multiple lengthy simulations in your geotechnical engineering workflow — but using Python can save the day. Without it, the process of manual adjustments, computations, and data extraction can be time-consuming and prone to human error.

In a past webinar, Rocscience software developers Daniel Wai and William Sati demonstrated how you can use Python scripting in RS2 to automate these repetitive steps to be more efficient. The key takeaway? Manual processes slow you down and pull focus away from actual analysis.

Here are five ways you can use Python scripting in your geotechnical workflows to eliminate bottlenecks and focus on high-value work:

1. Automate Model Adjustments Without Manual Tweaks

Design iteration often requires testing multiple variations — whether it’s bolt spacing in an excavation support system or slope reinforcement strategies. Adjusting these settings manually is inefficient, especially when small changes need to be tested across multiple scenarios.

"So what you might want to do is you might want to say bolts here and change the bolt spacing… then rerun that analysis and try another design. That manual process? We can actually automate it in scripting."

Scripting allows engineers to programmatically define a range of input values and run multiple simulations in sequence. Instead of modifying and recomputing each model individually, a single script can execute the entire batch, significantly reducing turnaround time.

python scripting automated model adjustments rs2
Figure 1. An example of automated model adjustments in RS2 using Python scripting.

2. Process Multiple Simulations Without Delays

Large-scale analyses often require running multiple simulations to compare different design parameters, loading conditions, or safety factors. Manually setting up each simulation and waiting for results introduces unnecessary delays.

"We provide a convenient function that lets you change the tieback spacing in a loop. Every time you change the spacing, it saves as a different model and computes automatically."

With scripting, engineers can queue up multiple simulations in a single run, reducing time spent on setup and execution. Whether adjusting excavation depths, foundation loads, or reinforcement configurations, automation ensures simulations are processed efficiently, keeping projects on schedule.

python scripting multi-simulations RS2
Figure 2. An example of multi-simulations in RS2 using Python scripting.

3. Extract and Visualize Data Instantly

Interpreting results is often as time-consuming as running the analysis itself. Engineers must manually extract values, compile datasets, and create visualizations — tasks that can be streamlined with automation.

"You can go ahead and extract that data to Excel, export it, or plot it using built-in Python libraries like Matplotlib."

Python scripting enables direct integration with data processing tools, allowing engineers to automatically extract key results, generate tables, and create plots without leaving their workflow. This approach ensures data is structured consistently and readily available for decision-making.

python scripting visualizing data RS2
Figure 3. An example of visualizing data in RS2 using Python scripting.

4. Eliminate Variability in Model Execution

Consistency is critical in geotechnical modeling. Minor variations in manual input — whether from different engineers or across different project phases — can lead to discrepancies in results.

"Ultimately, we want engineers across your company to carry out analyses efficiently and consistently."

By using scripted workflows, every simulation follows a standardized procedure, ensuring uniform application of design criteria. This consistency is particularly valuable in collaborative projects where multiple team members contribute to the same analysis.

python scripting standardized procedure RS2
Figure 4. An example of standardized procedure in RS2 using Python scripting.

5. Automate Complex Probabilistic Analyses

Unlike standard batch simulations, probabilistic analyses introduce additional complexity, requiring engineers to account for uncertainty in material properties, loading conditions, and failure probabilities. Traditionally, this process involves generating numerous randomized scenarios, modifying input distributions, and manually running iterative simulations. Python scripting now makes it possible to automate these complex analyses, defining probabilistic input variations, generating models, and compiling statistical distributions with minimal manual intervention.

"Now we have 100 models automatically created… and RS2 calculates that 11 out of these 100 samples have a factor of safety below one, with a probability of failure of 11%."

This allows for a more thorough understanding of failure risk and reliability, leading to better-informed design decisions while significantly reducing the effort required for large-scale probabilistic studies.

python scripting probabilistic analysis RS2
Figure 5. An example of probabilistic analysis in RS2 using Python scripting.

Optimizing Engineering Time Through Automation

Although it can be challenging to manage workflow inefficiencies, Python scripting in RS2 can help you:

  • Iterate designs faster by automating repetitive input adjustments.
  • Run large-scale simulations efficiently without constant user intervention.
  • Extract and visualize data automatically for quicker insights.
  • Ensure model consistency across teams and project phases.
  • Streamline advanced analyses without manual reconfiguration.

With scripting, you can reduce time spent on mechanical tasks and redirect your efforts toward higher-value engineering decisions. For a more thorough introduction, visit the Scripting Overview help page, and for more detail about scripting functions, read the scripting reference manual.

Want to start automating your manual tasks? Start a free trial of RS2 today!

Start Free Trial
Back to top

More from Rocscience