For years, I had a wood and plastic mechanical chaos demonstrator sitting on the front of my desk in my Navy office. As I anticipated, visitors could not resist the urge to spin the wheels and watch the chaotic motion that ensued.
Depending on the context of the conversation, those spinning wheels could represent the harmony or disharmony between individuals, or departments within an organization, or between the head office and various departments. In my novels, I had one demonstrator sitting on the desk of the President of the United States, serving as a reminder of how normal behavior can turn into chaotic conflict without warning. POTUS would use it as an object lesson when dealing with Senators, Representatives, or Heads of State.
In other words, the toy demonstrates far more than the physics of a toy.
Chaos Simulation Concept
The concept behind the toy is as follows: Each three-spoked wheel sits atop a pin, thereby earning the name pinwheel. At the end of each spoke is a magnet. The magnets all have the same polarity exposed to the outer surface of the spoke. Therefore, as magnets from one wheel approach a magnet from the other wheel, there is a repulsive force applied to each spoke.
The user spins each wheel in whichever direction they wish: clockwise or counterclockwise. The amount of rotational force applied to each wheel’s hub determines how fast the wheels turn. At high rotational speed, the magnetic repulsion exerts little influence on the spinning wheels. But as the wheels slow down due to resistance within the pin and wheel hub contact point, the repulsive forces begin to exert an effect on the wheel’s rotation. Very quickly, that battle of the magnets devolves into chaos. The rotation of each wheel becomes unpredictable.
It is entertaining to watch. That is, as long as you don’t think too hard about the geopolitical implications.
Chaos Simulation
I have an innate desire to simulate things. If I can successfully simulate something in code, then I know I understand what’s going on. So, I attempted the Wheels simulation using Visual Basic. My code sort of worked, but after a minute or so of running, the simulated wheels would speed up until they were nothing but a blur.
The code obviously had issues.
Losing interest, I moved on to other, more successful simulation topics and forgot about the Wheels. Until ChatGPT came along. After giving GPT-5 a detailed prompt, the AI laid out 550 lines of HTML code. I was amazed.
The first time I ran that code with my Chrome browser, it worked. And after two days of tweaking the code to work exactly the way I wanted, it worked well enough to share.
Chaos Video
The following link is to the YouTube video which accompanies this blog post.
YouTube Video Description
“A computer version of a mechanical Chaos Simulator was created in HTML code so it can be run from any popular web browser. It introduces Chaos Theory and is a model for the unpredictability of both interpersonal and geopolitical interactions.
Unlike the physical simulator it replaces, it is both quantitative and highly interactive. Thus, it is transformed from a toy to a teaching tool for high school introductory physics, or college-level, calculus-based classical mechanics lessons. The fact that it uses simulated magnetism to occasionally create a harmonic oscillator may also be of interest to junior-level Electricity and Magnetism students.”
The Result
Baseline
For a baseline, the wheels have no magnets; i.e., no repulsive or attractive force generators. The mass of the magnet is present, but no magnetic fields are produced.
Both wheels are spun with the same impulse magnitude, but in opposite directions. The left wheel (wheel 1) is “spun” with a clockwise motion, and the right wheel is forced counterclockwise. After the initial impulse, no other spinning force is applied to the wheels.

The wheels begin rotating with the same velocity. The gray line in the figure below is the line for zero angular velocity. The blue wheel spinning clockwise has, by convention, a positive angular velocity. The red wheel spinning counterclockwise has, by convention, a negative angular velocity.
Due to the effect of wheel hub friction (resistance), both wheels begin slowing down. After 50 seconds, the wheels are essentially still, approaching zero velocity.

Chaotic Repulsion
Now lets add magnetic fields to the ends of the spokes. Initially, the simulated magnets are oriented so that only repulsive forces are encountered as opposing magnets approach. However, the magnets do not make physical contact. Due to the strength of the magnetic fields, the magnets exert forces on each other from a distance.


Whenever a red or blue line approaches the central gray line, the respective wheel has essentially stopped momentarily. When the blue line descends below the gray line, the blue wheel has stopped moving clockwise and is moving counterclockwise. Likewise, when the red line rises above the gray zero line, the red wheel is moving clockwise, rather than its original counterclockwise motion.
The net result is chaotic movement.
The next figure captures the moment of magnetic (but not physical) contact between the opposing wheels. The oblique lines illustrate the repulsion force vectors, indicating angle and magnitude information about those vectors at that particular instant.

Teaching Tool
The more I played with the computer simulation, the more I discovered how sophisticated the model was and how useful the results were. On the one hand, it illustrates chaotic (unpredictable) behavior. As you might imagine, Chaos Theory is of considerable academic interest.
However, I quickly appreciated the sim’s potential for illustrating physics topics in Classical Mechanics. My aged library of freshman and sophomore college physics books contains calculus-based topics that are integral to the working of this model. Relevant examples range from force vectors to harmonic motion.
In Third-Year Electricity and Magnetism physics courses, the subject of magnetostatics covers boundary conditions on magnetic fields. That is relevant because within the Sim’s HTML code, a very simple implementation of changing magnetic field locality, is invoked. Although for simplicity, the magnets are considered as point sources, the extent of the magnetic fields is variable, encoded within the program’s code. Since the code is HTML, altering it to suit the user’s needs is trivial.
Force model: F = repulsive*exp(-kR*(d - d0)) - attractive*exp(-kA*(d - d0))
const kR = 0.01; // repulsion locality
const kA = 0.02; // attraction more spread-out
At the undergraduate level, these topics require calculus to adequately understand them. Indeed, looking at the constantly varying shape of the angular velocity plots produced by the simulation, the invocation of calculus is obvious. However, even when using algebra in a high school physics class, the simulation should still be a useful tool.
Physics Curricula
The following table illustrates where the topic of classical mechanics is typically distributed throughout the physics education curriculum. Within each educational topic, it is my opinion that the magnetic pinwheel simulator has a teaching role.
| Topic | High School (Intro) | University Physics I | Advanced Undergraduate / Graduate |
| Force & Vectors | ✓ | ✓ | |
| Inertia | ✓ | ✓ | |
| Momentum & Impulse | ✓ | ✓ | |
| Torque | ✓ | ✓ | ✓ |
| Rotational Velocity | ✓ | ✓ | ✓ |
| Harmonic Oscillator | ✓ | ✓ | ✓ |
The Unexpected Harmonic Oscillator
One of the delights of simulation is that the unexpected will occasionally appear. The fun part is figuring out why the unexpected happened.
A case in point follows.
When preparing the downloaded HTML code, nullify the repulsive force slider, maximize the attractive force slider, maximize hub resistance (friction coefficient), and set a moderate initial transient impulse on wheel 1. Set the initial transient wheel 2 impulse at about 60% of wheel 1. Select clockwise initial rotation for wheel 1 and counterclockwise rotation for wheel 2.
The result is remarkably different from the simulations with high repulsion forces. There is no chaos, per se, but a rapid decrease in rotational velocity as a result of the intermittent attraction forces between close magnets and hub resistance. When two magnets become magnetically bonded to each other, wheel motion transitions to that of a damped harmonic oscillator.

Curiously, the nature of the oscillation is probabilistic. About a third of the time, the two wheels oscillate in phase, a third, 180° out of phase, and another third, with no oscillation at all.
I’ll leave it to the interested reader to ponder why the oscillations seem less damped than the non-oscillatory movement.
Download
If you wish to try this simulator, the HTML code can be downloaded here in the form of a zip file. As always, be sure to check your download with a virus checker before running the code on a web browser like Chrome.
Here is a link to a zip file containing the HTML code for running in your browser.
Also, it’s a good habit to inspect any downloaded HTML code with a text editor like Notepad or Notepad++ to confirm it is harmless.
Questions?
As always, if you have questions, I can be contacted at john@johnclarkeonline.com.


































































