using System; using UnityEngine; // Used for Tooltip attributes, can be removed if not needed for standalone math. // OceanCalculations.cs // This static class centralizes empirical data and mathematical calculations // specifically for the Earth's oceans (hydrosphere). // All values are based on empirical data from WGS 84 and geological models. public static class OceanCalculations { // --- Fundamental Earth Constants (from WGS 84, needed for context) --- [Tooltip("WGS 84 Total Earth Mass (kg).")] public const double WGS84_TOTAL_EARTH_MASS_KG = 5.9722e24; // From WGS 84 reference [Tooltip("WGS 84 Equatorial Radius (a) in meters, used as Earth's overall outer boundary.")] public const double WGS84_EQUATORIAL_RADIUS_M = 6378137.0; // From WGS 84 reference // --- Ocean (Hydrosphere) Empirical Data --- [Tooltip("Total mass of the Earth's hydrosphere (oceans and all liquid surface water) in kg.")] public const double HYDROSPHERE_TOTAL_MASS_KG = 1.4e21; // From WGS 84 data [Tooltip("Average depth of the Earth's oceans in meters.")] public const double OCEANS_AVERAGE_DEPTH_M = 3800.0; // 3.8 km [Tooltip("Average density of ocean water (kg/m^3).")] public const double OCEAN_AVERAGE_DENSITY_KG_M3 = 1027.0; // Typical seawater density /// /// Gets the inner radius of the ocean layer from Earth's center (meters). /// This assumes the ocean sits on the Earth's surface (WGS84_EQUATORIAL_RADIUS_M). /// /// Inner radius of ocean layer in meters. public static double GetOceanInnerRadius_m() { return WGS84_EQUATORIAL_RADIUS_M; } /// /// Gets the outer radius of the ocean layer from Earth's center (meters). /// This assumes the ocean sits on the Earth's surface (WGS84_EQUATORIAL_RADIUS_M). /// /// Outer radius of ocean layer in meters. public static double GetOceanOuterRadius_m() { return WGS84_EQUATORIAL_RADIUS_M + OCEANS_AVERAGE_DEPTH_M; } /// /// Calculates the volume of the ocean layer (spherical shell). /// Assumes oceans are a uniform layer on the Earth's surface. /// /// Volume in cubic meters. public static double CalculateOceanVolume_m3() { double innerRadius = WGS84_EQUATORIAL_RADIUS_M; double outerRadius = GetOceanOuterRadius_m(); return (4.0 / 3.0) * Math.PI * (Math.Pow(outerRadius, 3) - Math.Pow(innerRadius, 3)); } /// /// Calculates the moment of inertia for the ocean layer (spherical shell). /// I = (2/5) * M * (R_outer^2 + R_inner * R_outer + R_inner^2) /// This is a simplified formula for a thin shell. For a more accurate one, refer to /// EarthConstantsAndCalculations.CalculateSphericalShellMomentOfInertia which uses /// I = (2/5) * M * (R_outer^5 - R_inner^5) / (R_outer^3 - R_inner^3) /// /// Moment of inertia in kg·m^2. public static double CalculateOceanMomentOfInertia() { double innerRadius = WGS84_EQUATORIAL_RADIUS_M; double outerRadius = GetOceanOuterRadius_m(); // Use the more accurate formula from EarthConstantsAndCalculations return EarthConstantsAndCalculations.CalculateSphericalShellMomentOfInertia(HYDROSPHERE_TOTAL_MASS_KG, innerRadius, outerRadius); } } Planetary Instability Model PIM - Copyright (C) 2025 James Pacha