{"id":19211730,"url":"https://github.com/edibotopic/stokes-law","last_synced_at":"2026-05-14T18:33:23.761Z","repository":{"id":39996814,"uuid":"492448853","full_name":"edibotopic/stokes-law","owner":"edibotopic","description":"Interactive 2D simulation of Stokes' Law, which describes how particles float/sediment in solvent. Subject of paper in the Journal of Chemical Education: https://pubs.acs.org/doi/10.1021/acs.jchemed.2c01201","archived":false,"fork":false,"pushed_at":"2023-08-02T13:46:10.000Z","size":861,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T07:44:34.593Z","etag":null,"topics":["animation","canvas","food","motion","particles","physics","physics-simulation","science","simulation"],"latest_commit_sha":null,"homepage":"https://edibotopic.github.io/stokes-law/","language":"JavaScript","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/edibotopic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-05-15T10:02:43.000Z","updated_at":"2024-02-16T09:45:33.000Z","dependencies_parsed_at":"2022-08-25T18:30:50.762Z","dependency_job_id":null,"html_url":"https://github.com/edibotopic/stokes-law","commit_stats":{"total_commits":91,"total_committers":3,"mean_commits":"30.333333333333332","dds":0.02197802197802201,"last_synced_commit":"b7bc26b850cd5c97d1c8c9f034765d39a805f623"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/edibotopic/stokes-law","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edibotopic%2Fstokes-law","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edibotopic%2Fstokes-law/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edibotopic%2Fstokes-law/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edibotopic%2Fstokes-law/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edibotopic","download_url":"https://codeload.github.com/edibotopic/stokes-law/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edibotopic%2Fstokes-law/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33037859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"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":["animation","canvas","food","motion","particles","physics","physics-simulation","science","simulation"],"created_at":"2024-11-09T13:44:34.847Z","updated_at":"2026-05-14T18:33:23.724Z","avatar_url":"https://github.com/edibotopic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stokes' Law Simulation\n\nThis is an interactive simulation of Stokes' Law, which is used by scientists and engineers to approximate the velocity of sedimentation (or flotation) for particles dispersed in a solvent.\n\nThe purpose of the simulation is to provide a visual tool for developing an intuition for the equation and the behaviour it describes, especially for students who are unfamiliar or uncomfortable with mathematics.\n\n## Basic Principles\n\nA particle will sediment if it is more dense than the solvent it is suspended in. If it is less dense than the solvent then it will float.\n\nStokes' Law is commonly used to calculate the average velocity of a population of particles as influenced by physical properties of the particles and solvent:\n\n![Equation for Stokes' Law](./img/equation_light.png#gh-light-mode-only)\n![Equation for Stokes' Law](./img/equation_dark.png#gh-dark-mode-only)\n\n$D$ is the diameter of the particle, $ρ_p - ρ_s$ represents the difference in density between particle and solvent, while $μ$ is the viscosity of the solvent. The $g$ represents gravitational acceleration, which can be multiplied by an appropriate g-force when separation in a centrifuge is of interest.\n\nIn the application the units for the physical quantities are taken to be:\n\n- Radius ($mm$)\n- Density ($kg/m^3$)\n- Viscosity ($Pa.s$)\n- Velocity ($m/s$)\n\nThe default centrifugal force is $1$ (no centrifugation) meaning\nthat acceleration due to gravity ($1 \\times 9.81 \\ m/s^2$) applies.\nApplying a centrifugal force of $2$ will double this value.\n\nNote: the units can be viewed at any time by hovering over the sliders or\nclicking on the variable name (mobile).\nOn mobile, clicking anywhere else on the screen after a tooltip appears will remove the tooltip.\n\n## Practical Significance\n\nManipulating the physical variables in this equation is the basis of commercial strategies to both promote separation (centrifugation) or reduce separation (homogenisation).\n\nIn food, for example:\n\n- Centrifugation is used to promote the flotation of oil droplets in the separation of cream\n- Homogenisation is used to reduce the size of oil droplets in beverages and thereby decrease their flotation speed\n- Thickeners are added to salad dressings to increase viscosity and slow the sedimentation of herbs and spices\n\nIn analytical science, re-arranging the Stokes' Law equation allows for estimation  of particle size or viscosity based on sedimentation data.\n\nA variety of other industrial and scientific examples can be found in the literature.\n\n## Implementation\n\nThe simulation is coded using vanilla JavaScript, with particles rendered using the HTML `\u003ccanvas\u003e` element.\n\nSliders can be used to modify the variables of Stokes' Law and observe the changes in real-time.\n\nButtons are provided to *restart* the simulation, show a brief *about* popup and access the *source* code.\n\nThe application is deliberately minimal and simple so that students can interact with it quickly and easily.\n\nThe code is made available under an MIT license and educators are free to copy and modify the code themselves.\n\nAs the application is served as a single `index.html` page it can be easily embedded as an iframe in web-based notes and slides, in addition to Learning Management Systems like Canvas.\nIt can also be downloaded onto your device and then run locally by opening `index.html` (inside the `stokes-law` folder) in a browser.\n\n## Release Notes\n\n1.1.0\n\nStatistical output added:\n\n- Graph readout of velocity over time\n- Numerical output of mean velocity, diameter and the density difference\n- Addition of a copy button for embedding in LMS\n\n1.0.0\n\nBasic implementation complete:\n\n- Simulation of particles with velocity determined by Stokes' Law\n- Manipulation of particle and solvent properties using sliders\n- Minimal UI with reset, about and source buttons\n\n## Future Plans\n\nAs of 1.0.0 the application is considered feature-complete.\n\nBeyond that, I will mainly be focusing on minor bug fixes and quality-of-life improvements and do not foresee major changes.\n\nIf you have any suggestions please file an *issue*, raise a *pull request* or send me an email at edibotopic@gmail.com. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedibotopic%2Fstokes-law","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedibotopic%2Fstokes-law","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedibotopic%2Fstokes-law/lists"}