GroundModels - AGSi Conversion Library
A Rust library for converting AGSi (Applied Ground Science Information) files to soil parameters and ground models.
Overview
This library provides functionality equivalent to the TypeScript addConvertCommand function, allowing you to:
- Convert AGSi files to arrays of
SoilParams - Convert AGSi files to
GroundModelobjects - Export results to JSON format
Core Functions
convert_agsi_file
The main conversion function that processes AGSi JSON files:
SoilParams::from_agsi_data_parameters
Converts AGSi data parameter values to soil parameters:
GroundModel::from_agsi_file
Creates a ground model from AGSi JSON data:
Supported AGSi Parameters
The conversion process maps the following AGSi parameter codes:
| AGSi Code ID | SoilParams Field | Description |
|---|---|---|
UnitWeight |
unit_weight |
Unit weight of soil |
AngleFriction |
phi_prime |
Angle of internal friction |
UndrainedShearStrength |
cu |
Undrained shear strength (sets behavior to Cohesive) |
YoungsModulus |
youngs_modulus |
Young's modulus |
Cohesion |
c_prime |
Effective cohesion |
ModulusOfVolumeCompressibility |
mv |
Coefficient of volume compressibility |
GeologicalStrengthIndex |
gsi |
Geological Strength Index |
UnconfinedCompressiveStrength |
ucs |
UCS (sets behavior to Rock) |
HoekBrownParamMi |
mi |
Hoek-Brown parameter mi |
Disturbance |
disturbance |
Disturbance factor |
Any unrecognized parameters are stored in the advanced_parameters field.
Usage Examples
Basic Conversion
use ;
// Convert to SoilParams array
let result = convert_agsi_file?;
// Convert to GroundModel
let result = convert_agsi_file?;
Direct Parameter Conversion
use ;
let data = vec!;
let soil_params = from_agsi_data_parameters;
Soil Behavior Classification
The library automatically determines soil behavior based on parameters:
- Cohesive: When
UndrainedShearStrengthis provided with a positive value - Rock: When
UnconfinedCompressiveStrengthis provided - Granular: Default behavior
Data Structures
AgsiDataParameterValueElement
ConvertType
AdvancedParameter
Error Handling
The conversion functions return Result types for proper error handling:
match convert_agsi_file
Input Format
The expected AGSi JSON structure:
Output Format
SoilParams Array
Returns a JSON array of soil parameter objects with all the geotechnical properties.
GroundModel
Returns a JSON object containing:
soil_layers: Array of soil layers (empty in basic conversion)soil_params: Array of soil parametersrigid_boundary: Optional rigid boundary depthgroundwater: Groundwater levelreference: Reference identifier