{"id":35603893,"url":"https://github.com/mechanicsdsl/mechanicsdsl","last_synced_at":"2026-05-30T02:03:00.739Z","repository":{"id":325541871,"uuid":"1101587373","full_name":"MechanicsDSL/mechanicsdsl","owner":"MechanicsDSL","description":"MechanicsDSL is a production-ready, enterprise-grade computational physics framework that enables physicists, researchers, and educators to define physical systems using a LaTeX-inspired syntax and automatically generates high-performance simulations.","archived":false,"fork":false,"pushed_at":"2026-05-24T03:43:41.000Z","size":6324,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-24T04:29:13.660Z","etag":null,"topics":["chaos-theory","classical-mechanics","computational-physics","dsl","dynamics","education","hamiltonian-mechanics","lagrangian-mechanics","mechanics","numerical-methods","ode-solver","physics","python","research","scientific-computing","simulation","symbolic-computation","visualization"],"latest_commit_sha":null,"homepage":"https://mechanicsdsl.github.io/mechanicsdsl/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MechanicsDSL.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":[],"custom":["https://doi.org/10.5281/zenodo.17771040"]}},"created_at":"2025-11-21T22:29:22.000Z","updated_at":"2026-05-24T03:43:44.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/MechanicsDSL/mechanicsdsl","commit_stats":null,"previous_names":["mechanicsdsl/mechanicsdsl"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/MechanicsDSL/mechanicsdsl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MechanicsDSL%2Fmechanicsdsl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MechanicsDSL%2Fmechanicsdsl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MechanicsDSL%2Fmechanicsdsl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MechanicsDSL%2Fmechanicsdsl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MechanicsDSL","download_url":"https://codeload.github.com/MechanicsDSL/mechanicsdsl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MechanicsDSL%2Fmechanicsdsl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33677261,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-30T02:00:06.278Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chaos-theory","classical-mechanics","computational-physics","dsl","dynamics","education","hamiltonian-mechanics","lagrangian-mechanics","mechanics","numerical-methods","ode-solver","physics","python","research","scientific-computing","simulation","symbolic-computation","visualization"],"created_at":"2026-01-05T02:17:00.523Z","updated_at":"2026-05-30T02:03:00.727Z","avatar_url":"https://github.com/MechanicsDSL.png","language":"Python","funding_links":["https://doi.org/10.5281/zenodo.17771040"],"categories":[],"sub_categories":[],"readme":"![MechanicsDSL Logo](docs/images/logo.png)\n\n# MechanicsDSL\n\n[![Python CI](https://github.com/MechanicsDSL/mechanicsdsl/actions/workflows/python-app.yml/badge.svg)](https://github.com/MechanicsDSL/mechanicsdsl/actions/workflows/python-app.yml)\n[![PyPI Downloads](https://static.pepy.tech/personalized-badge/mechanicsdsl-core?period=total\u0026units=INTERNATIONAL_SYSTEM\u0026left_color=GRAY\u0026right_color=BLUE\u0026left_text=Downloads)](https://pepy.tech/projects/mechanicsdsl-core)\n![Python 3.9+](https://img.shields.io/badge/python-3.9%2B-blue)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.17771040.svg)](https://doi.org/10.5281/zenodo.17771040)\n[![Documentation Status](https://readthedocs.org/projects/mechanicsdsl/badge/?version=latest)](https://mechanicsdsl.readthedocs.io/en/latest/?badge=latest)\n\n*Write a Lagrangian. Get a simulation.*\n\n---\n\nMechanicsDSL is a domain-specific language and compiler for physical systems. You write a Lagrangian or Hamiltonian in a LaTeX-inspired syntax; the symbolic engine (built on SymPy) derives the equations of motion automatically, and the compiler generates simulation code in your choice of thirteen target languages — from Python and C++ to CUDA, Rust, WebAssembly, and Arduino.\n\nThe goal is to collapse the distance between textbook physics and a running simulation, while keeping the path to lower-level, performance-tuned code open through code generation.\n\n```python\nfrom mechanics_dsl import PhysicsCompiler\n\ncompiler = PhysicsCompiler()\ncompiler.compile_dsl(r\"\"\"\n\\system{pendulum}\n\\defvar{theta}{Angle}{rad}\n\\parameter{m}{1.0}{kg}\n\\parameter{l}{1.0}{m}\n\\parameter{g}{9.81}{m/s^2}\n\n\\lagrangian{\\frac{1}{2} * m * l^2 * \\dot{theta}^2 - m * g * l * (1 - \\cos{theta})}\n\\initial{theta=0.5, theta_dot=0.0}\n\"\"\")\n\nsolution = compiler.simulate(t_span=(0, 10), num_points=1000)\ncompiler.plot(solution)\n```\n\n## What's in the box\n\n| Component | Description |\n|-----------|-------------|\n| **Symbolic engine** | Derives equations of motion from Lagrangians or Hamiltonians, built on SymPy |\n| **Code generation** | Thirteen targets: C++, Python, Rust, Julia, CUDA, Fortran, MATLAB, JavaScript, OpenMP, WebAssembly, Arduino, ARM, Modelica |\n| **JAX backend** | GPU acceleration with JIT compilation and automatic differentiation |\n| **Inverse problems** | Parameter estimation, sensitivity analysis, MCMC uncertainty quantification |\n| **Jupyter integration** | `%%mechanicsdsl` magic commands for interactive notebooks |\n| **Plugin architecture** | Custom physics domains and solvers without modifying the core |\n\n\u003e **Note on generated code.** The code generators produce working reference implementations, not production-tuned binaries. For high-performance or mission-critical work, treat the generated code as a starting point rather than a finished product.\n\n## Installation\n\n```bash\npip install mechanicsdsl-core\n```\n\nOptional extras:\n\n```bash\npip install mechanicsdsl-core[jax]      # GPU + autodiff\npip install mechanicsdsl-core[jupyter]  # Notebook magic\npip install mechanicsdsl-core[all]      # Everything\n```\n\nRequires Python 3.9+. NumPy, SciPy, SymPy, and Matplotlib are installed automatically.\n\n## Example: Figure-8 three-body orbit\n\n```python\nfrom mechanics_dsl import PhysicsCompiler\n\ncode = r\"\"\"\n\\system{figure8_orbit}\n\\defvar{x1}{Position}{m} \\defvar{y1}{Position}{m}\n\\defvar{x2}{Position}{m} \\defvar{y2}{Position}{m}\n\\defvar{x3}{Position}{m} \\defvar{y3}{Position}{m}\n\\defvar{m}{Mass}{kg} \\defvar{G}{Grav}{1}\n\n\\parameter{m}{1.0}{kg} \\parameter{G}{1.0}{1}\n\n\\lagrangian{\n    0.5 * m * (\\dot{x1}^2 + \\dot{y1}^2 + \\dot{x2}^2 + \\dot{y2}^2 + \\dot{x3}^2 + \\dot{y3}^2)\n    + G*m^2/\\sqrt{(x1-x2)^2 + (y1-y2)^2}\n    + G*m^2/\\sqrt{(x2-x3)^2 + (y2-y3)^2}\n    + G*m^2/\\sqrt{(x1-x3)^2 + (y1-y3)^2}\n}\n\"\"\"\n\ncompiler = PhysicsCompiler()\ncompiler.compile_dsl(code)\ncompiler.simulator.set_initial_conditions({\n    'x1': 0.97000436,  'y1': -0.24308753, 'x1_dot': 0.466203685, 'y1_dot': 0.43236573,\n    'x2': -0.97000436, 'y2': 0.24308753,  'x2_dot': 0.466203685, 'y2_dot': 0.43236573,\n    'x3': 0.0,         'y3': 0.0,         'x3_dot': -0.93240737, 'y3_dot': -0.86473146\n})\nsolution = compiler.simulate(t_span=(0, 6.326), num_points=2000)\n```\n\nThe `examples/` directory contains 30+ progressive examples, from harmonic oscillators to SPH fluid dynamics.\n\n## Code generation\n\nAny compiled system can be exported as standalone code in any of the supported targets:\n\n| Target | Output |\n|--------|--------|\n| C++ | CMake project with solver |\n| Python | NumPy/SciPy standalone script |\n| Rust | Cargo project, `no_std` option |\n| Julia | DifferentialEquations.jl |\n| CUDA | GPU-parallel solver |\n| Fortran | F90 with LAPACK |\n| MATLAB | `.m` script with `ode45` |\n| JavaScript | Browser or Node.js |\n| OpenMP | Multi-threaded C++ |\n| WebAssembly | Emscripten WASM |\n| Arduino | `.ino` embedded sketch |\n| ARM | Raspberry Pi / NEON |\n| Modelica | Standards-based FMU |\n\n```python\nfrom mechanics_dsl.codegen.rust import RustGenerator\n\ngen = RustGenerator(\n    system_name=\"pendulum\",\n    coordinates=compiler.get_coordinates(),\n    parameters=compiler.simulator.parameters,\n    initial_conditions=compiler.initial_conditions,\n    equations=compiler.equations,\n)\ngen.generate(\"pendulum.rs\")\n```\n\n## Physics coverage\n\n- **Classical mechanics** — Lagrangian and Hamiltonian formulations; holonomic, non-holonomic, and rolling constraints; Rayleigh dissipation; stability analysis; Noether's theorem; central forces; canonical transformations; normal modes; rigid body dynamics; perturbation theory; collisions; scattering; variable-mass systems; continuous media.\n- **Quantum mechanics** — Bound states, scattering, tunneling, WKB approximation, hydrogen atom, Ehrenfest theorem.\n- **Electromagnetism** — Lorentz force, cyclotron motion, plane waves, antennas, waveguides, Penning traps.\n- **Relativity** — Special: Lorentz boosts, four-vectors, Doppler effect. General: Schwarzschild and Kerr metrics, geodesics, gravitational lensing, FLRW cosmology.\n- **Statistical mechanics and thermodynamics** — Microcanonical, canonical, and grand canonical ensembles; Boltzmann, Fermi-Dirac, and Bose-Einstein distributions; Ising model; heat engines; phase transitions.\n- **Fluid dynamics** — SPH solver with Poly6, Spiky, and viscosity kernels; Tait equation of state; boundary conditions.\n\n## Project status\n\nMechanicsDSL is under active development. The v2.0.x line is stable; new features, additional backends, and broader validation are ongoing. Issues, pull requests, and use-case reports are all welcome — what the project becomes next depends in part on how people are using it.\n\n## Documentation\n\nFull documentation, tutorials, and DSL reference at **[mechanicsdsl.readthedocs.io](https://mechanicsdsl.readthedocs.io/)**.\n\n## Contributing\n\nContributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\n## License\n\nMIT — see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmechanicsdsl%2Fmechanicsdsl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmechanicsdsl%2Fmechanicsdsl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmechanicsdsl%2Fmechanicsdsl/lists"}