#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SurfaceCharging {
    pub local_time_hours: f64,
    pub solar_wind_density_cm3: f64,
    pub photoelectron_current_ua_m2: f64,
}

impl SurfaceCharging {
    pub fn dayside() -> Self {
        Self {
            local_time_hours: 15.0,
            solar_wind_density_cm3: 4.0,
            photoelectron_current_ua_m2: 1.2,
        }
    }

    pub fn nightside() -> Self {
        Self {
            local_time_hours: 0.0,
            solar_wind_density_cm3: 0.5,
            photoelectron_current_ua_m2: 0.0,
        }
    }

    pub fn surface_potential_v(&self) -> f64 {
        let diurnal_bias = if (5.0..=25.0).contains(&self.local_time_hours) {
            8.0
        } else {
            -25.0
        };
        diurnal_bias + self.photoelectron_current_ua_m2 * 4.0 - self.solar_wind_density_cm3 * 3.0
    }

    pub fn dust_lofting_risk(&self) -> f64 {
        (self.surface_potential_v().abs() / 80.0).clamp(0.0, 1.0)
    }
}
