| Crates.io | groundmodels-core |
| lib.rs | groundmodels-core |
| version | 0.1.0 |
| created_at | 2025-07-22 04:43:48.261054+00 |
| updated_at | 2025-07-22 04:43:48.261054+00 |
| description | A library for geotechnical ground modeling and soil parameter analysis |
| homepage | |
| repository | https://github.com/yourusername/groundmodels |
| max_upload_size | |
| id | 1763000 |
| size | 575,115 |
A Rust library for converting AGSi (Applied Ground Science Information) files to soil parameters and ground models.
This library provides functionality equivalent to the TypeScript addConvertCommand function, allowing you to:
SoilParamsGroundModel objectsconvert_agsi_fileThe main conversion function that processes AGSi JSON files:
pub fn convert_agsi_file(
file_path: &str,
convert_type: ConvertType,
output_path: Option<&str>
) -> Result<String, Box<dyn std::error::Error>>
SoilParams::from_agsi_data_parametersConverts AGSi data parameter values to soil parameters:
pub fn from_agsi_data_parameters(data: &[AgsiDataParameterValueElement]) -> Self
GroundModel::from_agsi_fileCreates a ground model from AGSi JSON data:
pub fn from_agsi_file(agsi_json: &serde_json::Value) -> Self
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.
use groundmodels::{convert_agsi_file, ConvertType};
// Convert to SoilParams array
let result = convert_agsi_file(
"input.json",
ConvertType::SoilParams,
Some("output.json")
)?;
// Convert to GroundModel
let result = convert_agsi_file(
"input.json",
ConvertType::GroundModel,
None // Print to stdout
)?;
use groundmodels::{SoilParams, AgsiDataParameterValueElement};
let data = vec![
AgsiDataParameterValueElement {
code_id: "UnitWeight".to_string(),
value_numeric: Some(18.0),
},
AgsiDataParameterValueElement {
code_id: "AngleFriction".to_string(),
value_numeric: Some(30.0),
},
];
let soil_params = SoilParams::from_agsi_data_parameters(&data);
The library automatically determines soil behavior based on parameters:
UndrainedShearStrength is provided with a positive valueUnconfinedCompressiveStrength is providedAgsiDataParameterValueElementpub struct AgsiDataParameterValueElement {
pub code_id: String,
pub value_numeric: Option<f64>,
}
ConvertTypepub enum ConvertType {
SoilParams,
GroundModel,
}
AdvancedParameterpub struct AdvancedParameter {
pub name: String,
pub value: f64,
}
The conversion functions return Result types for proper error handling:
match convert_agsi_file("input.json", ConvertType::SoilParams, None) {
Ok(json_output) => println!("Success: {}", json_output),
Err(e) => eprintln!("Error: {}", e),
}
The expected AGSi JSON structure:
{
"agsiModel": [
{
"agsiModelElement": [
{
"elementName": "Layer Name",
"agsiDataParameterValue": [
{
"codeID": "UnitWeight",
"valueNumeric": 18.0
}
]
}
]
}
]
}
Returns a JSON array of soil parameter objects with all the geotechnical properties.
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