Back to two atomic molecular page.
Top page ( correct Bohr model including the two electron atom )
This program is a little long. So if you copy and paste the below program source code into a text editor,
you can easily compile and run this.
This program's class file name is twoato, so save this text editor as "twoato.java", and compile it.
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.
In this program, A and B atomic nuclei (= gray color) are left and right.
Here we use the new units, ( 1 MM = 10-14 meter).
Each coordinate of electrons (+X (MM), +Y (MM), +Z (MM)) in the text box means "relative" positions from the nucleus they belong to.
(You can change this coordinates by entering the values into the text boxes, and press the Enter key.)
"nuc (MM)" means the distance between the nucleus and each electron.
"charge Z" is central positive charge of atom.
"internuc" is internuclear distance between two nuclei.
( You can change these "internuc", "nuc", "charge Z", by inputting arbitrary values into each textboxe and click each button. )
If you choose an atom, H, C, O, N, F, Si, S, P, Cl in the scrollbar and click A (or B ) atom button, each atom changes.
If you click "AB change" button, atom ( A or B ) textboxes displayed on the screen changes.
If you input some angle ( degree ) in designated textboxes, and click "x-y ang", "x-z ang", or "y-z ang" buttons, atom displayed on the textboxes rotates in x-y, x-z, or y-z plane counterclockwisely (= positive angle ).
V (eV) mean the potential energy of each electron.
CF means the force toward the nucleus acting on each electron.
(fx, fy, fz) mean the each component of the "remaining" force other than CF.
(FX, FY, FZ) mean each component of the force acting on the nuclei.
(The unit of force: 1000 = the force between +e nucleus and an -e electron which are Bohr radius apart from each other)
tV is the total potential energy (eV).
Waves (wn) means the number of de Broglie's waves contained in one orbit of each electron.
( In multi-electron atoms such as carbon, this waves is gotten only inside each atom. )
"direw" means de Broglie waves computed considering all forces including another atom.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Scanner;
public class twoato extends JPanel // various combination of two atoms
{
public static void main(String arg[])
{
JFrame frame = new JFrame("Two-atomic molecule"); // 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=5291.0*5291.0; // suh=(Bohr radius)^2
JTextField elp[][]=new JTextField[7][11];
JTextField impho=new JTextField(7); // total V text
JTextField mmpho[][]=new JTextField[2][3]; // nucleus text
// imppo = distance (= nuc ) between electron and nucleus text
JTextField imppo=new JTextField(7);
JTextField charge=new JTextField(7); // charge Z text
JTextField sou=new JTextField(7); // binding energy
JTextField avew=new JTextField(7); // average de Broglie wave
JTextField direc=new JTextField(7); // direct de Broglie wave
JTextField atom=new JTextField(7); // A or B on the screen
JTextField abdis=new JTextField(7); // internuclear distance
JTextField kait[]=new JTextField[3];
JTextField bangle[]=new JTextField[11]; // bond angle text
JButton b1=new JButton("x-y ang"); JButton b2=new JButton("x-z ang");
JButton b3=new JButton("y-z ang");
JButton b5=new JButton("AB change");
JButton b7=new JButton("A atom"); JButton b8=new JButton("B atom");
JButton b9=new JButton("internuc"); JButton bb1=new JButton("nuc");
JButton bb2=new JButton("charge Z");
String aato[]={"H","C","O","N","F","Si","S","P","Cl"};
String bato[]={"H","C","O","N","F","Si","S","P","Cl"};
JComboBox coom=new JComboBox(aato);
JComboBox coomm=new JComboBox(bato);
int marki[]=new int[3]; int mar=0; int abd=0; // marking
double saia=4.22; int saik=4; double diam=6415.0;
// kade[0, 1] = number of valence electrons in A and B
int kade[]={4,4};
double rtw=Math.sqrt(2); double rth=Math.sqrt(3);
double rsi=Math.sqrt(6); double rfi=Math.sqrt(5);
double apr[][]=new double[7][11]; // parameters of A atom
double bpr[][]=new double[7][11]; // parameters of B atom
double intnuc=15351.0; // internuclear distance (MM)
// nux[0,1][0-2] = coordinate of A, B nuclei
// nux[0,1][3] = charge of A, B nuclei
double nux[][]={{0, 0, 0, 4.22}, {intnuc, 0, 0,4.22}};
// te0=initial coodinate of hydrogen
double te0[][]={{0, 0, 4500}, {0, 0, 0},
{0, 0, 0}, {0, 0, 0},
{0, 0, 0}, {0, 0, 0},{0, 0, 0}};
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 coordinate of carbon
double te1[][]={{hens, 0.0, 0.0}, {-heno, 0.0, henf},
{-heno, -henr, -hent}, {-heno, henr, -hent},{0,0,0},{0,0,0},{0,0,0}};
double henss=4596; double henrr=4596/rtw;
// te2=initial coordinate of oxygen
double te2[][]={{henrr, -henrr, 0.0}, {henrr, henrr, 0},
{-henrr, henrr, 0}, {-henrr, -henrr, 0}, {0, 0, -henss}, {0, 0, henss}, {0,0,0}};
// te3= initial coodinate of nitrogen
double te3[][]={{-2666,4617.6, 0}, {-2666, -4617.6, 0},
{0, 0, 5332}, {5332, 0, 0},
{0, 0, -5332}, {0, 0, 0},{0, 0, 0}};
// te4= initial coordinate of fluorine
double te4[][]={{2537,-3045, 563}, {2537, 3047, 563},
{-2537, 3047, 563}, {-2537, -3047, 563},
{0, 0, 4003}, {-2500, 0, -3127},
{2500, 0, -3127}};
public J2DPanel()
{
setBackground(Color.black);
JPanel p=new JPanel();
p.setLayout(new GridLayout(12,12));
String vv,zww; int aaa=0;
for (int el=0; el <=6; el++) {
for (int pos=0; pos <=2; pos++) {
elp[el][pos]=new JTextField(7); elp[el][pos].addActionListener(this);
apr[el][pos]=0.0; bpr[el][pos]=0.0;
}}
for (int el=0; el <=6; el++) { // other parameters of each electron
for (int pos=3; pos <=10; pos++) {
elp[el][pos]=new JTextField(7);
apr[el][pos]=0.0; bpr[el][pos]=0.0;
}}
// mmpho[0-2] = force components acting on nucleus
for (int el=0; el <=1; el++) {
for (int pos=0; pos <=2; pos++) {
mmpho[el][pos]=new JTextField(7);
}}
for (int pos=0; pos <=2; pos++) {
kait[pos]=new JTextField(7);
}
for (int pos=0; pos <=10; pos++) {
bangle[pos]=new JTextField(7);
}
// layout
String sihy[]={"eNo. ", "+X (MM)", "+Y (MM)", "+Z (MM)", "nuc (MM)",
"V (eV)", "Force", "fx ", "fy", "fz", "direw", "Waves "};
// 1st line
for (int el=0; el <=11; el++) {
p.add(new Label(sihy[el]));
}
// 2nd - 8th line
for (int el=0; el <=6; el++) {
p.add(new Label("ele "+el+" "));
for (int pos=0; pos <=10; pos++) {
p.add(elp[el][pos]);
}}
// 9th line
p.add(new Label("A nuc "));
for (int pos=0; pos <=2; pos++) {
p.add(mmpho[0][pos]);
}
p.add(new Label("B nuc "));
for (int pos=0; pos <=2; pos++) {
p.add(mmpho[1][pos]);
}
p.add(new Label(" -- ")); p.add(new Label("average"));
p.add(direc); p.add(avew);
// 10th line
p.add(b9); p.add(abdis); p.add(b1); p.add(kait[0]);
p.add(b2); p.add(kait[1]); p.add(b3); p.add(kait[2]);
p.add(bb1); p.add(imppo); p.add(bb2); p.add(charge);
// 11th line
p.add(b7); p.add(coom); p.add(b8); p.add(coomm);
p.add(new Label("total V ")); p.add(impho);
p.add(new Label("binding ")); p.add(sou);
p.add(b5); p.add(atom);
p.add(new Label(" -- ")); p.add(new Label(" -- "));
// 12th line
p.add(new Label(" angle "));
for (int pos=0; pos <=10; pos++) {
p.add(bangle[pos]);
}
coom.setSelectedItem("C"); coomm.setSelectedItem("C");
b1.addActionListener(this); b2.addActionListener(this);
b3.addActionListener(this); b5.addActionListener(this);
b7.addActionListener(this); b8.addActionListener(this);
b9.addActionListener(this); bb1.addActionListener(this);
bb2.addActionListener(this);
add(p,"South");
imppo.setText(Double.toString(6415));
charge.setText(Double.toString(nux[0][3]));
abdis.setText(Double.toString(intnuc));
kait[0].setText(Double.toString(0));
kait[1].setText(Double.toString(0));
kait[2].setText(Double.toString(0));
atom.setText("A");
for (int el=0; el <=6; 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)(10*nnuc); nnuc=aaa/10.0;
// show distance between nuclei and electrons
elp[el][3].setText("nuc "+Double.toString(nnuc));
for (int jou=0; jou <=2; jou++) {
apr[el][jou]=te1[el][jou]+nux[0][jou];
bpr[el][jou]=te1[el][jou]+nux[1][jou];
// show initial coordinate
aaa=(int)(100*te1[el][jou]); double coordi=aaa/100.0;
elp[el][jou].setText(Double.toString(coordi));
}}
} // public J2DPanel() end
public void actionPerformed(ActionEvent e) { // when textboxes change
String ss; ss=" ";
double Rf1=0.0; mar=0;
if (e.getSource() == bb2) { // charge Z change
ss=charge.getText(); nux[abd][3]=Double.parseDouble(ss);
}
// abd = atom A (= 0) or B (= 1) on screen
if (e.getSource() == b9) { // internuclear distance change
ss=abdis.getText(); double intn=Double.parseDouble(ss);
for (int ba=0; ba <=kade[1]-1; ba++) {
bpr[ba][0] = bpr[ba][0] - intnuc + intn ;
}
// kade[1] = number of valence electrons in B
intnuc=intn;
nux[1][0]=intnuc;
}
if (e.getSource() == b5) { // A B atoms change on screen
if ( abd==0 ) { abd=1; atom.setText("B"); }
else { abd=0; atom.setText("A"); }
mar=1; double cha=nux[abd][3];
charge.setText(Double.toString(cha));
diam=4500;
if ( kade[abd]==4) { diam=6415; if ( cha > 5 ) { diam=11500; } }
if ( kade[abd]==6) { diam=4596; if ( cha > 7 ) { diam=8622; } }
if ( kade[abd]==5) { diam=5332; if ( cha > 6 ) { diam=9825; } }
if ( kade[abd]==7) { diam=4003; if ( cha > 8 ) { diam=7640; } }
imppo.setText(Double.toString(diam));
}
if (e.getSource() == b1) { mar=2; } // rotation on each plane
if (e.getSource() == b2) { mar=3; }
if (e.getSource() == b3) { mar=4; }
if (e.getSource() == bb1) { mar=9; } // nuc-ele distance change
if (e.getSource() == b7) { mar=7; // A atom change
ss=(String)coom.getSelectedItem();
if (ss=="H") {saia=1.0; saik=1; diam=4500; }
if (ss=="C") {saia=4.22; saik=4; diam=6415; }
if (ss=="O") {saia=6.273; saik=6; diam=4596; }
if (ss=="N") {saia=5.25; saik=5; diam=5332; }
if (ss=="F") {saia=7.3; saik=7; diam=4003; }
if (ss=="Si") {saia=5.05; saik=4; diam=11500;}
if (ss=="S") {saia=7.18; saik=6; diam=8622;}
if (ss=="P") {saia=6.12; saik=5; diam=9825;}
if (ss=="Cl") {saia=8.26; saik=7; diam=7640;}
imppo.setText(Double.toString(diam));
charge.setText(Double.toString(saia));
}
if (e.getSource() == b8) { mar=8; // B atom change
ss=(String)coomm.getSelectedItem();
if (ss=="H") {saia=1.0; saik=1; diam=4500; }
if (ss=="C") {saia=4.22; saik=4; diam=6415; }
if (ss=="O") {saia=6.273; saik=6; diam=4596; }
if (ss=="N") {saia=5.25; saik=5; diam=5332; }
if (ss=="F") {saia=7.3; saik=7; diam=4003; }
if (ss=="Si") {saia=5.05; saik=4; diam=11500;}
if (ss=="S") {saia=7.18; saik=6; diam=8622;}
if (ss=="P") {saia=6.12; saik=5; diam=9825;}
if (ss=="Cl") {saia=8.26; saik=7; diam=7640;}
imppo.setText(Double.toString(diam));
charge.setText(Double.toString(saia));
}
repaint();
}
public void update(Graphics g)
{
paint(g);
}
public void paintComponent(Graphics g)
{
double kro,krr, pot,gx,gy,gz,ggx,ggy,ggz,ttav,toav, aid; double toavv=0;
kro=0.0; gx=0.0;gy=0.0;gz=0.0;ggx=0.0; ggy=0.0; ggz=0.0;
int ex,ey,ez; String ww, wa, wb;
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 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 mmp[][]={{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}};
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,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}, {0,0,0,0,0},{0,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,0,0}};
if ( mar !=1 ) { // get electron coordinates from text
for (int yp=0; yp <=6; yp++) {
for (int kj=0; kj <=2; kj++) {
ww=elp[yp][kj].getText();
if (abd == 0) { // apr[0-6][0-2] = A atom electron coorinate
apr[yp][kj]=Double.parseDouble(ww); }
if (abd == 1) {
// bpr[0-6][0-2] = B atom electron coodinate
bpr[yp][kj]=Double.parseDouble(ww);
if (kj==0) { bpr[yp][kj] = bpr[yp][kj]+intnuc;}
}
}}
}
// "nuc" = distance between nucleus and electron change
ww=imppo.getText();
gz=Double.parseDouble(ww); gy=0;
if (mar==9) {
for (int yp=0; yp <=6; yp++) {
gx=Math.sqrt((apr[yp][0]-nux[0][0])*(apr[yp][0]-nux[0][0])+
(apr[yp][1]-nux[0][1])*(apr[yp][1]-nux[0][1])+(apr[yp][2]-nux[0][2])*(apr[yp][2]-nux[0][2]));
if (abd==1) {
gx=Math.sqrt((bpr[yp][0]-nux[1][0])*(bpr[yp][0]-nux[1][0])+
(bpr[yp][1]-nux[1][1])*(bpr[yp][1]-nux[1][1])+(bpr[yp][2]-nux[1][2])*(bpr[yp][2]-nux[1][2]));
}
if (gx==0) {gx=50;}
for (int kj=0; kj <=2; kj++) {
if (abd==0) {
gy=apr[yp][kj]; gy=(gy*gz)/gx; apr[yp][kj]=gy; }
if (abd==1) {
gy=bpr[yp][kj]-nux[1][kj]; gy=(gy*gz)/gx; bpr[yp][kj]=gy+nux[1][kj]; }
}} mar=0;
}
if (mar==7) { // A atom's kind change
kade[0]=saik; // kate[0] = number of A atom valence electrons
nux[0][3]=saia; // nux[0][3] = charge of A nucleus
for (int yp=0; yp <=6; yp++) {
for (int kj=0; kj <=2; kj++) {
if (kade[0]==1) { gx=te0[yp][kj];} // hydrogen coordinate
if (kade[0]==4) { gx=te1[yp][kj];} // carbon
if (kade[0]==6) { gx=te2[yp][kj];} // oxygen
if (kade[0]==5) { gx=te3[yp][kj];} // nitrogen
if (kade[0]==7) { gx=te4[yp][kj];} // fluorine
apr[yp][kj]=gx; // apr[][0-2] = A atom coodinate
}
ggx=Math.sqrt(apr[yp][0]*apr[yp][0]+apr[yp][1]*apr[yp][1]+apr[yp][2]*apr[yp][2]);
for (int kj=0; kj <=2; kj++) {
apr[yp][kj]=(apr[yp][kj]*diam)/ggx;
}
}
}
if (mar==8) { // B atom change
kade[1]=saik; nux[1][3]=saia;
for (int yp=0; yp <=6; yp++) {
for (int kj=0; kj <=2; kj++) {
if (kade[1]==1) { gx=te0[yp][kj];}
if (kade[1]==4) { gx=te1[yp][kj];}
if (kade[1]==6) { gx=te2[yp][kj];}
if (kade[1]==5) { gx=te3[yp][kj];}
if (kade[1]==7) { gx=te4[yp][kj];}
bpr[yp][kj]=gx;
}
ggx=Math.sqrt(bpr[yp][0]*bpr[yp][0]+bpr[yp][1]*bpr[yp][1]+bpr[yp][2]*bpr[yp][2]);
for (int kj=0; kj <=2; kj++) {
bpr[yp][kj]=(bpr[yp][kj]*diam)/ggx;
if (kj==0) { bpr[yp][kj]=bpr[yp][kj]+nux[1][kj];}
}
}
}
double ccos=0.0; double ssin=0.0;
if (mar==2) { // rotation of atom in x-y plane
ww=kait[0].getText(); // rotation angle
gz=Double.parseDouble(ww);
ccos=Math.cos((gz*pai)/180.0); ssin=Math.sin((gz*pai)/180.0);
for (int yp=0; yp <=6; yp++) {
gx=apr[yp][0]; gy=apr[yp][1];
if (abd==1) { gx=bpr[yp][0]-nux[1][0]; gy=bpr[yp][1]; }
ggx=gx*ccos-gy*ssin;
ggy=gx*ssin+gy*ccos;
if (abd==0) { apr[yp][0]=ggx; apr[yp][1]=ggy;}
if (abd==1) { bpr[yp][0]=ggx+nux[1][0]; bpr[yp][1]=ggy;}
} }
if (mar==3) { // rotation of atom in x-z plane
ww=kait[1].getText();
gz=Double.parseDouble(ww);
ccos=Math.cos((gz*pai)/180.0); ssin=Math.sin((gz*pai)/180.0);
for (int yp=0; yp <=6; yp++) {
gx=apr[yp][0]; gy=apr[yp][2];
if (abd==1) { gx=bpr[yp][0]-nux[1][0]; gy=bpr[yp][2]; }
ggx=gx*ccos-gy*ssin;
ggy=gx*ssin+gy*ccos;
if (abd==0) { apr[yp][0]=ggx; apr[yp][2]=ggy;}
if (abd==1) { bpr[yp][0]=ggx+nux[1][0]; bpr[yp][2]=ggy;}
}}
if (mar==4) { // rotation of atom in y-z plane
ww=kait[2].getText();
gz=Double.parseDouble(ww);
ccos=Math.cos((gz*pai)/180.0); ssin=Math.sin((gz*pai)/180.0);
for (int yp=0; yp <=6; yp++) {
gx=apr[yp][1]; gy=apr[yp][2];
if (abd==1) { gx=bpr[yp][1]; gy=bpr[yp][2]; }
ggx=gx*ccos-gy*ssin;
ggy=gx*ssin+gy*ccos;
if (abd==0) { apr[yp][1]=ggx; apr[yp][2]=ggy;}
if (abd==1) { bpr[yp][1]=ggx; bpr[yp][2]=ggy;}
}}
// noxx[0][0-2] = center of A valence electrons
if (kade[0] != 1 ) {
for (int kj=0; kj <=2; kj++) {
for (int yp=0; yp <=kade[0]-1; yp++) {
noxx[0][kj]=noxx[0][kj] + apr[yp][kj];
} noxx[0][kj]=noxx[0][kj]/kade[0];
}
}
// noxx[0][0-2] = center of B valence electrons
if (kade[1] != 1 ) {
for (int kj=0; kj <=2; kj++) {
for (int yp=0; yp <=kade[1]-1; yp++) {
noxx[1][kj]=noxx[1][kj] + bpr[yp][kj];
} noxx[1][kj]=noxx[1][kj]/kade[1];
}
}
for (int yp=0; yp <=6; yp++) { // show relative coordinates
for (int kj=0; kj <=2; kj++) {
gx=apr[yp][kj];
if (abd==1) { gx = bpr[yp][kj]-nux[1][kj]; }
if ( yp > kade[abd]-1 ) { gx = 0; }
ex=(int)(100*gx); gx=ex/100.0;
elp[yp][kj].setText(Double.toString(gx));
}}
int ank=0;
if (kade[abd] != 1 ) { // show bond angle
for (int yp=0; yp <=3; yp++) {
for (int kj=0; kj <=3; kj++) {
if ( yp < kj ) {
gx=Math.sqrt(apr[yp][0]*apr[yp][0]+apr[yp][1]*apr[yp][1]+apr[yp][2]*apr[yp][2]);
gy=Math.sqrt(apr[kj][0]*apr[kj][0]+apr[kj][1]*apr[kj][1]+apr[kj][2]*apr[kj][2]);
gz=Math.sqrt((apr[yp][0]-apr[kj][0])*(apr[yp][0]-apr[kj][0])+(apr[yp][1]-apr[kj][1] )*(apr[yp][1]-apr[kj][1])+(apr[yp][2]-apr[kj][2])*(apr[yp][2]-apr[kj][2]));
if (abd==1) {
gx=Math.sqrt((bpr[yp][0]-intnuc)*(bpr[yp][0]-intnuc)+bpr[yp][1]*bpr[yp][1]+bpr[yp][2]*bpr[yp][2]);
gy=Math.sqrt((bpr[kj][0]-intnuc)*(bpr[kj][0]-intnuc)+bpr[kj][1]*bpr[kj][1]+bpr[kj][2]*bpr[kj][2]);
gz=Math.sqrt((bpr[yp][0]-bpr[kj][0])*(bpr[yp][0]-bpr[kj][0])+(bpr[yp][1]-bpr[kj][1] )*(bpr[yp][1]-bpr[kj][1])+(bpr[yp][2]-bpr[kj][2])*(bpr[yp][2]-bpr[kj][2]));
}
aid=(gx*gx+gy*gy-gz*gz)/(2.0*gx*gy);
aid=(Math.acos(aid)*180.0)/pai;
wa=Integer.toString(yp); wb=Integer.toString(kj);
ex=(int)(10*aid); aid=ex/10.0;
bangle[ank].setText(wa+"-n-"+wb+" "+Double.toString(aid));
ank=ank+1;
}}}
if ( kade[abd] !=4 ) {
gx=Math.sqrt(apr[4][0]*apr[4][0]+apr[4][1]*apr[4][1]+apr[4][2]*apr[4][2]);
if (abd==1) {
gx=Math.sqrt((bpr[4][0]-intnuc)*(bpr[4][0]-intnuc)+bpr[4][1]*bpr[4][1]+bpr[4][2]*bpr[4][2]);
}
for (int yp=0; yp <=2; yp++) {
gy=Math.sqrt(apr[yp][0]*apr[yp][0]+apr[yp][1]*apr[yp][1]+apr[yp][2]*apr[yp][2]);
gz=Math.sqrt((apr[yp][0]-apr[4][0])*(apr[yp][0]-apr[4][0])+(apr[yp][1]-apr[4][1] )*(apr[yp][1]-apr[4][1])+(apr[yp][2]-apr[4][2])*(apr[yp][2]-apr[4][2]));
if (abd==1) {
gy=Math.sqrt((bpr[yp][0]-intnuc)*(bpr[yp][0]-intnuc)+bpr[yp][1]*bpr[yp][1]+bpr[yp][2]*bpr[yp][2]);
gz=Math.sqrt((bpr[yp][0]-bpr[4][0])*(bpr[yp][0]-bpr[4][0])+(bpr[yp][1]-bpr[4][1] )*(bpr[yp][1]-bpr[4][1])+(bpr[yp][2]-bpr[4][2])*(bpr[yp][2]-bpr[4][2])); }
aid=(gx*gx+gy*gy-gz*gz)/(2.0*gx*gy);
aid=(Math.acos(aid)*180.0)/pai;
wa=Integer.toString(yp); wb=Integer.toString(4);
ex=(int)(10*aid); aid=ex/10.0;
bangle[yp+6].setText(wa+"-n-"+wb+" "+Double.toString(aid));
}
if (kade[abd] !=5) {
for (int yp=4; yp <=5; yp++) {
if ( yp==4 || kade[abd]==7 ) {
gx=Math.sqrt(apr[yp][0]*apr[yp][0]+apr[yp][1]*apr[yp][1]+apr[yp][2]*apr[yp][2]);
gy=Math.sqrt(apr[yp+1][0]*apr[yp+1][0]+apr[yp+1][1]*apr[yp+1][1]+apr[yp+1][2]*apr[yp+1][2]);
gz=Math.sqrt((apr[yp][0]-apr[yp+1][0])*(apr[yp][0]-apr[yp+1][0])+(apr[yp][1]-apr[yp+1][1] )*(apr[yp][1]-apr[yp+1][1])+(apr[yp][2]-apr[yp+1][2])*(apr[yp][2]-apr[yp+1][2]));
if (abd==1) {
gx=Math.sqrt((bpr[yp][0]-intnuc)*(bpr[yp][0]-intnuc)+bpr[yp][1]*bpr[yp][1]+bpr[yp][2]*bpr[yp][2]);
gy=Math.sqrt((bpr[yp+1][0]-intnuc)*(bpr[yp+1][0]-intnuc)+bpr[yp+1][1]*bpr[yp+1][1]+bpr[yp+1][2]*bpr[yp+1][2]);
gz=Math.sqrt((bpr[yp][0]-bpr[yp+1][0])*(bpr[yp][0]-bpr[yp+1][0])+(bpr[yp][1]-bpr[yp+1][1] )*(bpr[yp][1]-bpr[yp+1][1])+(bpr[yp][2]-bpr[yp+1][2])*(bpr[yp][2]-bpr[yp+1][2]));
}
aid=(gx*gx+gy*gy-gz*gz)/(2.0*gx*gy);
aid=(Math.acos(aid)*180.0)/pai;
wa=Integer.toString(yp); wb=Integer.toString(yp+1);
ex=(int)(10*aid); aid=ex/10.0;
bangle[yp+5].setText(wa+"-n-"+wb+" "+Double.toString(aid));
}}}
}
}
for (int yp=0; yp <=10; yp++) {
if (kade[abd] ==1 ) {bangle[yp].setText(" 0 ");}
if (kade[abd] <=4 && yp > 5 ) {bangle[yp].setText(" 0 ");}
if (kade[abd] <=5 && yp > 8 ) {bangle[yp].setText(" 0 ");}
if (kade[abd] <=6 && yp > 9 ) {bangle[yp].setText(" 0 ");}
}
toav=0.0; // toav=total potential energy
double ppot;
// interaction between electrons 0-6 in atom A
for (int yp=0; yp <=kade[0]-1; yp++) {
for (int kj=0; kj <=kade[0]-1; kj++) {
if (yp < kj ) {
// kro=distance between electrons
kro=Math.sqrt((apr[yp][0]-apr[kj][0])*(apr[yp][0]-apr[kj][0])+
(apr[yp][1]-apr[kj][1])*(apr[yp][1]-apr[kj][1])+
(apr[yp][2]-apr[kj][2])*(apr[yp][2]-apr[kj][2]));
if (kro==0) {kro=5000.0;}
// ppot=repulsive potential energy (eV)
ppot=(elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
toav=toav+ppot;
// rhp[][3]= potential energy of each electron
rhp[yp][3]=rhp[yp][3]+ppot/2.0; rhp[kj][3]=rhp[kj][3]+ppot/2.0;
// teqq[][3] = potential energy only in A 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++) {
// rhp[][0-2]=force component acting on each electron
ggx=(suh*(apr[yp][jou]-apr[kj][jou]))/(kro*kro*kro);
rhp[yp][jou]=rhp[yp][jou]+ggx; rhp[kj][jou]=rhp[kj][jou]-ggx;
// teqq[][0-2] = force component only in A atom
teqq[yp][jou]=teqq[yp][jou]+ggx; teqq[kj][jou]=teqq[kj][jou]-ggx;
}
}}}
// interaction between electrons in B atom
for (int yp=0; yp <=kade[1]-1; yp++) {
for (int kj=0; kj <=kade[1]-1; kj++) {
if (yp < kj ) {
// kro=distance between electrons
kro=Math.sqrt((bpr[yp][0]-bpr[kj][0])*(bpr[yp][0]-bpr[kj][0])+
(bpr[yp][1]-bpr[kj][1])*(bpr[yp][1]-bpr[kj][1])+
(bpr[yp][2]-bpr[kj][2])*(bpr[yp][2]-bpr[kj][2]));
if (kro==0) {kro=5000.0;}
// ppot=repulsive potential energy (eV)
ppot=(elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
toav=toav+ppot;
// rhp[7-13][3]= potential energy of each electron (B)
rhp[yp+7][3]=rhp[yp+7][3]+ppot/2.0; rhp[kj+7][3]=rhp[kj+7][3]+ppot/2.0;
// teqq[7-13][3] = potential energy only in B atom
teqq[yp+7][3]=teqq[yp+7][3]+ppot/2.0; teqq[kj+7][3]=teqq[kj+7][3]+ppot/2.0;
for (int jou=0; jou <=2; jou++) {
// rhp[][0-2]=force component acting on each electron
ggx=(suh*(bpr[yp][jou]-bpr[kj][jou]))/(kro*kro*kro);
rhp[yp+7][jou]=rhp[yp+7][jou]+ggx; rhp[kj+7][jou]=rhp[kj+7][jou]-ggx;
// teqq[7-13][0-2] = force component only in B atom
teqq[yp+7][jou]=teqq[yp+7][jou]+ggx; teqq[kj+7][jou]=teqq[kj+7][jou]-ggx;
}
}}}
double zenf=0.0;
// interaction between A and B electrons
for (int yp=0; yp <=kade[0]-1; yp++) {
for (int kj=0; kj <=kade[1]-1; kj++) {
kro=Math.sqrt((apr[yp][0]-bpr[kj][0])*(apr[yp][0]-bpr[kj][0])+
(apr[yp][1]-bpr[kj][1])*(apr[yp][1]-bpr[kj][1])+
(apr[yp][2]-bpr[kj][2])*(apr[yp][2]-bpr[kj][2]));
if (kro==0) {kro=5000.0;}
// ppot=repulsive potential energy (eV)
ppot=(elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
toav=toav+ppot;
// rhp[][3]= potential energy of each electron
rhp[yp][3]=rhp[yp][3]+ppot/2.0; rhp[kj+7][3]=rhp[kj+7][3]+ppot/2.0;
for (int jou=0; jou <=2; jou++) {
// force component
ggx=(suh*(apr[yp][jou]-bpr[kj][jou]))/(kro*kro*kro);
rhp[yp][jou]=rhp[yp][jou]+ggx; rhp[kj+7][jou]=rhp[kj+7][jou]-ggx;
// zenf = x component force acting on overall A atom
if (jou==0) {zenf=zenf+ggx;}
}
}}
// ----- interaction between nucleus and A electron
for (int yp=0; yp <=kade[0]-1; yp++) {
for (int rv=0; rv <=1; rv++) {
// kro=distance between nucleus and electron
kro=Math.sqrt((apr[yp][0]-nux[rv][0])*(apr[yp][0]-nux[rv][0])+
(apr[yp][1]-nux[rv][1])*(apr[yp][1]-nux[rv][1])+
(apr[yp][2]-nux[rv][2])*(apr[yp][2]-nux[rv][2]));
if (kro == 0) {kro=5000.0;}
ex=(int)(kro*10); double dinu=ex/10.0;
if ( abd==0 && rv==0 ) { // show distance between nucleus and ele
elp[yp][3].setText("nuc "+Double.toString(dinu)); }
// ppot = each attractive potential energy
ppot=-(elc*elc*nux[rv][3]*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
toav=toav+ppot;
rhp[yp][3]=rhp[yp][3]+ppot;
// rhp[][6] = potential energy between another nucleus
if (rv==1) { rhp[yp][6]=rhp[yp][6]+ppot;}
// ggx=force component between nucleus and electron
for (int jou=0; jou <=2; jou++) {
ggx=(suh*nux[rv][3]*(apr[yp][jou]-nux[rv][jou]))/(kro*kro*kro);
rhp[yp][jou]=rhp[yp][jou]-ggx;
// mmp[][0-2] = force component acting on each nucleus
mmp[rv][jou]=mmp[rv][jou]+ggx;
if (jou==0 && rv==1 ) { zenf=zenf -ggx; }
}}}
// interaction between B electrons and nuclei
for (int yp=0; yp <=kade[1]-1; yp++) {
for (int rv=0; rv <=1; rv++) {
// kro=distance between nucleus and electron
kro=Math.sqrt((bpr[yp][0]-nux[rv][0])*(bpr[yp][0]-nux[rv][0])+
(bpr[yp][1]-nux[rv][1])*(bpr[yp][1]-nux[rv][1])+
(bpr[yp][2]-nux[rv][2])*(bpr[yp][2]-nux[rv][2]));
if (kro == 0) {kro=5000.0;}
ex=(int)(kro);
if ( abd==1 && rv==1 ) {
elp[yp][3].setText("nuc "+Integer.toString(ex)); }
// ppot = each attractive potential energy
ppot=-(elc*elc*nux[rv][3]*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
toav=toav+ppot;
rhp[yp+7][3]=rhp[yp+7][3]+ppot;
if (rv==0) { rhp[yp+7][6]=rhp[yp+7][6]+ppot;}
// ggx=force component between nucleus and electron
for (int jou=0; jou <=2; jou++) {
ggx=(suh*nux[rv][3]*(bpr[yp][jou]-nux[rv][jou]))/(kro*kro*kro);
rhp[yp+7][jou]=rhp[yp+7][jou]-ggx;
mmp[rv][jou]=mmp[rv][jou]+ggx;
if (jou==0 && rv==0 ) { zenf=zenf + ggx;}
}}}
// internuclear interaction
ppot=(elc*elc*nux[0][3]*nux[1][3] *6.241509e18)/(4.0*pai*epsi*intnuc*1.0e-14);
toav=toav+ppot;
ggx=(suh*nux[0][3]*nux[1][3])/(intnuc*intnuc);
mmp[0][0]=mmp[0][0]-ggx; mmp[1][0]=mmp[1][0]+ggx;
zenf = zenf - ggx ;
// distribute internuclear V to electron based on rhp[][6]
gx=0.0;
for (int yp=0; yp <= kade[0]-1; yp++) {
gx=gx+rhp[yp][6];
}
for (int yp=0; yp <= kade[1]-1; yp++) {
gx=gx+rhp[yp+7][6];
}
for (int rv=0; rv <= 1; rv++) {
for (int yp=0; yp <= kade[rv]-1; yp++) {
rhp[yp+rv*7][3]=rhp[yp+rv*7][3]+(ppot*rhp[yp+rv*7][6])/gx ;
}}
// interaction between A electrons and their center nuc
if ( kade[0] != 1 ) {
for (int yp=0; yp <= kade[0]-1; yp++) {
kro=Math.sqrt((apr[yp][0]-noxx[0][0])*(apr[yp][0]-noxx[0][0])+
(apr[yp][1]-noxx[0][1])*(apr[yp][1]-noxx[0][1])+
(apr[yp][2]-noxx[0][2])*(apr[yp][2]-noxx[0][2]));
if (kro == 0) {kro=5000.0;}
ppot=-(elc*elc*nux[0][3]*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
teqq[yp][3]=teqq[yp][3] + ppot;
for (int jou=0; jou <=2; jou++) {
ggx=(suh*nux[0][3]*(apr[yp][jou]-noxx[0][jou]))/(kro*kro*kro);
teqq[yp][jou]=teqq[yp][jou]-ggx;
}
}
}
// interaction between B electrons and their center nuc
if ( kade[1] != 1 ) {
for (int yp=0; yp <= kade[1]-1; yp++) {
kro=Math.sqrt((bpr[yp][0]-noxx[1][0])*(bpr[yp][0]-noxx[1][0])+
(bpr[yp][1]-noxx[1][1])*(bpr[yp][1]-noxx[1][1])+
(bpr[yp][2]-noxx[1][2])*(bpr[yp][2]-noxx[1][2]));
if (kro == 0) {kro=5000.0;}
ppot=-(elc*elc*nux[1][3]*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
teqq[yp+7][3]=teqq[yp+7][3] + ppot;
for (int jou=0; jou <=2; jou++) {
ggx=(suh*nux[1][3]*(bpr[yp][jou]-noxx[1][jou]))/(kro*kro*kro);
teqq[yp+7][jou]=teqq[yp+7][jou]-ggx;
}
}
}
toavv=toav;
ex=(int)(1000*toav); ggx=ex/1000.0;
impho.setText("tV "+Double.toString(ggx)); // show total V (eV)
double free[]={148.025,148.025}; // show binding energy
for (int frr=0; frr <=1; frr++) {
if (nux[frr][3] == 1.0) { free[frr]= 13.606; }
if (nux[frr][3] == 5.05) { free[frr]= 103.132; }
if (nux[frr][3] == 6.273) { free[frr]= 433.107; }
if (nux[frr][3] == 7.18) { free[frr]= 276.358; }
if (nux[frr][3] == 5.25) { free[frr]= 266.948; }
if (nux[frr][3] == 6.12) { free[frr]= 176.929; }
if (nux[frr][3] == 7.3) { free[frr]= 658.836; }
if (nux[frr][3] == 8.26) { free[frr]= 408.88; }
}
double bindd= (-toav-free[0]*2.0-free[1]*2.0)*0.5;
ex=(int)(1000*bindd); ggx=ex/1000.0;
sou.setText(Double.toString(ggx) + " eV" );
if ( kade[0]==1 && kade[1]==1 ) { sou.setText(" "); }
// show forces acting on electrons
for (int rv=0; rv <=kade[abd]-1; rv++) {
gx=Math.sqrt((apr[rv][0]-nux[0][0])*(apr[rv][0]-nux[0][0])+
(apr[rv][1]-nux[0][1])*(apr[rv][1]-nux[0][1])+(apr[rv][2]-nux[0][2])*(apr[rv][2]-nux[0][2]));
// gy=forces toward nucleus (CF)
gy=-(rhp[rv][0]*apr[rv][0]+rhp[rv][1]*apr[rv][1]+rhp[rv][2]*apr[rv][2])/gx;
if (abd==1) {
gx=Math.sqrt((bpr[rv][0]-nux[1][0])*(bpr[rv][0]-nux[1][0])+
(bpr[rv][1]-nux[1][1])*(bpr[rv][1]-nux[1][1])+(bpr[rv][2]-nux[1][2])*(bpr[rv][2]-nux[1][2]));
gy=-(rhp[rv+7][0]*(bpr[rv][0]-nux[1][0])+rhp[rv+7][1]*bpr[rv][1]+rhp[rv+7][2]*bpr[rv][2])/gx;
}
ex=(int)(1000*gy); ww="CF ";
elp[rv][5].setText(ww+Integer.toString(ex));
// show forces other than CF
for (int jou=0; jou <=2; jou++) {
gz=rhp[rv][jou]-(gy*(nux[0][jou]-apr[rv][jou]))/gx;
if (abd==1) {
gz=rhp[rv+7][jou]-(gy*(nux[1][jou]-bpr[rv][jou]))/gx;
}
if (kade[abd]==1 && jou==0) {
gz=rhp[rv+abd*7][0];
}
ex=(int)(1000*gz);
elp[rv][jou+6].setText(Integer.toString(ex));
}
}
for (int rv=0; rv <=1; rv++) {
for (int jou=0; jou <=2; jou++) { // show forces acting on nucleus
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));
}}
// show potential energy of each electron
for (int rv=0; rv <=kade[abd]-1; rv++) {
ex=(int)(100*rhp[rv][3]); ggx=ex/100.0;
if (abd==1) {
ex=(int)(100*rhp[rv+7][3]); ggx=ex/100.0;
}
elp[rv][4].setText("V "+Double.toString(ggx));
}
// show de Broglie wave
double gouk=0.0; double goukk=0.0; double gggx,gggy,gggz;
for (int rv=0; rv <=kade[abd]-1; rv++) {
gz=Math.sqrt(rhp[rv+abd*7][0]*rhp[rv+abd*7][0]+rhp[rv+abd*7][1]*rhp[rv+abd*7][1]+rhp[rv+abd*7][2]*rhp[rv+abd*7][2]);
gggz=gz;
if ( kade[abd] != 1 ) {
gz=Math.sqrt(teqq[rv+abd*7][0]*teqq[rv+abd*7][0]+teqq[rv+abd*7][1]*teqq[rv+abd*7][1]+teqq[rv+abd*7][2]*teqq[rv+abd*7][2]);
}
// gy=forces (N)
gy=(gz*elc*elc)/(4.0*pai*epsi*suh*1.0e-28);
gggy=(gggz*elc*elc)/(4.0*pai*epsi*suh*1.0e-28);
// gx=velocity (m/s) of each electron
gx=Math.sqrt((-1.0*rhp[rv+abd*7][3]*1.602177e-19)/me);
gggx=gx;
if ( kade[abd] != 1 ) {
gx=Math.sqrt((-1.0*teqq[rv+abd*7][3]*1.602177e-19)/me);
}
ggx=(me*gx*gx)/gy;
// ggy=number of de Broglie's wave in one orbit
double debroglie = h/(me*gx);
ggy=(2.0*pai*ggx)/debroglie;
gouk=gouk+ggy;
ex=(int)(ggy*10000); ggz=ex/10000.0; rhp[rv+abd*7][5]=ggz;
elp[rv][10].setText("wn "+Double.toString(ggz));
ggx=(me*gggx*gggx)/gggy;
debroglie = h/(me*gggx);
ggy=(2*pai*ggx)/debroglie; // number of de Broglie's wave (all direct)
goukk=goukk+ggy;
ex=(int)(ggy*10000); ggz=ex/10000.0;
elp[rv][9].setText("di "+Double.toString(ggz));
}
gouk=gouk/kade[abd];
ex=(int)(gouk*10000); gouk=ex/10000.0;
avew.setText("ave "+Double.toString(gouk));
goukk=goukk/kade[abd];
ex=(int)(goukk*10000); goukk=ex/10000.0;
direc.setText("ave "+Double.toString(goukk));
for (int yp=2; yp <=6; yp++) {
for (int kj=3; kj <=10; kj++) {
if (kade[abd] ==1) {elp[yp][kj].setText(" 0 ");}
if (kade[abd] <=4 && yp > 3 ) {elp[yp][kj].setText(" 0 ");}
if (kade[abd] <=5 && yp > 4 ) {elp[yp][kj].setText(" 0 ");}
if (kade[abd] <=6 && yp > 5 ) {elp[yp][kj].setText(" 0 ");}
}}
double app[][]=new double[7][11];
double bpp[][]=new double[7][11];
if ( kade[abd] == 1 ) { // hydrogen parameter after moving
if (kade[0]==1) {
gx=Math.sqrt(rhp[0][1]*rhp[0][1]+rhp[0][2]*rhp[0][2]);
gy=Math.sqrt(apr[0][1]*apr[0][1]+apr[0][2]*apr[0][2]);
// hyrogen electron moves in x direction by force
app[0][0]=apr[0][0]+(rhp[0][0] * gy*2)/gx;
}
else { app[0][0]=apr[0][0]; }
app[0][1]=apr[0][1]; app[0][2]=apr[0][2];
if (kade[1]==1) {
gx=Math.sqrt(rhp[7][1]*rhp[7][1]+rhp[7][2]*rhp[7][2]);
gy=Math.sqrt(bpr[0][1]*bpr[0][1]+bpr[0][2]*bpr[0][2]);
bpp[0][0]=bpr[0][0]+(rhp[7][0] * gy*2)/gx;
}
else { bpp[0][0]=bpr[0][0]; }
bpp[0][1]=bpr[0][1]; bpp[0][2]=bpr[0][2];
for (int rv=1; rv <=6; rv++) {
for (int jou=0; jou <=2; jou++) {
app[rv][jou]=apr[rv][jou]; bpp[rv][jou]=bpr[rv][jou];
}}
toav=0.0; // toav= total potential energy after moving
for (int yp=0; yp <=kade[0]-1; yp++) { // interaction between A ale
for (int kj=0; kj <=kade[0]-1; kj++) {
if (yp < kj ) {
// kro=distance between electrons
kro=Math.sqrt((app[yp][0]-app[kj][0])*(app[yp][0]-app[kj][0])+
(app[yp][1]-app[kj][1])*(app[yp][1]-app[kj][1])+
(app[yp][2]-app[kj][2])*(app[yp][2]-app[kj][2]));
if (kro==0) {kro=5000.0;}
// ppot=repulsive potential energy (eV)
ppot=(elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
toav=toav+ppot;
rpp[yp][3]=rpp[yp][3]+ppot/2.0; rpp[kj][3]=rpp[kj][3]+ppot/2.0;
for (int jou=0; jou <=2; jou++) {
ggx=(suh*(app[yp][jou]-app[kj][jou]))/(kro*kro*kro);
rpp[yp][jou]=rpp[yp][jou]+ggx; rpp[kj][jou]=rpp[kj][jou]-ggx;
}
}}}
for (int yp=0; yp <=kade[1]-1; yp++) { // interaction between B ale
for (int kj=0; kj <=kade[1]-1; kj++) {
if (yp < kj ) {
// kro=distance between electrons
kro=Math.sqrt((bpp[yp][0]-bpp[kj][0])*(bpp[yp][0]-bpp[kj][0])+
(bpp[yp][1]-bpp[kj][1])*(bpp[yp][1]-bpp[kj][1])+
(bpp[yp][2]-bpp[kj][2])*(bpp[yp][2]-bpp[kj][2]));
if (kro==0) {kro=5000.0;}
// ppot=repulsive potential energy (eV)
ppot=(elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
toav=toav+ppot;
// rpp[][3]= potential energy of each electron
rpp[yp+7][3]=rpp[yp+7][3]+ppot/2.0; rpp[kj+7][3]=rpp[kj+7][3]+ppot/2.0;
for (int jou=0; jou <=2; jou++) {
ggx=(suh*(bpp[yp][jou]-bpp[kj][jou]))/(kro*kro*kro);
rpp[yp+7][jou]=rpp[yp+7][jou]+ggx; rpp[kj+7][jou]=rpp[kj+7][jou]-ggx;
}
}}}
for (int yp=0; yp <=kade[0]-1; yp++) {
for (int kj=0; kj <=kade[1]-1; kj++) {
kro=Math.sqrt((app[yp][0]-bpp[kj][0])*(app[yp][0]-bpp[kj][0])+
(app[yp][1]-bpp[kj][1])*(app[yp][1]-bpp[kj][1])+
(app[yp][2]-bpp[kj][2])*(app[yp][2]-bpp[kj][2]));
if (kro==0) {kro=5000.0;}
// ppot=repulsive potential energy (eV)
ppot=(elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
toav=toav+ppot;
// rpp[][3]= potential energy of each electron
rpp[yp][3]=rpp[yp][3]+ppot/2.0; rpp[kj+7][3]=rpp[kj+7][3]+ppot/2.0;
for (int jou=0; jou <=2; jou++) {
ggx=(suh*(app[yp][jou]-bpp[kj][jou]))/(kro*kro*kro);
rpp[yp][jou]=rpp[yp][jou]+ggx; rpp[kj+7][jou]=rpp[kj+7][jou]-ggx;
}
}}
// interaction between nucleus and each electron
for (int yp=0; yp <=kade[0]-1; yp++) {
for (int rv=0; rv <=1; rv++) {
// kro=distance between nucleus and electron
kro=Math.sqrt((app[yp][0]-nux[rv][0])*(app[yp][0]-nux[rv][0])+
(app[yp][1]-nux[rv][1])*(app[yp][1]-nux[rv][1])+
(app[yp][2]-nux[rv][2])*(app[yp][2]-nux[rv][2]));
if (kro == 0) {kro=5000.0;}
ex=(int)(kro);
// ppot = each attractive potential energy
ppot=-(elc*elc*nux[rv][3]*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
toav=toav+ppot;
rpp[yp][3]=rpp[yp][3]+ppot;
if (rv==1) { rpp[yp][6]=rpp[yp][6]+ppot;}
// ggx=force component between nucleus and electron
for (int jou=0; jou <=2; jou++) {
ggx=(suh*nux[rv][3]*(app[yp][jou]-nux[rv][jou]))/(kro*kro*kro);
rpp[yp][jou]=rpp[yp][jou]-ggx;
}}}
for (int yp=0; yp <=kade[1]-1; yp++) {
for (int rv=0; rv <=1; rv++) {
// kro=distance between nucleus and electron
kro=Math.sqrt((bpp[yp][0]-nux[rv][0])*(bpp[yp][0]-nux[rv][0])+
(bpp[yp][1]-nux[rv][1])*(bpp[yp][1]-nux[rv][1])+
(bpp[yp][2]-nux[rv][2])*(bpp[yp][2]-nux[rv][2]));
if (kro == 0) {kro=5000.0;}
ppot=-(elc*elc*nux[rv][3]*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14);
toav=toav+ppot;
rpp[yp+7][3]=rpp[yp+7][3]+ppot;
if (rv==0) { rpp[yp+7][6]=rpp[yp+7][6]+ppot;}
// ggx=force component between nucleus and electron
for (int jou=0; jou <=2; jou++) {
ggx=(suh*nux[rv][3]*(bpp[yp][jou]-nux[rv][jou]))/(kro*kro*kro);
rpp[yp+7][jou]=rpp[yp+7][jou]-ggx;
}}}
// internuclear interaction
ppot=(elc*elc*nux[0][3]*nux[1][3] *6.241509e18)/(4.0*pai*epsi*intnuc*1.0e-14);
toav=toav+ppot;
ggx=(suh*nux[0][3]*nux[1][3])/(intnuc*intnuc);
gx=0.0; // distribute internuclear potential to electrons
for (int yp=0; yp <= kade[0]-1; yp++) {
gx=gx+rpp[yp][6];
}
for (int yp=0; yp <= kade[1]-1; yp++) {
gx=gx+rpp[yp+7][6];
}
for (int rv=0; rv <= 1; rv++) {
for (int yp=0; yp <= kade[rv]-1; yp++) {
rpp[yp+rv*7][3]=rpp[yp+rv*7][3]+(ppot*rpp[yp+rv*7][6])/gx ;
}}
if (kade[0]==1 && kade[1]==1) { // show H2 binding energy (eV)
ex=(int)(1000*toav); ggx=ex/1000.0;
bangle[4].setText("aV "+Double.toString(ggx));
ggy=-(toav+toavv)/2.0 * 0.5 - 13.606*2;
ex=(int)(1000*ggy); ggy=ex/1000.0;
sou.setText(Double.toString(ggy)+ " eV");
}
// ------ show de Broglie wave after
gz=Math.sqrt(rpp[0+abd*7][0]*rpp[0+abd*7][0]+rpp[0+abd*7][1]*rpp[0+abd*7][1]+rpp[0+abd*7][2]*rpp[0+abd*7][2]);
// gy=forces (N)
gy=(gz*elc*elc)/(4.0*pai*epsi*suh*1.0e-28);
// gx=velocity (m/s) of each electron
gx=Math.sqrt((-1.0*rpp[0+abd*7][3]*1.602177e-19)/me);
ggx=(me*gx*gx)/gy;
double debroglie = h/(me*gx);
ggy=(2*pai*ggx)/debroglie; // ggy=number of de Broglie's wave in one orbit
ex=(int)(ggy*10000); ggz=ex/10000.0;
elp[1][9].setText("afw "+Double.toString(ggz));
elp[1][10].setText("afw "+Double.toString(ggz));
gouk=(rhp[0+abd*7][5] + ggz)/2.0;
ex=(int)(gouk*10000); gouk=ex/10000.0;
avew.setText("ave "+Double.toString(gouk));
direc.setText(" 0 ");
for (int kj=0; kj <=2; kj++) {
gx=app[0][kj];
if (abd==1) { gx=bpp[0][kj] - nux[1][kj];}
elp[1][kj].setText(Integer.toString((int)gx));
}
for (int kj=3; kj <=8; kj++) {
elp[1][kj].setText(" 0 ");
}
gz=rpp[0+abd*7][0];
ex=(int)(1000*gz);
elp[1][6].setText(Integer.toString(ex));
} // hydrogen electron after moving end
// ---------- show picture
int nmx[][]=new int[2][3]; int hpk[][]=new int[14][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]/142.856);
}}
// change MM to pixel in electrons
for (int yp=0; yp <=kade[0]-1; yp++) {
for (int kj=0; kj <=2; kj++) {
hpk[yp][kj]=(int)(apr[yp][kj]/142.856);
}}
for (int yp=0; yp <=kade[1]-1; yp++) {
for (int kj=0; kj <=2; kj++) {
hpk[yp+7][kj]=(int)(bpr[yp][kj]/142.856);
}}
int med=(int)(277.5-(intnuc*0.5)/142.856); int medd=(int)(832.5-(intnuc*0.5)/142.856);
g.clearRect(9,299,1170,699);
g.setColor(Color.cyan); g.drawLine(555,310,555,660);
g.drawString("X - Z plane", 257,345);
g.drawString("X - Y plane", 810,345);
g.setColor(Color.lightGray); // show nucleus
for ( int rv=0; rv <= 1; rv++) {
g.fillOval(nmx[rv][0]+med-3,472,20,20);
g.fillOval(nmx[rv][0]+medd-3,472,20,20);
}
for ( int rv=0; rv <= 1; rv++) {
g.setColor(Color.white); // show electron 0 (particle)
g.fillOval(hpk[0+rv*7][0]+med, 475-hpk[0+rv*7][2],14,14);
g.fillOval(hpk[0+rv*7][0]+medd,475-hpk[0+rv*7][1],14,14);
if ( kade[rv] > 1 ) {
g.setColor(Color.pink); // show electron 1
g.fillOval(hpk[1+rv*7][0]+med, 475-hpk[1+rv*7][2],14,14);
g.fillOval(hpk[1+rv*7][0]+medd,475-hpk[1+rv*7][1],14,14);
g.setColor(Color.red); // show electron 2
g.fillOval(hpk[2+rv*7][0]+med, 475-hpk[2+rv*7][2],14,14);
g.fillOval(hpk[2+rv*7][0]+medd,475-hpk[2+rv*7][1],14,14);
g.setColor(Color.green); // show electron 3
g.fillOval(hpk[3+rv*7][0]+med, 475-hpk[3+rv*7][2],14,14);
g.fillOval(hpk[3+rv*7][0]+medd,475-hpk[3+rv*7][1],14,14);
}
if ( kade[rv] > 4 ) { // N last electron
g.setColor(Color.white);
g.fillOval(hpk[4+rv*7][0]+med, 475-hpk[4+rv*7][2],14,14);
g.fillOval(hpk[4+rv*7][0]+medd,475-hpk[4+rv*7][1],14,14); }
if ( kade[rv] > 5 ) { // O last electron
g.setColor(Color.pink);
g.fillOval(hpk[5+rv*7][0]+med, 475-hpk[5+rv*7][2],14,14);
g.fillOval(hpk[5+rv*7][0]+medd,475-hpk[5+rv*7][1],14,14); }
if ( kade[rv] > 6 ) { // F last electron
g.setColor(Color.red);
g.fillOval(hpk[6+rv*7][0]+med, 475-hpk[6+rv*7][2],14,14);
g.fillOval(hpk[6+rv*7][0]+medd,475-hpk[6+rv*7][1],14,14); }
for (int rw=0; rw <=kade[rv]-1; rw++) {
g.setColor(Color.blue);
g.drawString(Integer.toString(rw),hpk[rw+rv*7][0]+med+4, 487-hpk[rw+rv*7][2]);
g.drawString(Integer.toString(rw),hpk[rw+rv*7][0]+medd+4, 487-hpk[rw+rv*7][1] );
}
}
}
}