'Simple Model of Ionic Crystal v6 by QWERKEY 2018-11-23
CONST True
= -1`
, False
= 0`
CONST A0!
= 100, A1!
= 2, R0!
= 250, R1!
= 2.3, A2!
= 200, R2!
= 115, F2!
= 3000, FMin!
= -5 '-55 CONST TotBalls%%
= 125, NoSeed%%
= 75, Atom!
= 110, Xstal!
= 0.98, Kelvin!
= 0.35 CONST ChlorineSize%%
= 35, SodiumSize%%
= 25, Offset%
= 730, ScreenX%
= 1260, ScreenY%
= 800, ThetaMax!
= 0.5
DIM SHARED SodiumPos!
(TotBalls%%
- 1, 2), ChlorinePos!
(TotBalls%%
- 1, 2), NoBalls%%
DIM SHARED SodiumVel!
(TotBalls%%
- 1, 2), ChlorineVel!
(TotBalls%%
- 1, 2), ViewAngle!
DIM SodiumAcc!
(TotBalls%%
- 1, 2), ChlorineAcc!
(TotBalls%%
- 1, 2), BallStats%
(3, 2)
_TITLE "Very Accurate Quantum Physics Model"
'Set Seed Crystal
Default! = 0.69 * Atom!
ChlorinePos!(N%%, 0) = Default! * I%%
ChlorinePos!(N%%, 1) = Default! * J%%
ChlorinePos!(N%%, 2) = 2 * Default! * K%%
SodiumPos!(N%%, 0) = ChlorinePos!(N%%, 0)
SodiumPos!(N%%, 1) = ChlorinePos!(N%%, 1)
SodiumPos!(N%%, 2) = ChlorinePos!(N%%, 2) - Default!
ChlorinePos!(N%%, 0) = Default! * I%%
ChlorinePos!(N%%, 1) = Default! * J%%
ChlorinePos!(N%%, 2) = 2 * Default! * K%% - Default!
SodiumPos!(N%%, 0) = ChlorinePos!(N%%, 0)
SodiumPos!(N%%, 1) = ChlorinePos!(N%%, 1)
SodiumPos!(N%%, 2) = ChlorinePos!(N%%, 2) + Default!
N%% = N%% + 1
FOR N%%
= 0 TO NoSeed%%
- 1 ChlorineVel!
(N%%
, M%%
) = (RND - 0.5) * Kelvin!
SodiumVel!
(N%%
, M%%
) = (RND - 0.5) * Kelvin!
'Additional atom properties
FOR N%%
= NoSeed%
TO TotBalls%%
- 1 ChlorinePos!
(N%%
, 0) = (1 + 0.75 * RND) * ScreenX%
/ 3 IF RND > 0.5 THEN ChlorinePos!
(N%%
, 0) = ChlorinePos!
(N%%
, 0) * -1 RPosn!
= ChlorinePos!
(N%%
, 0) * TAN(Xi!
) ChlorinePos!
(N%%
, 1) = RPosn!
* SIN(Chi!
) ChlorinePos!
(N%%
, 2) = RPosn!
* COS(Chi!
) IF RND > 0.5 THEN ChlorinePos!
(N%%
, M%%
) = -ChlorinePos!
(N%%
, M%%
) ChlorineVel!
(N%%
, M%%
) = (RND - 0.5) * Kelvin!
SodiumVel!
(N%%
, M%%
) = (RND - 0.5) * Kelvin!
SodiumPos!
(N%%
, 2) = ChlorinePos!
(N%%
, 2) + Atom!
* SIN(Psi!
) * COS(Chi!
) SodiumPos!
(N%%
, 0) = ChlorinePos!
(N%%
, 0) + Atom!
* SIN(Psi!
) * SIN(Chi!
) SodiumPos!
(N%%
, 1) = ChlorinePos!
(N%%
, 1) + Atom!
* COS(Psi!
)
' Ball Colours (Cyperium Method)
READ BallStats%
(N%%
, P%%
) COLOR _RGBA(BallStats%
(N%%
, 0), BallStats%
(N%%
, 1), BallStats%
(N%%
, 2), 65), _RGBA(0, 0, 0, 0) 'Image data goes from 1 to 255 (not 0 to 255)
DeltaX% = X% - 127
DeltaY% = Y% - 127
DeltaZ% = Z% - 127
Dist!
= SQR((DeltaX%
* DeltaX%
) + (DeltaY%
* DeltaY%
) + (DeltaZ%
* DeltaZ%
)) IF Dist!
> 125 AND Dist!
< 127 THEN PSET (X%
, Y%
), _RGBA(CINT(Z%
* BallStats%
(N%%
, 0) * (1 - (XBright!
* X%
/ 255)) / 255), CINT(Z%
* BallStats%
(N%%
, 1) * (1 - (XBright!
* X%
/ 255)) / 255), CINT(Z%
* BallStats%
(N%%
, 2) * (1 - (XBright!
* X%
/ 255)) / 255), 65)
'Images
'Create screen
'Run simulation
NoBalls%% = NoSeed%%
Count% = 0
DrawBonds` = False
Paused` = False
ASaltyDog` = True
'Mouse Input
IF XMouse%
> ScreenX%
- 199 AND XMouse%
< ScreenX%
- 121 AND YMouse%
> 21 AND YMouse%
< 119 THEN DrawBonds` = False
DrawBonds` = True
ELSEIF XMouse%
> ScreenX%
- 99 AND XMouse%
< ScreenX%
- 21 AND YMouse%
> 21 AND YMouse%
< 119 THEN Paused` = False
Paused` = True
ELSEIF XMouse%
> ScreenX%
- 99 AND XMouse%
< ScreenX%
- 21 AND YMouse%
> ScreenY%
- 119 AND YMouse%
< ScreenY%
- 21 THEN ASaltyDog` = False
'Display atoms and calculate forces
MaxDist! = 0
F1! = 900 + 100 * ((NoBalls%% - NoSeed%%) / (TotBalls%% - NoSeed%%))
FOR N%%
= 0 TO NoBalls%%
- 1 XTemp! = XDash!((ChlorinePos!(N%%, 0)), (ChlorinePos!(N%%, 2))): ZTemp! = ZDash!((ChlorinePos!(N%%, 0)), (ChlorinePos!(N%%, 2)))
_MAPTRIANGLE (0, 0)-(255, 0)-(0, 255), Chlorine&
TO(-(ChlorineSize%%
- 1) \
2 + XTemp!
, (ChlorineSize%%
- 1) \
2 + ChlorinePos!
(N%%
, 1), ZTemp!
- Offset%
)-((ChlorineSize%%
- 1) \
2 + XTemp!
, (ChlorineSize%%
- 1) \
2 + ChlorinePos!
(N%%
, 1), ZTemp!
- Offset%
)-(-(ChlorineSize%%
- 1) \
2 + XTemp!
, -(ChlorineSize%%
- 1) \
2 + ChlorinePos!
(N%%
, 1), ZTemp!
- Offset%
) _MAPTRIANGLE (255, 255)-(0, 255)-(255, 0), Chlorine&
TO((ChlorineSize%%
- 1) \
2 + XTemp!
, -(ChlorineSize%%
- 1) \
2 + ChlorinePos!
(N%%
, 1), ZTemp!
- Offset%
)-(-(ChlorineSize%%
- 1) \
2 + XTemp!
, -(ChlorineSize%%
- 1) \
2 + ChlorinePos!
(N%%
, 1), ZTemp!
- Offset%
)-((ChlorineSize%%
- 1) \
2 + XTemp!
, (ChlorineSize%%
- 1) \
2 + ChlorinePos!
(N%%
, 1), ZTemp!
- Offset%
) _MAPTRIANGLE (0, 0)-(255, 0)-(0, 255), Pink&
TO(-(ChlorineSize%%
- 1) \
2 + XTemp!
, (ChlorineSize%%
- 1) \
2 + ChlorinePos!
(N%%
, 1), ZTemp!
- Offset%
)-((ChlorineSize%%
- 1) \
2 + XTemp!
, (ChlorineSize%%
- 1) \
2 + ChlorinePos!
(N%%
, 1), ZTemp!
- Offset%
)-(-(ChlorineSize%%
- 1) \
2 + XTemp!
, -(ChlorineSize%%
- 1) \
2 + ChlorinePos!
(N%%
, 1), ZTemp!
- Offset%
) _MAPTRIANGLE (255, 255)-(0, 255)-(255, 0), Pink&
TO((ChlorineSize%%
- 1) \
2 + XTemp!
, -(ChlorineSize%%
- 1) \
2 + ChlorinePos!
(N%%
, 1), ZTemp!
- Offset%
)-(-(ChlorineSize%%
- 1) \
2 + XTemp!
, -(ChlorineSize%%
- 1) \
2 + ChlorinePos!
(N%%
, 1), ZTemp!
- Offset%
)-((ChlorineSize%%
- 1) \
2 + XTemp!
, (ChlorineSize%%
- 1) \
2 + ChlorinePos!
(N%%
, 1), ZTemp!
- Offset%
) XTemp! = XDash!((SodiumPos!(N%%, 0)), (SodiumPos!(N%%, 2))): ZTemp! = ZDash!((SodiumPos!(N%%, 0)), (SodiumPos!(N%%, 2)))
_MAPTRIANGLE (0, 0)-(255, 0)-(0, 255), Sodium&
TO(-(SodiumSize%%
- 1) \
2 + XTemp!
, (SodiumSize%%
- 1) \
2 + SodiumPos!
(N%%
, 1), ZTemp!
- Offset%
)-((SodiumSize%%
- 1) \
2 + XTemp!
, (SodiumSize%%
- 1) \
2 + SodiumPos!
(N%%
, 1), ZTemp!
- Offset%
)-(-(SodiumSize%%
- 1) \
2 + XTemp!
, -(SodiumSize%%
- 1) \
2 + SodiumPos!
(N%%
, 1), ZTemp!
- Offset%
) _MAPTRIANGLE (255, 255)-(0, 255)-(255, 0), Sodium&
TO((SodiumSize%%
- 1) \
2 + XTemp!
, -(SodiumSize%%
- 1) \
2 + SodiumPos!
(N%%
, 1), ZTemp!
- Offset%
)-(-(SodiumSize%%
- 1) \
2 + XTemp!
, -(SodiumSize%%
- 1) \
2 + SodiumPos!
(N%%
, 1), ZTemp!
- Offset%
)-((SodiumSize%%
- 1) \
2 + XTemp!
, (SodiumSize%%
- 1) \
2 + SodiumPos!
(N%%
, 1), ZTemp!
- Offset%
) _MAPTRIANGLE (0, 0)-(255, 0)-(0, 255), Cyan&
TO(-(SodiumSize%%
- 1) \
2 + XTemp!
, (SodiumSize%%
- 1) \
2 + SodiumPos!
(N%%
, 1), ZTemp!
- Offset%
)-((SodiumSize%%
- 1) \
2 + XTemp!
, (SodiumSize%%
- 1) \
2 + SodiumPos!
(N%%
, 1), ZTemp!
- Offset%
)-(-(SodiumSize%%
- 1) \
2 + XTemp!
, -(SodiumSize%%
- 1) \
2 + SodiumPos!
(N%%
, 1), ZTemp!
- Offset%
) _MAPTRIANGLE (255, 255)-(0, 255)-(255, 0), Cyan&
TO((SodiumSize%%
- 1) \
2 + XTemp!
, -(SodiumSize%%
- 1) \
2 + SodiumPos!
(N%%
, 1), ZTemp!
- Offset%
)-(-(SodiumSize%%
- 1) \
2 + XTemp!
, -(SodiumSize%%
- 1) \
2 + SodiumPos!
(N%%
, 1), ZTemp!
- Offset%
)-((SodiumSize%%
- 1) \
2 + XTemp!
, (SodiumSize%%
- 1) \
2 + SodiumPos!
(N%%
, 1), ZTemp!
- Offset%
) SodiumAcc!(N%%, M%%) = 0
ChlorineAcc!(N%%, M%%) = 0
FOR L%%
= 0 TO NoBalls%%
- 1 'opposites
D!
= SQR((SodiumPos!
(N%%
, 0) - ChlorinePos!
(L%%
, 0)) * (SodiumPos!
(N%%
, 0) - ChlorinePos!
(L%%
, 0)) + (SodiumPos!
(N%%
, 1) - ChlorinePos!
(L%%
, 1)) * (SodiumPos!
(N%%
, 1) - ChlorinePos!
(L%%
, 1)) + (SodiumPos!
(N%%
, 2) - ChlorinePos!
(L%%
, 2)) * (SodiumPos!
(N%%
, 2) - ChlorinePos!
(L%%
, 2))) F! = (Attraction!(D!) + Repulsion!(D!)) / F1!
'IF F! < FMin! / F1! THEN F! = FMin! / F1!
SodiumAcc!(N%%, M%%) = -F! * (SodiumPos!(N%%, M%%) - ChlorinePos!(L%%, M%%)) / D! + SodiumAcc!(N%%, M%%)
IF D!
< 0.9 * Atom!
AND DrawBonds`
THEN _MAPTRIANGLE (0, 0)-(101, 0)-(101, 51), LineImage&
TO(XDash!
(SodiumPos!
(N%%
, 0), SodiumPos!
(N%%
, 2)), SodiumPos!
(N%%
, 1), ZDash!
(SodiumPos!
(N%%
, 0), SodiumPos!
(N%%
, 2)) - Offset%
)-(XDash!
(ChlorinePos!
(L%%
, 0), ChlorinePos!
(L%%
, 2)), ChlorinePos!
(L%%
, 1), ZDash!
(ChlorinePos!
(L%%
, 0), ChlorinePos!
(L%%
, 2)) - Offset%
)-(XDash!
(ChlorinePos!
(L%%
, 0), ChlorinePos!
(L%%
, 2)), ChlorinePos!
(L%%
, 1), ZDash!
(ChlorinePos!
(L%%
, 0), ChlorinePos!
(L%%
, 2)) - Offset%
- 1), , _SMOOTH D!
= SQR((SodiumPos!
(L%%
, 0) - ChlorinePos!
(N%%
, 0)) * (SodiumPos!
(L%%
, 0) - ChlorinePos!
(N%%
, 0)) + (SodiumPos!
(L%%
, 1) - ChlorinePos!
(N%%
, 1)) * (SodiumPos!
(L%%
, 1) - ChlorinePos!
(N%%
, 1)) + (SodiumPos!
(L%%
, 2) - ChlorinePos!
(N%%
, 2)) * (SodiumPos!
(L%%
, 2) - ChlorinePos!
(N%%
, 2))) F! = (Attraction!(D!) + Repulsion!(D!)) / F1!
'IF F! < FMin! / F1! THEN F! = FMin! / F1!
ChlorineAcc!(N%%, M%%) = F! * (SodiumPos!(L%%, M%%) - ChlorinePos!(N%%, M%%)) / D! + ChlorineAcc!(N%%, M%%)
'same type
D!
= SQR((SodiumPos!
(N%%
, 0) - SodiumPos!
(L%%
, 0)) * (SodiumPos!
(N%%
, 0) - SodiumPos!
(L%%
, 0)) + (SodiumPos!
(N%%
, 1) - SodiumPos!
(L%%
, 1)) * (SodiumPos!
(N%%
, 1) - SodiumPos!
(L%%
, 1)) + (SodiumPos!
(N%%
, 2) - SodiumPos!
(L%%
, 2)) * (SodiumPos!
(N%%
, 2) - SodiumPos!
(L%%
, 2))) F! = -(Attraction!(D!)) / F2!
SodiumAcc!(N%%, M%%) = -F! * (SodiumPos!(N%%, M%%) - SodiumPos!(L%%, M%%)) / D! + SodiumAcc!(N%%, M%%)
D!
= SQR((ChlorinePos!
(N%%
, 0) - ChlorinePos!
(L%%
, 0)) * (ChlorinePos!
(N%%
, 0) - ChlorinePos!
(L%%
, 0)) + (ChlorinePos!
(N%%
, 1) - ChlorinePos!
(L%%
, 1)) * (ChlorinePos!
(N%%
, 1) - ChlorinePos!
(L%%
, 1)) + (ChlorinePos!
(N%%
, 2) - ChlorinePos!
(L%%
, 2)) * (ChlorinePos!
(N%%
, 2) - ChlorinePos!
(L%%
, 2))) F! = -(Attraction!(D!)) / F2!
ChlorineAcc!(N%%, M%%) = -F! * (ChlorinePos!(N%%, M%%) - ChlorinePos!(L%%, M%%)) / D! + ChlorineAcc!(N%%, M%%)
'Pause
SodiumPos!(N%%, M%%) = SodiumPos!(N%%, M%%) + SodiumVel!(N%%, M%%)
ChlorinePos!(N%%, M%%) = ChlorinePos!(N%%, M%%) + ChlorineVel!(N%%, M%%)
SodiumVel!(N%%, M%%) = SodiumVel!(N%%, M%%) + SodiumAcc!(N%%, M%%)
IF ABS(SodiumVel!
(N%%
, M%%
)) > Kelvin!
THEN SodiumVel!
(N%%
, M%%
) = Kelvin!
* (ABS(SodiumVel!
(N%%
, M%%
)) / SodiumVel!
(N%%
, M%%
)) ChlorineVel!(N%%, M%%) = ChlorineVel!(N%%, M%%) + ChlorineAcc!(N%%, M%%)
IF ABS(ChlorineVel!
(N%%
, M%%
)) > Kelvin!
THEN ChlorineVel!
(N%%
, M%%
) = Kelvin!
* (ABS(ChlorineVel!
(N%%
, M%%
)) / ChlorineVel!
(N%%
, M%%
)) 'Pause/Adjust for orthogonal forces
FOR N%%
= 0 TO NoBalls%%
- 1 FOR M%%
= 0 TO 5 'the six orthogonal positions from each sodium atom CALL Orthogonal
(N%%
, M%%
) 'Move chlorine atom ViewAngle! = ViewAngle! + 0.008
IF NoBalls%%
< TotBalls%%
THEN Count%
= Count%
+ 1 IF Count%
>= 2000 AND ((ViewAngle!
> -0.05 AND ViewAngle!
< 0.05) OR (ViewAngle!
> -_PI - 0.05 AND ViewAngle!
< 0.05 - _PI)) THEN NoBalls%% = NoBalls%% + 2
Count% = 0
'might try the angle of the next ball, not just viewing angle - future version
ELSEIF Count%
>= 100 AND NoBalls%%
< TotBalls%
AND ((ViewAngle!
> -0.05 AND ViewAngle!
< 0.05) OR (ViewAngle!
> -_PI - 0.05 AND ViewAngle!
< 0.05 - _PI)) THEN NoBalls%% = NoBalls%% + 2
Count% = 0
'Draw Bonds
_PUTIMAGE (ScreenX%
- 100, ScreenY%
- 120), Quit&
Attraction! = A0! * (1 / (Dist! / A2!) ^ A1!)
Repulsion! = -R0! * (1 / (Dist! / R2!) ^ R1!)
XDash!
= X!
* COS(ViewAngle!
) + Z!
* SIN(ViewAngle!
)
ZDash!
= -X!
* SIN(ViewAngle!
) + Z!
* COS(ViewAngle!
)
SUB Orthogonal
(P%%
, Q%%
) OnlyOneChlorine%% = True
NoChlorines%% = 0
R%% = 0
WHILE R%%
<= NoBalls%%
- 1 AND OnlyOneChlorine%%
Sepn!
= SQR((SodiumPos!
(R%%
, 0) - SodiumPos!
(P%%
, 0)) * (SodiumPos!
(R%%
, 0) - SodiumPos!
(P%%
, 0)) + (SodiumPos!
(R%%
, 1) - SodiumPos!
(P%%
, 1)) * (SodiumPos!
(R%%
, 1) - SodiumPos!
(P%%
, 1)) + (SodiumPos!
(R%%
, 2) - SodiumPos!
(P%%
, 2)) * (SodiumPos!
(R%%
, 2) - SodiumPos!
(P%%
, 2))) X! = SodiumPos!(R%%, 0) - SodiumPos!(P%%, 0)
Y! = SodiumPos!(R%%, 1) - SodiumPos!(P%%, 1)
Z! = SodiumPos!(R%%, 2) - SodiumPos!(P%%, 2)
S1!
= SQR(Y!
* Y!
+ Z!
* Z!
) IF X!
> 0 AND X!
< Atom!
AND ABS(Theta!
) < ThetaMax!
THEN OnlyOneChlorine%%
= False
S1!
= SQR(X!
* X!
+ Z!
* Z!
) IF Y!
> 0 AND Y!
< Atom!
AND ABS(Theta!
) < ThetaMax!
THEN OnlyOneChlorine%%
= False
S1!
= SQR(Y!
* Y!
+ X!
* X!
) IF Z!
> 0 AND Z!
< Atom!
AND ABS(Theta!
) < ThetaMax!
THEN OnlyOneChlorine%%
= False
S1!
= SQR(Y!
* Y!
+ Z!
* Z!
) IF X!
< 0 AND X!
> -Atom!
AND ABS(Theta!
) < ThetaMax!
THEN OnlyOneChlorine%%
= False
S1!
= SQR(X!
* X!
+ Z!
* Z!
) IF Y!
< 0 AND Y!
> -Atom!
AND ABS(Theta!
) < ThetaMax!
THEN OnlyOneChlorine%%
= False
S1!
= SQR(Y!
* Y!
+ X!
* X!
) IF Z!
< 0 AND Z!
> -Atom!
AND ABS(Theta!
) < ThetaMax!
THEN OnlyOneChlorine%%
= False
Sepn!
= SQR((ChlorinePos!
(R%%
, 0) - SodiumPos!
(P%%
, 0)) * (ChlorinePos!
(R%%
, 0) - SodiumPos!
(P%%
, 0)) + (ChlorinePos!
(R%%
, 1) - SodiumPos!
(P%%
, 1)) * (ChlorinePos!
(R%%
, 1) - SodiumPos!
(P%%
, 1)) + (ChlorinePos!
(R%%
, 2) - SodiumPos!
(P%%
, 2)) * (ChlorinePos!
(R%%
, 2) - SodiumPos!
(P%%
, 2))) X! = ChlorinePos!(R%%, 0) - SodiumPos!(P%%, 0)
Y! = ChlorinePos!(R%%, 1) - SodiumPos!(P%%, 1)
Z! = ChlorinePos!(R%%, 2) - SodiumPos!(P%%, 2)
S1!
= SQR(Y!
* Y!
+ Z!
* Z!
) NoChlorines%% = NoChlorines%% + 1
ROne%% = R%%
S1!
= SQR(X!
* X!
+ Z!
* Z!
) NoChlorines%% = NoChlorines%% + 1
ROne%% = R%%
S1!
= SQR(Y!
* Y!
+ X!
* X!
) NoChlorines%% = NoChlorines%% + 1
ROne%% = R%%
S1!
= SQR(Y!
* Y!
+ Z!
* Z!
) NoChlorines%% = NoChlorines%% + 1
ROne%% = R%%
S1!
= SQR(X!
* X!
+ Z!
* Z!
) NoChlorines%% = NoChlorines%% + 1
ROne%% = R%%
S1!
= SQR(Y!
* Y!
+ X!
* X!
) NoChlorines%% = NoChlorines%% + 1
ROne%% = R%%
IF NoChlorines%%
> 1 THEN OnlyOneChlorine%%
= False
R%% = R%% + 1
IF NoChlorines%%
= 0 THEN OnlyOneChlorine%%
= False
'Move Chlorine Atom
X! = ChlorinePos!(ROne%%, 0) - SodiumPos!(P%%, 0)
Y! = ChlorinePos!(ROne%%, 1) - SodiumPos!(P%%, 1)
Z! = ChlorinePos!(ROne%%, 2) - SodiumPos!(P%%, 2)
ChlorinePos!(ROne%%, 1) = ChlorinePos!(ROne%%, 1) - Y! * (1 - Xstal!)
ChlorinePos!(ROne%%, 2) = ChlorinePos!(ROne%%, 2) - Z! * (1 - Xstal!)
ChlorinePos!(ROne%%, 0) = ChlorinePos!(ROne%%, 0) - X! * (1 - Xstal!)
ChlorinePos!(ROne%%, 2) = ChlorinePos!(ROne%%, 2) - Z! * (1 - Xstal!)
ChlorinePos!(ROne%%, 0) = ChlorinePos!(ROne%%, 0) - X! * (1 - Xstal!)
ChlorinePos!(ROne%%, 1) = ChlorinePos!(ROne%%, 1) - Y! * (1 - Xstal!)
SUB CentreOfMass
'centre on original seed atoms TotMass! = 0
MRx! = 0: MRy! = 0: MRz! = 0
Px! = 0: Py! = 0: Pz! = 0
FOR N%
= 0 TO NoSeed%%
- 1 TotMass! = TotMass! + 1
MRx! = MRx! + SodiumPos!(N%, 0)
MRy! = MRy! + SodiumPos!(N%, 1)
MRz! = MRz! + SodiumPos!(N%, 2)
Px! = SodiumVel!(N%, 0) + Px!
Py! = SodiumVel!(N%, 1) + Py!
Pz! = SodiumVel!(N%, 2) + Pz!
TotMass! = TotMass! + 1
MRx! = MRx! + ChlorinePos!(N%, 0)
MRy! = MRy! + ChlorinePos!(N%, 1)
MRz! = MRz! + ChlorinePos!(N%, 2)
Px! = ChlorineVel!(N%, 0) + Px!
Py! = ChlorineVel!(N%, 1) + Py!
Pz! = ChlorineVel!(N%, 2) + Pz!
FOR N%
= 0 TO NoSeed%%
- 1 SodiumPos!(N%, 0) = SodiumPos!(N%, 0) - (MRx! / TotMass!)
SodiumPos!(N%, 1) = SodiumPos!(N%, 1) - (MRy! / TotMass!)
SodiumPos!(N%, 2) = SodiumPos!(N%, 2) - (MRz! / TotMass!)
SodiumVel!(N%, 0) = SodiumVel!(N%, 0) - (Px! / TotMass!)
SodiumVel!(N%, 1) = SodiumVel!(N%, 1) - (Py! / TotMass!)
SodiumVel!(N%, 2) = SodiumVel!(N%, 2) - (Pz! / TotMass!)
ChlorinePos!(N%, 0) = ChlorinePos!(N%, 0) - (MRx! / TotMass!)
ChlorinePos!(N%, 1) = ChlorinePos!(N%, 1) - (MRy! / TotMass!)
ChlorinePos!(N%, 2) = ChlorinePos!(N%, 2) - (MRz! / TotMass!)
ChlorineVel!(N%, 0) = ChlorineVel!(N%, 0) - (Px! / TotMass!)
ChlorineVel!(N%, 1) = ChlorineVel!(N%, 1) - (Py! / TotMass!)
ChlorineVel!(N%, 2) = ChlorineVel!(N%, 2) - (Pz! / TotMass!)