GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - nitya-d/shm-pendulum-simulation: Driven-damped pendulum simulation with real-time parameter sliders and phase space plotting. Built with VPython/GlowScript. Click link below for interactive simulation

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
README.md
README.md
 
 
main.py
main.py
 
 
readme_ss.png
readme_ss.png
 
 
requirements.txt
requirements.txt
 
 

Repository files navigation

SHM Pendulum Simulation

An interactive simulation of a driven-damped pendulum built with VPython/GlowScript. Originally written as a high school project: a first attempt at computational physics and learning to turn physical equations into working code. It's not perfect, but it was the project that got me interested in the overlap between physics and computer science.

Simulation screenshot

Try the interactive version


Physics

The simulation models a pendulum governed by:

θ'' = -(g/L)sin(θ) - bθ' + F₀cos(ω₀t)

where:

  • g is gravitational acceleration
  • L is pendulum length
  • b is the damping coefficient
  • F₀ is the driving force amplitude
  • ω₀ = √(g/L) is the natural frequency

The driving force is applied at the natural frequency, producing resonance behaviour when combined with low damping. Time integration uses the Euler-Cromer method.

Features

  • Real-time 3D pendulum visualisation
  • Adjustable parameters via sliders:
    • Pendulum length and bob mass
    • Gravitational acceleration (e.g. set to 24.79 m/s² for Jupiter)
    • Damping coefficient
    • Driving force amplitude
    • Timestep dt
  • 6 live graphs: position, velocity, acceleration, theta, KE/PE/total energy, and a phase space plot (θ vs dθ/dt), the phase space portrait shows the transition from simple oscillation to chaotic motion as driving force increases
  • Reset button to restore all parameters and clear graphs

Running locally

Requires Python 3.11 (vpython has known compatibility issues with Python 3.12+).

pip install vpython
python main.py

This opens the simulation in your browser via a local server.

GlowScript

The code runs as-is on glowscript.org. Just remove the from vpython import * import line, as GlowScript provides all built-ins globally.

About

Driven-damped pendulum simulation with real-time parameter sliders and phase space plotting. Built with VPython/GlowScript. Click link below for interactive simulation

www.glowscript.org/#/user/ND/folder/MyPrograms/program/PendulumPublic

Topics

computational-physicsdifferential-equationsnumerical-methodspendulumphysics-simulationvpython

Resources

Readme
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.