using System; using UnityEngine; // This static class centralizes all Earth-specific empirical constants and provides common calculation methods. public static class EarthConstantsAndCalculations { // --- WGS 84 & Core Earth Parameters --- public const double WGS84_EQUATORIAL_RADIUS_M = 6378137.0; public const double WGS84_TOTAL_EARTH_MASS_KG = 5.9722e24; public const double WGS84_GM = 3.986004418e14; public const double LOVE_NUMBER_H = 0.607; // For elastic deformation due to tidal forces // --- Earth Layer Radii (Empirical) --- // Source: Standard Earth models like PREM (Preliminary Reference Earth Model) public const double INNER_CORE_OUTER_RADIUS_M = 1220.0 * 1000.0; // 1220 km public const double OUTER_CORE_OUTER_RADIUS_M = 3485.0 * 1000.0; // 3485 km (UPDATED from WGS 84 data: Core radius (km) = 3485) public const double LOWER_MANTLE_OUTER_RADIUS_M = 5700.0 * 1000.0; // 5700 km public const double ASTHENOSPHERE_OUTER_RADIUS_M = 6300.0 * 1000.0; // ~6300 km (Approximate, often considered part of upper mantle) public const double LITHOSPHERE_OUTER_RADIUS_M = 6368.0 * 1000.0; // ~6368 km (Average thickness around 70-100km) public const double CRUST_OUTER_RADIUS_M = WGS84_EQUATORIAL_RADIUS_M; // Earth's surface // --- Hydrosphere & Cryosphere (Ocean & Ice) Data --- public const double HYDROSPHERE_TOTAL_MASS_KG = 1.4e21; // From WGS 84 data public const double OCEANS_AVERAGE_DEPTH_M = 3800.0; // 3.8 km public const double OCEAN_AVERAGE_DENSITY_KG_M3 = 1027.0; // Average density of seawater public const double ANTARCTICA_ICE_MASS_KG = 2.6e19; // Initial mass of Antarctic ice sheet public const double GREENLAND_ICE_MASS_KG = 2.9e18; // Initial mass of Greenland ice sheet public const double SEASONAL_ICE_MASS_SWING_KG = 1.0e15; // Amplitude of seasonal mass change for ice caps public const double ANTARCTICA_AVG_LATITUDE_DEG = 82.0; // Average latitude for MOI calculations public const double GREENLAND_AVG_LATITUDE_DEG = 72.0; // Average latitude for MOI calculations public const double ICE_AVERAGE_DENSITY_KG_M3 = 917.0; // Average density of ice public const double ESTIMATED_TOTAL_ICE_MASS_KG = ANTARCTICA_ICE_MASS_KG + GREENLAND_ICE_MASS_KG; // Sum of initial ice masses // --- Earth Layer Empirical Properties (NEED EMPIRICAL DATA for precise values) --- // These are average properties for each layer, used for initialization and conceptual calculations. // Mass percentages should sum to 1.0 (or close to it) for all layers. // Inner Core public const double INNER_CORE_MASS_PERCENTAGE = 0.017; // ~1.7% of Earth's mass public const double INNER_CORE_AVERAGE_DENSITY_KG_M3 = 13000.0; // kg/m^3 public const double INNER_CORE_AVERAGE_PRESSURE_GPA = 360.0; // GPa public const double INNER_CORE_AVERAGE_TEMPERATURE_C = 5400.0; // °C // Outer Core public const double OUTER_CORE_MASS_PERCENTAGE = 0.308; // ~30.8% of Earth's mass public const double OUTER_CORE_AVERAGE_DENSITY_KG_M3 = 11000.0; // kg/m^3 public const double OUTER_CORE_AVERAGE_PRESSURE_GPA = 135.0; // GPa public const double OUTER_CORE_AVERAGE_TEMPERATURE_C = 4400.0; // °C public const double OUTER_CORE_VISCOSITY_CP = 4.2146445; // cP (from previous specification) // Lower Mantle public const double LOWER_MANTLE_MASS_PERCENTAGE = 0.492; // ~49.2% of Earth's mass public const double LOWER_MANTLE_AVERAGE_DENSITY_KG_M3 = 4400.0; public const double LOWER_MANTLE_AVERAGE_PRESSURE_GPA = 35.0; public const double LOWER_MANTLE_AVERAGE_TEMPERATURE_C = 2000.0; public const double LOWER_MANTLE_VISCOSITY_CP = 1.0e23; // cP // Asthenosphere (part of upper mantle) public const double ASTHENOSPHERE_MASS_PERCENTAGE = 0.088; // ~8.8% of Earth's mass public const double ASTHENOSPHERE_AVERAGE_DENSITY_KG_M3 = 3400.0; public const double ASTHENOSPHERE_AVERAGE_PRESSURE_GPA = 20.0; public const double ASTHENOSPHERE_AVERAGE_TEMPERATURE_C = 1300.0; public const double ASTHENOSPHERE_VISCOSITY_CP = 1.0e21; // cP // Lithosphere (part of upper mantle and crust) public const double LITHOSPHERE_MASS_PERCENTAGE = 0.035; // ~3.5% of Earth's mass public const double LITHOSPHERE_AVERAGE_DENSITY_KG_M3 = 3300.0; public const double LITHOSPHERE_AVERAGE_PRESSURE_GPA = 10.0; public const double LITHOSPHERE_AVERAGE_TEMPERATURE_C = 800.0; public const double LITHOSPHERE_VISCOSITY_CP = 1.0e25; // cP // Crust public const double CRUST_MASS_PERCENTAGE = 0.004; // ~0.4% of Earth's mass public const double CRUST_AVERAGE_DENSITY_KG_M3 = 2700.0; public const double CRUST_AVERAGE_PRESSURE_GPA = 0.0; public const double CRUST_AVERAGE_TEMPERATURE_C = 20.0; public const double CRUST_VISCOSITY_CP = 1.0e27; // cP // --- Core Dynamics Parameters (NEED EMPIRICAL DATA for optimal values) --- // These constants are crucial for modeling the outer core's fluid dynamics and magnetic field generation. // They represent parameters that would feed into the Navier-Stokes and Magnetohydrodynamic (MHD) equations. // You will empirically determine and refine these values. [Tooltip("Electrical conductivity of the outer core fluid (Siemens/meter). Crucial for magnetic field generation. NEED EMPIRICAL DATA.")] public const double OUTER_CORE_ELECTRICAL_CONDUCTIVITY_SIEMENS_PER_METER = 5.0e5; // Placeholder value (e.g., from literature, highly debated) [Tooltip("Thermal expansion coefficient of the outer core fluid (1/K). Relates temperature changes to density changes for convection. NEED EMPIRICAL DATA.")] public const double OUTER_CORE_THERMAL_EXPANSION_COEFFICIENT_PER_K = 1.0e-5; // Placeholder value, typical for liquids [Tooltip("Compositional expansion coefficient of the outer core fluid. Relates compositional changes (e.g., light elements) to density changes for convection. Dimensionless. NEED EMPIRICAL DATA.")] public const double OUTER_CORE_COMPOSITIONAL_EXPANSION_COEFFICIENT = 0.5; // Placeholder dimensionless value [Tooltip("Reference density for buoyancy calculations in the outer core (kg/m^3). This is a baseline density around which variations occur. NEED EMPIRICAL DATA.")] public const double OUTER_CORE_REFERENCE_DENSITY_KG_M3 = 11000.0; // Placeholder, close to average outer core density [Tooltip("Magnetic permeability of the outer core fluid (Henry/meter). Often approximated as that of free space (mu_0). NEED EMPIRICAL DATA.")] public const double OUTER_CORE_MAGNETIC_PERMEABILITY_H_PER_M = 1.25663706212e-6; // Permeability of free space (mu_0) [Tooltip("Estimated total internal heat production from radioactive decay within the core (Watts). This drives thermal convection. NEED EMPIRICAL DATA.")] public const double CORE_RADIOGENIC_HEAT_PRODUCTION_W = 1.0e12; // Placeholder [Tooltip("Latent heat released by inner core solidification (Joules/kg). This is a source of buoyancy for outer core convection. NEED EMPIRICAL DATA.")] public const double INNER_CORE_LATENT_HEAT_J_PER_KG = 2.0e5; // Placeholder [Tooltip("Reference magnetic field strength for the outer core (Tesla). Used for initial conditions and scaling. NEED EMPIRICAL DATA.")] public const double OUTER_CORE_REFERENCE_MAGNETIC_FIELD_STRENGTH_T = 5.0e-3; // Placeholder, typical for Earth's core field // --- NEW: Thermal and Compositional Dynamics Constants --- [Tooltip("Specific heat capacity of the outer core fluid (Joules/kg·K). NEED EMPIRICAL DATA.")] public const double OUTER_CORE_SPECIFIC_HEAT_CAPACITY_J_PER_KG_K = 700.0; // Placeholder, typical for liquid metals [Tooltip("Thermal diffusivity of the outer core fluid (m^2/s). Governs heat conduction. NEED EMPIRICAL DATA.")] public const double OUTER_CORE_THERMAL_DIFFUSIVITY_M2_PER_S = 1.0e-5; // Placeholder, typical for liquid metals [Tooltip("Compositional diffusivity of the outer core fluid (m^2/s). Governs diffusion of light elements. NEED EMPIRICAL DATA.")] public const double OUTER_CORE_COMPOSITIONAL_DIFFUSIVITY_M2_PER_S = 1.0e-9; // Placeholder, much slower than thermal diffusion // --- General Calculation Methods --- /// /// Calculates the volume of a sphere. /// public static double CalculateSphereVolume(double radius_m) { return (4.0 / 3.0) * Math.PI * Math.Pow(radius_m, 3); } /// /// Calculates the volume of a spherical shell. /// public static double CalculateSphericalShellVolume(double innerRadius_m, double outerRadius_m) { return CalculateSphereVolume(outerRadius_m) - CalculateSphereVolume(innerRadius_m); } /// /// Calculates the moment of inertia for a solid sphere. I = (2/5)MR^2 /// public static double CalculateSolidSphereMomentOfInertia(double mass_kg, double radius_m) { return (2.0 / 5.0) * mass_kg * Math.Pow(radius_m, 2); } /// /// **CORRECTED** Calculates the moment of inertia for a spherical shell. /// I = (2/5) * M * (R_outer^5 - R_inner^5) / (R_outer^3 - R_inner^3) /// This formula is for a shell with uniform density, where M is the mass of the shell. /// public static double CalculateSphericalShellMomentOfInertia(double mass_kg, double innerRadius_m, double outerRadius_m) { if (outerRadius_m <= innerRadius_m) return 0; // Invalid radii double r_o_5 = Math.Pow(outerRadius_m, 5); double r_i_5 = Math.Pow(innerRadius_m, 5); double r_o_3 = Math.Pow(outerRadius_m, 3); double r_i_3 = Math.Pow(innerRadius_m, 3); if (r_o_3 - r_i_3 == 0) return 0; // Avoid division by zero for infinitesimally thin shells return (2.0 / 5.0) * mass_kg * (r_o_5 - r_i_5) / (r_o_3 - r_i_3); } /// /// Calculates average density given mass and volume. /// public static double CalculateAverageDensity(double mass_kg, double volume_m3) { if (volume_m3 == 0) return 0; // Avoid division by zero return mass_kg / volume_m3; } /// /// Helper method to get a layer's viscosity based on its name. /// In a full empirical model, this could dynamically query EarthLayerProperties instances /// or use more sophisticated lookup based on temperature/pressure. /// /// The name of the Earth layer. /// Viscosity in centipoise (cP). public static double GetLayerViscosity(string layerName) { // Placeholder values. These would be empirically determined. switch (layerName) { case "Inner Core": return INNER_CORE_VISCOSITY_CP; case "Outer Core": return OUTER_CORE_VISCOSITY_CP; case "Lower Mantle": return LOWER_MANTLE_VISCOSITY_CP; case "Asthenosphere": return ASTHENOSPHERE_VISCOSITY_CP; case "Lithosphere": return LITHOSPHERE_VISCOSITY_CP; case "Crust": return CRUST_VISCOSITY_CP; case "Water": return 1.0; // Water at room temp (cP) case "Ice": return 1.0e13; // Ice viscosity (cP) default: Debug.LogWarning($"Viscosity not defined for layer: {layerName}. Returning 0."); return 0; } } // Individual layer viscosities (moved here for centralization) public const double INNER_CORE_VISCOSITY_CP = 1.0e22; // Solid-like, very high viscosity // OUTER_CORE_VISCOSITY_CP is defined above with other core properties public const double LOWER_MANTLE_VISCOSITY_CP = 1.0e23; // High viscosity, but still ductile public const double ASTHENOSPHERE_VISCOSITY_CP = 1.0e20; // Lower viscosity, allows for convection public const double LITHOSPHERE_VISCOSITY_CP = 1.0e25; // Very high, rigid public const double CRUST_VISCOSITY_CP = 1.0e26; // Highest, most rigid } Planetary Instability Model PIM - Copyright (C) 2025 James Pacha