
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
mechanicsdsl-core
Advanced tools
MechanicsDSL is a computational physics framework that lets you define physical systems in a natural, LaTeX-inspired syntax and automatically generates high-performance simulations. From pendulums to planetary orbits, from Lagrangian mechanics to fluid dynamics—describe it once, simulate it anywhere.
| Feature | Description |
|---|---|
| Symbolic Engine | Automatically derives equations of motion from Lagrangians or Hamiltonians |
| 12+ Code Generators | C++, Rust, Julia, CUDA, WebAssembly, Unity, Unreal, Modelica, and more |
| GPU Acceleration | JAX backend with JIT compilation and automatic differentiation |
| Inverse Problems | Parameter estimation, sensitivity analysis, MCMC uncertainty |
| Jupyter Native | %%mechanicsdsl magic commands for notebooks |
| Real-time API | FastAPI server with WebSocket streaming |
| IDE Support | LSP server for VS Code with autocomplete and diagnostics |
| Plugin Architecture | Extensible with custom physics domains and solvers |
pip install mechanicsdsl-core
With optional features:
pip install mechanicsdsl-core[jax] # GPU acceleration + autodiff
pip install mechanicsdsl-core[server] # FastAPI real-time server
pip install mechanicsdsl-core[jupyter] # Notebook magic commands
pip install mechanicsdsl-core[lsp] # VS Code language server
pip install mechanicsdsl-core[embedded] # Raspberry Pi / ARM support
pip install mechanicsdsl-core[all] # Everything
Docker deployment:
# CPU version
docker pull ghcr.io/mechanicsdsl/mechanicsdsl:latest
docker run -it ghcr.io/mechanicsdsl/mechanicsdsl:latest
# GPU version (requires nvidia-docker)
docker pull ghcr.io/mechanicsdsl/mechanicsdsl:gpu
docker run --gpus all -it ghcr.io/mechanicsdsl/mechanicsdsl:gpu
Requirements: Python 3.9+ with NumPy, SciPy, SymPy, and Matplotlib (installed automatically).
Released January 17, 2026 — Now deployed in 19 countries across enterprise, research, and embedded platforms.
generate_cmake() and generate_project() methodsno_std embedded option📖 See RELEASE_NOTES_v2.0.0.md for full details.
Define a gravitational three-body system and watch it trace the celebrated Figure-8 periodic orbit:
from mechanics_dsl import PhysicsCompiler
# Define the system using LaTeX-inspired DSL
figure8_code = r"""
\system{figure8_orbit}
\defvar{x1}{Position}{m} \defvar{y1}{Position}{m}
\defvar{x2}{Position}{m} \defvar{y2}{Position}{m}
\defvar{x3}{Position}{m} \defvar{y3}{Position}{m}
\defvar{m}{Mass}{kg} \defvar{G}{Grav}{1}
\parameter{m}{1.0}{kg} \parameter{G}{1.0}{1}
\lagrangian{
0.5 * m * (\dot{x1}^2 + \dot{y1}^2 + \dot{x2}^2 + \dot{y2}^2 + \dot{x3}^2 + \dot{y3}^2)
+ G*m^2/\sqrt{(x1-x2)^2 + (y1-y2)^2}
+ G*m^2/\sqrt{(x2-x3)^2 + (y2-y3)^2}
+ G*m^2/\sqrt{(x1-x3)^2 + (y1-y3)^2}
}
"""
# Compile and simulate
compiler = PhysicsCompiler()
compiler.compile_dsl(figure8_code)
compiler.simulator.set_initial_conditions({
'x1': 0.97000436, 'y1': -0.24308753, 'x1_dot': 0.466203685, 'y1_dot': 0.43236573,
'x2': -0.97000436, 'y2': 0.24308753, 'x2_dot': 0.466203685, 'y2_dot': 0.43236573,
'x3': 0.0, 'y3': 0.0, 'x3_dot': -0.93240737, 'y3_dot': -0.86473146
})
solution = compiler.simulate(t_span=(0, 6.326), num_points=2000)
Simulate fluid dynamics with the integrated SPH solver:
from mechanics_dsl import PhysicsCompiler
fluid_code = r"""
\system{dam_break}
\parameter{h}{0.04}{m}
\parameter{g}{9.81}{m/s^2}
\fluid{water}
\region{rectangle}{x=0.0 .. 0.4, y=0.0 .. 0.8}
\particle_mass{0.02}
\equation_of_state{tait}
\boundary{walls}
\region{line}{x=-0.05, y=0.0 .. 1.5}
\region{line}{x=1.5, y=0.0 .. 1.5}
\region{line}{x=-0.05 .. 1.5, y=-0.05}
"""
compiler = PhysicsCompiler()
compiler.compile_dsl(fluid_code)
compiler.compile_to_cpp("dam_break.cpp", target="standard", compile_binary=True)
%load_ext mechanics_dsl.jupyter
%%mechanicsdsl --animate --t_span=0,20
\system{pendulum}
\defvar{theta}{Angle}{rad}
\parameter{m}{1.0}{kg}
\lagrangian{\frac{1}{2}*m*l^2*\dot{theta}^2 - m*g*l*(1-\cos{theta})}
\initial{theta=2.5, theta_dot=0.0}
from mechanics_dsl.inverse import ParameterEstimator
estimator = ParameterEstimator(compiler)
result = estimator.fit(observations, t_obs, ['m', 'k'])
print(f"Fitted: m={result.parameters['m']:.3f}, k={result.parameters['k']:.3f}")
python -m mechanics_dsl.server
# -> http://localhost:8000/docs
| Platform | Module | Purpose |
|---|---|---|
| OpenMDAO | integrations.openmao | Multidisciplinary optimization |
| ROS2 | integrations.ros2 | Robotics simulation |
| Unity | integrations.unity | Game engine (C#) |
| Unreal | integrations.unreal | Game engine (C++) |
| Modelica | integrations.modelica | Standards-based simulation |
| # | Tutorial | Topics |
|---|---|---|
| 1 | Getting Started | DSL basics, simple pendulum, export |
| 2 | Double Pendulum | Chaos, sensitivity, phase space |
| 3 | Parameter Estimation | Inverse problems, Sobol analysis |
The examples/ directory contains 30+ progressive examples:
| Level | Examples |
|---|---|
| Beginner | Harmonic oscillator, Simple pendulum, Plotting basics |
| Intermediate | Double pendulum, Coupled oscillators, 2D motion, Damping |
| Advanced | 3D gyroscope, Hamiltonian formulation, Phase space, Energy analysis |
| Expert | C++ export, WebAssembly targets, SPH fluid dynamics |
Full documentation with tutorials, API reference, and DSL syntax guide:
We welcome contributions! See CONTRIBUTING.md for guidelines.
MIT License — see LICENSE for details.
Built with ❤️ for physicists, engineers, and curious minds.
FAQs
A Domain-Specific Language and Transpiler for Classical Mechanics
We found that mechanicsdsl-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.