ボーア模型の酸素分子 の電子配置を視覚化するサンプルJAVAプログラム

2重結合のページに戻る
トップページ(2電子原子も含む新ボーア模型)

このプログラムは少し長いので、下に示すソースプログラムをコピーして、テキストエディタ(メモ帳など)にそのまま貼り付けて、コンパイルすれば簡単に実行できる。
このプログラムの class file name は oxymol なので、このデキストエディタを "oxymol.java" のファイル名で保存してコンパイルしてほしい。

このプログラムでは、原子核は灰色の円で示してある。
各粒子は、x-y (左)、x-z (右)平面に表示される。 ここでは、新しい単位として ( 1 MM = 10-14 meter) を使っている。
テキストボックス内の電子の各座標 (+X (MM), +Y (MM), +Z (MM)) は、これらの原子核からの”相対的な”位置座標を示している。
(ele 0-5 は酸素原子核 (O0) からの、 ele 6-11 は 酸素原子核 (O1) からの相対座標である。)
電子 (ele 0,2,4) のみの座標 (+X, +Y, +Z) を自由に変更することができる。
(ele0,2,4) のテキストボックス内に値を入力して、Enter キーを押せばいい。他の粒子はそれをもとに変更される。)
"nuc (MM)" はこれらの核と電子の距離である。
V (eV) と T (eV) は各電子の位置エネルギーと運動エネルギーを示している。
tV (eV) は全位置エネルギーである。
CF は、中心方向への力を意味する。
(fx, fy, fz) は CF を除いた残りの力の成分を意味する。
(FX, FY, FZ) は各原子核に作用する力の成分を意味する。
Waves (wn) は1軌道に含まれるド。ブロイ波の数を示している。
スクロールバーの中から値を選択して、O=O (MM) ボタンをクリックすれば、酸素分子の O=O長が変化する。


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Scanner;
public class oxymol extends JPanel     // virial theorem of O2
 {
  public static void main(String arg[])
 {
   JFrame frame = new JFrame("O=O (oxygen molecule)");
   J2DPanel j2dpanel = new J2DPanel();
   frame.getContentPane().add(j2dpanel); frame.setSize(1180,720);
   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=5200.0*5200.0; // suh=(Bohr radius)^2
 
    JTextField elp[][]=new JTextField[9][11];  JTextField impho=new JTextField(7); 
    JTextField mmpho[][]=new JTextField[2][3];  JButton b1=new JButton("O=O (MM)");
     String ope[]={"11000","12074","13000"};   // scrollbar of O=O distances
    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=6.271;                         // den = central charge
    double oolen=12074.0;                     // oolen= O=O length (MM)

                                    // nux[0-1][0-2] nuclear coordinate of oxygen
    double nux[][]={{18571.28-oolen*0.5, 13214.18, 13214.18, den},
     {18571.28+oolen*0.5, 13214.18, 13214.18, den}};                          

                                       // te1[][]=control O=O: 12074 MM
    double te1[][]={{3295, 0, -3165}, {3295, 0, 3165}, 
    {-3200, 0, 3260}, {10, -4580, 0}, 
    {-3295, -3165, 0}, {+3200, 3260, 0}, {3200, -3260, 0},
    {-10, 0, -4580}, {-10, 0, 4580}};

                                      // te2[][]  O=O: 13000 MM
    double te2[][]={{3295, 0, -3178}, {3295, 0, 3178}, 
    {-3200, 0, 3263}, {5, -4584, 0}, 
    {-3295, -3178, 0}, {+3200, 3263, 0}, {3200, -3263, 0},
    {-5, 0, -4584}, {-5, 0, 4584}};

                                      // te3[][]  O=O: 11000 MM
    double te3[][]={{3295, 0, -3154}, {3295, 0, 3154}, 
    {-3195, 0, 3269}, {15, -4582, 0}, 
    {-3295, -3154, 0}, {+3195, 3269, 0}, {3195, -3269, 0},
    {-15, 0, -4582}, {-15, 0, 4582}};

  public J2DPanel()
 {
  setBackground(Color.black);
  JPanel p=new JPanel();
  p.setLayout(new GridLayout(11,12));
  int aaa=0; 
                     //  elp[el=0-8][] : textboxes of electrons 0,1,2,4,6,8,9,10,11              
  for (int el=0; el <=8; el++) {         
  for (int pos=0; pos <=2; pos++) {
  elp[el][pos]=new JTextField(7); 
  if (el == 0) {elp[el][pos].addActionListener(this);}
  if (el== 2 || el==3) {elp[el][pos].addActionListener(this);}
  }}
                                   
   for (int el=0; el <=8; el++) {        
  for (int pos=3; pos <=10; pos++) {
  elp[el][pos]=new JTextField(7);     
  }}
                           // mmpho[0-1][] = textboxes of nuclei O-0 and O-1
   for (int el=0; el <=1; 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)", "T(eV)", "Force", "fx ", "fy", "fz", "Waves"};
  for (int el=0; el <= 11; el++) {
   p.add(new Label(sihy[el]));
  }

   String yy;
  for (int el=0; el <=8; el++) {   
  yy=" ";    
  if (el==0) {yy="ele "; aaa=0;}
  if (el==1) {yy=" "; aaa=1;}
  if (el == 2) {yy="ele "; aaa=2;}
  if (el == 3) {yy="ele "; aaa=4;}
  if (el==4) {yy=" "; aaa=6;}
  if (el == 5) {yy=" "; aaa=8;}
  if (el == 6) {yy=" "; aaa=9;}
  if (el==7) {yy=" "; aaa=10;}
  if (el == 8) {yy=" "; aaa=11;}
  p.add(new Label(yy+aaa+" "));
  for (int pos=0; pos <=10; pos++) {
  p.add(elp[el][pos]);
  }}

   p.add(new Label("O-0nuc "));
  for (int pos=0; pos <=2; pos++) {
  p.add(mmpho[0][pos]);  
  }
    p.add(new Label(" -- ")); p.add(impho);
    p.add(new Label("O1 nuc "));
  for (int pos=0; pos <=2; pos++) {
  p.add(mmpho[1][pos]);  
  }
   
   p.add(b1); p.add(coom); coom.setSelectedItem("12074"); b1.addActionListener(this);
   
  
  add(p,"South");
  
   for (int el=0; el <=8; 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].setText(Integer.toString(aaa));
 
    for (int jou=0; jou <=2; jou++) {          
    if (el < 3) {hpr[el][jou]=te1[el][jou]+nux[0][jou];}
    if (el== 3) {hpr[4][jou]=te1[3][jou]+nux[0][jou];}
    if (el== 4) {hpr[6][jou]=te1[4][jou]+nux[0][jou];}
     if (el > 4) {hpr[el+3][jou]=te1[el][jou]+nux[1][jou];}
      
     elp[el][jou].setText(Integer.toString((int)(te1[el][jou])));
     }}
   
  }     // public J2DPanel() end
 
  public void actionPerformed(ActionEvent e) {  
    String ss; double Rf=0.0;
   
    if (e.getSource() == b1) {          // when O=O distance change (b1 click)
   ss=(String)coom.getSelectedItem();
   if (ss=="11000") {oolen=11000;}  if (ss=="12074") {oolen=12074; } 
   if (ss=="13000") {oolen=13000;} 
   double nuxx[][]={{18571.28-oolen*0.5, 13214.18, 13214.18},
     {18571.28+oolen*0.5, 13214.18, 13214.18}};
    
    for (int ett=0; ett <= 1; ett++) {
     for (int sws=0; sws <=2; sws++) { 
     nux[ett][sws]=nuxx[ett][sws];
    }}
      for (int ett=0; ett <= 8; ett++) {
      for (int sws=0; sws <= 2; sws++) {  
     if (oolen==11000) {Rf=te3[ett][sws];}  if (oolen==12074) {Rf=te1[ett][sws];}  
     if (oolen==13000) {Rf=te2[ett][sws];}    
    elp[ett][sws].setText(Integer.toString((int)Rf));
     }}
    }

   repaint();
  }

  public void update(Graphics g)
 {
  paint(g);
 }
 public void paintComponent(Graphics g)
 {
   
  double kro,krr,krk,kro2,krr2,krk2,kkk,kkk2, pot,pota,potb,
  pot2,pota2,potb2,potc,potc2,gx,gy,gz,ggx,ggy,ggz,ttav,toav;
  kro=0.0; krr=0.0; krk=0.0; kro2=0.0; krr2=0.0; krk2=0.0; kkk=0.0; kkk2=0.0;
  int ex,ey,ez,xk,yk,zk; String ww,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}};
  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}};
  double mmp[][]={{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},{0,0,0,0},{0,0,0,0}};
   double noxx[][]={{0,0,0,0},{0,0,0,0}}; 
 
                         // set electrons 0(=elp[0][0-2]), 2(=elp[2][0-2]), 4(=elp[3][0-2]) 
   elp[0][1].setText("0");  elp[2][1].setText("0");  elp[3][2].setText("0"); 
   for (int jou=0; jou <=2; jou++) {
   ww=elp[0][jou].getText(); gx=Double.parseDouble(ww);
   hpr[0][jou]=gx;                               
    }       
   for (int jou=0; jou <=2; jou++) {
   ww=elp[2][jou].getText(); gx=Double.parseDouble(ww);
   hpr[2][jou]=gx;                                
    }   
   for (int jou=0; jou <=2; jou++) {
   ww=elp[3][jou].getText(); gx=Double.parseDouble(ww);
   hpr[4][jou]=gx;                                
    }     
                 // set electrons 1, 3, and 5-11 based on the upper ele 0, 2, 4                         
   hpr[1][0]=hpr[0][0]; hpr[1][1]=0.0; hpr[1][2]=-hpr[0][2];
   hpr[6][0]=-hpr[0][0]; hpr[6][1]=hpr[0][2]; hpr[6][2]=0.0;
   hpr[7][0]=-hpr[0][0]; hpr[7][1]=-hpr[0][2]; hpr[7][2]=0.0;

   hpr[3][0]=hpr[2][0]; hpr[3][1]=0.0; hpr[3][2]=-hpr[2][2];
   hpr[8][0]=-hpr[2][0]; hpr[8][1]=hpr[2][2]; hpr[8][2]=0.0;
   hpr[9][0]=-hpr[2][0]; hpr[9][1]=-hpr[2][2]; hpr[9][2]=0.0;

   hpr[5][0]=hpr[4][0]; hpr[5][1]=-hpr[4][1]; hpr[5][2]=0.0;
   hpr[10][0]=-hpr[4][0]; hpr[10][1]=0.0; hpr[10][2]=hpr[4][1];
   hpr[11][0]=-hpr[4][0]; hpr[11][1]=0.0; hpr[11][2]=-hpr[4][1];

   
     for (int yp=0; yp <=5; yp++) { 
   for (int jou=0; jou <=2; jou++) {
   if (yp==1) {elp[1][jou].setText(Integer.toString((int)hpr[yp][jou]));}
   hpr[yp][jou]=hpr[yp][jou]+nux[0][jou];   // hpr[0-11][0-2] = absolute coordinate
   }}

   for (int yp=6; yp <=11; yp++) { 
   for (int jou=0; jou <=2; jou++) {
   if (yp==6) {elp[4][jou].setText(Integer.toString((int)hpr[yp][jou]));}
   if (yp > 7) {elp[yp-3][jou].setText(Integer.toString((int)hpr[yp][jou]));}
   hpr[yp][jou]=hpr[yp][jou]+nux[1][jou];
   }}

                                   // noxx[0][0-2]=center of electrons 0-5
                                   // noxx[1][0-2]=center of electrons 6-11

   for (int yp=0; yp <=5; 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+6][jou];
    }}
    for (int jou=0; jou <=2; jou++) {
    noxx[0][jou]=noxx[0][jou]/6.0;  noxx[1][jou]=noxx[1][jou]/6.0;
    }
             
    toav=0.0;              // toav=total potential energy (eV)

     double ppot;
             //------------------------- interaction among electrons 0-5, (and among 6-11)

   for (int yp=0; yp <=5; yp++) {             
    for (int kj=0; kj <=5; kj++) { 
    if (yp < kj ) {                    // kro =distance between electrons 0-5
    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;}
                                    // kro2 =distance between electrons 6-11
    kro2=Math.sqrt((hpr[yp+6][0]-hpr[kj+6][0])*(hpr[yp+6][0]-hpr[kj+6][0])+
   (hpr[yp+6][1]-hpr[kj+6][1])*(hpr[yp+6][1]-hpr[kj+6][1])+
   (hpr[yp+6][2]-hpr[kj+6][2])*(hpr[yp+6][2]-hpr[kj+6][2]));
    if (kro2==0) {kro2=5000.0;}
     ppot=(elc*elc*6.241509e18)/(4*pai*epsi*kro*1.0e-14);   // potential energy (eV)
     potb=(elc*elc*6.241509e18)/(4*pai*epsi*kro2*1.0e-14); 
    toav=toav+ppot+potb;   

                                      // rhp[el][3] = each electron's V (eV)
                             // teqq[el][3] = each electron's V (eV) only in oxygen atom
   rhp[yp][3]=rhp[yp][3]+ppot/2.0; rhp[kj][3]=rhp[kj][3]+ppot/2.0;
   teqq[yp][3]=teqq[yp][3]+ppot/2.0;  teqq[kj][3]=teqq[kj][3]+ppot/2.0;
   rhp[yp+6][3]=rhp[yp+6][3]+potb/2.0; rhp[kj+6][3]=rhp[kj+6][3]+potb/2.0;
   teqq[yp+6][3]=teqq[yp+6][3]+potb/2.0;  teqq[kj+6][3]=teqq[kj+6][3]+potb/2.0;
    for (int jou=0; jou <=2; jou++) {
                               // ggx=force components between electrons
                                // rhp[el][0-2]=force components acting on each electron
                       // teqq[el][0-2]=force components acting on electron only in oxygen atom
   ggx=(suh*(hpr[yp][jou]-hpr[kj][jou]))/(kro*kro*kro);
   rhp[yp][jou]=rhp[yp][jou]+ggx; rhp[kj][jou]=rhp[kj][jou]-ggx;   
   teqq[yp][jou]=teqq[yp][jou]+ggx; teqq[kj][jou]=teqq[kj][jou]-ggx;
   ggy=(suh*(hpr[yp+6][jou]-hpr[kj+6][jou]))/(kro2*kro2*kro2);
   rhp[yp+6][jou]=rhp[yp+6][jou]+ggy; rhp[kj+6][jou]=rhp[kj+6][jou]-ggy;   
   teqq[yp+6][jou]=teqq[yp+6][jou]+ggy; teqq[kj+6][jou]=teqq[kj+6][jou]-ggy;
    } 
   }}}  

         //---------------------------------- interaction between ele (0-5) x ele (6-11)

    for (int yp=0; yp <=5; yp++) {    
    for (int kj=6; kj <=11; 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;}
    pot=(elc*elc*6.241509e18)/(4*pai*epsi*kro*1.0e-14);   // potential energy (eV)
    rhp[yp][3]=rhp[yp][3]+pot/2.0; rhp[kj][3]=rhp[kj][3]+pot/2.0;
    toav=toav+pot;
      for (int jou=0; jou <=2; jou++) {
   ggx=(suh*(hpr[yp][jou]-hpr[kj][jou]))/(kro*kro*kro);
   rhp[yp][jou]=rhp[yp][jou]+ggx; rhp[kj][jou]=rhp[kj][jou]-ggx;
                     // rpp[0-11][0-2] = the total force from other nuclei's electrons and 2 nuclei
   rpp[yp][jou]=rpp[yp][jou]+ggx;  rpp[kj][jou]=rpp[kj][jou]-ggx;  
    }
     }}    

      //------------------------ interaction between noxx and ele0-5 (and ele 6-11) 

    for (int rv=0; rv <=5; rv++) {     
                             // kro=distance between electrons 0-5 and noxx[0][] 
    kro=Math.sqrt((hpr[rv][0]-noxx[0][0])*(hpr[rv][0]-noxx[0][0])+
   (hpr[rv][1]-noxx[0][1])*(hpr[rv][1]-noxx[0][1])+
   (hpr[rv][2]-noxx[0][2])*(hpr[rv][2]-noxx[0][2]));
    if (kro == 0) {kro=5000.0;} 
                            // kro2=distance between electrons 6-11 and noxx[1][]
    kro2=Math.sqrt((hpr[rv+6][0]-noxx[1][0])*(hpr[rv+6][0]-noxx[1][0])+
   (hpr[rv+6][1]-noxx[1][1])*(hpr[rv+6][1]-noxx[1][1])+
   (hpr[rv+6][2]-noxx[1][2])*(hpr[rv+6][2]-noxx[1][2]));
    if (kro2 == 0) {kro2=5000.0;}   
       ppot=(elc*elc*den*6.241509e18)/(4*pai*epsi*kro*1.0e-14);
      teqq[rv][3]=teqq[rv][3]-ppot;     // teqq[0-5][3]=potential energy only in oxygen 0 atom
        potb=(elc*elc*den*6.241509e18)/(4*pai*epsi*kro2*1.0e-14);
      teqq[rv+6][3]=teqq[rv+6][3]-potb;  // teqq[6-11][3]=potential energy only in oxygen 1 atom 
    for (int jou=0; jou <=2; jou++) {
     ggx=(suh*den*(hpr[rv][jou]-noxx[0][jou]))/(kro*kro*kro);
     ggy=(suh*den*(hpr[rv+6][jou]-noxx[1][jou]))/(kro2*kro2*kro2);
     teqq[rv][jou]=teqq[rv][jou]-ggx; teqq[rv+6][jou]=teqq[rv+6][jou]-ggy;
     }}

                                    // interaction between electrons and nuclei
   for (int rv=0; rv <=11; rv++) {    
                                              // ---------------- O 0,1nucleus

   for (int yp=0; yp <=1; yp++) {
   kro=Math.sqrt((hpr[rv][0]-nux[yp][0])*(hpr[rv][0]-nux[yp][0])+
   (hpr[rv][1]-nux[yp][1])*(hpr[rv][1]-nux[yp][1])+
   (hpr[rv][2]-nux[yp][2])*(hpr[rv][2]-nux[yp][2])); kro2=1000.0;
    if (kro == 0) {kro=5000.0;}

    pot =-den/kro;         
   ttav= (elc*elc*6.241509e18*pot)/(4*pai*epsi*1.0e-14);     // ttav=potential energy (eV)
   rhp[rv][3]=rhp[rv][3]+ttav;  toav=toav+ttav;   gx=0;
      
        
   if (rv < 6 && yp==0) {ex=(int)(kro); gx=1; 
                          // show distance between electrons 0-2,4 and O-0 nucleus
   if (rv < 3) {elp[rv][3].setText("nuc "+Integer.toString(ex)); }
   if (rv ==4) {elp[3][3].setText("nuc "+Integer.toString(ex)); }
    }

   if (rv > 5 && yp==1) { ex=(int)(kro);  gx=2;
                          // show distance between electrons 6,8,9-11 and O-1 nucleus
     if (rv==6)  {elp[4][3].setText("nuc "+Integer.toString(ex));}
     if (rv > 7)  {elp[rv-3][3].setText("nuc "+Integer.toString(ex));} 
    }   

                        // rhp[rv][5]=interaction between each electron and another nucleus
   if (gx==0) {rhp[rv][5]=rhp[rv][5]+ttav;}

   for (int kj=0; kj <=2; kj++) {  
                    // ggx (ggy) = force component between O nucleus and each electron                                      
   ggx=(suh*den*(hpr[rv][kj]-nux[yp][kj]))/(kro*kro*kro); 
                   // mmp[0-1][0-2]=force component acting on O-0,1nuclei
                 // rpp[0-11][0-2] = the total force from another nuclear electrons and 2 nuclei
    mmp[yp][kj]=mmp[yp][kj]+ggx;  rhp[rv][kj]=rhp[rv][kj]-ggx; rpp[rv][kj]=rpp[rv][kj]-ggx;
   }
   }                              
   }       
                   
    potc=0.0; double potf=0.0;       // interaction between 2 oxygen nuclei
    
     kro=Math.sqrt((nux[0][0]-nux[1][0])*(nux[0][0]-nux[1][0])+
  (nux[0][1]-nux[1][1])*(nux[0][1]-nux[1][1])+
   (nux[0][2]-nux[1][2])*(nux[0][2]-nux[1][2]));

    ttav=(elc*elc*6.241509e18*den*den)/(4*pai*epsi*kro*1.0e-14);
    toav=toav+ttav; potc=ttav;       // potc = repulsive potential energy between 2 nuclei   
      for (int jou=0; jou <=2; jou++) {
                                  // ggx=force between 2 nuclei
     ggx=(suh*den*den*(nux[0][jou]-nux[1][jou]))/(kro*kro*kro);
     mmp[0][jou]=mmp[0][jou]+ggx; 
     mmp[1][jou]=mmp[1][jou]-ggx;
    }

                                        
   ex=(int)(100*toav); ggx=ex/100.0;
   impho.setText("tV "+Double.toString(ggx));     // show total V to two decimal places
 
                      // distribute repulsive V among nuclei to each electron based on rhp[][5]
     double hiwa=0.0;
  for (int rv=0; rv <=11; rv++) { hiwa=hiwa+rhp[rv][5]; }
  for (int rv=0; rv <=11; rv++) {
  rhp[rv][3]=rhp[rv][3]+(potc*rhp[rv][5])/hiwa;
  
   ex=(int)(100*rhp[rv][3]); ggx=ex/100.0;
   if (rv < 3) {elp[rv][4].setText("V "+Double.toString(ggx));}
   if (rv==4) {elp[3][4].setText("V "+Double.toString(ggx));}
    if (rv==6) {elp[4][4].setText("V "+Double.toString(ggx));}
    if (rv > 7) {elp[rv-3][4].setText("V "+Double.toString(ggx));}
   }

   gx=0.0;                       // gx=sum of each potential energy
   for (int rv=0; rv <=11; rv++) { gx=gx+rhp[rv][3]; }    
                               
   gy=-toav*0.5;             // gy=total kinetic energy (eV)       
                            // distribute kinetic energy to each electron based on rhp[][3]
   for (int rv=0; rv <=11; rv++) {       
    gz=(gy*rhp[rv][3])/gx; rhp[rv][4]=gz;    
   ex=(int)(100*gz); gz=ex/100.0; 
    if (rv < 3) {elp[rv][5].setText("T "+Double.toString(gz));}
     if (rv==4) {elp[3][5].setText("T "+Double.toString(gz));}
     if (rv==6) {elp[4][5].setText("T "+Double.toString(gz));}
    if (rv > 7) {elp[rv-3][5].setText("T "+Double.toString(gz));} 
    }               
   
    int rvv=0;
    for (int el=0; el <=1; el++) {
    for (int rv=0; rv <=5; rv++) {        // show force component acting on elctrons 0-11 
    rvv=rv+el*6;
    gx=Math.sqrt(rpp[rvv][0]*rpp[rvv][0]+rpp[rvv][1]*rpp[rvv][1]+rpp[rvv][2]*rpp[rvv][2]);
    gy=(rhp[rvv][0]*rpp[rvv][0]+rhp[rvv][1]*rpp[rvv][1]+rhp[rvv][2]*rpp[rvv][2])/gx;

    ex=(int)(1000*gy); ww="CF ";             // CF = force in the direction of rpp
    if (rvv < 3) {elp[rvv][6].setText(ww+Integer.toString(ex));}
    if (rvv==4) {elp[3][6].setText(ww+Integer.toString(ex));}
    if (rvv==6) {elp[4][6].setText(ww+Integer.toString(ex));}
    if (rvv > 7) {elp[rvv-3][6].setText(ww+Integer.toString(ex));}
    for (int jou=0; jou <=2; jou++) {                                 
    gz=rhp[rvv][jou]-(gy*rpp[rvv][jou])/gx;
    ex=(int)(1000*gz);       // show force component other than CF
    if (rvv < 3) {elp[rvv][jou+7].setText(Integer.toString(ex));}
    if (rvv==4) {elp[3][jou+7].setText(Integer.toString(ex));}
    if (rvv==6) {elp[4][jou+7].setText(Integer.toString(ex));}
    if (rvv > 7) {elp[rvv-3][jou+7].setText(Integer.toString(ex));}
     }
    }}
                                      

    for (int rv=0; rv <=1; rv++) {
    for (int jou=0; jou <=2; jou++) {       // show mmpho[0-1][0-2]= force acting on each electron
    ex=(int)(1000*mmp[rv][jou]); ww=" ";
   if (jou==0) {ww="FX=";}
   if (jou==1) {ww="FY=";}
   if (jou==2) {ww="FZ=";}
    mmpho[rv][jou].setText(ww+Integer.toString(ex));
    }}
                                                                             
                                 
   for (int rv=0; rv <=11; rv++) {         // show de Broglie wave of each electron
                                         
                            // gz=force only in each oxygen atom
   gz=Math.sqrt(teqq[rv][0]*teqq[rv][0]+teqq[rv][1]*teqq[rv][1]+teqq[rv][2]*teqq[rv][2]);
    
   gy=(gz*elc*elc)/(4*pai*epsi*suh*1.0e-28);    // gy=force (N)
   
                       // electrons 0-5 use potential V (and T) only in each oxygen atom
    gx=Math.sqrt((-teqq[rv][3]*1.602177e-19)/me);   // gx=velocity (m/s)

   ggx=(me*gx*gx)/gy;             // ggx= "temporary" radius (m)
   ggy=(2*pai*ggx*me*gx)/h;       // ggy (wn) = number of de Broglie's waves contained in one orbit 
   
  ex=(int)(ggy*1000);  ggy=ex/1000.0;   // show wn to three decimal places
  if (rv <3) {elp[rv][10].setText("wn "+Double.toString(ggy));}
  if (rv==4) {elp[3][10].setText("wn "+Double.toString(ggy));}
  if (rv==6) {elp[4][10].setText("wn "+Double.toString(ggy));}
  if (rv >7) {elp[rv-3][10].setText("wn "+Double.toString(ggy));}
   }

                          // --------------------- show picture
   int nmx[][]=new int[2][3]; int hpk[][]=new int[12][4]; 

  for (int yp=0; yp <=1; yp++) {
  for (int kj=0; kj <=2; kj++) {     // change MM to pixel in nuclei
  nmx[yp][kj]=(int)(nux[yp][kj]/71.428);
  }}
  for (int yp=0; yp <=11; yp++) {
  for (int kj=0; kj <=2; kj++) {     // change MM to pixel in electrons
  hpk[yp][kj]=(int)(hpr[yp][kj]/71.428);
   if (hpk[yp][kj] > 529 && kj==0) {hpk[yp][kj]=529;}    // upper and lower limit
   if (hpk[yp][kj] > 369 && kj > 0) {hpk[yp][kj]=369;} 
   if (hpk[yp][kj] < 1) {hpk[yp][kj]=1;}
  }}

  g.clearRect(9,299,1170,699);
  g.setColor(Color.cyan); g.drawLine(555,310,555,660); 

  g.setColor(Color.lightGray);         // show 2 oxygen nuclei
  for (int rv=0; rv <=1; rv++) {
  g.fillOval(nmx[rv][0]+10,670-nmx[rv][1],20,20);g.fillOval(550+nmx[rv][0],670-nmx[0][2],20,20);
   }


    for (int rv=0; rv <=11; rv++) {
  
  g.setColor(Color.white);     // set color based on each electron
  if (rv > 1 && rv < 4) {g.setColor(Color.red);}
  if (rv > 3 && rv < 6) {g.setColor(Color.green);}
   if (rv > 5 && rv < 8) {g.setColor(Color.pink);}
    if (rv > 7 && rv < 10) {g.setColor(Color.green);}
    if (rv > 9 && rv < 12) {g.setColor(Color.yellow);}
       
  g.fillOval(hpk[rv][0]+13,673-hpk[rv][1],14,14); 
  g.fillOval(hpk[rv][0]+553,673-hpk[rv][2],14,14);
  }
     
    g.setColor(Color.white);                // show each oxygen nuclear number
   ww="O-"+Integer.toString(0);
  g.drawString(ww,nmx[0][0]+11,685-nmx[0][1]);
   ww="O-"+Integer.toString(1);
  g.drawString(ww,nmx[1][0]+551,685-nmx[1][2] );
  
                                  
  for (int rw=0; rw <=11; rw++) {         // show each electron's number
  g.setColor(Color.blue);
  if (rw < 10) {
  g.drawString(Integer.toString(rw),hpk[rw][0]+17,685-hpk[rw][1]);
  g.drawString(Integer.toString(rw),hpk[rw][0]+557,685-hpk[rw][2] );}
  if (rw > 9) {
   g.drawString(Integer.toString(rw),hpk[rw][0]+14,685-hpk[rw][1]);
  g.drawString(Integer.toString(rw),hpk[rw][0]+554,685-hpk[rw][2] );}
    
  }
   }
   }