Swift physics libraries for celestial mechanics, gas and liquid dynamics, atmospheres and magnetic fields.
The celmek library implements several astronomical algorithms.
| Algorithm | Status |
|---|---|
| VSOP87 | Done |
| ELP2000 82b | Done |
| Goffin2000 | Done |
CelMek is very much in development, and the scope has grown to implement more astronomical algorithms. It is currently NOT in a 1.0 state, so expect that API breakage happens.
A companion app for interactivelly working with this library is developed here: [https://github.com/lorrden/CelMek-Viewer]
The package has grown beyond the original CelMek port. Shared fluid physics now lives in FluidDynamics, with dedicated Aerodynamics and Hydrodynamics modules.
Swift 6.4 or newer. Apple deployment targets are macOS 15, iOS 18, tvOS 18,
watchOS 11, and visionOS 2 or newer, matching Synchronization.Mutex availability.
Linux and Windows builds are covered by CI.
Use the CelMek, Mechanics, Math, FluidDynamics, Aerodynamics, Hydrodynamics,
Atmospheres, or MagneticFields product for the modules your application needs.
The Physics product bundles all eight.
Import the corresponding module names. See MODULES.md for responsibilities and dependency rules.
The public guides and API references use DocC. See documentation build instructions for the seven module catalogs and the combined package archive.
python3 Tools/Documentation/build.py
python3 Tools/Documentation/preview.pyBrowse the result at localhost:8080/documentation.
Precise epochs, durations, UTC leap seconds, and calendar readings with explicit TAI/TT/TDB/UTC scales are documented in time guide.
Coordinate handedness, quaternion and angle conventions, transform direction, and error handling are documented in CONVENTIONS.md.
The tests use Swift Testing and require a Swift 6.4 or newer toolchain. Run all test targets with:
swift testApache 2.0 for the package's original code. ERFA-derived Earth-orientation and
Fairhead TDB numerical code is isolated in the internal ERFASwift module under
its BSD terms and attribution. See the
module README for its scope.
Shared Cartesian states use metres and metres per second, with explicit unit conversion and a VSOP87 provider adapter. See STATES.md.
Time-dependent frame trees, rotating transforms, and their conventions are documented in FRAMES.md.
The IAU coefficient review, updated data, and independent SPICE reference tests are documented in IAU_ROTATION_AUDIT.md.
Body identities, sourced SI properties, and the injectable JPL GM catalogue are documented in BODIES.md.
The common ephemeris contract, validating state-provider adapter, and body-query collection are documented in EPHEMERIDES.md.
Shared accuracy intent and each adapter's supported levels are documented in ACCURACY.md.
Reduced VSOP87 error and query-cost measurements, with a reproducible release tool, are in VSOP87_ACCURACY_CHARACTERIZATION.md.
Atmospheric profiles are provided by the Atmospheres target, shared by CelMek and Aerodynamics. It includes Earth ISA, nominal planetary/moon profiles, and gas-giant pressure during descent below the 1-bar level.
The MagneticFields target supplies pluggable magnetic-field models, ideal dipoles and CelMek body/orientation adapters. It also includes Swift WMM/IGRF evaluators, coefficient-file loaders and bundled WMM2025/IGRF-14 datasets with explicit date coverage.
swift run FluidPhysicsDemo
swift run -c release -debug-info-format none FluidPhysicsDemo --cfd --compressibleThe example includes dedicated Earth/Titan liquid displacement and pressure cases, optional incompressible rotor/body CFD and a compressible Sod reference problem. Liquid properties and vehicle coefficients in these examples are illustrative. See the FluidDynamics and Hydrodynamics DocC guides for coverage, numerical cost, pressure-reference rules and the remaining real-gas/free-surface fidelity work.
Single finite-burn position targeting is available through
FiniteBurnPositionTargeting.refine. It keeps ignition, thrust and exhaust speed
fixed, correcting duration and inertial direction through numerical endpoint
sensitivities and bounded backtracking. The result reports position convergence,
velocity residual, propellant, evaluation count and rejection count. Velocity is
not a targeted constraint; callers must separately verify it along with
clearance, attitude and reserve. Every trial uses ScheduledThrustPropagator and
caller-supplied force models; no gravity or physical origin is assumed implicitly.
FiniteBurnStateTargeting.refine corrects two fixed-ignition finite burns against
both terminal position and velocity using six duration-vector controls, central
differences, pivoted elimination and bounded backtracking/evaluation count.
It returns the best evaluated schedule, including on nonconvergence: callers must
check both residuals and independently validate clearance, resources and operations.