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

impl SurfaceCharging {
    pub fn dayside() -> Self {
        Self {
            local_time_hours: 382.7 * 0.5,
            plasma_density_cm3: 0.3,
            photoelectron_current_ua_m2: 0.5,
        }
    }
    pub fn nightside() -> Self {
        Self {
            local_time_hours: 0.0,
            plasma_density_cm3: 0.06,
            photoelectron_current_ua_m2: 0.0,
        }
    }
    pub fn surface_potential_v(&self) -> f64 {
        let day_half = 382.7 * 0.5;
        let diurnal_bias = if (day_half * 0.4..=day_half * 1.5).contains(&self.local_time_hours) {
            5.0
        } else {
            -35.0
        };
        diurnal_bias + self.photoelectron_current_ua_m2 * 3.0 - self.plasma_density_cm3 * 8.0
    }
    pub fn dust_lofting_risk(&self) -> f64 {
        (self.surface_potential_v().abs() / 100.0).clamp(0.0, 1.0)
    }
}
