/// Compute the maximum value for the ground step to respect stability criterion of heat
/// conduction.
pub fn compute_ground_step_from_time_and_stability(
    time_step: f64,
    diffusivity: f64,
    numerical_stability: f64,
) -> f64 {
    (time_step * diffusivity / numerical_stability).sqrt()
}

/// Compute the maximum value for the ground step to respect stability criterion of heat
/// conduction from basic properties.
pub fn compute_ground_step_from_basic(
    time_step: f64,
    thermal_inertia: f64,
    density: f64,
    heat_capacity: f64,
    numerical_stability: f64,
) -> f64 {
    compute_ground_step_from_time_and_stability(
        time_step,
        compute_diffusivity_from_basic(thermal_inertia, density, heat_capacity),
        numerical_stability,
    )
}

/// Compute the diffusivity.
pub fn compute_diffusivity(conductivity: f64, density: f64, heat_capacity: f64) -> f64 {
    conductivity / (density * heat_capacity)
}

/// Compute the diffusivity from basic properties.
pub fn compute_diffusivity_from_basic(
    thermal_inertia: f64,
    density: f64,
    heat_capacity: f64,
) -> f64 {
    (thermal_inertia / (density * heat_capacity)).powi(2)
}

/// Compute the conductivity.
pub fn compute_conductivity(thermal_inertia: f64, density: f64, heat_capacity: f64) -> f64 {
    thermal_inertia.powi(2) / (density * heat_capacity)
}
