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

Quick Start

from mechanicsdsl-core 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://mechanicsdsl.readthedocs.io/en/latest/index.html

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-1.0.0.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-1.0.0-py3-none-any.whl (47.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mechanicsdsl_core-1.0.0.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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e3303c24a378edefc0afed4de863829ff4e8764de3d5e9072733015de43df3d2
MD5 d24b6a2b5fc7cc569026f495c7b9d72d
BLAKE2b-256 fa55e30cd767a85120131cffc377677c890d6822d6dcdf550196e3d25a9cc52d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mechanicsdsl_core-1.0.0.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-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mechanicsdsl_core-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22d32a40f292edc7a5da041db612e87c30733b002fc455b87493c7a000009980
MD5 da54727156768e2eb64507b263608fc8
BLAKE2b-256 4a963d9e718123ec4a7eb3c8ce1fc74946c18b4d9526da8a320530e9e21baf62

See more details on using hashes here.

Provenance

The following attestation bundles were made for mechanicsdsl_core-1.0.0-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