{"id":16870437,"url":"https://github.com/narimiran/double_pendulum","last_synced_at":"2026-03-18T00:48:39.883Z","repository":{"id":37951972,"uuid":"121372731","full_name":"narimiran/double_pendulum","owner":"narimiran","description":"Animations of random double pendulums","archived":false,"fork":false,"pushed_at":"2023-01-11T22:20:16.000Z","size":60,"stargazers_count":132,"open_issues_count":2,"forks_count":18,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-11-16T05:03:32.879Z","etag":null,"topics":["animation","differential-equations","matplotlib","numerical-methods","numerics","numpy","python","twitter","twitter-bot"],"latest_commit_sha":null,"homepage":"https://twitter.com/pendulum_bot","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/narimiran.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-13T11:05:59.000Z","updated_at":"2025-07-17T06:43:45.000Z","dependencies_parsed_at":"2023-02-09T08:17:11.471Z","dependency_job_id":null,"html_url":"https://github.com/narimiran/double_pendulum","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/narimiran/double_pendulum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narimiran%2Fdouble_pendulum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narimiran%2Fdouble_pendulum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narimiran%2Fdouble_pendulum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narimiran%2Fdouble_pendulum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/narimiran","download_url":"https://codeload.github.com/narimiran/double_pendulum/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narimiran%2Fdouble_pendulum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30637778,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-18T00:09:27.587Z","status":"ssl_error","status_checked_at":"2026-03-18T00:09:26.123Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["animation","differential-equations","matplotlib","numerical-methods","numerics","numpy","python","twitter","twitter-bot"],"created_at":"2024-10-13T15:04:22.638Z","updated_at":"2026-03-18T00:48:39.845Z","avatar_url":"https://github.com/narimiran.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Double pendulum](double_pendulum.png)\n\n\nThe code behind [@pendulum_bot](https://twitter.com/pendulum_bot) Twitter bot which posts animations of a double pendulum released from a random position to swing for 30 seconds.\n\n\n\u0026nbsp;\n\n\n# Basic usage\n\nTo create an animation of a random double pendulum:\n\n```python\n\u003e\u003e\u003e from simulation import create_random_example, simulate\n\u003e\u003e\u003e from animations import single_animation\n\u003e\u003e\u003e rand_ex = create_random_example()\n\u003e\u003e\u003e results = simulate(rand_ex)\n\u003e\u003e\u003e single_animation(results, rand_ex)\n```\n\nThe animation is saved as .mp4 video in `animations` subdirectory.\n\n---\n\nTo create an animation and post it on Twitter, a valid API key is needed, and should be stored in `api_key.txt`.\n\n```python\n\u003e\u003e\u003e from tweet_it import new_tweet\n\u003e\u003e\u003e new_tweet() # creates a new animation of random double pendulum\n# or\n\u003e\u003e\u003e new_tweet('existing_file', 'My custom Twitter status')\n```\n\n---\n\nTo create double pendulum with the exact values for initial conditions:\n\n```python\n\u003e\u003e\u003e from pendulum import Pendulum, DoublePendulum\n\u003e\u003e\u003e p1 = Pendulum(m=2.7, x=2.5, y=3.7, u=0, v=0)\n\u003e\u003e\u003e p2 = Pendulum(m=3.1, x=0.2, y=6.3, u=0, v=0)\n\u003e\u003e\u003e dp = DoublePendulum(p1, p2)\n```\n\n---\n\nTo create multiple pendulums with slight perturbations of initial conditions to observe chaotic behaviour:\n\n```python\n\u003e\u003e\u003e from simulation import create_random_example, create_perturbations, simulate_multiple_examples\n\u003e\u003e\u003e from animations import multi_animation\n\u003e\u003e\u003e rand_ex = create_random_example()\n\u003e\u003e\u003e perturbed = create_perturbations(10, rand_ex, amount=1e-5)\n\u003e\u003e\u003e results = simulate_multiple_examples(perturbed)\n\u003e\u003e\u003e multi_animation(results, rand_ex)\n```\n\n\n\u0026nbsp;\n\n\n# Installation\n\n```\ngit clone https://github.com/narimiran/double_pendulum.git\ncd double_pendulum\n```\n\n### Dependencies\n\n* Python 3\n* numpy (running simulations)\n* matplotlib (creating animations)\n* ffmpeg or avconv/libavtools (saving videos)\n* twython (posting Twitter updates)\n\n\n\u0026nbsp;\n\n\n# FAQ\n\nQ: *Why do you use Cartesian coordinates? I prefer polar coordinates.*\n\nA: The initial task I was given was to implement double pendulum as DAE system in Cartesian coordinates. The idea for animations and Twitter bot came later, and Cartesian coordinates remained.\n\nQ: *Which Runge-Kutta methods can I use?*\n\nA: Any of these:\n\n* Forward Euler (`Euler`)\n* Explicit midpoint (`ExplicitMidpoint`)\n* Ralston's method (`Ralston`)\n* Kutta's 3rd order method (`Kutta3`)\n* *the* Runge-Kutta 4th order method (`RK4`)\n* Runge-Kutta-Fehlberg (`RKF`)\n* Cash-Karp (`Cash-Karp`)\n* Dormand-Prince method (`DOPRI5`)\n\nQ: *Why can't I use implicit Runge-Kutta methods?*\n\nA: Implicit methods require different solving method (solving a system of non-linear equations). This is not (yet) implemented.\n\nQ: *Is there any damping/friction?*\n\nThere is no damping and no friction. The only force acting on the system is gravity.\n\nQ: *Couldn't all/some of this be done simpler?*\n\nA: Probably.\n\n\n\u0026nbsp;\n\n\n# License\n\n[MIT License](LICENSE.txt)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnarimiran%2Fdouble_pendulum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnarimiran%2Fdouble_pendulum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnarimiran%2Fdouble_pendulum/lists"}