You are browsing as a guest. Sign up (or log in) to start making projects!

Atom Simulator VSEPR

  • 5 Devlogs
  • 21 Total hours

What if you had enough energy to build a molecule with any number of atoms? AtomSim simulates how particles arrange themselves around a central atom through physics-based repulsion, forming real molecular geometries like tetrahedral and trigonal planar structures — inspired by VSEPR theory from chemistry. Set your particle count, rotate and zoom with orbit controls, and use Render End Frame to skip the live simulation and jump straight to the final structure for larger counts.

Super Star

As a prize for your great work, look out for a bonus prize in the mail :)

Ship #2

HOW TO USE THE PROJECT ? : Enter the number of particles in the input box (1000 is a recommended number), hit Apply and watch the simulation run. Left click and drag to rotate, scroll to zoom. Hit Explanation for a full breakdown of how it works.

I built a 3D molecular geometry simulator inspired by VSEPR theory from chemistry class using physics calculation, basically simulating how atoms arrange themselves through repulsion. V1 existed but had no controls and was written in VPython, so I learned Three.js from scratch, raw-dogging documentation the entire way.

The challenging part was understanding how Three.js actually works while simultaneously figuring out the physics, forces, dampening, normalisation, cylinder connections between stable particles. The “magic numbers” problem was real problem too, tuning variables so the simulation looks correct and visually pleasing at the same time. But tbh, the writing the code turned out to be so confusing, it took me like 15 hours in total, where as I expected it to get finished in 2 hours, since I thought I was “just gonna translate some code from one language to another”

Most proud of just finishing it honestly. When it finally worked, legendary doesn’t even cover it. IT WAS MORE THAN AMAZING.

  • 3 devlogs
  • 14h
  • 16.52x multiplier
  • 237 Stardust
Try project → See source code →
Open comments for this post

9h 20m 54s logged

Finished V2 of my Atom simulator with A LOT OF IMPROVEMENTS

https://cirqatha.github.io/AtomSim/
So for the V1, I made an Atom simulator out of pure curiosity from my 11th grade chemistry concept called VSEPR theory.
I was told that the website didnt have any controlls, or any interaction, which made it kinda plain. But I stll managed to get high ratings.
So I decided to improve it, but I wrote the previous simulation using VPython, which tbh is the grandfather level compared to three.js which is actively used in websites.
So I learnt three.js and wrote the code. And here is the working of the code if anybody’s interested in it.

  • PROBLEMS I FACED = yea I did not use AI to write code, but the problem is I was learning a new language and three.js. AND I RAW DOGGED DOCUMENTATIONS, i’ve never in my life coded in a more primitive way. I also had to understand the way three.js works, its actual way of doing things.
    You can only imagine how legendary I felt when the project was over.

  • The “magic numbers” = I’ve recieved question from my previous ship about seemingly random values set for variables in the simulation. Remember, this is a very simplified simulation, a simulation with 99.99% accuracy requires a lot of factors, making this complex. The second reason is simply because that the numbers are set to make the motion of particles and visibility of particles visually pleasing while still keeping the structures mostly correct. Hence the “magic numbers”. Like I cannot set distance between atoms super low to simulate reality, thats why you would see the force constant super bumped up.

  • The UI = I’ve added a box to change the number of particles and simulate them, along with a “render End Frame” checkbox which as the name suggests, only calculates stuff till the end frame, without simultaneously updating positions, rather updating at last. There is also a guide for how many particles it can handle safely, I’ve also shown a orbit control guide there which tells you how to rotate and zoom into the simulation.

  • Updating objects = When you enter the number of particles, it first clears all the particles rom previous simulation, along with arrays and stuff.
    Then it adds particles, initialises velocites, and positions.

  • Calculation Forces = In the beginning of each simulation, the arrays is first cleared to clear the forces from previous simulation. Now, For each particle, force from every other particle is calculated, then added together to give a final force vector for that particle.

  • Calculating Velocities = Same clearing up loop with this.Also, This one’s really simple, its just a simple v = u + at formula. Every calculation is followed by a 0.9 factor scaling which dampens the velocity every frame.

  • Calculating Positions = For this one we first store the previous position in a temp variable before clearing it. We then calculate the distance travelled using the formula s = ut + (1/2)at^2. This is followed by a little normalisation, which is basically like if you are spinning a ball with a string, normalisation factor decides how much stretchy the string is. 100% normalisation means the ball travells on the edge of a perfect sphere, a 10% normalisation means it can sometimes go away from that edge, but will not drift away because an additional force is attracting it to the edge.
    That distance travelled is added to the previous position stored in temp and that gives the position for that frame.

  • Calculating Cylinders = For each particle, if it moves less than 0.1 distance between two frames, its considered stable then and it is connected to its nearest surrounding particles using cylinders.

  • Render End Frame = Theres a feature which lets you to only render final frame of a 20 second simulation, which probably saves your system some resource usage. Though all the major stuff like calculation has to happen to calculate it.

2
0
182
Open comments for this post

3h 34m 19s logged

So I took the recommendations from people that rated my previous ship.
Now I’ve switched from VPython to Three.js, the code doesnt exactly translate directly, I’m working on structural changes as well.
The part that takes the longest is not using AI to code, I’m raw dogging this task through documentations.
So far I’ve learnt how to use Three.js, and set up some structural base for the code. I guess it’ll take around 3-5 hours more to complete the project.

0
0
25
Open comments for this post

1h 31m 5s logged

Added a smart cylinder calculation

This is a 10000 particle beast which took 20 minutes to compute one final frame after settling.

Added numpy because calculations are reduced from hours to minutes

0
0
12
Ship #1

What did you make?

An Atom Simulator that visualises VSEPR theory — a chemistry concept I was studying
in 11th grade that explains how atoms arrange themselves when forming compounds.
I gave each particle a repulsive force and used some physics where atoms naturally settle into the same structures VSEPR predicts.

What was challenging?

Two things:

  1. The radial force, getting particles to stay on the sphere surface without snapping or drifting took a lot of tuning (damping constants, partial normalisation, force scaling)

2.Dynamic bond drawing, since particles move every frame, the cylinders connecting them have to be recalculated each frame, including figuring out which particles are close enough to be “bonded” and hiding the rest

What are you proud of?

I started by manually hard-coding forces between every pair of atoms, then refactored
everything into loops and 2D lists, cutting the code down massively. I also pre-compute all the frames before the animation starts, so playback is smooth with
no lag.

To test it

Use the GlowScript web version, it works in any browser instantly.
If you run it locally, note that it freezes for ~30 seconds while pre-computing
frames before the animation starts. That’s normal, not a crash.

  • 1 devlog
  • 6h
  • 11.34x multiplier
  • 73 Stardust
Try project → See source code →
Open comments for this post

6h 24m 3s logged

*Built an Atom Simulator

I’m in 11th so I had the topic of VSEPR in my curriculum, So I built a program that simulates these structures by giving repulsion energies to these atoms. Then after using VPython, vectors, partial normalisation, 2D Lists and stuff I made it a bit not so boring.
The structure automatically takes place when they go into lowest energy state. The positions are all first calculated and then the animation begins where you can see them going into lowest energy states.

The maximum limit is said to be 12, but you could try with any number of particles you want, seeing how the structure would look like if it were real

0
0
10

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…