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 mechanicsdsl-core

Or install from source:

git clone https://github.com/MechanicsDSL/mechanicsdsl
cd src
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.2.tar.gz (61.1 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.2-py3-none-any.whl (47.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mechanicsdsl_core-0.6.2.tar.gz
  • Upload date:
  • Size: 61.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mechanicsdsl_core-0.6.2.tar.gz
Algorithm Hash digest
SHA256 4b9411674c3a21884eb6dd7955ea6e7542256072573fbdb936d73754134abd24
MD5 0b466754e4c45ace8b517a77ec7ef01a
BLAKE2b-256 116b8eed93792f757e9d3091c9ea00a297c7fff3f64e60f72c66af174c20b052

See more details on using hashes here.

Provenance

The following attestation bundles were made for mechanicsdsl_core-0.6.2.tar.gz:

Publisher: publish.yml on MechanicsDSL/mechanicsdsl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for mechanicsdsl_core-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 98ae1a2ebb55d64d3573cb8972da0877c695e0922f59b378ca24be1204ad75df
MD5 c2b4ab34d3c41ffdd91024c27c57dc02
BLAKE2b-256 d355802b1767d30f49f3d3d61c19cd4039893026dcd8054042f3f3609433ff0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mechanicsdsl_core-0.6.2-py3-none-any.whl:

Publisher: publish.yml on MechanicsDSL/mechanicsdsl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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