Skip to content

vmfreixas/Euler_Lagrange_Solutions

Repository files navigation

Euler Lagrange Solutions (Python)

CI Python License: MIT

Give me (L(q,\dot q,t)) and I’ll give you the motion. This repo auto-derives the Euler–Lagrange equations with SymPy and integrates the resulting ODEs with SciPy. It includes ready-to-run examples (pendulum, double pendulum, N-body gravity, and spring–mass networks) and lightweight animations.

Features

  • Symbolically derive Euler–Lagrange equations from a user-specified Lagrangian (SymPy).
  • Convert to first-order ODEs and integrate (SciPy solve_ivp).
  • Jupyter notebooks with visualizations and energy-drift diagnostics.

Install

  • python3 -m venv .venv
  • source .venv/bin/activate
  • pip install -r requirements.txt
  • pip install -e .

Notebooks

  • notebooks/01_simple_pendulum_lib.ipynb — minimal library usage.
  • notebooks/02_double_pendulum.ipynb — chaotic two-link example.
  • notebooks/03_springs_random.ipynb — 4-mass spring ring with random initialization and animation.

Development

lint/format/strip (pre-commit)

pre-commit run --all-files

tests

pytest -q

coverage (optional)

pytest --cov=src/euler_lagrange_solutions --cov-report=term-missing

Licence

MIT Licence

Citation

If you use this code in academic work, please cite the repository.

Why this repo

  • End-to-end EL pipeline (symbolic → numeric → integration).
  • Clean, modern Python: type hints, tests, CI, pre-commit.
  • Clear demos with small, readable notebooks + animations.

About

Auto-derive Euler–Lagrange equations from a Lagrangian; integrate and visualize in Jupyter.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages