.. SPDX-FileCopyrightText: 1992-2026 NWO-I/SRON Space Research Organisation Netherlands .. .. SPDX-License-Identifier: CC-BY-4.0 Mathematical Constants (cspex) =============================== **Module**: ``utils_cspex`` Overview -------- Provides fundamental mathematical constants and precision definitions used throughout SPEX. Key Features ------------ - Double precision arithmetic (15-digit accuracy) - Common mathematical constants (π, √2, etc.) - Useful numeric constants (zero, one, two, etc.) - Consistent precision across all SPEX modules API Reference ------------- Constants ~~~~~~~~~ **Mathematical Constants** .. list-table:: :widths: 20 30 50 :header-rows: 1 * - Constant - Value - Description * - ``pi`` - 3.14159265358979323846 - Mathematical constant π * - ``twopi`` - 6.28318530717958647692 - 2 × π * - ``fourpi`` - 12.56637061435917295385 - 4 × π * - ``sqrtpi`` - 1.7724538509055159 - √π **Common Values** .. list-table:: :widths: 20 30 50 :header-rows: 1 * - Constant - Value - Description * - ``zero`` - 0.0 - Double precision zero * - ``half`` - 0.5 - Double precision 0.5 * - ``one`` - 1.0 - Double precision one * - ``two`` - 2.0 - Double precision two Usage Examples -------------- **Basic Usage** .. code-block:: fortran use utils_cspex, only: dp, pi, twopi, zero, one real(dp) :: radius, circumference radius = 5.0_dp circumference = twopi * radius **Precision Calculations** .. code-block:: fortran use utils_cspex, only: dp, sqrtpi real(dp) :: result result = sqrtpi * some_value **Type Definitions** .. code-block:: fortran use utils_cspex, only: dp real(dp) :: high_precision_value integer :: precision_bits precision_bits = selected_real_kind(15, 307) ! Same as dp Notes ----- - All constants are defined with ``dp`` (double precision) type - Constants use ``_dp`` suffix for literal values - Module has no dependencies - safe to use anywhere - Designed for maximum numerical stability See Also -------- - :doc:`../data/energy` - Energy unit conversions - :doc:`../core/system` - System information