Friday, July 4, 2008

Modeling ATOMS

Particles that flow with each others movement is nice, but not what an atom is. So here is the newest of the computer models, for our first simple atom!



Here we see a much better defined orbital, in this case a for the most part circular orbit in the particles innermost shell.

To achive this, paticles were made stationary so they did not move. Their rounded cube visual area (see below) was also divided internally into three shell areas as shown below, which in 2 and 3 are spherically calculated to remove squareness of cube from their path.



After the first shell shown in the first picture making more spherical shells does not leave a path all around due to edges being removed, but that is solved by later combining shell 2 and 3, or 1 and 2, depending on how you want to use them.


The loop is made confident going into the other particles inner shell, but not back out again. So it's drawn into its shell to for the most part stay. This way we make a very simple model of an atom with these If..Then.. statements.

'INSTINCTS are described by the following If..Then.. statements.
CnfChange = -1
'Is confident when moving through the three shells into 1.
If Dist1(N, 0) = 3 And Dist1(N, 1) = 0 Then CnfChange = 1
If Dist1(N, 0) = 2 And Dist1(N, 1) = 3 Then CnfChange = 1
If Dist1(N, 0) = 1 And Dist1(N, 1) = 2 Then CnfChange = 1
'Is confident when the second angle moving into shell 1.
If Dist2(N, 0) = 3 And Dist2(N, 1) = 0 Then CnfChange = 1
If Dist2(N, 0) = 2 And Dist2(N, 1) = 3 Then CnfChange = 1
If Dist2(N, 0) = 1 And Dist2(N, 1) = 2 Then CnfChange = 1
'Is confident when following the same shell around for some distance.
If Dist1(N, 0) = 1 And Dist1(N, 1) = 1 Then CnfChange = 1
If Dist2(N, 0) = 1 And Dist2(N, 1) = 1 Then CnfChange = 1
If Dist1(N, 0) = 2 And Dist1(N, 1) = 2 Then CnfChange = 1
If Dist2(N, 0) = 2 And Dist2(N, 1) = 2 Then CnfChange = 1
If Dist1(N, 0) = 3 And Dist1(N, 1) = 3 Then CnfChange = 1
If Dist2(N, 0) = 3 And Dist2(N, 1) = 3 Then CnfChange = 1
'Not confident when both distances are zero, meaning it sees nothing else
If Dist1(N, 0) = 0 And Dist2(N, 0) = 0 Then CnfChange = -1
'Loses Confidence when it is sitting still.
If Abs(XMR(N) - XMF(N)) + Abs(YMR(N) - YMF(N)) + Abs(ZMR(N) - ZMF(N)) = 0 Then CnfChange = -1
'Loses Confidence when hits the Wall, they Bump, or more than 2 neighbors.
If Wall(N) = 1 Or Bump(N) = 1 Or Greater2 = 1 Then CnfChange = -1

We can predict what that should do, and the model did it, which means we're already at a milestone. We have made our first simple atom, of hydrogen!

The next step is a matter of adding repulsion, to what is at the moment all attraction. Adding one more moving particle, to the one already there, has them meeting up then they go off dancing together. Atoms do have electrons that do this, they repel, so that must be added for the model to add more electrons in orbit, which could get interesting after the first two occupy the inner shell leaving the rest to find a less than circular orbit through, for more complex orbital geometries typical of atoms. Are one step at a time,

It uses 26 bits of RAM memory for the Main Memory, 67 megs total, which is not much for program size but be be patient if you save main memory since it's large for a disk file that comes out twice that in size due to how it saves the array. Or try to draw many at a time, since Visual Basic is wasting a great deal of CPU time doing 32 bit divison and more just to shift a bit that can be coded in Assembler to do superfast.

For highest speed possible, you need a MASM32 editor like this free one.



It is what the Intel (or clone) chip communicates in. Not another layer of software in between such as Visual Basic, C++, or others which can speed up development time by making writing and debugging easier. But the program runs slower since you're not directly communicating to the CPU, are going through the VB editor that goes through Windows to get to the CPU.

MASM32 is worth learning, coded for years in it. Easy one to learn. In the above download has a tutorial, data on all the instructions, and plenty of sample code to try out. Makes learning how to code in it, rather easy. In case you're interested in rewriting the Atom3D.frm program Visual Basic reads into Assembler, to see how fast it can go. With no super number crunching math like the physicists use in supercomputers, it should be like having a supercomputer inside our PC, with atoms that at times kinda have a mind all their own but are otherwise amusing. In time, possibly a better way to model some things.