A Domain-Specific Language for Classical Mechanics with Symbolic and Numerical Analysis
Project description
MechanicsDSL
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b9411674c3a21884eb6dd7955ea6e7542256072573fbdb936d73754134abd24
|
|
| MD5 |
0b466754e4c45ace8b517a77ec7ef01a
|
|
| BLAKE2b-256 |
116b8eed93792f757e9d3091c9ea00a297c7fff3f64e60f72c66af174c20b052
|
Provenance
The following attestation bundles were made for mechanicsdsl_core-0.6.2.tar.gz:
Publisher:
publish.yml on MechanicsDSL/mechanicsdsl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mechanicsdsl_core-0.6.2.tar.gz -
Subject digest:
4b9411674c3a21884eb6dd7955ea6e7542256072573fbdb936d73754134abd24 - Sigstore transparency entry: 731817067
- Sigstore integration time:
-
Permalink:
MechanicsDSL/mechanicsdsl@c484eb402fcdae9969f33a37c273ce44a1715d7c -
Branch / Tag:
refs/tags/v.0.6.3 - Owner: https://github.com/MechanicsDSL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c484eb402fcdae9969f33a37c273ce44a1715d7c -
Trigger Event:
release
-
Statement type:
File details
Details for the file mechanicsdsl_core-0.6.2-py3-none-any.whl.
File metadata
- Download URL: mechanicsdsl_core-0.6.2-py3-none-any.whl
- Upload date:
- Size: 47.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98ae1a2ebb55d64d3573cb8972da0877c695e0922f59b378ca24be1204ad75df
|
|
| MD5 |
c2b4ab34d3c41ffdd91024c27c57dc02
|
|
| BLAKE2b-256 |
d355802b1767d30f49f3d3d61c19cd4039893026dcd8054042f3f3609433ff0e
|
Provenance
The following attestation bundles were made for mechanicsdsl_core-0.6.2-py3-none-any.whl:
Publisher:
publish.yml on MechanicsDSL/mechanicsdsl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mechanicsdsl_core-0.6.2-py3-none-any.whl -
Subject digest:
98ae1a2ebb55d64d3573cb8972da0877c695e0922f59b378ca24be1204ad75df - Sigstore transparency entry: 731817068
- Sigstore integration time:
-
Permalink:
MechanicsDSL/mechanicsdsl@c484eb402fcdae9969f33a37c273ce44a1715d7c -
Branch / Tag:
refs/tags/v.0.6.3 - Owner: https://github.com/MechanicsDSL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c484eb402fcdae9969f33a37c273ce44a1715d7c -
Trigger Event:
release
-
Statement type: