A Data-Oriented Toolkit for High-Assurance Simulation & Operational Modeling
clj-physics is a high-assurance, data-oriented toolkit designed to simulate physical systems where speed, robustness, and data transparency matter more than microscopic visual fidelity.
Unlike a game engine (which prioritizes frame rate) or a finite-element solver (which prioritizes microscopic accuracy at high computational cost), clj-physics is built for Operational Modeling: asking "what if?" questions in real-time, generating synthetic training data for AI, or running tactical loops in "messy" environments.
Model the motion of aircraft, submarines, and ground vehicles with high fidelity.
This is the library's "Survival Mode"—a layer designed for mission planners and autonomy systems that must operate on noisy, imperfect data.
Instead of taking hours to solve a fluid dynamics or electromagnetic problem, clj-physics uses Surrogate Models to give you 90% accurate answers in milliseconds.
If you have noisy sensors (like a jittery GPS), you can use the built-in Extended Kalman Filter (EKF).
:mass-kg, :pressure-pa) and includes "Survival Mode" guardrails. It won't crash if you feed it NaN; it degrades gracefully.Pull the latest version from Clojars:
;; deps.edn
net.clojars.helsingin/physics {:mvn/version "RELEASE"}
"Can my interceptor reach the target before it enters the restricted zone?"
(require '[physics.ops.kinematics :as k]
'[physics.ops.intercept :as int]
'[physics.ops.safety :as safe])
;; 1. Predict where the target is going (Risk-Aware)
(def future-target (k/propagate target-state 10.0))
;; 2. Check if that future position breaches the safety perimeter
(def safe? (safe/conservative-predictive-boundary?
future-target
(:uncertainty future-target)
restricted-zone-polygon
{:min-alt 0 :max-alt 500}))
;; 3. If safe, calculate the intercept course
(when (:safe? safe?)
(int/time-to-go interceptor-pos (:position future-target) interceptor-speed))
(require '[physics.dynamics :as dyn]
'[physics.models.common :as models]
'[physics.environment :as env]
'[physics.core :as core])
(def model models/fixed-wing)
(def state {:position [0 0 1000]
:velocity [60 0 0]
:orientation (core/euler->quaternion {:roll 0 :pitch 0 :yaw 0})
:angular-rate [0 0 0]})
;; Compute forces at 1,000m altitude
(dyn/rigid-body-derivatives model state (env/isa-profile 1000) {:throttle 0.5})
(require '[physics.electromagnetics.fields :as f]
'[physics.electromagnetics.constraints :as c])
(def radar-pulse (f/->field {:type :electric :frequency-hz 9e9 :amplitude 200.0}))
(c/evaluate-field-amplitude radar-pulse {:limit 100.0})
;; => Checks if amplitude exceeds hardware limits
clojure -M:test
make jarmake deployLicensed under GPL-3.0-only. See LICENSE for details.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |