Top page (correct Bohr model including helium).
Back to molecular bond page.
Back to molecular bond appendix.
If you copy and paste the program source code below into a text editor, you can easily compile and run this.
(This class file name is cchh, so save this text editor as "cchh.java", and compile it.)
Here we use the new unit of 1 MM = 1 × 10-14 meter.
This JAVA program can be compiled in almost all browsers, I think.
In some version of JAVA, some notes such as "-Xlint : unchecked ---" may appear on the screen, after you compile it.
But you can run it as it is, neglecting those messages.
About these detailed methods, see also this page.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Scanner;
public class cchh extends JPanel
{
public static void main(String arg[])
{
JFrame frame = new JFrame("CH2=CH2 (ethylene-new)"); // set frame
J2DPanel j2dpanel = new J2DPanel();
frame.getContentPane().add(j2dpanel); frame.setSize(1180,700);
frame.setVisible(true); frame.setBackground(Color.black);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
class J2DPanel extends JPanel implements ActionListener
{
double pai=3.141592653589793; double epsi=8.85418781787346e-12;
double h=6.62606896e-34; double elc=1.60217653e-19;
double me=9.1093826e-31; double suh=5292.0*5292.0*1000.0;
int labe=0; double CC=13390.0; double CH=10870.0;
// elp[][] = each electron textboxes
JTextField elp[][]=new JTextField[12][11];
// elpp[][] = electron (after moving) textboxes
JTextField elpp[][]=new JTextField[6][11];
// mmpho = each nucleus textboxes
JTextField mmpho[][]=new JTextField[4][3];
// impho = total V text
JTextField impho=new JTextField(7);
JTextField imphoo=new JTextField(7);
// average wave textboxes
JTextField averwa0=new JTextField(7); JTextField averwa2=new JTextField(7);
JTextField averwa8=new JTextField(7); JTextField averwael=new JTextField(7); JTextField reawav0=new JTextField(7); JTextField reawav8=new JTextField(7);
JButton b1=new JButton("C=C (MM)");
String ope[]={"10000","11500","12000","12500","13390","14000","14500","15000", "16000","17000"};
JComboBox coom=new JComboBox(ope);
double rtw=Math.sqrt(2); double rth=Math.sqrt(3);
double rsi=Math.sqrt(6); double rfi=Math.sqrt(5);
double hpr[][]=new double[12][11];
double den=4.22; // den = central density
double hpr3[][]=new double[12][11];
double hprr[][]=new double[12][11];
double hprr2[][]=new double[12][11];
double hens = 6415.0; double henr =(hens*2.0)/rsi;
double heno=henr/rtw;
// te1 = initial (relative) coordinate of each electron
double te1[][]={{-heno, henr, 0.0}, {-heno, -henr, 0.0},
{heno, 0.0, -henr}, {heno, 0.0, henr},
{-heno, henr, 0.0}, {-heno, -henr, 0.0},
{heno, 0.0, -henr}, {heno, 0.0, henr},
{500.0, -4000.0, 0.0},
{500.0, 4000.0, 0.0}, {500.0, -4000.0, 0.0},
{500.0, -4000.0, 0.0}};
double hen3=10870.0; double henrr=hen3*Math.sin((pai*117.4*0.5)/180.0);
double hen1=hen3*Math.cos((pai*117.4*0.5)/180.0);
double henp1 = -13390-hen1;
// nux[0,1][0-2] = C0,C1 coordinate
// nux[2-5][0-2] = H0-H3 coordinate
// den, 1 = each nuclear charge
double nux[][]={{0, 0, 0, den},{-13390.0, 0, 0, den}, {hen1, 0, -henrr, 1}, {hen1, 0, henrr, 1},{henp1, 0, henrr,1},{henp1, 0, -henrr, 1}
};
public J2DPanel()
{
setBackground(Color.black);
JPanel p=new JPanel();
p.setLayout(new GridLayout(21,12));
int aaa=0;
double tx,ty,tz,tkk;
for (int el=0; el <=11; el++) {
for (int pos=0; pos <=2; pos++) { // hpr[][0-2]=each electron's coordinate
elp[el][pos]=new JTextField(7);
// textbox input setting
if (el==0 && pos==0 ) {elp[el][pos].addActionListener(this); }
if (el==0 && pos==1 ) {elp[el][pos].addActionListener(this); }
if (el==2 && pos==0 ) {elp[el][pos].addActionListener(this); }
if (el==2 && pos==2 ) {elp[el][pos].addActionListener(this); }
if (el==4 && pos==0 ) {elp[el][pos].addActionListener(this); }
if (el==4 && pos==1 ) {elp[el][pos].addActionListener(this); }
if (el==6 && pos==0 ) {elp[el][pos].addActionListener(this); }
if (el==6 && pos==2 ) {elp[el][pos].addActionListener(this); }
if (el==8) {elp[el][pos].addActionListener(this); }
hpr[el][pos]=0.0; hprr[el][pos]=0.0; hpr3[el][pos]=0.0;
}}
for (int el=0; el <=11; el++) {
for (int pos=3; pos <=10; pos++) { // hpr[][3-10]=electron's other parameters
elp[el][pos]=new JTextField(7);
hpr[el][pos]=0.0; hprr[el][pos]=0.0;
hpr3[el][pos]=0.0; hprr2[el][pos]=0.0;
}}
for (int el=0; el <=5; el++) {
for (int pos=0; pos <=10; pos++) {
elpp[el][pos]=new JTextField(7);
}}
for (int el=0; el <=3; el++) { // mmpho[0-3][]=nuclear textboxes
for (int pos=0; pos <=2; pos++) {
mmpho[el][pos]=new JTextField(7);
}}
// layout
String sihy[]={"eNo ", "+X(CH)", "+Y(MM)", "+Z(MM)", "nuc(MM)",
"V(eV)", "cforce ", "rforce", "Waves", " -- ", " -- ", " -- "};
for (int el=0; el <=11; el++) {
p.add(new Label(sihy[el]));
}
p.add(new Label("C0 ele0 "));
for (int pos=0; pos <=8; pos++) {
p.add(elp[0][pos]);
}
p.add(new Label("0-C-1 angle")); p.add(elp[0][10]);
p.add(new Label("-- 1 "));
for (int pos=0; pos <=10; pos++) {
p.add(elp[1][pos]);
}
p.add(new Label("C0 ele2 "));
for (int pos=0; pos <=8; pos++) {
p.add(elp[2][pos]);
}
p.add(new Label("2-C-3 angle")); p.add(elp[2][10]);
p.add(new Label("-- 3 "));
for (int pos=0; pos <=10; pos++) {
p.add(elp[3][pos]);
}
p.add(new Label("C1 ele4 "));
for (int pos=0; pos <=8; pos++) {
p.add(elp[4][pos]);
}
p.add(new Label("4-C-5 angle")); p.add(elp[4][10]);
p.add(new Label("-- 5 "));
for (int pos=0; pos <=10; pos++) {
p.add(elp[5][pos]);
}
p.add(new Label("C1 ele6 "));
for (int pos=0; pos <=8; pos++) {
p.add(elp[6][pos]);
}
p.add(new Label("6-C-7 angle")); p.add(elp[6][10]);
p.add(new Label("-- 7 "));
for (int pos=0; pos <=10; pos++) {
p.add(elp[7][pos]);
}
p.add(new Label("H0 ele8 "));
for (int pos=0; pos <=10; pos++) {
p.add(elp[8][pos]);
}
p.add(new Label("-- 9 "));
for (int pos=0; pos <=10; pos++) {
p.add(elp[9][pos]);
}
p.add(new Label("-- 10 "));
for (int pos=0; pos <=10; pos++) {
p.add(elp[10][pos]);
}
p.add(new Label("-- 11 "));
for (int pos=0; pos <=10; pos++) {
p.add(elp[11][pos]);
}
p.add(new Label("C0 nuc ")); p.add(mmpho[0][0]);
p.add(new Label("H0 nuc ")); p.add(mmpho[2][0]);
p.add(new Label("total V ")); p.add(impho);
p.add(new Label("avewave 0 ")); p.add(averwa0); p.add(reawav0);
p.add(new Label("avewave 2")); p.add(averwa2);
p.add(mmpho[0][1]);
p.add(new Label("C1 nuc ")); p.add(mmpho[1][0]);
p.add(new Label("H3 nuc ")); p.add(mmpho[3][0]);
p.add(new Label("af tV ")); p.add(imphoo);
p.add(new Label("avewave 8")); p.add(averwa8); p.add(reawav8);
p.add(new Label("avewave 11 ")); p.add(averwael);
p.add(mmpho[1][1]);
p.add(new Label("afel 0 "));
for (int pos=0; pos <=10; pos++) {
p.add(elpp[0][pos]);
}
p.add(new Label("afel 2 "));
for (int pos=0; pos <=10; pos++) {
p.add(elpp[1][pos]);
}
p.add(new Label("afel 4 "));
for (int pos=0; pos <=10; pos++) {
p.add(elpp[2][pos]);
}
p.add(new Label("afel 6 "));
for (int pos=0; pos <=10; pos++) {
p.add(elpp[3][pos]);
}
p.add(new Label("afel 8 "));
for (int pos=0; pos <=10; pos++) {
p.add(elpp[4][pos]);
}
p.add(new Label("afel 10"));
for (int pos=0; pos <=8; pos++) {
p.add(elpp[5][pos]);
}
p.add(b1); p.add(coom);
coom.setSelectedItem("13390"); b1.addActionListener(this);
add(p,"South");
double xx,yy,zz;
for (int el=0; el <=11; el++) {
double nnuc=Math.sqrt(te1[el][0]*te1[el][0]+te1[el][1]*te1[el][1]+te1[el][2]*te1[el][2]);
aaa=(int)(nnuc);
// elp[el][3] = distance between electron and close nucleus
elp[el][3].setText("nuc "+Integer.toString(aaa));
// hpr[el][0-2] = absolute coordinate of each electron
// te1[][0-2] = relative coordinate wrt. each nucleus
for (int jou=0; jou <=2; jou++) {
hpr[el][jou]=te1[el][jou];
if (el > 3 && el < 8 ) { hpr[el][jou]=te1[el][jou] + nux[1][jou];}
if (el > 7) { hpr[el][jou]=te1[el][jou] + nux[el-6][jou];}
xx = te1[el][jou];
elp[el][jou].setText(Integer.toString((int)xx));
}}
} // public J2DPanel() end
public void actionPerformed(ActionEvent e) {
String ss;
labe=0;
if (e.getSource() == b1) {labe=3;} // C=C button click
if (labe == 3) {
ss=(String)coom.getSelectedItem();
if (ss=="10000") {CC=10000;} if (ss=="11500") {CC=11500;}
if (ss=="12000") {CC=12000;} if (ss=="12500") {CC=12500;}
if (ss=="13390") {CC=13390;} if (ss=="14000") {CC=14000;}
if (ss=="14500") {CC=14500;} if (ss=="15000") {CC=15000;}
if (ss=="16000") {CC=16000;} if (ss=="17000") {CC=17000;}
hen3=10870.0;
double henr=hen3*Math.sin((pai*117.4*0.5)/180.0);
hen1=hen3*Math.cos((pai*117.4*0.5)/180.0);
henp1 = -CC-hen1;
double noxxx[][]={{0, 0, 0},{-CC, 0, 0}, {hen1, 0, -henr}, {hen1, 0, henr},{henp1, 0, henr},{henp1, 0, -henr}
};
// set new nuclear coordinates
for (int ett=0; ett <=5; ett++) {
for (int sws=0; sws <=2; sws++) {
nux[ett][sws]=noxxx[ett][sws];
}}
} // if ( labe == 3 ) end
repaint();
}
public void update(Graphics g)
{
paint(g);
}
public void paintComponent(Graphics g)
{
double kro,krr,krk,kwr,kww,kro2,krr2,krk2,kwr2,kww2,aa,bb,cc,alpa,
pot,pota,potb,potc,potd,gx,gy,gz,ggx,ggy,ggz,ttav,toav;
int ex,ey,ez,xk,yk,zk; String ww,pxw,pyw;
double rhp[][]= {{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},
{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0}, {0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},
{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}};
double rhp5[][]= {{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},
{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0}, {0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},
{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}};
double rpp[][]= {{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},
{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0}, {0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},
{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}};
double rpp5[][]= {{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},
{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0}, {0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},
{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}};
double mmp[][]={{0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0}};
double mpp[][]={{0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0}};
double teqq[][]={{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}};
gx = 0.0; gy = 0.0; gz = 0.0;
kro = 0.0; kro2=0.0 ; krr2=0.0; krk2=0.0; kwr2=0.0; kww2=0.0;
double ede1=0.5; // ede1 = half charge 0.5 times 8 = 4 valence electron
ww=elp[0][0].getText(); hpr[0][0]=Double.parseDouble(ww);
hpr[1][0]= hpr[0][0];
ww=elp[0][1].getText(); hpr[0][1]=Double.parseDouble(ww);
hpr[1][1]= -hpr[0][1];
hpr[0][2]=0.0; hpr[1][2]=0.0;
ww=elp[2][0].getText(); hpr[2][0]=Double.parseDouble(ww);
hpr[3][0]= hpr[2][0];
ww=elp[2][2].getText(); hpr[2][2]=Double.parseDouble(ww);
hpr[3][2]= -hpr[2][2];
hpr[2][1]=0.0; hpr[3][1]=0.0;
ww=elp[4][0].getText(); hpr[4][0]=Double.parseDouble(ww)-CC;
hpr[5][0]= hpr[4][0];
ww=elp[4][1].getText(); hpr[4][1]=Double.parseDouble(ww);
hpr[5][1]= -hpr[4][1];
hpr[4][2]=0.0; hpr[5][2]=0.0;
ww=elp[6][0].getText(); hpr[6][0]=Double.parseDouble(ww)-CC;
hpr[7][0]= hpr[6][0];
ww=elp[6][2].getText(); hpr[6][2]=Double.parseDouble(ww);
hpr[7][2]= -hpr[6][2];
hpr[6][1]=0.0; hpr[7][1]=0.0;
// show electron - C nuc - electron angle
aa=hpr[0][1]-hpr[1][1];
bb= Math.sqrt(hpr[1][0]*hpr[1][0]+hpr[1][1]*hpr[1][1]+hpr[1][2]*hpr[1][2]);
cc= Math.sqrt(hpr[0][0]*hpr[0][0]+hpr[0][1]*hpr[0][1]+hpr[0][2]*hpr[0][2]);
alpa=(bb*bb+cc*cc-aa*aa)/(2.0*bb*cc);
gx=(Math.acos(alpa)*180.0)/pai;
elp[0][10].setText(Integer.toString((int)gx) + " deg");
aa=hpr[3][2]-hpr[2][2];
bb= Math.sqrt(hpr[3][0]*hpr[3][0]+hpr[3][1]*hpr[3][1]+hpr[3][2]*hpr[3][2]);
cc= Math.sqrt(hpr[2][0]*hpr[2][0]+hpr[2][1]*hpr[2][1]+hpr[2][2]*hpr[2][2]);
alpa=(bb*bb+cc*cc-aa*aa)/(2.0*bb*cc);
gx=(Math.acos(alpa)*180.0)/pai;
elp[2][10].setText(Integer.toString((int)gx) + " deg");
aa=hpr[7][2]-hpr[6][2];
bb= Math.sqrt((hpr[7][0]+CC)*(hpr[7][0]+CC)+hpr[7][1]*hpr[7][1]+hpr[7][2]*hpr[7][2]);
cc= Math.sqrt((hpr[6][0]+CC)*(hpr[6][0]+CC)+hpr[6][1]*hpr[6][1]+hpr[6][2]*hpr[6][2]);
alpa=(bb*bb+cc*cc-aa*aa)/(2.0*bb*cc);
gx=(Math.acos(alpa)*180.0)/pai;
elp[6][10].setText(Integer.toString((int)gx) + " deg");
aa=hpr[4][1]-hpr[5][1];
bb= Math.sqrt((hpr[4][0]+CC)*(hpr[4][0]+CC)+hpr[4][1]*hpr[4][1]+hpr[4][2]*hpr[4][2]);
cc= Math.sqrt((hpr[5][0]+CC)*(hpr[5][0]+CC)+hpr[5][1]*hpr[5][1]+hpr[5][2]*hpr[5][2]);
alpa=(bb*bb+cc*cc-aa*aa)/(2.0*bb*cc);
gx=(Math.acos(alpa)*180.0)/pai;
elp[4][10].setText(Integer.toString((int)gx) + " deg");
// get electron 8 (hydrogen) coordinate from textbox
ww= elp[8][0].getText(); gx=Double.parseDouble(ww);
ww= elp[8][1].getText(); gy=Double.parseDouble(ww);
// set 8-11 electron coordinates based on ele 8
for (int yp=8; yp <=11; yp++) {
elp[yp][0].setText(Integer.toString((int)gx));
elp[yp][2].setText(Integer.toString(0));
if ( yp==8 || yp == 10) {
hpr[yp][1]=gy;
elp[yp][1].setText(Integer.toString((int)gy));
}
if ( yp==9 || yp == 11) {
hpr[yp][1]=-gy;
elp[yp][1].setText(Integer.toString((int)(-gy)));
}
// gx = each C-H direction (= nux) coordinate
for (int kj=0; kj <=1; kj++) {
hpr[yp][kj*2]=(nux[yp-6][kj*2]*(CH+gx))/CH;
if (yp > 9 && kj==0 ) {
hpr[yp][kj*2]=((nux[yp-6][kj*2]+CC)*(CH+gx))/CH -CC;
}
}}
// show electron 0-7 relative coordinate in textbox
for (int yp=0; yp <=3; yp++) {
for (int kj=0; kj <=2; kj++) {
elp[yp*2][kj].setText(Integer.toString((int)hpr[yp*2][kj]));
elp[1+yp*2][kj].setText(Integer.toString((int)hpr[1+yp*2][kj]));
if ( yp > 1 && kj == 0) {
elp[yp*2][kj].setText(Integer.toString((int)(hpr[yp*2][kj]+CC)));
elp[1+yp*2][kj].setText(Integer.toString((int)(hpr[1+yp*2][kj]+CC)));
}
}}
// hpr3[][] symmetric position of ele 0-7 wrt. C nucleus
for (int yp=0; yp <=3; yp++) {
for (int kj=0; kj <=2; kj++) {
hpr3[yp][kj] = -hpr[yp+4][kj];
if (kj==0) { hpr3[yp][kj] = -(hpr[yp+4][kj]+CC);
}
}}
for (int yp=4; yp <=7; yp++) {
for (int kj=0; kj <=2; kj++) {
hpr3[yp][kj] = -hpr[yp-4][kj];
if (kj==0) { hpr3[yp][kj] = -hpr[yp-4][kj]-CC;
}
}}
toav=0.0; ggy=0.0; // toav=total potential energy (eV)
double ppot;
// interaction among electron 8-11 (hydrogen)
for (int yp=8; yp <=11; yp++) {
for (int kj=8; kj <=11; kj++) {
if (yp < kj ) {
kro=Math.sqrt((hpr[yp][0]-hpr[kj][0])*(hpr[yp][0]-hpr[kj][0])+
(hpr[yp][1]-hpr[kj][1])*(hpr[yp][1]-hpr[kj][1])+
(hpr[yp][2]-hpr[kj][2])*(hpr[yp][2]-hpr[kj][2]));
if (kro==0) {kro=5000.0;}
// ppot = each potential energy (eV)
ppot=(elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
// rhp[el][3] = potential energy of each electron
// rhp5[8-13][] = interaction of electrons as they are
rhp[yp][3]=rhp[yp][3]+ppot/2.0; rhp[kj][3]=rhp[kj][3]+ppot/2.0;
rhp5[yp][3]=rhp5[yp][3]+ppot/2.0; rhp5[kj][3]=rhp5[kj][3]+ppot/2.0;
toav=toav+ppot;
for (int jou=0; jou <=2; jou++) {
ggx=(suh*(hpr[yp][jou]-hpr[kj][jou]))/(kro*kro*kro);
// rhp[el][0-2] = force component acting on each electron
rhp[yp][jou]=rhp[yp][jou]+ggx; rhp[kj][jou]=rhp[kj][jou]-ggx;
rhp5[yp][jou]=rhp5[yp][jou]+ggx; rhp5[kj][jou]=rhp5[kj][jou]-ggx;
}
}}}
krr=0.0; potb=0.0; ggy=0.0;
for (int yp=8; yp <=11; yp++) {
for (int kj=0; kj <=7; kj++) {
kro=Math.sqrt((hpr[yp][0]-hpr[kj][0])*(hpr[yp][0]-hpr[kj][0])+
(hpr[yp][1]-hpr[kj][1])*(hpr[yp][1]-hpr[kj][1])+
(hpr[yp][2]-hpr[kj][2])*(hpr[yp][2]-hpr[kj][2]));
// hpr3[0-7][0-2] = symmetric position of ele0-7 wrt. nucleus
krr=Math.sqrt((hpr[yp][0]-hpr3[kj][0])*(hpr[yp][0]-hpr3[kj][0])+
(hpr[yp][1]-hpr3[kj][1])*(hpr[yp][1]-hpr3[kj][1])+
(hpr[yp][2]-hpr3[kj][2])*(hpr[yp][2]-hpr3[kj][2]));
// ede1 = 0.5 half charge
ppot=(ede1*elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
potb=(ede1*elc*elc*6.241509e18)/(4.0*pai*epsi*krr*1.0e-14);
rhp[yp][3]=rhp[yp][3]+ppot/2.0+potb/2.0;
rhp5[yp][3]=rhp5[yp][3]+ppot; // rhp5 = interaction as they are
rhp[kj][3]=rhp[kj][3]+ppot/2.0+potb/2.0;
toav=toav+ppot+potb;
for (int jou=0; jou <=2; jou++) {
ggx=(ede1*suh*(hpr[yp][jou]-hpr[kj][jou]))/(kro*kro*kro);
ggy=(ede1*suh*(hpr[yp][jou]-hpr3[kj][jou]))/(krr*krr*krr);
ggz=(suh*(hpr[yp][jou]-hpr[kj][jou]))/(kro*kro*kro);
// force component of each electron
rhp[yp][jou]=rhp[yp][jou]+ggx+ggy;
rhp5[yp][jou]=rhp5[yp][jou]+ggz;
rhp5[kj][jou]=rhp5[kj][jou]-ggz;
}
}}
// interaction among electrons 0-7
for (int yp=0; yp <=7; yp++) {
for (int kj=0; kj <=7; kj++) {
if (yp < kj ) { // kro=distance between electrons
kro=Math.sqrt((hpr[yp][0]-hpr[kj][0])*(hpr[yp][0]-hpr[kj][0])+
(hpr[yp][1]-hpr[kj][1])*(hpr[yp][1]-hpr[kj][1])+
(hpr[yp][2]-hpr[kj][2])*(hpr[yp][2]-hpr[kj][2]));
if (kro==0) {kro=5000.0;}
ppot=(elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
// rhp[][3]=each electron's potential energy
rhp[yp][3]=rhp[yp][3]+ppot/2.0; rhp[kj][3]=rhp[kj][3]+ppot/2.0;
toav=toav+ppot;
for (int jou=0; jou <=2; jou++) {
ggx=(suh*(hpr[yp][jou]-hpr[kj][jou]))/(kro*kro*kro);
rhp5[yp][jou]=rhp5[yp][jou]+ggx; rhp5[kj][jou]=rhp5[kj][jou]-ggx;
}
}}}
// between electron8-11 and each nucleus
for (int yp=8; yp <=11; yp++) {
for (int rv=0; rv <=5; rv++) {
kro=Math.sqrt((hpr[yp][0]-nux[rv][0])*(hpr[yp][0]-nux[rv][0])+
(hpr[yp][1]-nux[rv][1])*(hpr[yp][1]-nux[rv][1])+
(hpr[yp][2]-nux[rv][2])*(hpr[yp][2]-nux[rv][2]));
if (kro == 0) {kro=5000.0;}
ppot=-(nux[rv][3]*elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
toav = toav + ppot; rhp[yp][3] = rhp[yp][3] + ppot;
rhp5[yp][3] = rhp5[yp][3] + ppot;
// rhp[el][6] = interaction with other nuclei
zk = yp -6;
if ( rv != zk ) { rhp[yp][6] = rhp[yp][6] + ppot;
rhp5[yp][6] = rhp5[yp][6] + ppot;
}
for (int jou=0; jou <=2; jou++) { // force component
ggx=(suh*nux[rv][3]*(hpr[yp][jou]-nux[rv][jou]))/(kro*kro*kro);
rhp[yp][jou] = rhp[yp][jou] - ggx; // force against electron
rhp5[yp][jou] = rhp5[yp][jou] - ggx; // force against electron
mmp[rv][jou] = mmp[rv][jou] + ggx; // force against nuclei
}
}}
// interaction between H nuclei and electrons 0-7
ggz=0.0;
for (int rv=2; rv <=5; rv++) {
for (int yp=0; yp <=7; yp++) {
kro=Math.sqrt((hpr[yp][0]-nux[rv][0])*(hpr[yp][0]-nux[rv][0])+
(hpr[yp][1]-nux[rv][1])*(hpr[yp][1]-nux[rv][1])+
(hpr[yp][2]-nux[rv][2])*(hpr[yp][2]-nux[rv][2]));
krr=Math.sqrt((hpr3[yp][0]-nux[rv][0])*(hpr3[yp][0]-nux[rv][0])+
(hpr3[yp][1]-nux[rv][1])*(hpr3[yp][1]-nux[rv][1])+
(hpr3[yp][2]-nux[rv][2])*(hpr3[yp][2]-nux[rv][2]));
ppot=-(ede1*nux[rv][3]*elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
ggz=-(ede1*nux[rv][3]*elc*elc*6.241509e18)/(4.0*pai*epsi*krr*1.0e-14);
toav = toav + ppot+ggz;
rhp[yp][3] = rhp[yp][3] + ppot+ggz;
rhp[yp][6] = rhp[yp][6] + ppot+ggz;
for (int jou=0; jou <=2; jou++) {
ggx=(ede1*suh*nux[rv][3]*(hpr[yp][jou]-nux[rv][jou]))/(kro*kro*kro);
ggy=(ede1*suh*nux[rv][3]*(hpr3[yp][jou]-nux[rv][jou]))/(krr*krr*krr);
ggz=(suh*nux[rv][3]*(hpr[yp][jou]-nux[rv][jou]))/(kro*kro*kro);
rhp5[yp][jou] = rhp5[yp][jou] - ggz;
mmp[rv][jou] = mmp[rv][jou] + ggx+ggy;
}
}}
// between electron0-7 and C nuclei
for (int yp=0; yp <=7; yp++) {
for (int rv=0; rv <=1; rv++) {
kro=Math.sqrt((hpr[yp][0]-nux[rv][0])*(hpr[yp][0]-nux[rv][0])+
(hpr[yp][1]-nux[rv][1])*(hpr[yp][1]-nux[rv][1])+
(hpr[yp][2]-nux[rv][2])*(hpr[yp][2]-nux[rv][2]));
krr=Math.sqrt((hpr3[yp][0]-nux[rv][0])*(hpr3[yp][0]-nux[rv][0])+
(hpr3[yp][1]-nux[rv][1])*(hpr3[yp][1]-nux[rv][1])+
(hpr3[yp][2]-nux[rv][2])*(hpr3[yp][2]-nux[rv][2]));
ppot=-(ede1*nux[rv][3]*elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
ggz=-(ede1*nux[rv][3]*elc*elc*6.241509e18)/(4.0*pai*epsi*krr*1.0e-14);
toav = toav +ppot+ggz; rhp[yp][3] = rhp[yp][3] + ppot+ggz;
// rhp[][6] = potential V with another nucleus
if ( yp < 4 && rv==1 ) {
rhp[yp][6] = rhp[yp][6] + ppot+ggz; }
if ( yp > 3 && rv==0 ) {
rhp[yp][6] = rhp[yp][6] + ppot+ggz; }
for (int jou=0; jou <=2; jou++) {
ggx=(ede1*suh*nux[rv][3]*(hpr[yp][jou]-nux[rv][jou]))/(kro*kro*kro);
ggy=(ede1*suh*nux[rv][3]*(hpr3[yp][jou]-nux[rv][jou]))/(krr*krr*krr);
ggz=(suh*nux[rv][3]*(hpr[yp][jou]-nux[rv][jou]))/(kro*kro*kro);
// force component
rhp5[yp][jou] = rhp5[yp][jou] - ggz;
mmp[rv][jou] = mmp[rv][jou] + ggx+ggy;
}
}}
// interaction among nuclei
pota = 0.0; // pota = potential V among nuclei
for (int yp=0; yp <=5; yp++) {
for (int kj=0; kj <=5; kj++) {
if (yp < kj ) {
kro = Math.sqrt((nux[yp][0]-nux[kj][0])*(nux[yp][0]-nux[kj][0]) + (nux[yp][1]-nux[kj][1])*(nux[yp][1]-nux[kj][1]) + (nux[yp][2]-nux[kj][2])*(nux[yp][2]-nux[kj][2]) );
if (kro == 0) {kro=5000.0;}
ppot = (nux[yp][3]*nux[kj][3]*elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
toav=toav+ppot; pota=pota+ppot;
for (int jou=0; jou <=2; jou++) {
ggx=(suh*nux[yp][3]*nux[kj][3]*(nux[yp][jou]-nux[kj][jou]))/(kro*kro*kro);
// mmp[][0-2] = force acting on each nucleus
mmp[yp][jou] = mmp[yp][jou] + ggx; mmp[kj][jou] = mmp[kj][jou] - ggx;
// mmp[][3-5] = force component only among nuclei
mmp[yp][jou+3] = mmp[yp][jou+3] + ggx;
mmp[kj][jou+3] = mmp[kj][jou+3] - ggx;
}
}}}
ex=(int)(toav*100.0); ggx=ex/100.0;
impho.setText("tV "+Double.toString(ggx)); // show total V
gz = 0.0; // distribute nucler V to electron based on rhp[][6]
for (int yp=0; yp <=11; yp++) {
gz = gz + rhp[yp][6];
}
for (int yp=0; yp <=11; yp++) {
rhp[yp][3] = rhp[yp][3] + (pota * rhp[yp][6])/gz;
}
gz = 0.0; // distribute nuclear V to electron based on rhp5[][6]
for (int yp=0; yp <=7; yp++) {
gz = gz + rhp[yp][6];
}
for (int yp=8; yp <=11; yp++) {
gz = gz + rhp5[yp][6];
}
for (int yp=8; yp <=11; yp++) {
rhp5[yp][3] = rhp5[yp][3] + (pota * rhp5[yp][6])/gz;
}
gz=0.0;
for (int yp=0; yp <=7; yp++) {
gz = gz + rhp[yp][3];
}
for (int yp=0; yp <=7; yp++) {
rhp[yp][3] = gz/8.0;
}
// noxx[0,1][0-2] = center coordinate of C1 and C2
double noxx[][]={{0,0,0},{0,0,0}};
for (int yp=0; yp <=3; yp++) {
for (int jou=0; jou <=2; jou++) {
noxx[0][jou]=noxx[0][jou]+hpr[yp][jou];
noxx[1][jou]=noxx[1][jou]+hpr[yp+4][jou];
}}
for (int jou=0; jou <=2; jou++) {
noxx[0][jou]=noxx[0][jou]/4.0;
noxx[1][jou]=noxx[1][jou]/4.0;
}
// interaction only in carbon 0
for (int yp=0; yp <=3; yp++) {
for (int kj=0; kj <=3; kj++) {
if (yp < kj ) {
kro=Math.sqrt((hpr[yp][0]-hpr[kj][0])*(hpr[yp][0]-hpr[kj][0])+
(hpr[yp][1]-hpr[kj][1])*(hpr[yp][1]-hpr[kj][1])+
(hpr[yp][2]-hpr[kj][2])*(hpr[yp][2]-hpr[kj][2]));
if (kro==0) {kro=5000.0;}
ppot=(elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
teqq[yp][3] = teqq[yp][3] + ppot/2.0;
teqq[kj][3] = teqq[kj][3] + ppot/2.0;
for (int jou=0; jou <=2; jou++) {
ggx=(suh*(hpr[yp][jou]-hpr[kj][jou]))/(kro*kro*kro);
teqq[yp][jou]=teqq[yp][jou]+ggx; teqq[kj][jou]=teqq[kj][jou]-ggx;
}
}}}
// interaction only in carbon 1
for (int yp=4; yp <=7; yp++) {
for (int kj=4; kj <=7; kj++) {
if (yp < kj ) {
ez = 0;
kro=Math.sqrt((hpr[yp][0]-hpr[kj][0])*(hpr[yp][0]-hpr[kj][0])+
(hpr[yp][1]-hpr[kj][1])*(hpr[yp][1]-hpr[kj][1])+
(hpr[yp][2]-hpr[kj][2])*(hpr[yp][2]-hpr[kj][2]));
if (kro==0) {kro=5000.0;}
ppot=(elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
teqq[yp][3] = teqq[yp][3] + ppot/2.0;
teqq[kj][3] = teqq[kj][3] + ppot/2.0;
for (int jou=0; jou <=2; jou++) {
ggx=(suh*(hpr[yp][jou]-hpr[kj][jou]))/(kro*kro*kro);
teqq[yp][jou]=teqq[yp][jou]+ggx; teqq[kj][jou]=teqq[kj][jou]-ggx;
}
}}}
// interaction between noxx and C electron
for (int yp=0; yp <=1; yp++) {
for (int rv=0; rv <=3; rv++) {
ez = rv+yp*4;
kro=Math.sqrt((hpr[ez][0]-noxx[yp][0])*(hpr[ez][0]-noxx[yp][0])+
(hpr[ez][1]-noxx[yp][1])*(hpr[ez][1]-noxx[yp][1])+
(hpr[ez][2]-noxx[yp][2])*(hpr[ez][2]-noxx[yp][2]));
if (kro == 0) {kro=5000.0;}
ppot=(elc*elc*den*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
teqq[ez][3]=teqq[ez][3]-ppot;
for (int jou=0; jou <=2; jou++) {
ggx=(suh*den*(hpr[ez][jou]-noxx[yp][jou]))/(kro*kro*kro);
teqq[ez][jou]=teqq[ez][jou]-ggx;
}}}
// show electron 0-7 data
for (int yp=0; yp <=7; yp++) {
ex=(int)(rhp[yp][3]*100.0); ggx=ex/100.0;
elp[yp][4].setText("V "+Double.toString(ggx)); //show electron 0-7 's V
kro = Math.sqrt(hpr[yp][0]*hpr[yp][0]+hpr[yp][1]*hpr[yp][1]+hpr[yp][2]*hpr[yp][2]);
if ( yp > 3 ) {kro= Math.sqrt((hpr[yp][0]+CC)*(hpr[yp][0]+CC)+hpr[yp][1]*hpr[yp][1]+hpr[yp][2]*hpr[yp][2]);}
ex=(int)(kro);
// show distance between electron and close nucleus
elp[yp][3].setText("nuc "+Integer.toString(ex));
ex = 0; if (yp > 3) {ex=1;}
ez=yp-(ex*4);
gx=-hpr[yp][0]; gy=-hpr[yp][1];
gz=-hpr[yp][2];
if (yp > 3) {
gx=-(hpr[yp][0]+CC); gy=-hpr[yp][1];
gz=-hpr[yp][2];
}
ggx=Math.sqrt(gx*gx+gy*gy+gz*gz);
rhp[yp][4] = (gx*rhp5[yp][0] +gy*rhp5[yp][1] + gz*rhp5[yp][2])/ggx;
rhp[yp][5] = 0.0; // rhp[0-3][4,5] = 4 -- c force, 5-- r force
ex=(int)(rhp[yp][4]);
elp[yp][5].setText("cf "+Integer.toString(ex));
elp[yp][6].setText("rf "+Integer.toString(0));
}
// vvh[][0-2] = vector toward each CH line
double vvh[][]=new double[4][6]; // rhp[8-13][] force based
double vvh2[][]=new double[4][6]; // rhp5[8-13][] force based
for (int yp=8; yp <=11; yp++) {
kro=(hpr[yp][0]*nux[yp-6][0]+hpr[yp][1]*nux[yp-6][1]+hpr[yp][2]*nux[yp-6][2])/CH;
if ( yp > 9 ) {
kro=-((hpr[yp][0]+CC)*nux[yp-8][0]+hpr[yp][1]*nux[yp-8][1]+hpr[yp][2]*nux[yp-8][2])/CH;
}
for (int kj=0; kj <=2; kj++) {
vvh[yp-8][kj] = (nux[yp-6][kj]*kro)/CH;
ggz = hpr[yp][kj];
if ( yp > 9 ) {
vvh[yp-8][kj] =-(nux[yp-8][kj]*kro)/CH;
if (kj==0) {ggz = hpr[yp][kj]+ CC;}
}
vvh[yp-8][kj] = vvh[yp-8][kj] - ggz;
}
}
// show electron 8-11 data
for (int yp=8; yp <=11; yp++) {
ex=(int)(rhp[yp][3]*100.0); ggx=ex/100.0;
elp[yp][4].setText("V "+Double.toString(ggx));
kro=Math.sqrt((hpr[yp][0]-nux[yp-6][0])*(hpr[yp][0]-nux[yp-6][0])+
(hpr[yp][1]-nux[yp-6][1])*(hpr[yp][1]-nux[yp-6][1])+
(hpr[yp][2]-nux[yp-6][2])*(hpr[yp][2]-nux[yp-6][2]));
if (kro == 0) {kro=5000.0;}
ex=(int)(kro);
elp[yp][3].setText("nuc "+Integer.toString(ex));
// rhp[][4] = force component toward center
rhp[yp][4] = -(nux[yp-6][0]*rhp[yp][0] +nux[yp-6][1]*rhp[yp][1] + nux[yp-6][2]*rhp[yp][2])/CH;
rhp5[yp][4] = -(nux[yp-6][0]*rhp5[yp][0] +nux[yp-6][1]*rhp5[yp][1] + nux[yp-6][2]*rhp5[yp][2])/CH;
if (yp > 9 ) {
rhp[yp][4] = (nux[yp-8][0]*rhp[yp][0] +nux[yp-8][1]*rhp[yp][1] + nux[yp-8][2]*rhp[yp][2])/CH;
rhp5[yp][4] = (nux[yp-8][0]*rhp5[yp][0] +nux[yp-8][1]*rhp5[yp][1] + nux[yp-8][2]*rhp5[yp][2])/CH;
}
krr = Math.sqrt( vvh[yp-8][0]*vvh[yp-8][0]+vvh[yp-8][1]*vvh[yp-8][1]+ vvh[yp-8][2]*vvh[yp-8][2] );
// rhp[][5] = force component toward CH line
rhp[yp][5] = (vvh[yp-8][0]*rhp[yp][0] +vvh[yp-8][1]*rhp[yp][1] + vvh[yp-8][2]*rhp[yp][2])/krr;
rhp5[yp][5] = (vvh[yp-8][0]*rhp5[yp][0] +vvh[yp-8][1]*rhp5[yp][1] + vvh[yp-8][2]*rhp5[yp][2])/krr;
ex=(int)(rhp[yp][4]);
elp[yp][5].setText("cf "+Integer.toString(ex));
ex=(int)(rhp[yp][5]);
elp[yp][6].setText("rf "+Integer.toString(ex));
// vvh[][4-6] = moving direction toward center by force
gx = (rhp[yp][4] * krr) / rhp[yp][5];
gy = (rhp5[yp][4] * krr) / rhp5[yp][5];
for (int kj=0; kj <=2; kj++) {
vvh[yp-8][kj+3] = -(nux[yp-6][kj] * gx)/CH;
vvh2[yp-8][kj+3] = -(nux[yp-6][kj] * gy)/CH;
if (yp > 9) {
vvh[yp-8][kj+3] = (nux[yp-8][kj] * gx)/CH;
vvh2[yp-8][kj+3] = (nux[yp-8][kj] * gy)/CH;
}
}}
// show electron 8-11 de Broglie waves
for (int yp=8; yp <=11; yp++) {
gz = Math.sqrt(rhp[yp][0]*rhp[yp][0]+rhp[yp][1]*rhp[yp][1]+rhp[yp][2]*rhp[yp][2]);
gy=(gz*elc*elc)/(4.0*pai*epsi*suh*1.0e-28); // gy=force (N)
gx=Math.sqrt((-1.0*rhp[yp][3]*1.602177e-19)/me); // gx=velocity (m/s)
ggx=(me*gx*gx)/gy; // ggx="temporary" radius
ggy=(2*pai*ggx*me*gx)/h; // ggy=de Broglie's waves
hpr[yp][3]=ggy; // hpr[][3] = waves
ex=(int)(ggy*1000); ggy=ex/1000.0;
elp[yp][7].setText("wn "+Double.toString(ggy));
}
// show electron 0-7 de Broglie wave
for (int yp=0; yp <=7; yp++) {
gz = Math.sqrt(teqq[yp][0]*teqq[yp][0]+teqq[yp][1]*teqq[yp][1]+teqq[yp][2]*teqq[yp][2]);
gy=(gz*elc*elc)/(4.0*pai*epsi*suh*1.0e-28); // gy=force (N)
gx=Math.sqrt((-1.0*teqq[yp][3]*1.602177e-19)/me); // gx=velocity (m/s)
ggx=(me*gx*gx)/gy;
ggy=(2*pai*ggx*me*gx)/h;
hpr[yp][3]=ggy;
ex=(int)(ggy*1000); ggy=ex/1000.0;
elp[yp][7].setText("wn "+Double.toString(ggy));
}
// show force FX acting on C nuclei
for (int rv=0; rv <=1; rv++) {
ww=" FX ";
ex=(int)(mmp[rv][0]);
mmpho[rv][0].setText(ww+Integer.toString(ex));
}
// show force acting on H0,H3 nuclei toward center
for (int rv=0; rv <=1; rv++) {
gx = -(nux[2][0]*mmp[2][0] +nux[2][1]*mmp[2][1] + nux[2][2]*mmp[2][2])/CH;
if ( rv == 1) {
gx = (nux[3][0]*mmp[5][0] +nux[3][1]*mmp[5][1] + nux[3][2]*mmp[5][2])/CH;
}
ex=(int)(gx);
mmpho[rv+2][0].setText("CF "+Integer.toString(ex));
}
// upper table ends
for (int yp=0; yp <=7; yp++) {
for (int jou=0; jou <=2; jou++) {
hprr[yp][jou] = hpr[yp][jou];
}}
// hprr [8-11][0-2] = position after moving toward center by force
// hprr2[8-11][0-2] = position after moving by force (=rhp5[][])
for (int yp=8; yp <=11; yp++) {
for (int kj=0; kj <=2; kj++) {
hprr[yp][kj] = hpr[yp][kj] + vvh[yp-8][kj+3] * 2.0 ;
hprr2[yp][kj] = hpr[yp][kj] + vvh2[yp-8][kj+3] * 2.0 ;
}}
toav=0.0; // toav= total potential energy after moving
// interaction among ele8-11 (aftger moving)
for (int yp=8; yp <=11; yp++) {
for (int kj=8; kj <=11; kj++) {
if (yp < kj ) {
kro=Math.sqrt((hprr[yp][0]-hprr[kj][0])*(hprr[yp][0]-hprr[kj][0])+
(hprr[yp][1]-hprr[kj][1])*(hprr[yp][1]-hprr[kj][1])+
(hprr[yp][2]-hprr[kj][2])*(hprr[yp][2]-hprr[kj][2]));
kro2=Math.sqrt((hprr2[yp][0]-hprr2[kj][0])*(hprr2[yp][0]-hprr2[kj][0])+
(hprr2[yp][1]-hprr2[kj][1])*(hprr2[yp][1]-hprr2[kj][1])+
(hprr2[yp][2]-hprr2[kj][2])*(hprr2[yp][2]-hprr2[kj][2]));
ppot=(elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
potd=(elc*elc*6.241509e18)/(4.0*pai*epsi*kro2*1.0e-14);
rpp[yp][3]=rpp[yp][3]+ppot/2.0; rpp[kj][3]=rpp[kj][3]+ppot/2.0;
rpp5[yp][3]=rpp5[yp][3]+potd/2.0; rpp5[kj][3]=rpp5[kj][3]+potd/2.0;
toav=toav+ppot;
for (int jou=0; jou <=2; jou++) {
ggx=(suh*(hprr[yp][jou]-hprr[kj][jou]))/(kro*kro*kro);
ggy=(suh*(hprr2[yp][jou]-hprr2[kj][jou]))/(kro2*kro2*kro2);
rpp[yp][jou]=rpp[yp][jou]+ggx; rpp[kj][jou]=rpp[kj][jou]-ggx;
rpp5[yp][jou]=rpp5[yp][jou]+ggy; rpp5[kj][jou]=rpp5[kj][jou]-ggy;
}
}}}
krr=0.0; potb=0.0; ggy=0.0;
for (int yp=8; yp <=11; yp++) {
for (int kj=0; kj <=7; kj++) {
kro=Math.sqrt((hprr[yp][0]-hprr[kj][0])*(hprr[yp][0]-hprr[kj][0])+
(hprr[yp][1]-hprr[kj][1])*(hprr[yp][1]-hprr[kj][1])+
(hprr[yp][2]-hprr[kj][2])*(hprr[yp][2]-hprr[kj][2]));
krr=Math.sqrt((hprr[yp][0]-hpr3[kj][0])*(hprr[yp][0]-hpr3[kj][0])+
(hprr[yp][1]-hpr3[kj][1])*(hprr[yp][1]-hpr3[kj][1])+
(hprr[yp][2]-hpr3[kj][2])*(hprr[yp][2]-hpr3[kj][2]));
kro2=Math.sqrt((hprr2[yp][0]-hprr[kj][0])*(hprr2[yp][0]-hprr[kj][0])+
(hprr2[yp][1]-hprr[kj][1])*(hprr2[yp][1]-hprr[kj][1])+
(hprr2[yp][2]-hprr[kj][2])*(hprr2[yp][2]-hprr[kj][2]));
// ede1 = 0.5 half charge
ppot=(ede1*elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
potb=(ede1*elc*elc*6.241509e18)/(4.0*pai*epsi*krr*1.0e-14);
rpp[yp][3]=rpp[yp][3]+ppot/2.0+potb/2.0;
rpp[kj][3]=rpp[kj][3]+ppot/2.0+potb/2.0;
toav=toav+ppot+potb;
ppot=(elc*elc*6.241509e18)/(4.0*pai*epsi*kro2*1.0e-14);
rpp5[yp][3]=rpp5[yp][3]+ppot/2.0; // interaction as they are
for (int jou=0; jou <=2; jou++) {
ggx=(ede1*suh*(hprr[yp][jou]-hprr[kj][jou]))/(kro*kro*kro);
ggy=(ede1*suh*(hprr[yp][jou]-hpr3[kj][jou]))/(krr*krr*krr);
ggz=(suh*(hprr[yp][jou]-hprr[kj][jou]))/(kro*kro*kro);
gz=(suh*(hprr2[yp][jou]-hprr[kj][jou]))/(kro2*kro2*kro2);
rpp[yp][jou]=rpp[yp][jou]+ggx+ggy;
rpp5[yp][jou]=rpp5[yp][jou]+gz;
rpp5[kj][jou]=rpp5[kj][jou]-ggz;
}
}}
// interaction among electrons 0-7
for (int yp=0; yp <=7; yp++) {
for (int kj=0; kj <=7; kj++) {
if (yp < kj ) { // kro=distance between electrons
kro=Math.sqrt((hprr[yp][0]-hprr[kj][0])*(hprr[yp][0]-hprr[kj][0])+
(hprr[yp][1]-hprr[kj][1])*(hprr[yp][1]-hprr[kj][1])+
(hprr[yp][2]-hprr[kj][2])*(hprr[yp][2]-hprr[kj][2]));
if (kro==0) {kro=5000.0;}
// rpp[][3]=each electron's potential energy
ppot=(elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
rpp[yp][3]=rpp[yp][3]+ppot/2.0; rpp[kj][3]=rpp[kj][3]+ppot/2.0;
toav=toav+ppot;
for (int jou=0; jou <=2; jou++) {
ggx=(suh*(hprr[yp][jou]-hprr[kj][jou]))/(kro*kro*kro);
// rpp5[][0-2] = force component
rpp5[yp][jou]=rpp5[yp][jou]+ggx; rpp5[kj][jou]=rpp5[kj][jou]-ggx;
}
}}}
// between electron8-11 and each nucleus
for (int yp=8; yp <=11; yp++) {
for (int rv=0; rv <=5; rv++) {
kro=Math.sqrt((hprr[yp][0]-nux[rv][0])*(hprr[yp][0]-nux[rv][0])+
(hprr[yp][1]-nux[rv][1])*(hprr[yp][1]-nux[rv][1])+
(hprr[yp][2]-nux[rv][2])*(hprr[yp][2]-nux[rv][2]));
kro2=Math.sqrt((hprr2[yp][0]-nux[rv][0])*(hprr2[yp][0]-nux[rv][0])+
(hprr2[yp][1]-nux[rv][1])*(hprr2[yp][1]-nux[rv][1])+
(hprr2[yp][2]-nux[rv][2])*(hprr2[yp][2]-nux[rv][2]));
ppot=-(nux[rv][3]*elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
potd=-(nux[rv][3]*elc*elc*6.241509e18)/(4.0*pai*epsi*kro2*1.0e-14);
toav = toav + ppot; rpp[yp][3] = rpp[yp][3] + ppot;
rpp5[yp][3] = rpp5[yp][3] + potd;
// rpp[][6]= potential V with other nuclei
zk = yp -6;
if ( rv != zk ) { rpp[yp][6] = rpp[yp][6] + ppot;
rpp5[yp][6] = rpp5[yp][6] + potd;
}
for (int jou=0; jou <=2; jou++) { // force component
ggx=(suh*nux[rv][3]*(hprr[yp][jou]-nux[rv][jou]))/(kro*kro*kro);
ggy=(suh*nux[rv][3]*(hprr2[yp][jou]-nux[rv][jou]))/(kro2*kro2*kro2);
rpp[yp][jou] = rpp[yp][jou] - ggx;
rpp5[yp][jou] = rpp5[yp][jou] - ggy;
mpp[rv][jou] = mpp[rv][jou] + ggx;
}
}}
// interaction between H nuclei and electrons 0-7
ggz=0.0;
for (int rv=2; rv <=5; rv++) {
for (int yp=0; yp <=7; yp++) {
kro=Math.sqrt((hprr[yp][0]-nux[rv][0])*(hprr[yp][0]-nux[rv][0])+
(hprr[yp][1]-nux[rv][1])*(hprr[yp][1]-nux[rv][1])+
(hprr[yp][2]-nux[rv][2])*(hprr[yp][2]-nux[rv][2]));
// hpr3[0-7][0-2] = symmetric position of ele0-7
krr=Math.sqrt((hpr3[yp][0]-nux[rv][0])*(hpr3[yp][0]-nux[rv][0])+
(hpr3[yp][1]-nux[rv][1])*(hpr3[yp][1]-nux[rv][1])+
(hpr3[yp][2]-nux[rv][2])*(hpr3[yp][2]-nux[rv][2]));
ppot=-(ede1*nux[rv][3]*elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
ggz=-(ede1*nux[rv][3]*elc*elc*6.241509e18)/(4.0*pai*epsi*krr*1.0e-14);
toav = toav + ppot+ggz;
rpp[yp][3] = rpp[yp][3] + ppot+ggz;
rpp[yp][6] = rpp[yp][6] + ppot+ggz;
for (int jou=0; jou <=2; jou++) {
ggx=(ede1*suh*nux[rv][3]*(hprr[yp][jou]-nux[rv][jou]))/(kro*kro*kro);
ggy=(ede1*suh*nux[rv][3]*(hpr3[yp][jou]-nux[rv][jou]))/(krr*krr*krr);
ggz=(suh*nux[rv][3]*(hprr[yp][jou]-nux[rv][jou]))/(kro*kro*kro);
rpp5[yp][jou] = rpp5[yp][jou] - ggz;
mpp[rv][jou] = mpp[rv][jou] + ggx+ggy;
}
}}
// interaction between electron0-7 and C nuclei
for (int yp=0; yp <=7; yp++) {
for (int rv=0; rv <=1; rv++) {
kro=Math.sqrt((hprr[yp][0]-nux[rv][0])*(hprr[yp][0]-nux[rv][0])+
(hprr[yp][1]-nux[rv][1])*(hprr[yp][1]-nux[rv][1])+
(hprr[yp][2]-nux[rv][2])*(hprr[yp][2]-nux[rv][2]));
krr=Math.sqrt((hpr3[yp][0]-nux[rv][0])*(hpr3[yp][0]-nux[rv][0])+
(hpr3[yp][1]-nux[rv][1])*(hpr3[yp][1]-nux[rv][1])+
(hpr3[yp][2]-nux[rv][2])*(hpr3[yp][2]-nux[rv][2]));
ppot=-(ede1*nux[rv][3]*elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
ggz=-(ede1*nux[rv][3]*elc*elc*6.241509e18)/(4.0*pai*epsi*krr*1.0e-14);
toav = toav +ppot+ggz; rpp[yp][3] = rpp[yp][3] + ppot+ggz;
// rpp[][6] = potential V with other nuclei
if ( yp < 4 && rv==1 ) {
rpp[yp][6] = rpp[yp][6] + ppot+ggz; }
if ( yp > 3 && rv==0 ) {
rpp[yp][6] = rpp[yp][6] + ppot+ggz; }
for (int jou=0; jou <=2; jou++) {
ggx=(ede1*suh*nux[rv][3]*(hprr[yp][jou]-nux[rv][jou]))/(kro*kro*kro);
ggy=(ede1*suh*nux[rv][3]*(hpr3[yp][jou]-nux[rv][jou]))/(krr*krr*krr);
ggz=(suh*nux[rv][3]*(hprr[yp][jou]-nux[rv][jou]))/(kro*kro*kro);
// force component
rpp5[yp][jou] = rpp5[yp][jou] - ggz;
mpp[rv][jou] = mpp[rv][jou] + ggx+ggy;
}
}}
// add interaction among nuclei
toav = toav + pota;
for (int rv=0; rv <=5; rv++) {
for (int jou=0; jou <=2; jou++) {
mpp[rv][jou]=mpp[rv][jou]+mmp[rv][jou+3];
}}
// distribute nucler V to electrons based on rpp[][6]
gz = 0.0;
for (int yp=0; yp <=11; yp++) {
gz = gz + rpp[yp][6];
}
for (int yp=0; yp <=11; yp++) {
rpp[yp][3] = rpp[yp][3] + (pota * rpp[yp][6])/gz;
}
gz = 0.0;
for (int yp=0; yp <=7; yp++) {
gz = gz + rpp[yp][6];
}
for (int yp=8; yp <=11; yp++) {
gz = gz + rpp5[yp][6];
}
for (int yp=8; yp <=11; yp++) {
rpp5[yp][3] = rpp5[yp][3] + (pota * rpp5[yp][6])/gz;
}
gz=0.0;
for (int yp=0; yp <=7; yp++) {
gz = gz + rpp[yp][3];
}
for (int yp=0; yp <=7; yp++) {
rpp[yp][3] = gz/8.0;
}
ex=(int)(toav*100.0); ggx=ex/100.0;
imphoo.setText("tV "+Double.toString(ggx)); // show total V after moving
for (int yp=0; yp <=5; yp++) {
xk=0; // xk = nuclear number electron belongs to
if ( yp < 4 && yp > 1 ) {
xk=1;
}
if ( yp == 4 ) {
xk=2;
}
if ( yp == 5 ) {
xk=4;
}
for (int jou=0; jou <=2; jou++) {
ex=(int)(hprr[yp*2][jou]-nux[xk][jou]);
// show relative coordinate of electron after moving
elpp[yp][jou].setText(Integer.toString(ex));
}
kro = Math.sqrt((hprr[yp*2][0] - nux[xk][0])*(hprr[yp*2][0]-nux[xk][0])+(hprr[yp*2][1]-nux[xk][1])*(hprr[yp*2][1]-nux[xk][1])+(hprr[yp*2][2]-nux[xk][2])*(hprr[yp*2][2]-nux[xk][2]));
if (kro == 0) {kro=5000.0;}
ex=(int)(kro);
elpp[yp][3].setText("nuc "+Integer.toString(ex));
ex=(int)(rpp[yp*2][3]*100.0); ggx=ex/100.0;
elpp[yp][4].setText("V "+Double.toString(ggx));
gx=-hprr[yp*2][0]; gy=-hprr[yp*2][1];
gz=-hprr[yp*2][2];
if (yp > 1 && yp < 4) {
gx=-(hprr[yp*2][0]+CC); gy=-hprr[yp*2][1];
gz=-hprr[yp*2][2];
}
ggx=Math.sqrt(gx*gx+gy*gy+gz*gz);
ggz = (gx*rpp5[yp*2][0] +gy*rpp5[yp*2][1] + gz*rpp5[yp*2][2])/ggx;
if (yp==4) {
ggz=-(nux[2][0]*rpp[8][0] +nux[2][1]*rpp[8][1] + nux[2][2]*rpp[8][2])/CH;
}
if (yp==5) {
ggz=(nux[2][0]*rpp[10][0] +nux[2][1]*rpp[10][1] + nux[2][2]*rpp[10][2])/CH;
}
// cf = force component toward center
elpp[yp][5].setText("cf "+Integer.toString((int)ggz));
elpp[yp][6].setText("rf "+Integer.toString(0));
gz = Math.sqrt(rpp[yp*2][0]*rpp[yp*2][0]+rpp[yp*2][1]*rpp[yp*2][1]+rpp[yp*2][2]*rpp[yp*2][2]);
if ( yp < 4 ) {
gz = Math.sqrt(teqq[yp*2][0]*teqq[yp*2][0]+teqq[yp*2][1]*teqq[yp*2][1]+teqq[yp*2][2]*teqq[yp*2][2]);
}
gy=(gz*elc*elc)/(4.0*pai*epsi*suh*1.0e-28); // gy=force (N)
gx=Math.sqrt((-1.0*rpp[yp*2][3]*1.602177e-19)/me); // gx=velocity (m/s)
if ( yp < 4 ) {
gx=Math.sqrt((-1.0*teqq[yp*2][3]*1.602177e-19)/me);
}
ggx=(me*gx*gx)/gy;
ggy=(2*pai*ggx*me*gx)/h;
hprr[yp*2][3]=ggy;
ex=(int)(ggy*1000); ggy=ex/1000.0;
elpp[yp][7].setText("wn "+Double.toString(ggy));
}
for (int yp=0; yp <=7; yp++) {
gz = Math.sqrt(teqq[yp][0]*teqq[yp][0]+teqq[yp][1]*teqq[yp][1]+teqq[yp][2]*teqq[yp][2]);
gy=(gz*elc*elc)/(4.0*pai*epsi*suh*1.0e-28); // gy=force (N)
gx=Math.sqrt((-1.0*teqq[yp][3]*1.602177e-19)/me); // gx=velocity (m/s)
ggx=(me*gx*gx)/gy;
ggy=(2*pai*ggx*me*gx)/h;
hprr[yp][3]=ggy;
}
for ( int yp=8; yp <=11; yp++ ) {
gz = Math.sqrt(rpp[yp][0]*rpp[yp][0]+rpp[yp][1]*rpp[yp][1]+rpp[yp][2]*rpp[yp][2]);
gy=(gz*elc*elc)/(4.0*pai*epsi*suh*1.0e-28); // gy=force (N)
gx=Math.sqrt((-1.0*rpp[yp][3]*1.602177e-19)/me); // gx=velocity (m/s)
ggx=(me*gx*gx)/gy;
ggy=(2*pai*ggx*me*gx)/h;
hprr[yp][3]=ggy;
}
gx = (hpr[0][3]+hprr[0][3])/2.0;
ex=(int)(gx*1000); ggz=ex/1000.0;
averwa0.setText("wn "+Double.toString(ggz));
gy = (hpr[2][3]+hprr[2][3])/2.0;
ex=(int)(gy*1000); ggz=ex/1000.0;
averwa2.setText("wn "+Double.toString(ggz));
gx = (hpr[8][3]+hprr[8][3])/2.0;
ex=(int)(gx*1000); gx=ex/1000.0;
averwa8.setText("wn "+Double.toString(gx));
gx = (hpr[11][3]+hprr[11][3])/2.0;
ex=(int)(gx*1000); gx=ex/1000.0;
averwael.setText("wn "+Double.toString(gx));
gx = (hpr[0][3]+hpr[2][3]+hpr[4][3]+hpr[6][3])/4.0;
ex=(int)(gx*1000); gx=ex/1000.0;
reawav0.setText("e0-7 ave "+Double.toString(gx));
// de Broglie wave of electron 8 as it is
gz = Math.sqrt(rhp5[8][0]*rhp5[8][0]+rhp5[8][1]*rhp5[8][1]+rhp5[8][2]*rhp5[8][2]);
gy=(gz*elc*elc)/(4.0*pai*epsi*suh*1.0e-28); // gy=force (N)
gx=Math.sqrt((-1.0*rhp5[8][3]*1.602177e-19)/me); // gx=velocity (m/s)
ggx=(me*gx*gx)/gy;
ggy=(2*pai*ggx*me*gx)/h;
gz = Math.sqrt(rpp5[8][0]*rpp5[8][0]+rpp5[8][1]*rpp5[8][1]+rpp5[8][2]*rpp5[8][2]);
gy=(gz*elc*elc)/(4.0*pai*epsi*suh*1.0e-28); // gy=force (N)
gx=Math.sqrt((-1.0*rpp5[8][3]*1.602177e-19)/me); // gx=velocity (m/s)
ggx=(me*gx*gx)/gy;
ggz=(2*pai*ggx*me*gx)/h; ggy=(ggy+ggz)/2.0;
ex=(int)(ggy*1000); gx=ex/1000.0;
reawav8.setText("nosplit "+Double.toString(gx));
}
}