use sciforge::hub::domain::geology::tectonics::{airy_root, isostatic_equilibrium};

pub const ICEMANTLEDENSITY: f64 = 1600.0;
pub const ROCKYCOREDENSITY: f64 = 5000.0;

pub struct IceMountain {
    pub name: &'static str,
    pub peakelevationm: f64,
    pub baseelevationm: f64,
    pub iceshellthicknesskm: f64,
}

impl IceMountain {
    pub fn height(&self) -> f64 {
        self.peakelevationm - self.baseelevationm
    }

    pub fn rootdepthm(&self) -> f64 {
        airy_root(self.height(), ICEMANTLEDENSITY, ROCKYCOREDENSITY)
    }

    pub fn totalthicknessm(&self) -> f64 {
        self.iceshellthicknesskm * 1000.0 + self.rootdepthm()
    }

    pub fn isostaticelevation(&self) -> f64 {
        isostatic_equilibrium(
            self.iceshellthicknesskm * 1000.0,
            ICEMANTLEDENSITY,
            ROCKYCOREDENSITY,
        )
    }
}

pub fn interioricepeak() -> IceMountain {
    IceMountain {
        name: "Interior Ice Peak",
        peakelevationm: 500.0,
        baseelevationm: 0.0,
        iceshellthicknesskm: 7000.0,
    }
}

pub fn rockycorepeak() -> IceMountain {
    IceMountain {
        name: "Rocky Core Peak",
        peakelevationm: 2000.0,
        baseelevationm: 0.0,
        iceshellthicknesskm: 0.0,
    }
}
