1 - Building a Single Profile and Running an Analysis
1.0 Introduction
The RSSeismic Scripting feature is an API tool based on the Python programming language, designed to model and interpret results with the interface. This tutorial walks you through how to build a profile, automatically define reference curves and fit the GQ/H model, select an input motion for analysis and run compute. You will also learn the basic steps required to run your first RSSeismic Python Script.
Topics covered in this tutorial include scripting exercises to conduct the following operations:
- Importing libraries
- Configure a project
- Connect to RSSeismic and create a blank project
- Configure project settings (metric, GQ/H, Non-Masing)
- Build soil layers
- Register motion folder and select an input motion
- Save the project and run compute
1.1 Prerequisites
Before you begin, ensure you have the RSSeismic program installed at minimum Version 3.000 and have gone through the Getting Started with RSSeismic Python Scripting tutorial so you have the initial setup with RSSeismic Scripting completed.
1.2 Tutorial Files
All tutorial files installed with RSSeismic can be accessed by selecting File > Recent Files/Folders > Tutorials Folder from the RSSeismic main menu. The starting files can be found in the Scripting > Tutorial_1 subfolder, including an initial model file, and a Python file (.py).
2.0 Set Up RSSeismic and RocScript Editor
- Open RSSeismic.
- Select Scripting > Launch RocScript Editor
from the menu. The RocScript Editor will be launched. - In the RocScript Editor, select File > Open Folder, and select folder C:\Users\Public\Documents\Rocscience\RSSeismic Examples\Tutorials\Scripting\ Tutorial_1.
3.0 Set Up the Script and Open the Model
3.1 Import the Required Modules from RSSeismic Scripting
The RSSeismic module is the primary module that contains scripting functions used to manipulate the models through scripts. Import the required modules from RSSeismic Python API library, math and OS libraries.
# =============================================================================
# STEP 0 — Import libraries
# =============================================================================
import math
import os
from rsseismic import RSSeismicApplication, UnitSystem3.2 Setup project variables
In this step, the different variables that will be used at different stages of the development of the project. For this tutorial the ChiChi input motion will be employed.
# =============================================================================
# Step 1 — Configuration
# =============================================================================
OUTPUT_PROJECT = r"C:\Users\Public\Documents\Rocscience\RSSeismic Examples\Tutorials\Scripting\Tutorial_1\tutorial_1_simple_profile.rsseismicfile"
PROFILE_NAME = "Profile 1"
CHICHI_MOTION_DIR = r"C:\Program Files\Rocscience\RSSeismic\Resources\InputMotions"
CHICHI_MOTION_NAME = "ChiChi"A soil profile composed of 5 layers with constant thickness and shear wave velocity (VS) will be employed. Other relevant properties are listed as well.
N_LAYERS = 5
THICKNESS = 5.0 # m
UNIT_WEIGHT = 20.0 # kN/m³
VS = 250.0 # m/s
K0 = 0.46
PI_VALUE = 0.0 # plasticity index (%)
PHI_DEG = 35.0 # friction angle (degrees)
4.0 Connect to the application and create project
- Start the RSSeismic program with port number 60058
# =============================================================================
# Step 2 — Connect and create a blank project
# =============================================================================
SCRIPTING_PORT = 60058
app = RSSeismicApplication(port=SCRIPTING_PORT)
app.ping()
model = app.newProject()5.0 Define project settings
- Select the following:
- Unit system
- Manual profile generation
- Nonlinear analysis
- GQ/H as the soil model
- Non-masing hysteretic formulation
# =============================================================================
# Step 3 — Project settings
# =============================================================================
model.ProjectSettings.changeUnitSystem(UnitSystem.Metric)
model.ProjectSettings.Data.setBoolValue("automaticProfileGeneration", False)
model.ProjectSettings.Data.setEnumValue("analysisMode", "Nonlinear")
model.ProjectSettings.Data.setEnumValue("defaultSoilModel", "GQ_H")
model.ProjectSettings.Data.setEnumValue("hystereticFormulation", "NonMasing")6.0 Create a soil profile and assign properties
- Create soil profile. When creating a new project, “Profile 1” is already defined and a single layer of 1 m is created. 4 additional layers are added.
# =============================================================================
# Step 4 — Build five GQ/H layers on Profile 1
# =============================================================================
# A new project already has "Profile 1" with one default soil layer.
# Add four more layers, then set properties on all five.
model.Profiles.setActiveProfile(PROFILE_NAME)
layers = model.Profiles.listActiveSoilLayers()
model.SoilLayers.appendLayers(N_LAYERS - len(layers))- Assign properties to each layer. In this example Darendeli (2001) will be employed, as such the specific properties for this model are defined. After creating the reference curves, curve fitting to a target shear strength is performed.
for i, summary in enumerate(model.Profiles.listActiveSoilLayers()):
layer = model.Profiles.getSoilLayer(summary.layerID)
z_mid = i * THICKNESS + THICKNESS / 2.0
sigma_v = UNIT_WEIGHT * z_mid
tau_max = sigma_v * math.tan(math.radians(PHI_DEG))
layer.setSoilModel("GQ_H")
layer.setThickness(THICKNESS)
layer.setUnitWeight(UNIT_WEIGHT)
layer.Data.setDoubleProperty("ShearWaveVelocity", VS)
layer.Data.setDoubleProperty("ShearStrength", tau_max)
ref = layer.ReferenceCurve
ref.setSoilType("Sand")
ref.setCurveModel("Darendeli_2001")
ref.Data.setDoubleProperty("Ko", K0)
ref.Data.setDoubleProperty("PI", PI_VALUE)
ref.generateReferenceCurve()
layer.Curve.runCurveFit("MRDF_UIUC")7.0 Assign input motion
The ChiChi motion, one of the default input motions in RSSeismic, is selected.
# =============================================================================
# Step 5 — Select input motion
# =============================================================================
model.Motions.refreshMotionsList()
model.Motions.setMotionSelection([CHICHI_MOTION_NAME], selectOnlyListed=True)8.0 Save and compute project
The project file is then saved based on the defined output path and project name and the simulation is conducted.
# =============================================================================
# Step 6 — Save and compute
# =============================================================================
os.makedirs(os.path.dirname(OUTPUT_PROJECT), exist_ok=True)
model.saveAs(OUTPUT_PROJECT)
model.runCompute()9.0 Close the application
After the simulation finishes running, the application is closed.
# =============================================================================
# Step 7 — Result path (on disk, next to the project file)
# =============================================================================
project_stem = os.path.splitext(os.path.basename(OUTPUT_PROJECT))[0]
db3_path = os.path.join(
os.path.dirname(OUTPUT_PROJECT),
project_stem,
PROFILE_NAME,
f”Motion_{CHICHI_MOTION_NAME}”,
“deepsoilout.db3”,
)
print(db3_path)
model.close(saveProject=False)
app.close()