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 water, so save this text editor as "water.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 the detailed methods, see this page.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Scanner;
public class water extends JPanel // virial theorem of H2O(water)
{
public static void main(String arg[])
{
JFrame frame = new JFrame("H2O (water)");
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; // pi=3.14
double epsi=8.85418781787346e-12; // permittivity
double h=6.62606896e-34; // Planck constant
double elc=1.60217653e-19; // electron charge
double me=9.1093826e-31; // electron mass
double suh=5292.0*5292.0*1000.0; // Bohr radius^2 x 1000
int labe=0; // distinguish label
JTextField elp[][]=new JTextField[8][11]; // text of electron 0-7
JTextField elpp[][]=new JTextField[8][11]; // text after electron
JTextField mmpho[][]=new JTextField[6][4]; // text nucleus H0 H2
JTextField impho=new JTextField(7); // text total V (eV)
JTextField imphoo=new JTextField(7); // text after total V
JTextField averwa0=new JTextField(7); // text average de Broglie wave 0
JTextField averwa6=new JTextField(7); // text average de Broglie wave 6
JButton b1=new JButton("O-H (MM)");
JButton b2=new JButton("angle");
String ope[]={"8000","8500","9000","9584","10000","11000","12000"};
JComboBox coom=new JComboBox(ope);
String ope2[]={"70.0","80.0","90.0","104.45","110.0","120.0","130.0"};
JComboBox coom2=new JComboBox(ope2);
double rtw=Math.sqrt(2); double rth=Math.sqrt(3);
double rsi=Math.sqrt(6); double rfi=Math.sqrt(5);
double hpr[][]=new double[8][11]; // each electron's parameter
double hprr[][]=new double[8][11]; // after electron parameter
double den=6.273; // den=central charge
double lengt=9584.0; double angl=104.45; // lengt=O-H distance
// angl=H-O-H angle
double lengt2=lengt*Math.sin(angl*0.5*pai/180.0);
double lengt3=lengt*Math.cos(angl*0.5*pai/180.0);
//nux[n][0-2]=nucleus coordinate,
// O nuc (n=0), H0 and H1 nuclei ( n=1,2 )
double nux[][]={{0.0, 0.0, 0.0, den},
{lengt3, -lengt2, 0.0, 1.0},
{lengt3, lengt2, 0.0, 1.0}};
// te1,teez = each electron initial coordinate wrt. each close nucleus
double te1[][]={{3250,-3250, 0.0}, {3250, 3250, 0.0},
{-3250, 3250, 0}, {-3250, -3250, 0},
{0, 0, -4596}, {0,0, 4596},
{0.0, 0.0 , -4600.0}, {0.0, 0.0, 4600.0}};
double teez[][]={{3250,-3250, 0.0}, {3250, 3250, 0.0},
{-3250, 3250, 0}, {-3250, -3250, 0},
{0, 0, -4596}, {0,0, 4596},
{0.0, 0.0 , -4600.0}, {0.0, 0.0, 4600.0}};
public J2DPanel()
{
setBackground(Color.black);
JPanel p=new JPanel();
p.setLayout(new GridLayout(20,12));
int aaa=0;
for (int el=0; el <=7; el++) { // hpr[][0-2]=each electron's coordinate
for (int pos=0; pos <=2; pos++) {
elp[el][pos]=new JTextField(7); elpp[el][pos]=new JTextField(7);
if ( el == 0 || el == 2 || el == 4 || el == 6 ) {elp[el][pos].addActionListener(this);}
hpr[el][pos]=0.0; hprr[el][pos]=0.0;
}}
for (int el=0; el <=7; el++) { // elp[0-7][3-10]= other parameters
for (int pos=3; pos <=10; pos++) {
elp[el][pos]=new JTextField(7); elpp[el][pos]=new JTextField(7);
hpr[el][pos]=0.0; hprr[el][pos]=0.0;
}}
for (int el=0; el <=5; el++) { // mmpho[0-2][]=nuclei parameters
// mmpho[3-5][]=nuclei parameters after
for (int pos=0; pos <=3; pos++) {
mmpho[el][pos]=new JTextField(7);
}}
String stri,sang;
// layout
String sihy[]={"eNo ", "+X(MM)", "+Y(MM)", "+Z(MM)", "nuc(MM)",
"V(eV)", "tForce", "cforce", "rforce ", "Waves", " -- ", " -- "};
for (int el=0; el <=11; el++) {
p.add(new Label(sihy[el]));
}
for (int el=0; el <=7; el++) {
stri=" ";
if ( el == 0 || el == 2 || el == 4 || el == 6 ) {stri=" text";}
p.add(new Label("ele "+el+stri));
sang=" e0-nuc-e1 =";
if ( el== 2 ) { sang=" e2-nuc-e3 ="; }
if ( el== 4 ) { sang=" e4-nuc-e5 ="; }
if ( el==0 || el==2 || el==4 ) {
for (int pos=0; pos <=8; pos++) {
p.add(elp[el][pos]);
}
p.add(new Label(sang)); p.add(elp[el][10]);
}
if ( el != 0 && el !=2 && el !=4 ){
for (int pos=0; pos <=10; pos++) {
p.add(elp[el][pos]);
}}
}
p.add(new Label("O nuc "));
for (int pos=0; pos <=2; pos++) {
p.add(mmpho[0][pos]);
}
p.add(new Label("H0nuc "));
for (int pos=0; pos <=1; pos++) {
p.add(mmpho[1][pos]);
}
p.add(new Label("H1nuc "));
for (int pos=0; pos <=1; pos++) {
p.add(mmpho[2][pos]);
}
p.add(new Label("total V ")); p.add(impho);
p.add(new Label("aO nuc "));
for (int pos=0; pos <=2; pos++) {
p.add(mmpho[3][pos]);
}
p.add(new Label("aH0nuc "));
for (int pos=0; pos <=1; pos++) {
p.add(mmpho[4][pos]);
}
p.add(new Label("aH1nuc "));
for (int pos=0; pos <=1; pos++) {
p.add(mmpho[5][pos]);
}
p.add(new Label("af tV ")); p.add(imphoo);
p.add(new Label("aele 0"));
for (int pos=0; pos <=8; pos++) {
p.add(elpp[0][pos]);
}
p.add(new Label("0-avewave ")); p.add(averwa0);
p.add(new Label("aele 1"));
for (int pos=0; pos <=8; pos++) {
p.add(elpp[1][pos]);
}
p.add(new Label("6-avewave ")); p.add(averwa6);
p.add(new Label("aele 2"));
for (int pos=0; pos <=10; pos++) {
p.add(elpp[2][pos]);
}
p.add(new Label("aele 3"));
for (int pos=0; pos <=10; pos++) {
p.add(elpp[3][pos]);
}
p.add(new Label("aele 4"));
for (int pos=0; pos <=10; pos++) {
p.add(elpp[4][pos]);
}
p.add(new Label("aele 5"));
for (int pos=0; pos <=10; pos++) {
p.add(elpp[5][pos]);
}
p.add(new Label("aele 6"));
for (int pos=0; pos <=10; pos++) {
p.add(elpp[6][pos]);
}
p.add(new Label("aele 7"));
for (int pos=0; pos <=10; pos++) {
p.add(elpp[7][pos]);
}
p.add(new Label(" -- ")); p.add(new Label(" -- "));
p.add(new Label(" -- ")); p.add(new Label(" -- "));
p.add(b1); p.add(coom); p.add(b2); p.add(coom2);
for (int pos=0; pos <=3; pos++) {
p.add(new Label(" -- "));
}
coom.setSelectedItem("9584"); b1.addActionListener(this);
coom2.setSelectedItem("104.45"); b2.addActionListener(this);
add(p,"South");
for (int el=0; el <=7; el++) {
double nnuc=Math.sqrt(teez[el][0]*teez[el][0]+teez[el][1]*teez[el][1]+teez[el][2]*teez[el][2]);
aaa=(int)(nnuc);
elp[el][3].setText(Integer.toString(aaa));
for (int jou=0; jou <=2; jou++) {
hpr[el][jou]=teez[el][jou];
// hpr[el][0-2] = electron absolute coordinate
if (el==6) {hpr[el][jou]=hpr[el][jou]+nux[1][jou];}
if (el==7) {hpr[el][jou]=hpr[el][jou]+nux[2][jou];}
elp[el][jou].setText(Integer.toString((int)(teez[el][jou])));
}}
} // public J2DPanel() end
public void actionPerformed(ActionEvent e) {
String ss;
labe = 0;
if (e.getSource() == b1) { labe = 4;
ss=(String)coom.getSelectedItem();
if (ss=="8000") {lengt=8000;} if (ss=="8500") {lengt=8500;}
if (ss=="9000") {lengt=9000;} if (ss=="9584") {lengt=9584;}
if (ss=="10000") {lengt=10000;} if (ss=="11000") {lengt=11000;}
if (ss=="12000") {lengt=12000;}
}
if (e.getSource() == b2) { labe = 3;
ss=(String)coom2.getSelectedItem();
if (ss=="70.0") {angl=70.0;} if (ss=="80.0") {angl=80.0;}
if (ss=="90.0") {angl=90.0;} if (ss=="104.45") {angl=104.45;}
if (ss=="110.0") {angl=110.0;} if (ss=="120.0") {angl=120.0;}
if (ss=="130.0") {angl=130.0;}
}
if ( labe==3 || labe == 4 ) { // nuclei position change
lengt2=lengt*Math.sin(angl*0.5*pai/180.0);
lengt3=lengt*Math.cos(angl*0.5*pai/180.0);
double nuux[][]={{0.0, 0.0, 0.0},
{lengt3, -lengt2, 0.0},
{lengt3, lengt2, 0.0}};
for (int ett=0; ett <=2; ett++) {
for (int sws=0; sws <=2; sws++) {
nux[ett][sws]=nuux[ett][sws];
}}
}
repaint();
}
public void update(Graphics g)
{
paint(g);
}
public void paintComponent(Graphics g)
{
double kro,krr,kwr,kww,krk,kro2,krr2,krk2,pot,pota,potb,potc,pot2,pota2,potb2;
double 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; kww=0.0; kwr=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}};
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}};
double mmp[][]={{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}};
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}};
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}};
double hevec[][]=new double[3][4];
for (int jou=0; jou <=2; jou++) {
hevec[0][jou]=nux[1][jou]-nux[0][jou]; // hevec[0] = O nuc - H0 nuc vector
hevec[1][jou]=nux[2][jou]-nux[0][jou]; // hevec[1] = O nuc - H1 nuc vector
}
// hevec[2][0-2] = vector perpendicular to H-O-H plane
// outer product of hevec[0] x hevec[1]
hevec[2][0]=hevec[0][1]*hevec[1][2]-hevec[0][2]*hevec[1][1];
hevec[2][1]=hevec[0][2]*hevec[1][0]-hevec[0][0]*hevec[1][2];
hevec[2][2]=hevec[0][0]*hevec[1][1]-hevec[0][1]*hevec[1][0];
// hevec[][3]=length of each vector
hevec[2][3]=Math.sqrt(hevec[2][0]*hevec[2][0]+hevec[2][1]*hevec[2][1]+hevec[2][2]*hevec[2][2]);
hevec[0][3]=Math.sqrt(hevec[0][0]*hevec[0][0]+hevec[0][1]*hevec[0][1]+hevec[0][2]*hevec[0][2]);
hevec[1][3]=Math.sqrt(hevec[1][0]*hevec[1][0]+hevec[1][1]*hevec[1][1]+hevec[1][2]*hevec[1][2]);
// get each electron coordinate from textboxes
ww=elp[6][0].getText(); hpr[6][0]=Double.parseDouble(ww)+nux[1][0];
hpr[7][0]=Double.parseDouble(ww);
elp[7][0].setText(Integer.toString((int)hpr[7][0]));
hpr[7][0]=hpr[7][0]+nux[2][0];
ww=elp[6][1].getText(); hpr[6][1]=Double.parseDouble(ww)+nux[1][1];
hpr[7][1]=Double.parseDouble(ww);
hpr[7][1] = - hpr[7][1];
elp[7][1].setText(Integer.toString((int)hpr[7][1]));
hpr[7][1]=hpr[7][1]+nux[2][1];
ww=elp[6][2].getText(); hpr[6][2]=Double.parseDouble(ww)+nux[1][2];
hpr[7][2]=Double.parseDouble(ww);
hpr[7][2]=-hpr[7][2];
elp[7][2].setText(Integer.toString((int)hpr[7][2]));
hpr[7][2]=hpr[7][2]+nux[2][2];
for (int yp=0; yp <=2; yp++) {
for (int jou=0; jou <=2; jou++) {
ww=elp[yp*2][jou].getText();
hpr[yp*2][jou]=Double.parseDouble(ww);
hpr[yp*2+1][jou] = -hpr[yp*2][jou];
if (jou == 0) { hpr[yp*2+1][jou] = hpr[yp*2][jou]; }
elp[yp*2+1][jou].setText(Integer.toString((int)hpr[yp*2+1][jou]));
}}
// show angle
double aa=Math.sqrt(hpr[0][0]*hpr[0][0]+hpr[0][1]*hpr[0][1]+hpr[0][2]*hpr[0][2]);
double bb =Math.sqrt((hpr[1][0]-hpr[0][0])*(hpr[1][0]-hpr[0][0])+(hpr[1][1]-hpr[0][1])*(hpr[1][1]-hpr[0][1])+(hpr[1][2]-hpr[0][2])*(hpr[1][2]-hpr[0][2]));
double ccos=(2.0*aa*aa - bb*bb)/(2.0*aa*aa);
double angg=(Math.acos(ccos)*180.0)/pai;
elp[0][10].setText(Integer.toString((int)angg) + " deg" );
aa=Math.sqrt(hpr[2][0]*hpr[2][0]+hpr[2][1]*hpr[2][1]+hpr[2][2]*hpr[2][2]);
bb =Math.sqrt((hpr[2][0]-hpr[3][0])*(hpr[2][0]-hpr[3][0])+(hpr[2][1]-hpr[3][1])*(hpr[2][1]-hpr[3][1])+(hpr[2][2]-hpr[3][2])*(hpr[2][2]-hpr[3][2]));
ccos=(2.0*aa*aa - bb*bb)/(2.0*aa*aa);
angg=(Math.acos(ccos)*180.0)/pai;
elp[2][10].setText(Integer.toString((int)angg) + " deg");
aa=Math.sqrt(hpr[4][0]*hpr[4][0]+hpr[4][1]*hpr[4][1]+hpr[4][2]*hpr[4][2]);
bb =Math.sqrt((hpr[4][0]-hpr[5][0])*(hpr[4][0]-hpr[5][0])+(hpr[4][1]-hpr[5][1])*(hpr[4][1]-hpr[5][1])+(hpr[4][2]-hpr[5][2])*(hpr[4][2]-hpr[5][2]));
ccos=(2.0*aa*aa - bb*bb)/(2.0*aa*aa);
angg=(Math.acos(ccos)*180.0)/pai;
elp[4][10].setText(Integer.toString((int)angg) + " deg");
double noxx[]={0,0,0}; // noxx[0-2]=center of six electrons 0-5
for (int yp=0; yp <=5; yp++) {
for (int jou=0; jou <=2; jou++) {
noxx[jou]=noxx[jou]+hpr[yp][jou];
}}
for (int jou=0; jou <=2; jou++) {
noxx[jou]=noxx[jou]/6.0;
}
toav=0.0; // toav = total potential energy
// interactions among electrons 0-7
double ppot=0.0;
for (int yp=0; yp <=7; yp++) {
for (int kj=0; kj <=7; 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);
toav=toav+ppot;
rhp[yp][3]=rhp[yp][3]+ppot/2.0; rhp[kj][3]=rhp[kj][3]+ppot/2.0;
if ( yp < 6 && kj < 6 ) { // V only in oxygen atom
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);
rhp[yp][jou]=rhp[yp][jou]+ggx; rhp[kj][jou]=rhp[kj][jou]-ggx;
if ( yp < 6 && kj < 6 ) { // force only in oxygen atom
teqq[yp][jou]=teqq[yp][jou]+ggx;
teqq[kj][jou]=teqq[kj][jou]-ggx;
}
}
}}}
// interaction between electrons and nuclei
for (int yp=0; yp <=7; yp++) {
for (int rv=0; rv <=2; 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;
if ( yp < 6 ) { // interaction between electron and other nuclei
if ( rv > 0 ) { rhp[yp][6] = rhp[yp][6] + ppot; }
}
if ( yp > 5 ) {
if ( rv != yp-5 ) { 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[yp][jou] = rhp[yp][jou] - ggx;
mmp[rv][jou] = mmp[rv][jou] + ggx; // mmp = force acting on each nuclei
}
}}
// between noxx (= center of ele0-5 ) and electron 0-5
for (int rv=0; rv <=5; rv++) {
kro=Math.sqrt((hpr[rv][0]-noxx[0])*(hpr[rv][0]-noxx[0])+
(hpr[rv][1]-noxx[1])*(hpr[rv][1]-noxx[1])+
(hpr[rv][2]-noxx[2])*(hpr[rv][2]-noxx[2]));
if (kro == 0) {kro=5000.0;}
ppot=(elc*elc*den*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
teqq[rv][3]=teqq[rv][3]-ppot;
for (int jou=0; jou <=2; jou++) {
ggx=(suh*den*(hpr[rv][jou]-noxx[jou]))/(kro*kro*kro);
teqq[rv][jou]=teqq[rv][jou]-ggx;
}}
// among nuclei
pota = 0.0; // pota = potential V only among nuclei
for (int yp=0; yp <=2; yp++) {
for (int kj=0; kj <=2; 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 only among nuclei
mmp[yp][jou+3] = mmp[yp][jou+3] + ggx;
mmp[kj][jou+3] = mmp[kj][jou+3] - ggx;
}
}}}
// show total V to two decimal places
ex=(int)(100.0*toav); ggx=ex/100.0;
impho.setText("tV "+Double.toString(ggx));
gz = 0.0; // distribute nuclear V to electron based on rhp[][6]
for (int yp=0; yp <=7; yp++) {
gz = gz + rhp[yp][6];
}
for (int yp=0; yp <=7; yp++) {
rhp[yp][3] = rhp[yp][3] + (pota * rhp[yp][6])/gz;
}
for (int yp=0; yp <=5; yp++) {
ex=(int)(rhp[yp][3]*100.0); ggx=ex/100.0;
elp[yp][4].setText("V "+Double.toString(ggx)); //show electron 0-5 's V
kro = Math.sqrt(hpr[yp][0]*hpr[yp][0]+hpr[yp][1]*hpr[yp][1]+hpr[yp][2]*hpr[yp][2]);
if (kro == 0) {kro=5000.0;}
ex=(int)(kro);
// show electron 0-5 and O nuc distance
elp[yp][3].setText("nuc "+Integer.toString(ex));
// rho[][4]=force toward center
rhp[yp][4] = -(hpr[yp][0]*rhp[yp][0] +hpr[yp][1]*rhp[yp][1] + hpr[yp][2]*rhp[yp][2])/kro;
rhp[yp][5] = 0.0;
ex=(int)(rhp[yp][4]);
elp[yp][5].setText("tF "+Integer.toString(ex));
elp[yp][6].setText("cf "+Integer.toString(ex));
elp[yp][7].setText(Integer.toString(0));
}
// vvh[0-1][0-2] = vector from ele 6,7 toward (perpendicular to ) O-H line
double vvh[][]=new double[2][6];
for (int yp=6; yp <=7; yp++) {
kro=(hpr[yp][0]*nux[yp-5][0]+hpr[yp][1]*nux[yp-5][1]+hpr[yp][2]*nux[yp-5][2])/lengt;
for (int kj=0; kj <=2; kj++) {
vvh[yp-6][kj] = (nux[yp-5][kj]*kro)/lengt;
vvh[yp-6][kj] = vvh[yp-6][kj] - hpr[yp][kj];
}
}
// show electron 6-7 data
for (int yp=6; yp <=7; yp++) {
ex=(int)(rhp[yp][3]*100.0); ggx=ex/100.0;
elp[yp][4].setText("V "+Double.toString(ggx)); //show electron 6-7 's V
kro=Math.sqrt((hpr[yp][0]-nux[yp-5][0])*(hpr[yp][0]-nux[yp-5][0])+
(hpr[yp][1]-nux[yp-5][1])*(hpr[yp][1]-nux[yp-5][1])+
(hpr[yp][2]-nux[yp-5][2])*(hpr[yp][2]-nux[yp-5][2]));
if (kro == 0) {kro=5000.0;}
ex=(int)(kro);
elp[yp][3].setText("nuc "+Integer.toString(ex)); // show electron 4-7's nuc
// rhp[ele 6,7][4] = force acting on ele 6,7 toward center
rhp[yp][4] = -(nux[yp-5][0]*rhp[yp][0] +nux[yp-5][1]*rhp[yp][1] + nux[yp-5][2]*rhp[yp][2])/lengt;
krr = Math.sqrt( vvh[yp-6][0]*vvh[yp-6][0]+vvh[yp-6][1]*vvh[yp-6][1]+ vvh[yp-6][2]*vvh[yp-6][2] );
// rhp[yp][5] = force acting on ele 6,7 toward O-H line
rhp[yp][5] = (vvh[yp-6][0]*rhp[yp][0] +vvh[yp-6][1]*rhp[yp][1] + vvh[yp-6][2]*rhp[yp][2])/krr;
gx=Math.sqrt(rhp[yp][0]*rhp[yp][0]+rhp[yp][1]*rhp[yp][1]+rhp[yp][2]*rhp[yp][2]);
ex=(int)(gx);
elp[yp][5].setText("tF "+Integer.toString(ex)); // total force on ele4-7
ex=(int)(rhp[yp][4]);
if (yp == 7){
elp[yp][6].setText("cf "+Integer.toString(ex));
}
if (yp == 6){
elp[yp][6].setText("cf "+Integer.toString(ex)+" *");
}
ex=(int)(rhp[yp][5]);
elp[yp][7].setText("rf "+Integer.toString(ex));
}
// vvh[0,1][3-5] = vector toward center based on force compoment ratio
for (int yp=6; yp <=7; yp++) {
krr = Math.sqrt( vvh[yp-6][0]*vvh[yp-6][0]+vvh[yp-6][1]*vvh[yp-6][1]+ vvh[yp-6][2]*vvh[yp-6][2] );
gx = rhp[yp][4] * krr / rhp[yp][5];
for (int kj=0; kj <=2; kj++) {
vvh[yp-6][kj+3] = -(nux[yp-5][kj] * gx)/lengt;
}
}
// show electron 6-7 de Broglie waves
for (int yp=6; yp <=7; 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 in one orbit
hpr[yp][3]=ggy; // hpr[][3] = waves
ex=(int)(ggy*1000); ggy=ex/1000.0;
elp[yp][8].setText("wn "+Double.toString(ggy));
}
// ele 0-5 de Broglie wave
for (int yp=0; yp <=5; 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][8].setText("wn "+Double.toString(ggy));
}
// show force compoment acting on O-nuc
for (int kj=0; kj <=2; kj++) {
ex=(int)(mmp[0][kj]);
if (kj==0) { ww = " FX ";}
if (kj==1) { ww = " FY ";}
if (kj==2) { ww = " FZ ";}
mmpho[0][kj].setText(ww+Integer.toString(ex));
}
// show force acting on H0 H1 nuclei toward O and another H nucleus
for (int rv=1; rv <=2; rv++) {
gx = -(nux[rv][0]*mmp[rv][0] +nux[rv][1]*mmp[rv][1] + nux[rv][2]*mmp[rv][2])/lengt;
ex=(int)(gx);
mmpho[rv][0].setText("On "+Integer.toString(ex));
if (rv==1) {
ex=(int)(mmp[rv][1]);
mmpho[rv][1].setText("Hn "+Integer.toString(ex));
}
if (rv==2) {
ex=(int)(-mmp[rv][1]);
mmpho[rv][1].setText("Hn "+Integer.toString(ex));
}
}
// hprr[el][0-2]= another coordinate of each electron
for (int yp=0; yp <=5; yp++) {
for (int jou=0; jou <=2; jou++) {
hprr[yp][jou] = hpr[yp][jou];
gx = hprr[yp][jou] ;
elpp[yp][jou].setText(Integer.toString((int)gx));
} }
// hpr[6,7][0-2] = ele 6,7 another coordinate "after" moving by force
for (int yp=6; yp <=7; yp++) {
for (int kj=0; kj <=2; kj++) {
hprr[yp][kj] = hpr[yp][kj] + vvh[yp-6][kj+3] * 2.0 ;
gx = hprr[yp][kj] - nux[yp-5][kj];
elpp[yp][kj].setText(Integer.toString((int)gx));
}}
toav=0.0; // toav= "after" total potential energy
for (int yp=0; yp <=7; yp++) { // interaction between after ele 0-7
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*pai*epsi*kro*1.0e-14);
if ( yp < 6 && kj < 6 ) { // V only in oxygen atom
teqqq[yp][3]=teqqq[yp][3]+ppot/2.0;
teqqq[kj][3]=teqqq[kj][3]+ppot/2.0;
}
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;
if ( yp < 6 && kj < 6 ) { // force only in oxygen atom
teqqq[yp][jou]=teqqq[yp][jou]+ggx;
teqqq[kj][jou]=teqqq[kj][jou]-ggx;
}
}
}}}
// between each nuclei and electron
for (int yp=0; yp <=7; yp++) {
for (int rv=0; rv <=2; 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;
if ( yp < 6 ) { // rpp[][6]= V among electron and other nuclei
if ( rv > 0 ) {
rpp[yp][6] = rpp[yp][6] + ppot;
}}
if ( yp > 5 ) {
zk = yp -5;
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;
}
}}
toav = toav + pota;
for (int rv=0; rv <=2; rv++) {
for (int jou=0; jou <=2; jou++) {
mpp[rv][jou]=mpp[rv][jou]+mmp[rv][jou+3];
}}
for (int rv=0; rv <=5; rv++) { // between noxx and ele0-5
kro=Math.sqrt((hprr[rv][0]-noxx[0])*(hprr[rv][0]-noxx[0])+
(hprr[rv][1]-noxx[1])*(hprr[rv][1]-noxx[1])+
(hprr[rv][2]-noxx[2])*(hprr[rv][2]-noxx[2]));
if (kro == 0) {kro=5000.0;}
ppot=(elc*elc*den*6.241509e18)/(4*pai*epsi*kro*1.0e-14);
teqqq[rv][3]=teqqq[rv][3]-ppot;
for (int jou=0; jou <=2; jou++) {
ggx=(suh*den*(hprr[rv][jou]-noxx[jou]))/(kro*kro*kro);
teqqq[rv][jou]=teqqq[rv][jou]-ggx;
}}
gz = 0.0; // distribute nucler V to ele
for (int yp=0; yp <=7; yp++) {
gz = gz + rpp[yp][6];
}
for (int yp=0; yp <=7; yp++) {
rpp[yp][3] = rpp[yp][3] + (pota * rpp[yp][6])/gz;
}
// show each data "after" electrons
ex=(int)(100.0*toav); ggx=ex/100.0;
imphoo.setText("atV "+Double.toString(ggx));
for (int yp=0; yp <=5; yp++) {
ex=(int)(rpp[yp][3]*100.0); ggx=ex/100.0;
elpp[yp][4].setText("V "+Double.toString(ggx)); //show electron 0-5 's V
kro = Math.sqrt(hprr[yp][0]*hprr[yp][0]+hprr[yp][1]*hprr[yp][1]+hprr[yp][2]*hprr[yp][2]);
if (kro == 0) {kro=5000.0;}
ex=(int)(kro);
elpp[yp][3].setText("nuc "+Integer.toString(ex));
rpp[yp][4] = -(hprr[yp][0]*rpp[yp][0] +hprr[yp][1]*rpp[yp][1] + hprr[yp][2]*rpp[yp][2])/kro;
rpp[yp][5] = 0.0; // rhp[0-3][4,5] = 4 -- c force, 5-- r force
ex=(int)(rpp[yp][4]);
elpp[yp][5].setText("tF "+Integer.toString(ex));
elpp[yp][6].setText("cf "+Integer.toString(ex));
elpp[yp][7].setText("rf "+Integer.toString(0));
}
// show electron 6-7 data
for (int yp=6; yp <=7; yp++) {
ex=(int)(rpp[yp][3]*100.0); ggx=ex/100.0;
elpp[yp][4].setText("V "+Double.toString(ggx)); //show electron 4-7 's V
kro=Math.sqrt((hprr[yp][0]-nux[yp-5][0])*(hprr[yp][0]-nux[yp-5][0])+
(hprr[yp][1]-nux[yp-5][1])*(hprr[yp][1]-nux[yp-5][1])+
(hprr[yp][2]-nux[yp-5][2])*(hprr[yp][2]-nux[yp-5][2]));
if (kro == 0) {kro=5000.0;}
ex=(int)(kro);
elpp[yp][3].setText("nuc "+Integer.toString(ex));
rpp[yp][4] = -(nux[yp-5][0]*rpp[yp][0] +nux[yp-5][1]*rpp[yp][1] + nux[yp-5][2]*rpp[yp][2])/lengt;
krr = Math.sqrt( vvh[yp-6][0]*vvh[yp-6][0]+vvh[yp-6][1]*vvh[yp-6][1]+ vvh[yp-6][2]*vvh[yp-6][2] );
rpp[yp][5] = (vvh[yp-6][0]*rpp[yp][0] +vvh[yp-6][1]*rpp[yp][1] + vvh[yp-6][2]*rpp[yp][2])/krr;
gx=Math.sqrt(rpp[yp][0]*rpp[yp][0]+rpp[yp][1]*rpp[yp][1]+rpp[yp][2]*rpp[yp][2]);
ex=(int)(gx);
elpp[yp][5].setText("tF "+Integer.toString(ex)); // total force
ex=(int)(rpp[yp][4]);
if (yp == 7){
elpp[yp][6].setText("cf "+Integer.toString(ex));
}
if (yp == 6){
elpp[yp][6].setText("cf "+Integer.toString(ex)+" *"); } // cf force
ex=(int)(rpp[yp][5]);
elpp[yp][7].setText("rf "+Integer.toString(ex)); // r-force ele 4-7
}
// show electron 6-7 de Broglie waves
for (int yp=6; yp <=7; 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; // ggx="temporary" radius
ggy=(2.0*pai*ggx*me*gx)/h; // ggy=de Broglie's waves
hprr[yp][3]=ggy; // hprr[][3] = waves
ex=(int)(ggy*1000); ggy=ex/1000.0;
elpp[yp][8].setText("wn "+Double.toString(ggy));
}
// ele 0-5 de Broglie wave
for (int yp=0; yp <=5; yp++) {
gz = Math.sqrt(teqqq[yp][0]*teqqq[yp][0]+teqqq[yp][1]*teqqq[yp][1]+teqqq[yp][2]*teqqq[yp][2]);
gy=(gz*elc*elc)/(4.0*pai*epsi*suh*1.0e-28); // gy=force (N)
gx=Math.sqrt((-1.0*teqqq[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;
ex=(int)(ggy*1000); ggy=ex/1000.0;
elpp[yp][8].setText("wn "+Double.toString(ggy));
}
for (int kj=0; kj <=2; kj++) {
ex=(int)(mpp[0][kj]);
if (kj==0) { ww = "aFX ";}
if (kj==1) { ww = "aFY ";}
if (kj==2) { ww = "aFZ ";}
mmpho[3][kj].setText(ww+Integer.toString(ex));
}
// show force acting on "after" H0 H1 nuclei
for (int rv=1; rv <=2; rv++) {
gx = -(nux[rv][0]*mpp[rv][0] +nux[rv][1]*mpp[rv][1] + nux[rv][2]*mpp[rv][2])/lengt;
ex=(int)(gx);
mmpho[rv+3][0].setText("aOn "+Integer.toString(ex));
if (rv==1) {
ex=(int)(mpp[rv][1]);
mmpho[rv+3][1].setText("aHn "+Integer.toString(ex));
}
if (rv==2) {
ex=(int)(-mpp[rv][1]);
mmpho[rv+3][1].setText("aHn "+Integer.toString(ex));
}
}
gx = (hpr[0][3]+hprr[0][3])/2.0;
gy= (hpr[2][3]+hprr[2][3])/2.0;
gz= (hpr[4][3]+hprr[4][3])/2.0;
gx = (gx+gy+gz)/3.0;
ex=(int)(gx*1000); gx=ex/1000.0;
averwa0.setText("wn "+Double.toString(gx));
gx = (hpr[6][3]+hprr[6][3])/2.0;
ex=(int)(gx*1000); gx=ex/1000.0;
averwa6.setText("wn "+Double.toString(gx));
}
}