Sample JAVA program of ethane molecule (CH3-CH3).

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 ethane2, so save this text editor as "ethane2.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.
The reason why central charge is about +4.22 instead of +4.00 (= +6.0e -2.0e ) can be understood running this program and this program ( visualization of carbon ).
About these detailed methods, see also this page.


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Scanner;
public class ethane2 extends JPanel         
    {
  public static void main(String arg[])
 {
   JFrame frame = new JFrame("CH3-CH3 (ethane-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;    // suh = Bohr radius^2 * 1000 
   int labe=0;
   double CC=15351.0; double CH=10940.0;        // bond length
   
 
    JTextField elp[][]=new JTextField[17][11];   // each electron text
                             // elpp[][] =  electron text (after moving)
    JTextField elpp[][]=new JTextField[4][11];   
    JTextField mmpho[][]=new JTextField[4][3];  // mmpho= nuclei text
    JTextField impho=new JTextField(7);    // impho = total V text   
    JTextField imphoo=new JTextField(7);  // total V (after moving) text 
   
    JTextField averwa0=new JTextField(7);  // average de Broglie wave text
    JTextField averwa4=new JTextField(7);
    JTextField averwa8=new JTextField(7); 
    JTextField averwael=new JTextField(7);

    JButton b1=new JButton("C-C (MM)");

    String ope[]={"13000","13500","14000","14500","15351","16000","16500","17000", "18000","19000"};  
    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[15][11];  // each electron parameters  
    double den=4.22;                    // central charge Z
    double hpr3[][]=new double[15][11]; // symmetric position of ele0-7              
    double hprr[][]=new double[15][11];  // aftter-ele parameters
                                                               
    double hens = 6415.0;  double henr =(hens*2.0)/rsi;  
    double heno=(henr*rsi)/6.0; double hent=henr/rth; double henf=2.0*hent;

                                  // te1 = initial electron coordinates           
    double te1[][]={{hens, 0.0, 0.0}, {-heno, 0.0, henf}, 
    {-heno, -henr, -hent}, {-heno, henr, -hent},
    {hens, 0.0, 0.0}, {-heno, 0.0, henf}, 
    {-heno, -henr, -hent}, {-heno, henr, -hent},
    {-1885.0, -3464.0, -666.0}, 
    {-1885.0, 2309.0, -2666.0}, {3771.0, 1154.0, -666.0},
    {1885.0, -2309.0, 2666.0},{-3771.0, -1154.0, 666.0},
     {1885.0, 3464.0, 666.0}, {0.0, 0.0, 4000.0}};

                                             // te2= ele8-13 vector
    double te2[][]={{0.0, 0.0, -10000.0}, {4714.0, 8660.3, 1666.7}, {4714.0,-5773.5,6666.7}, {-9428.1,-2886.8,1666.7}};

    double hen3=10940.0;  double henrr=(hen3*2.0)/rsi;                              double hen1=(henrr*rsi)/6.0; double hen2=henrr/rth; double hen4=2.0*hen2;
    double henp1= hen1+15351.0; 

                 // nux[0-7][0-2] = nuclei coordinates
                 // nux[0-7][3] = each nucleus charge
   
    double nux[][]={{0, 0, 0, den},{15351, 0, 0, den}, {-hen1, 0, hen4, 1}, {-hen1, -henrr, -hen2, 1},{-hen1, henrr, -hen2,1},{henp1, henrr, hen2, 1},
    {henp1, -henrr, hen2, 1}, {henp1, 0, -hen4, 1}
    }; 


  public J2DPanel()
 {
  setBackground(Color.black);
  JPanel p=new JPanel();
  p.setLayout(new GridLayout(24,12));
  int aaa=0; 
   double tx,ty,tz,tkk;
                               
  for (int el=0; el <=14; el++) {   
  for (int pos=0; pos <=2; pos++) {  
  elp[el][pos]=new JTextField(7);     
  
                  // Only electron 0,1,4,5,vir8 textboxes can be changed
  if (el==0 && pos==0 ) {elp[el][pos].addActionListener(this); }
  if (el==1 ) {elp[el][pos].addActionListener(this); }

  if (el==4 && pos==0) {elp[el][pos].addActionListener(this);}
  if (el==5 ) {elp[el][pos].addActionListener(this); }
                                // elp[14][]= virtual 8-10 electron coordinate
  if (el==14 ) {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 <=14; el++) {
  for (int pos=3; pos <=10; pos++) { 
  elp[el][pos]=new JTextField(7);    
  hpr[el][pos]=0.0;  hprr[el][pos]=0.0; hpr3[el][pos]=0.0;
  }}

    for (int el=0; el <=3; el++) {   
  for (int pos=0; pos <=10; pos++) {
    elpp[el][pos]=new JTextField(7);
    }} 

   for (int el=0; el <=1; el++) { 
  for (int pos=0; pos <=10; pos++) {  
  elp[15+el][pos]=new JTextField(7);
  }} 
                          // mmpho[0-1][]=C0 and C1 nuc's textboxes
                          // mmpho[2-3][]=H0 and H3 nuc's textboxes
   for (int el=0; el <=3; el++) {    
   for (int pos=0; pos <=2; pos++) {
    mmpho[el][pos]=new JTextField(7);
   }}
                 
                                        // layout
  String sihy[]={"eNo ", "+X(MM)", "+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 ele 0 "));
    for (int pos=0; pos <=10; pos++) {
  p.add(elp[0][pos]);
  }

    p.add(new Label("-- ele 1 "));
    for (int pos=0; pos <=10; pos++) {
  p.add(elp[1][pos]);
  }

   p.add(new Label("--    2 "));
    for (int pos=0; pos <=10; pos++) {
  p.add(elp[2][pos]);
  }

    p.add(new Label("--    3 "));
    for (int pos=0; pos <=10; pos++) {
  p.add(elp[3][pos]);
  }

    p.add(new Label("C1 ele 4 "));
    for (int pos=0; pos <=10; pos++) {
  p.add(elp[4][pos]);
  }

     p.add(new Label("-- ele 5 "));
    for (int pos=0; pos <=10; pos++) {
  p.add(elp[5][pos]);
  }

    p.add(new Label("--    6 "));
    for (int pos=0; pos <=10; pos++) {
  p.add(elp[6][pos]);
  }

    p.add(new Label("--    7 "));
    for (int pos=0; pos <=10; pos++) {
  p.add(elp[7][pos]);
  }

    p.add(new Label("     "));
    for (int pos=0; pos <=10; pos++) {
  p.add(elp[15][pos]);
  }

  p.add(new Label("Virtual 8-13"));
    for (int pos=0; pos <=10; pos++) {
  p.add(elp[14][pos]);
  }

  for (int el=8; el <=13; el++) {  
  if (el != 8 && el !=11 ) {     
  p.add(new Label("...  "+el+" "));}
  if (el==8) {p.add(new Label("** H0 e8"));}
  if (el==11) {p.add(new Label("** H3 e11"));}
   
  for (int pos=0; pos <=10; pos++) {
  p.add(elp[el][pos]);
  }}

   p.add(new Label("     "));
    for (int pos=0; pos <=10; pos++) {
  p.add(elp[16][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-3"));  p.add(averwa0);
   p.add(new Label("avewave 4-7"));  p.add(averwa4);
   p.add(new Label("  --  "));  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-10"));  p.add(averwa8);
  p.add(new Label("avewave 11-13"));  p.add(averwael);
   p.add(new Label("  --  "));  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 4 "));
    for (int pos=0; pos <=10; pos++) {
    p.add(elpp[1][pos]);
     }
    p.add(new Label("afel 8 "));
    for (int pos=0; pos <=10; pos++) {
    p.add(elpp[2][pos]);
     }
    p.add(new Label("afel 11 "));
    for (int pos=0; pos <=8; pos++) {
    p.add(elpp[3][pos]);
     }

    p.add(b1); p.add(coom);

   coom.setSelectedItem("15351"); b1.addActionListener(this); 

   add(p,"South");

   double xx,yy,zz;
   for (int el=0; el <=14; 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 each electron and close nucleus
   elp[el][3].setText("nuc "+Integer.toString(aaa));

          // te1[el][0-2] = relative coordinate of each electron wrt. nucleus
          // hpr[el][0-2] = absolute coordinate of each electron
    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 && el < 14) { hpr[el][jou]=te1[el][jou] + nux[el-6][jou];}

    xx = te1[el][jou];   // show relative coordinate texts
    elp[el][jou].setText(Integer.toString((int)xx));
     }}
  }     // public J2DPanel() end
 

  public void actionPerformed(ActionEvent e) {  
    String ss;

     labe=0;  // labe = mark
   if (e.getSource() == b1) {labe=3;}   // click C-C button
    
   if (labe == 3) {                    // C-C length change   
   ss=(String)coom.getSelectedItem();
    if (ss=="13000") {CC=13000;}   if (ss=="13500") {CC=13500;}
   if (ss=="14000") {CC=14000;}  if (ss=="14500") {CC=14500;} 
   if (ss=="15351") {CC=15351;}  if (ss=="16000") {CC=16000;}
   if (ss=="16500") {CC=16500;}  if (ss=="17000") {CC=17000;}
    if (ss=="18000") {CC=18000;} if (ss=="19000") {CC=19000;}


    hen3=10940.0;  henr=(hen3*2.0)/rsi;     
                                              
    hen1=(henr*rsi)/6.0;  hen2=henr/rth; hen4=2.0*hen2;

    henp1= hen1+CC; 
   
    double noxxx[][]={{0, 0, 0},{CC, 0, 0}, {-hen1, 0, hen4}, {-hen1, -henr, -hen2},{-hen1, henr, -hen2},{henp1, henr, hen2},
    {henp1, -henr, hen2}, {henp1, 0, -hen4}}; 

    for (int ett=0; ett <=7; 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,
  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}};
   double teqqq[][]={{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,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;   // split charge -- 0.5 times 8 = 4 valence electrons
    
                    // get each coordinate from textboxes
  ww=elp[0][0].getText(); hpr[0][0]=Double.parseDouble(ww);
  hpr[0][1]=0.0; hpr[0][2]=0.0;
  ww=elp[1][0].getText(); hpr[1][0]=Double.parseDouble(ww);
  ww=elp[1][2].getText(); hpr[1][2]=Double.parseDouble(ww);
  hpr[1][1]=0.0;

  ww=elp[4][0].getText(); hpr[4][0]=Double.parseDouble(ww)+CC;
  hpr[4][1]=0.0; hpr[4][2]=0.0;
  ww=elp[5][0].getText(); hpr[5][0]=Double.parseDouble(ww)+CC;
  ww=elp[5][2].getText(); hpr[5][2]=Double.parseDouble(ww);
  hpr[5][1]=0.0;

                 // get virtual ele8-13 coordinates
  ww= elp[14][0].getText(); gx=Double.parseDouble(ww); hpr[14][0]=gx;
  ww= elp[14][1].getText(); gy=Double.parseDouble(ww); hpr[14][1]=gy;
  ww= elp[14][2].getText(); gz=Double.parseDouble(ww); hpr[14][2]=gz;

  kww=Math.sqrt(hpr[14][0]*hpr[14][0]+hpr[14][1]*hpr[14][1]+hpr[14][2]*hpr[14][2]);
    elp[14][3].setText(Integer.toString((int)kww));
 
                // set ele 2-3 coordinates based on ele 1
    double cor=Math.cos(60.0*(pai/180.0));  
    double sor=Math.sin(60.0*(pai/180.0)); 
  
  hpr[2][0]=hpr[1][0]; hpr[3][0] = hpr[1][0];
  hpr[2][2] = -cor*hpr[1][2]; hpr[3][2]= -cor*hpr[1][2];
  hpr[2][1] = -sor*hpr[1][2]; hpr[3][1]= sor*hpr[1][2];
   
   for (int yp=2; yp <=3; yp++) {  
   for (int kj=0; kj <=2; kj++) {
   elp[yp][kj].setText(Integer.toString((int)hpr[yp][kj]));
   }}

               // set ele 6-7 coordinates based on ele 5
  hpr[6][0]=hpr[5][0]; hpr[7][0] = hpr[5][0];
  hpr[6][2] = -cor*hpr[5][2]; hpr[7][2]= -cor*hpr[5][2];
  hpr[6][1] = -sor*hpr[5][2]; hpr[7][1]= sor*hpr[5][2];
    
   for (int yp=6; yp <=7; yp++) {  
   for (int kj=0; kj <=2; kj++) {

   krk=hpr[yp][kj];
   if (kj==0) {krk=krk-CC;}

   elp[yp][kj].setText(Integer.toString((int)krk));
    
   }
   } 

   for (int yp=8; yp <=10; yp++) {     
   for (int kj=0; kj <=2; kj++) {

   hpr[yp][kj] = (nux[yp-6][kj] * gx)/CH - (te2[yp-7][kj]*gz)/10000.0;       
   elp[yp][kj].setText(Integer.toString((int)hpr[yp][kj]));
   hpr[yp][kj] = hpr[yp][kj] + nux[yp-6][kj];
   }} 

   ez=0;
    for (int yp=11; yp <=13; yp++) { 
    if (yp==11) { ez = 2;}   if (yp==12) { ez = 3;}
     if (yp==13) { ez = 1;}
    
   for (int kj=0; kj <=2; kj++) {

   hpr[yp][kj] = (-nux[ez+1][kj] * gx)/CH + (te2[ez][kj]*gz)/10000.0;       
   elp[yp][kj].setText(Integer.toString((int)hpr[yp][kj]));
   hpr[yp][kj] = hpr[yp][kj] + nux[yp-6][kj];
   }}

                // hpr3[][] symmetric position of ele 0-7 wrt. C nuclei

    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

    double ppot;
                                 // interaction among electron 8-13
      for (int yp=8; yp <=13; yp++) {      
      for (int kj=8; kj <=13; kj++) {
      if (yp < kj ) {       
                                 // kro = distance among 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 = 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
      rhp[yp][3]=rhp[yp][3]+ppot/2.0;  rhp[kj][3]=rhp[kj][3]+ppot/2.0;
      toav=toav+ppot;         // toav = total potential energy

         for (int jou=0; jou <=2; jou++) {
     ggx=(suh*(hpr[yp][jou]-hpr[kj][jou]))/(kro*kro*kro);
                              
                      // rhp[el][0-2] = force acting on each electron
    rhp[yp][jou]=rhp[yp][jou]+ggx;  rhp[kj][jou]=rhp[kj][jou]-ggx;
      }
     }}}

                     // interaction between electron 0-7 and 8-13
     krr=0.0; potb=0.0; ggy=0.0;
    for (int yp=8; yp <=13; 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]));
                        
                     // krr = distance between ele8-13 and symmetric ele0-7
    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]));
             // split potential energy into two (ele 0-7 and their symmetric )
      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; 
      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);
  
    rhp[yp][jou]=rhp[yp][jou]+ggx+ggy;  

               // rhp5[0-7][0-2] = force acting on electron 0-7
    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 (eV)
   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[el][0-2] = force acting on electron 0-7
    rhp5[yp][jou]=rhp5[yp][jou]+ggx;  rhp5[kj][jou]=rhp5[kj][jou]-ggx;
    }
    }}}
   
                         // interaction between electron 8-13 and nuclei                      
   for (int yp=8; yp <=13; yp++) {   
   for (int rv=0; rv <=7; 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 = each potential energy between ele and nuclei
     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;

                  // rhp[el][6] = potential between electron and other nuclei
        zk = yp -6;   
      if ( rv != zk ) { rhp[yp][6] = rhp[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[el][0-2] = force component acting on each electron  
                 // mmp[ev][0-2] = force component acting on each nucleus  
                              
   rhp[yp][jou] = rhp[yp][jou] - ggx; 
   mmp[rv][jou] = mmp[rv][jou] + ggx;
       }
               
    }} 
                 // interaction between electron 0-7 and hydrogen nuclei
    ggz=0.0;
   for (int rv=2; rv <=7; 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;
       }
     }} 

                    // interaction between electron0-7 and C nuclei
      for (int yp=0; yp <=7; yp++) {   
      for (int rv=0; rv <=1; rv++) { 

                   // kro = distance between ele0-7 and C nuclei
      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 = distance between symmetric ele0-7 and C nuclei
      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[el][6] = potential between electron and other nuclei
      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;  
       }}}                           

                                      // among nuclei
    pota = 0.0;                       // pota = potential V among nuclei
    for (int yp=0; yp <=7; yp++) {       
    for (int kj=0; kj <=7; 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[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;                             
       for (int yp=0; yp <=13; yp++) {
        gz = gz + rhp[yp][6];
        }
                  // distribute nuclear V to each electron based on rhp[el][6]
       for (int yp=0; yp <=13; yp++) {
        rhp[yp][3] = rhp[yp][3] + (pota * rhp[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][0-2] = center coordinate of electron 0-3
                 // noxx[1][0-2] = center coordinate of electron 4-7
        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;
    }

     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[0-3][3] = potential energy only in carbon 0
     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[0-3][0-2] = force component only in carbon 0  
   teqq[yp][jou]=teqq[yp][jou]+ggx; teqq[kj][jou]=teqq[kj][jou]-ggx;
                     
    } 
    }}}

     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[4-7][3] = potential energy only in carbon 1
     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[4-7][0-2] = force component only in carbon 1    
   teqq[yp][jou]=teqq[yp][jou]+ggx; teqq[kj][jou]=teqq[kj][jou]-ggx;
                     
    } 
    }}}
    
            // interaction between electron 0-3 (4-7) and center (noxx[0,1])
       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-3 '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 ele0-7 and their C nucleus
     elp[yp][3].setText("nuc "+Integer.toString(ex)); 

       ex = 0; if (yp > 3) {ex=1;}
       ez=yp-(ex*4)+1;

       rhp[yp][4] = -(nux[ez][0]*rhp5[yp][0] +nux[ez][1]*rhp5[yp][1] + nux[ez][2]*rhp5[yp][2])/CH;
     
     if (yp ==0 || yp == 4 ) {
     rhp[yp][4] = -(nux[1][0]*rhp5[yp][0] +nux[1][1]*rhp5[yp][1] + nux[1][2]*rhp5[yp][2])/CC;
        }
      
     rhp[yp][5] = 0.0;     // rhp[0-7][4], cf = force component toward center
     ex=(int)(rhp[yp][4]);  

     if (yp > 0) {
     elp[yp][5].setText("cf "+Integer.toString(ex));}

     if (yp == 0) {
     elp[yp][5].setText("cf "+Integer.toString(ex) + "  *");}

     elp[yp][6].setText("rf "+Integer.toString(0));
    
      }

                 // vvh[0-5][0-2] = each electron vector toward C-H line
    double vvh[][]=new double[6][6];       
    for (int yp=8; yp <=13; yp++) { 
          
    ez=yp-6; ggx=1.0;

     if (yp==11) { ez=3; ggx = -1.0;}
     if (yp==12) { ez=4; ggx = -1.0;}
     if (yp==13) { ez=2; ggx = -1.0;}
    
                // kro = projection of each coordinate vector to C-H line
     kro=ggx*(hpr[yp][0]*nux[ez][0]+hpr[yp][1]*nux[ez][1]+hpr[yp][2]*nux[ez][2])/CH;

   if ( yp > 10 ) {
        kro=ggx*((hpr[yp][0]-CC)*nux[ez][0]+hpr[yp][1]*nux[ez][1]+hpr[yp][2]*nux[ez][2])/CH;
      }

   for (int kj=0; kj <=2; kj++) { 
     vvh[yp-8][kj] = ggx*(nux[ez][kj]*kro)/CH; 
     ggz = hpr[yp][kj];
  if ( yp > 10 && kj ==0 ) {
    ggz = hpr[yp][kj]- CC;
    }
                // vvh[0-5][0-2] = each electron vector toward C-H line
    vvh[yp-8][kj] = vvh[yp-8][kj] - ggz; 
    
     }
     }

                                               // show electron 8-13 data
     for (int yp=8; yp <=13; yp++) {
       ez=yp-6; ggz=1.0;

     if (yp==11) { ez=3; ggz = -1.0;}
      if (yp==12) { ez=4; ggz = -1.0;}
       if (yp==13) { ez=2; ggz = -1.0;}

     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[yp][4] = -ggz*(nux[ez][0]*rhp[yp][0] +nux[ez][1]*rhp[yp][1] + nux[ez][2]*rhp[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[yp][5] = (vvh[yp-8][0]*rhp[yp][0] +vvh[yp-8][1]*rhp[yp][1] + vvh[yp-8][2]*rhp[yp][2])/krr;
       
                    // rhp[][4] = force toward center
        ex=(int)(rhp[yp][4]);  
     elp[yp][5].setText("cf "+Integer.toString(ex)); 

                    // rhp[][5] = force toward C-H line   
        ex=(int)(rhp[yp][5]);  
     elp[yp][6].setText("rf "+Integer.toString(ex)); 

        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] );

                   // vvh[0-6][3-5] = force vector toward center
      gx = (rhp[yp][4] * krr) / rhp[yp][5];
    for (int kj=0; kj <=2; kj++) {
      vvh[yp-8][kj+3]  = -ggz*(nux[ez][kj] * gx)/CH;  
     }
     }
                                  
                              // show electron 8-13 de Broglie waves

      for (int yp=8; yp <=13; yp++) {    
                              // gz = total force acting on each ele8-13
     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  electon 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));                        
     }


      for (int rv=0; rv <=1; rv++) {
       ww=" FX ";    
      ex=(int)(mmp[rv][0]);
      mmpho[rv][0].setText(ww+Integer.toString(ex) + "   *");
      }

                                                                       
     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-13][0-2] = ele8-13 coordinates after moving in force direction
    for (int yp=8; yp <=13; yp++) {
    for (int kj=0; kj <=2; kj++) {
    
     hprr[yp][kj] = hpr[yp][kj] + vvh[yp-8][kj+3] * 2.0 ;   
     }}
               
     toav=0.0;             // toav= total potential energy (after moving)
                             
                       // interaction among ele8-13 (after)
      for (int yp=8; yp <=13; yp++) {      
      for (int kj=8; kj <=13; 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]));
       if (kro==0) {kro=5000.0;}  
       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);
  
    rpp[yp][jou]=rpp[yp][jou]+ggx;  rpp[kj][jou]=rpp[kj][jou]-ggx;
      }

     }}}
                             // interaction between ele8-13 (after) and ele0-7
     krr=0.0; potb=0.0; ggy=0.0;
    for (int yp=8; yp <=13; 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]));
      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;

     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);
  
                            // rpp[][0-2] = force component
    rpp[yp][jou]=rpp[yp][jou]+ggx+ggy;
                        // rpp5[0-7][0-2] = force  acting on ele0-7 (after)
    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;}          // rhp[][3]=each electron's potential energy
   ppot=(elc*elc*6.241509e18)/(4*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[yp][jou]=rpp5[yp][jou]+ggx;  rpp5[kj][jou]=rpp5[kj][jou]-ggx;
    }
    }}}
   
                                 //  between electron and each nucleus
                                 
   for (int yp=8; yp <=13; yp++) {   
   for (int rv=0; rv <=7; 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])); 
     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; rpp[yp][3] = rpp[yp][3] + ppot;

        zk = yp -6;   
      if ( rv != zk ) { rpp[yp][6] = rpp[yp][6] + ppot;}                    
      
       for (int jou=0; jou <=2; jou++) {        // force component
      ggx=(suh*nux[rv][3]*(hprr[yp][jou]-nux[rv][jou]))/(kro*kro*kro);
                                              
     rpp[yp][jou] = rpp[yp][jou] - ggx; 
     mpp[rv][jou] = mpp[rv][jou] + ggx;
  
       }            
    }}     
                            // between ele0-7 and H nuclei
    ggz=0.0;
   for (int rv=2; rv <=7; 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]));   
      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++) {    // force component    
      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);
                                       
   rpp5[yp][jou] = rpp5[yp][jou] - ggz; 
   mpp[rv][jou] = mpp[rv][jou] + ggx+ggy;
       }
     }}  
  
                            // between ele0-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;
      
      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);
                                       
    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 <=7; rv++) { 
     for (int jou=0; jou <=2; jou++) { 

       mpp[rv][jou]=mpp[rv][jou]+mmp[rv][jou+3];
       
     }}
     
      gz = 0.0;        // distribute nucler V to ele based on rpp[][6]
       for (int yp=0; yp <=13; yp++) {
        gz = gz + rpp[yp][6];
        }

       for (int yp=0; yp <=13; 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][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) 
                  // show date of electron 0, 4, 8, 11 after moving
     for (int yp=0; yp <=3; yp++) {
      ez=0; ey=1; xk=0; krk=CC; ggz=1.0;

     if (yp==1) {  ez=1; ey=1; xk=4; krk=CC; ggz=1.0;  }
     if (yp==2) {  ez=2; ey=2; xk=8; krk=CH; ggz=1.0;  }
     if (yp==3) {  ez=5; ey=3; xk=11 ; krk=CH; ggz=-1.0;  }

      for (int jou=0; jou <=2; jou++) {
         ex=(int)(hprr[xk][jou]-nux[ez][jou]);  
     elpp[yp][jou].setText(Integer.toString(ex));
       }

       kro = Math.sqrt((hprr[xk][0] - nux[ez][0])*(hprr[xk][0]-nux[ez][0])+(hprr[xk][1]-nux[ez][1])*(hprr[xk][1]-nux[ez][1])+(hprr[xk][2]-nux[ez][2])*(hprr[xk][2]-nux[ez][2]));
     if (kro == 0) {kro=5000.0;}
     ex=(int)(kro);  
     elpp[yp][3].setText("nuc "+Integer.toString(ex)); 

     ex=(int)(rpp[xk][3]*100.0);  ggx=ex/100.0;
     elpp[yp][4].setText("V "+Double.toString(ggx));  

     rpp[xk][4] = -ggz*(nux[ey][0]*rpp[xk][0] +nux[ey][1]*rpp[xk][1] + nux[ey][2]*rpp[xk][2])/krk;

    rpp5[xk][4] = -ggz*(nux[ey][0]*rpp5[xk][0] +nux[ey][1]*rpp5[xk][1] + nux[ey][2]*rpp5[xk][2])/krk;
       
       ex=(int)(rpp[xk][4]); 
     if (xk < 8) {ex=(int)(rpp5[xk][4]);}  
     elpp[yp][5].setText("cf "+Integer.toString(ex));
     elpp[yp][6].setText("rf "+Integer.toString(0)); 

      gz = Math.sqrt(rpp[xk][0]*rpp[xk][0]+rpp[xk][1]*rpp[xk][1]+rpp[xk][2]*rpp[xk][2]);

      if ( xk < 7 ) {
        gz = Math.sqrt(teqq[xk][0]*teqq[xk][0]+teqq[xk][1]*teqq[xk][1]+teqq[xk][2]*teqq[xk][2]);
          }

     gy=(gz*elc*elc)/(4.0*pai*epsi*suh*1.0e-28);    // gy=force (N)      
     gx=Math.sqrt((-1.0*rpp[xk][3]*1.602177e-19)/me);  // gx=velocity (m/s)

     if ( xk < 7 ) {
      gx=Math.sqrt((-1.0*teqq[xk][3]*1.602177e-19)/me); 
      }
                              // show each de Broglie wave
     ggx=(me*gx*gx)/gy;        // ggx = centrifugal radius        
     ggy=(2*pai*ggx*me*gx)/h;    // ggy = waves in one orbit              
     hprr[xk][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;          // hprr[][3] = each de Broglie wave                       
     }

    for ( int yp=8; yp <=13; 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;  
      }

      ggx=0.0; gx=0.0; gy=0.0; gz=0.0;
      for (int yp=0; yp <=3; yp++) {                                    
      ggx = (hpr[yp][3]+hprr[yp][3])/2.0; 
      ggy = (hpr[yp+4][3]+hprr[yp+4][3])/2.0;
      gx=gx+ggx; gy=gy+ggy;  
       }
      
      gx=gx/4.0; gy=gy/4.0; 
                           // show average wave of ele 0-3
      ex=(int)(gx*1000);  gx=ex/1000.0;                        
      averwa0.setText("wn "+Double.toString(gx)); 
                          // show average wave of ele 4-7
      ex=(int)(gy*1000);  gy=ex/1000.0;                          
      averwa4.setText("wn "+Double.toString(gy)); 

                          // show average wave of ele 0 and 4
      gz = (hpr[0][3]+hprr[0][3]+hpr[4][3]+hprr[4][3])/4.0; 
      ex=(int)(gz*1000);  gz=ex/1000.0;
      elp[13][10].setText("0,4ave "+Double.toString(gz)); 

      gx = (hpr[8][3]+hprr[8][3]+hpr[9][3]+hprr[9][3]+hpr[10][3]+hprr[10][3])/6.0; 
                              // show average wave of ele 8-10
      ex=(int)(gx*1000);  gx=ex/1000.0;
      averwa8.setText("wn "+Double.toString(gx)); 

        gx = (hpr[11][3]+hprr[11][3]+hpr[12][3]+hprr[12][3]+hpr[13][3]+hprr[13][3])/6.0; 
                             // show average wave of ele 11-13
      ex=(int)(gx*1000);  gx=ex/1000.0;
      averwael.setText("wn "+Double.toString(gx)); 
                                              
   }
   }