MechanicsDSL Documentation

MechanicsDSL is a comprehensive Python-based computational framework that unifies symbolic derivation and numerical simulation for classical mechanics and fluid dynamics. Using a LaTeX-inspired domain-specific language, it enables physicists, engineers, and students to describe complex physical systems in natural mathematical notation.

MechanicsDSL Logo

Key Features

🔬 Symbolic Mechanics

Automatic derivation of Euler-Lagrange and Hamilton’s equations from Lagrangians and Hamiltonians, with constraint handling via Lagrange multipliers.

💧 Computational Fluid Dynamics

Full Smoothed Particle Hydrodynamics (SPH) implementation with viscosity, pressure, surface tension, and multiple boundary conditions.

High-Performance Backends

Generate optimized C++, OpenMP, WebAssembly, and CUDA code for production deployment. Achieve real-time performance with automatic parallelization.

🔗 Multiphysics Coupling

Seamlessly combine rigid body dynamics with fluid mechanics for complex simulations like floating objects, fluid-structure interaction, and more.

📊 Advanced Visualization

Real-time 3D animations, phase space portraits, Poincaré sections, energy conservation plots, and publication-ready figures.

Quick Start

from mechanics_dsl import PhysicsCompiler

compiler = PhysicsCompiler()

source = r'''
\system{pendulum}
\defvar{theta}{angle}{rad}
\parameter{m}{1.0}{kg}
\parameter{l}{1.0}{m}
\parameter{g}{9.81}{m/s^2}
\lagrangian{\frac{1}{2} m l^2 \dot{\theta}^2 - m g l (1 - \cos(\theta))}
\initial{theta=0.5, theta_dot=0}
'''

result = compiler.compile_dsl(source)
solution = compiler.simulate((0, 10))
compiler.animate(solution)

Documentation Contents

Physics Domains

Code Generation

Indices and Tables

Version Information

Version:

2.1.2

Release:

2.1.2

Date:

Jun 04, 2026

License

MechanicsDSL is released under the MIT License. See License for details.

Citation

If you use MechanicsDSL in your research, please cite:

@software{mechanicsdsl,
  title = {MechanicsDSL: A Domain-Specific Language for Classical Mechanics},
  author = {Parsons, Noah},
  year = {2026},
  url = {https://github.com/MechanicsDSL/mechanicsdsl}
}