Skip to main content

A Domain-Specific Language for Classical Mechanics with Symbolic and Numerical Analysis

Project description

MechanicsDSL

Python CI Python 3.8+ License: MIT

A Domain-Specific Language for Classical Mechanics - A comprehensive framework for symbolic and numerical analysis of classical mechanical systems using LaTeX-inspired notation.

Features

  • Symbolic Computation: Automatic derivation of equations of motion from Lagrangians and Hamiltonians
  • Numerical Simulation: Advanced ODE solvers with adaptive step sizing
  • Visualization: Interactive animations and phase space plots
  • Unit System: Comprehensive dimensional analysis and unit checking
  • Constraint Handling: Support for holonomic and non-holonomic constraints
  • Performance Monitoring: Built-in profiling and optimization tools

Installation

pip install mechanics-dsl

Or install from source:

git clone https://github.com/MechanicsDSL/mechanicsdsl
cd mechanics_dsl
pip install -e .

Quick Start

from mechanics_dsl import PhysicsCompiler

# Define a simple pendulum system
dsl_code = """
system pendulum
var theta: angle [rad]
parameter g = 9.81 [m/s^2]
parameter L = 1.0 [m]
lagrangian = 0.5 * m * L^2 * \\dot{theta}^2 - m * g * L * (1 - \\cos{theta})
initial theta = 0.1, \\dot{theta} = 0
solve method=rk45 t_span=[0, 10]
animate
"""

# Compile and run
compiler = PhysicsCompiler()
result = compiler.compile_dsl(dsl_code)
solution = compiler.simulate(t_span=(0, 10))
compiler.animate(solution)

Testing

Run the test suite:

pytest tests/ -v

Or run tests in Google Colab - see COLAB_TESTING.md for instructions!

Documentation

Full documentation is available at https://mechanics-dsl.readthedocs.io

License

MIT License - see LICENSE file for details.

Citation

If you use MechanicsDSL in your research, please cite:

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mechanicsdsl_core-0.6.1.tar.gz (61.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mechanicsdsl_core-0.6.1-py3-none-any.whl (47.0 kB view details)

Uploaded Python 3

File details

Details for the file mechanicsdsl_core-0.6.1.tar.gz.

File metadata

  • Download URL: mechanicsdsl_core-0.6.1.tar.gz
  • Upload date:
  • Size: 61.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for mechanicsdsl_core-0.6.1.tar.gz
Algorithm Hash digest
SHA256 d84ec03a09d3a9e5af75af350608304e8c3e8715d6f3eb4d7b7cb631450abfbc
MD5 478c861cb7f8aecb1a5c1202006b2f8d
BLAKE2b-256 06fe0a29f812350f5ff35d2066633645a6736e4e64e43b3a56434de89b896104

See more details on using hashes here.

File details

Details for the file mechanicsdsl_core-0.6.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mechanicsdsl_core-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 683f1584ae78920f4ea3d94ee33ff36a431c524b09dfe0ccdd0077d0aa82b804
MD5 5489a038932e08dd1a27c6282f12dbfd
BLAKE2b-256 fca60e88e1d1bc1d2fe045188d713c627f980cfeb7c04381b61abe5c9cfaa885

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page