soilrust/
soil_coefficient.rs

1/// Calculates the soil coefficient based on settlement and foundation load.
2/// Returns a high value (999_999.0) if settlement is zero or negative to avoid division by zero.
3///
4/// # Arguments
5///
6/// * `settlement` - The settlement of the foundation in meters.
7/// * `foundation_pressure` - The load on the foundation in tons.
8///
9/// # Returns
10/// * The soil coefficient in tons per cubic meter (t/m³).
11pub fn calc_by_settlement(settlement: f64, foundation_pressure: f64) -> f64 {
12    if settlement <= 0.0 {
13        return 999_999.0;
14    }
15    100.0 * foundation_pressure / settlement // units: t/m³
16}
17
18/// Calculates the soil coefficient based on bearing capacity.
19/// Uses a factor of 400 as specified in empirical design practice.
20///
21/// # Arguments
22///
23/// * `bearing_capacity` - The bearing capacity of the soil in tons per square meter (t/m²).
24///
25/// # Returns
26/// * The soil coefficient in tons per cubic meter (t/m³).
27pub fn calc_by_bearing_capacity(bearing_capacity: f64) -> f64 {
28    400.0 * bearing_capacity // units: t/m³
29}