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
Constant |
Value |
Description |
|---|---|---|
|
3.14159265358979323846 |
Mathematical constant π |
|
6.28318530717958647692 |
2 × π |
|
12.56637061435917295385 |
4 × π |
|
1.7724538509055159 |
√π |
Common Values
Constant |
Value |
Description |
|---|---|---|
|
0.0 |
Double precision zero |
|
0.5 |
Double precision 0.5 |
|
1.0 |
Double precision one |
|
2.0 |
Double precision two |
Usage Examples¶
Basic Usage
use utils_cspex, only: dp, pi, twopi, zero, one
real(dp) :: radius, circumference
radius = 5.0_dp
circumference = twopi * radius
Precision Calculations
use utils_cspex, only: dp, sqrtpi
real(dp) :: result
result = sqrtpi * some_value
Type Definitions
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) typeConstants use
_dpsuffix for literal valuesModule has no dependencies - safe to use anywhere
Designed for maximum numerical stability
See Also¶
Energy Unit Conversions (energy) - Energy unit conversions
System Interface (sys) - System information