2重結合のページに戻る
トップページ(2電子原子も含む新ボーア模型)
このプログラムは少し長いので、下に示すソースプログラムをコピーして、テキストエディタ(メモ帳など)にそのまま貼り付けて、コンパイルすれば簡単に実行できる。
このプログラムの class file name は methan22 なので、このデキストエディタを "methan22.java" のファイル名で保存してコンパイルしてほしい。
このプログラムでは、原子核は灰色の円で示してある。
各粒子は、x-y (左)、x-z (まん中)、y-z (右)平面に表示される。
ここでは、新しい単位として ( 1 MM = 10-14 meter) を使っている。
テキストボックス内の電子の各座標 (+X (MM), +Y (MM), +Z (MM)) は、これらの原子核からの”相対的な”位置座標を示している。
(ele 0-3 は炭素原子核からの、 ele 4 は 水素原子核 0 (H0)からの、ele5 はH1 からの、ele6 は H2 からの、ele7 は H3 からの相対座標である。)
電子4 (ele4) のみの座標 (+X, +Y, +Z) を自由に変更することができる。
(ele4 のテキストボックス内に値を入力して、Enter キーを押せばいい。他の粒子はそれをもとに変更される。)
"nuc (MM)" はこれらの核と電子の距離である。
V (eV) と T (eV) は各電子の位置エネルギーと運動エネルギーを示している。
tV (eV) は全位置エネルギーである。
ele 0-3 の CF は、中心方向への力を意味し、ele 4-7 のCF は 各 C-H line 方向への力(= C-H line に垂直な力)を意味する。
(fx, fy, fz) は CF を除いた残りの力の成分を意味する。
(FX, FY, FZ) は各原子核に作用する力の成分を意味する。
H0 核の Cn は C 核方向への力の成分を意味する。
(このプログラムでは、2つの原子核 (H0, H2) の情報のみ示される。)
Waves (wn) は1軌道に含まれるド。ブロイ波の数を示している。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Scanner;
public class methan22 extends JPanel // virial theorem of CH4 (second version)
{
public static void main(String arg[])
{
JFrame frame = new JFrame("CH4 (methane) -2"); // 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=5200.0*5200.0; // suh=(Bohr radius)^2
// textboxes: elp[0-7][]=electrons, mmpho[0-2][]=C,H0,H2 nuclei, impho=total V (eV)
JTextField elp[][]=new JTextField[8][11]; JTextField impho=new JTextField(7);
JTextField mmpho[][]=new JTextField[3][4];
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]; double den=4.23; // den= central positive charge
double hpr2[][]=new double[8][11]; // hpr=each electron's parameters
double hen3=10900.0; // 10900 = C-H distance (MM)
double hen1=(hen3*rsi)/3; double hen2=hen1/rtw; double cka=12500.0;
// nux[0][0-2]=coordinates of C nucleus
// nux[1][0-2]=coordinates of H0 nucleus
// nux[2][0-2]=coordinates of H1 nucleus
// nux[3][0-2]=coordinates of H2 nucleus
// nux[4][0-2]=coordinates of H3 nucleus
double nux[][]={{cka,cka,cka}, {cka+hen1, cka, cka+hen2}, {cka-hen1, cka, cka+hen2},
{cka, cka+hen1, cka-hen2},{cka, cka-hen1, cka-hen2}};
// te1=initial coordinates of eight electrons
double ina1=5260.426; double ina2=ina1/rtw;
double te1[][]={{ -ina1, 0, -ina2},{ina1, 0, -ina2},
{0, -ina1, ina2},{0, ina1, ina2},
{-838, -3530, -2000}, {837, 3530, -2000},
{3530, -838, 2000}, {-3530, 837, 2000}};
public J2DPanel()
{
setBackground(Color.black);
JPanel p=new JPanel();
p.setLayout(new GridLayout(11,12));
int aaa=0;
for (int el=0; el <=7; el++) {
for (int pos=0; pos <=2; pos++) { // hpr[][0-2]=each electron's coordinate
elp[el][pos]=new JTextField(7);
// we can input the values only in electron 4's textboxes
if (el==4) {elp[el][pos].addActionListener(this);}
hpr[el][pos]=0.0;
}}
for (int el=0; el <=7; el++) {
for (int pos=3; pos <=10; pos++) { // hpr[][3-10]=electron's other parameters
elp[el][pos]=new JTextField(7);
hpr[el][pos]=0.0;
}}
for (int el=0; el <=2; el++) { // mmpho[0-2][]=C, H0 and H2 nuc's parameters
for (int pos=0; pos <=3; 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]));
}
for (int el=0; el <=7; el++) {
if (el != 4) {
p.add(new Label(" "+el+" "));}
if (el==4) {p.add(new Label("ele 4"));}
for (int pos=0; pos <=10; pos++) {
p.add(elp[el][pos]);
}}
p.add(new Label("C nuc "));
for (int pos=0; pos <=3; pos++) {
p.add(mmpho[0][pos]);
}
p.add(new Label("H0nuc "));
for (int pos=0; pos <=3; pos++) {
p.add(mmpho[1][pos]);
}
for (int pos=0; pos <=1; pos++) {
p.add(new Label(" -- "));
}
p.add(new Label("H2nuc "));
for (int pos=0; pos <=3; pos++) {
p.add(mmpho[2][pos]);
}
p.add(impho);
for (int pos=0; pos <=5; pos++) {
p.add(new Label(" -- "));
}
add(p,"South");
for (int el=0; el <=7; 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("nuc "+Integer.toString(aaa)); // show distance between nuclei and electrons
for (int jou=0; jou <=2; jou++) {
hpr[el][jou]=te1[el][jou];
if (el < 4) {hpr[el][jou]=hpr[el][jou]+nux[0][jou];}
if (el==4) {hpr[el][jou]=hpr[el][jou]+nux[1][jou];}
if (el==5) {hpr[el][jou]=hpr[el][jou]+nux[2][jou];}
if (el==6) {hpr[el][jou]=hpr[el][jou]+nux[3][jou];}
if (el==7) {hpr[el][jou]=hpr[el][jou]+nux[4][jou];}
elp[el][jou].setText(Integer.toString((int)(te1[el][jou])));
}}
} // public J2DPanel() end
public void actionPerformed(ActionEvent e) {
String ss;
int RR=0; double Rf1,Rf2; int teis=0;
for (int el=0; el <=3; el++) {
for (int jou=0; jou <=2; jou++) {
hpr[el][jou]=te1[el][jou];
hpr[el][jou]=hpr[el][jou]+nux[0][jou];
elp[el][jou].setText(Integer.toString((int)(te1[el][jou])));
}}
teis=0;
// when electron's 4 positions change
for (int sws=0; sws <=2; sws++) {
ss=elp[4][sws].getText(); Rf1=Double.parseDouble(ss);
// change relative coordinate to absolute coordinate
Rf2=Rf1+nux[1][sws]; hpr[4][sws]=Rf2;
// upper and lower limits of coordinates
// if (Rf2 > 24999 ) {Rf2=24999; teis=1; hpr[4][sws]=Rf2;}
if (Rf2 < nux[0][sws] && sws !=1) {Rf2=nux[0][sws]+500.0; teis=1; hpr[4][sws]=Rf2;}
if (Rf2 < 1) {Rf2=1; teis=1; hpr[4][sws]=Rf2;}
Rf1=Rf2-nux[1][sws];
if (teis==1) {elp[4][sws].setText(Integer.toString((int)(Rf1)));}
}
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,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}};
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}};
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}};
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 nuckan=0.0;
kro2=0.0 ; krr2=0.0; krk2=0.0; kwr2=0.0; kww2=0.0;
//---------- calculation each coordinate based on electron 4
hpr[5][0]=-(hpr[4][0]-nux[0][0])+nux[0][0];
hpr[5][1]=-(hpr[4][1]-nux[0][1])+nux[0][1];
hpr[5][2]=hpr[4][2];
hpr[6][0]=-(hpr[4][1]-nux[0][1])+nux[0][0];
hpr[6][1]=(hpr[4][0]-nux[0][0])+nux[0][1];
hpr[6][2]=-(hpr[4][2]-nux[0][2])+nux[0][2];
hpr[7][0]=+(hpr[4][1]-nux[0][1])+nux[0][0];
hpr[7][1]=-(hpr[4][0]-nux[0][0])+nux[0][1];
hpr[7][2]=-(hpr[4][2]-nux[0][2])+nux[0][2];
for (int yp=1; yp <=3; yp++) { // set hpr [5-7][0-2] = ele 5-7 coordinates
for (int kj=0; kj <=2; kj++) {
ex=(int)(hpr[4+yp][kj]-nux[1+yp][kj]);
elp[yp+4][kj].setText(Integer.toString(ex));
}}
for (int yp=0; yp <=3; yp++) { // hpr [0-3][0-2] = ele 0-3 coordinates don't change
for (int kj=0; kj <=2; kj++) {
ex=(int)(hpr[yp][kj]-nux[0][kj]);
elp[yp][kj].setText(Integer.toString(ex));
}}
double vvh[][]=new double[4][4];
// calculate hpr2[4-7][] = symmetric positions of ele4-7 with respect to C-H lines
for (int yp=4; yp <=7; yp++) {
for (int kj=0; kj <=2; kj++) {
vvh[0][kj]=nux[yp-3][kj]-nux[0][kj]; vvh[1][kj]=hpr[yp][kj]-nux[0][kj];
}
vvh[0][3]=Math.sqrt(vvh[0][0]*vvh[0][0]+vvh[0][1]*vvh[0][1]+vvh[0][2]*vvh[0][2]);
vvh[2][3]=(vvh[1][0]*vvh[0][0]+vvh[1][1]*vvh[0][1]+vvh[1][2]*vvh[0][2])/vvh[0][3];
for (int kj=0; kj <=2; kj++) {
vvh[2][kj]=(vvh[0][kj]*vvh[2][3])/vvh[0][3];
hpr2[yp][kj]=hpr[yp][kj]+2*(vvh[2][kj]-vvh[1][kj]);
}
}
toav=0.0; // toav=total potential energy
double ppot;
for (int yp=0; yp <=3; yp++) { // interaction between electrons 0-3
for (int kj=0; kj <=3; 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;} // rhp[][3]=each electron's potential energy
ppot=(elc*elc*6.241509e18)/(4*pai*epsi*kro*1.0e-14);
rhp[yp][3]=rhp[yp][3]+ppot/2.0; rhp[kj][3]=rhp[kj][3]+ppot/2.0;
toav=toav+ppot;
// teqq[][3]=each electron's V only in carbon 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[][0-2]=force component of each electron
// teqq[][0-2]=force component of electrons only in carbon atom
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;
}
}}}
for (int yp=0; yp <=3; yp++) { // interaction between electron 0-3 and electron 4-7
for (int kj=4; 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]));
// kro2= distance between ele0-3 and symmetric positions(=hpr2) of ele4-7
kro2=Math.sqrt((hpr[yp][0]-hpr2[kj][0])*(hpr[yp][0]-hpr2[kj][0])+
(hpr[yp][1]-hpr2[kj][1])*(hpr[yp][1]-hpr2[kj][1])+
(hpr[yp][2]-hpr2[kj][2])*(hpr[yp][2]-hpr2[kj][2]));
if (kro==0) {kro=5000.0;} if (kro2==0) {kro2=5000.0;}
ppot=(elc*elc*6.241509e18*0.5*(1.0/kro+1.0/kro2))/(4*pai*epsi*1.0e-14);
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*0.5*(hpr[yp][jou]-hpr[kj][jou]))/(kro*kro*kro);
ggy=(suh*0.5*(hpr[yp][jou]-hpr2[kj][jou]))/(kro2*kro2*kro2);
rhp[yp][jou]=rhp[yp][jou]+ggx+ggy; rhp[kj][jou]=rhp[kj][jou]-ggx*2.0;
// rpp[0-3][0-2]=force component of ele0-3 influenced only by C,H0-3 nuc, and ele4-7
rpp[yp][jou]=rpp[yp][jou]+ggx+ggy;
}
}}
for (int yp=4; yp <=7; yp++) { // interaction between electrons 4-7
for (int kj=4; 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*pai*epsi*kro*1.0e-14);
rhp[yp][3]=rhp[yp][3]+ppot/2; rhp[kj][3]=rhp[kj][3]+ppot/2;
toav=toav+ppot;
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;
}
}}}
// interaction between electron and each nucleus
for (int rv=0; rv <=7; rv++) {
// -------------------- C nucleus
kro=Math.sqrt((hpr[rv][0]-nux[0][0])*(hpr[rv][0]-nux[0][0])+
(hpr[rv][1]-nux[0][1])*(hpr[rv][1]-nux[0][1])+
(hpr[rv][2]-nux[0][2])*(hpr[rv][2]-nux[0][2])); kro2=5000.0;
if (kro == 0) {kro=5000.0;}
// kro2= distance between C nucleus and symmetric positions(=hpr2) of ele4-7
if (rv > 3) { kro2=Math.sqrt((hpr2[rv][0]-nux[0][0])*(hpr2[rv][0]-nux[0][0])+
(hpr2[rv][1]-nux[0][1])*(hpr2[rv][1]-nux[0][1])+
(hpr2[rv][2]-nux[0][2])*(hpr2[rv][2]-nux[0][2]));
if (kro2 == 0) {kro2=5000.0;}
}
pot =-den/kro; if (rv > 3) { pot=(-den/kro-den/kro2)*0.5; }
// show distance between C nuc and ele 0-3
// teqq[][3]=potential energy of each electron only in carbon atom
if (rv < 4) {ex=(int)(kro); elp[rv][3].setText("nuc "+Integer.toString(ex));
teqq[rv][3]=teqq[rv][3]+(elc*elc*6.241509e18*pot)/(4*pai*epsi*1.0e-14);
}
for (int kj=0; kj <=2; kj++) {
ggx=(suh*den*(hpr[rv][kj]-nux[0][kj]))/(kro*kro*kro); ggy=0.0;
rhp[rv][kj]=rhp[rv][kj]-ggx;
if (rv > 3) {ggx=ggx*0.5; ggy=(suh*den*0.5*(hpr2[rv][kj]-nux[0][kj]))/(kro2*kro2*kro2);}
mmp[0][kj]=mmp[0][kj]+ggx+ggy;
// mmp[0][0-2]= force component of carbon nucleus
// rpp[0-3][0-2]=force component of ele0-3 influenced only by C,H0-3 nuc, and ele4-7
// teqq[][0-2]=force component of each electron only in carbon atom
if (rv < 4) {rpp[rv][kj]=rpp[rv][kj]-ggx;
teqq[rv][kj]=teqq[rv][kj]-ggx;}
}
// ----------------------- H0 nucleus
krr=Math.sqrt((hpr[rv][0]-nux[1][0])*(hpr[rv][0]-nux[1][0])+
(hpr[rv][1]-nux[1][1])*(hpr[rv][1]-nux[1][1])+
(hpr[rv][2]-nux[1][2])*(hpr[rv][2]-nux[1][2]));
if (krr ==0) {krr=5000.0;}
if (rv > 3) { krr2=Math.sqrt((hpr2[rv][0]-nux[1][0])*(hpr2[rv][0]-nux[1][0])+
(hpr2[rv][1]-nux[1][1])*(hpr2[rv][1]-nux[1][1])+
(hpr2[rv][2]-nux[1][2])*(hpr2[rv][2]-nux[1][2]));
if (krr2 == 0) {krr2=5000.0;}
}
pota=-1.0/krr; if (rv > 3) {pota=(-1.0/krr-1.0/krr2)*0.5; }
// show distance between electron 4 and H0 nucleus
if (rv==4) {ex=(int)(krr); elp[rv][3].setText("nuc "+Integer.toString(ex));}
for (int kj=0; kj <=2; kj++) {
ggx=(suh*(hpr[rv][kj]-nux[1][kj]))/(krr*krr*krr);
rhp[rv][kj]=rhp[rv][kj]-ggx;
// mmp[1][0-2]=force component of H0 nucleus
if (rv < 4) {mmp[1][kj]=mmp[1][kj]+ggx; }
if (rv > 3) {mmp[1][kj]=mmp[1][kj]+ggx*0.5+(suh*0.5*(hpr2[rv][kj]-nux[1][kj]))/(krr2*krr2*krr2);}
if (rv < 4) {rpp[rv][kj]=rpp[rv][kj]-ggx; }
}
// --------------------- H1 nucleus
krk=Math.sqrt((hpr[rv][0]-nux[2][0])*(hpr[rv][0]-nux[2][0])+
(hpr[rv][1]-nux[2][1])*(hpr[rv][1]-nux[2][1])+
(hpr[rv][2]-nux[2][2])*(hpr[rv][2]-nux[2][2]));
if (krk ==0) {krk=5000.0;}
if (rv > 3) { krk2=Math.sqrt((hpr2[rv][0]-nux[2][0])*(hpr2[rv][0]-nux[2][0])+
(hpr2[rv][1]-nux[2][1])*(hpr2[rv][1]-nux[2][1])+
(hpr2[rv][2]-nux[2][2])*(hpr2[rv][2]-nux[2][2]));
if (krk2 ==0) {krk2=5000.0;}
}
potb=-1.0/krk; if (rv > 3) {potb=(-1.0/krk-1.0/krk2)*0.5; }
// show distance between electron 5 and H1 nucleus
if (rv==5) {ex=(int)(krk); elp[rv][3].setText("nuc "+Integer.toString(ex));}
for (int kj=0; kj <=2; kj++) {
ggx=(suh*(hpr[rv][kj]-nux[2][kj]))/(krk*krk*krk);
rhp[rv][kj]=rhp[rv][kj]-ggx;
if (rv < 4) {rpp[rv][kj]=rpp[rv][kj]-ggx;}
}
// ------------- H2 nucleus
kwr=Math.sqrt((hpr[rv][0]-nux[3][0])*(hpr[rv][0]-nux[3][0])+
(hpr[rv][1]-nux[3][1])*(hpr[rv][1]-nux[3][1])+
(hpr[rv][2]-nux[3][2])*(hpr[rv][2]-nux[3][2]));
if (kwr ==0) {kwr=5000.0;}
if (rv > 3) { kwr2=Math.sqrt((hpr2[rv][0]-nux[3][0])*(hpr2[rv][0]-nux[3][0])+
(hpr2[rv][1]-nux[3][1])*(hpr2[rv][1]-nux[3][1])+
(hpr2[rv][2]-nux[3][2])*(hpr2[rv][2]-nux[3][2]));
if (kwr2 ==0) {krk2=5000.0;}
}
potc=-1.0/kwr; if (rv > 3) {potc=(-1.0/kwr-1.0/kwr2)*0.5; }
// show distance between electron 6 and H2 nucleus
if (rv==6) {ex=(int)(kwr); elp[rv][3].setText("nuc "+Integer.toString(ex));}
for (int kj=0; kj <=2; kj++) {
ggx=(suh*(hpr[rv][kj]-nux[3][kj]))/(kwr*kwr*kwr);
// mmp[2][0-2]=force component of H2 nucleus
if (rv < 4) {mmp[2][kj]=mmp[2][kj]+ggx;}
if (rv > 3) {mmp[2][kj]=mmp[2][kj]+ggx*0.5+(suh*0.5*(hpr2[rv][kj]-nux[3][kj]))/(kwr2*kwr2*kwr2);}
rhp[rv][kj]=rhp[rv][kj]-ggx;
if (rv < 4) {rpp[rv][kj]=rpp[rv][kj]-ggx; }
}
// ----------------------- H3 nucleus
kww=Math.sqrt((hpr[rv][0]-nux[4][0])*(hpr[rv][0]-nux[4][0])+
(hpr[rv][1]-nux[4][1])*(hpr[rv][1]-nux[4][1])+
(hpr[rv][2]-nux[4][2])*(hpr[rv][2]-nux[4][2]));
if (kww ==0) {kww=5000.0;}
if (rv > 3) { kww2=Math.sqrt((hpr2[rv][0]-nux[4][0])*(hpr2[rv][0]-nux[4][0])+
(hpr2[rv][1]-nux[4][1])*(hpr2[rv][1]-nux[4][1])+
(hpr2[rv][2]-nux[4][2])*(hpr2[rv][2]-nux[4][2]));
if (kww2 ==0) {kww2=5000.0;}
}
potd=-1.0/kww; if (rv > 3) {potd=(-1.0/kww-1.0/kww2)*0.5; }
// show distance between electron 7 and H3 nucleus
if (rv==7) {ex=(int)(kww); elp[rv][3].setText("nuc "+Integer.toString(ex));}
for (int kj=0; kj <=2; kj++) {
ggx=(suh*(hpr[rv][kj]-nux[4][kj]))/(kww*kww*kww);
rhp[rv][kj]=rhp[rv][kj]-ggx;
if (rv < 4) {rpp[rv][kj]=rpp[rv][kj]-ggx; }
}
// ttav=potential energy between one electron and three nuclei
ttav= (elc*elc*6.241509e18*(pot+pota+potb+potc+potd))/(4*pai*epsi*1.0e-14);
rhp[rv][3]=rhp[rv][3]+ttav; toav=toav+ttav;
// rhp[0-7][5]=interaction between each electron and other nuclei
if (rv < 4) {rhp[rv][5]=(elc*elc*6.241509e18*(pota+potb+potc+potd))/(4*pai*epsi*1.0e-14);}
if (rv == 4) {rhp[rv][5]=(elc*elc*6.241509e18*(pot+potb+potc+potd))/(4*pai*epsi*1.0e-14);}
if (rv == 5) {rhp[rv][5]=(elc*elc*6.241509e18*(pot+pota+potc+potd))/(4*pai*epsi*1.0e-14);}
if (rv == 6) {rhp[rv][5]=(elc*elc*6.241509e18*(pot+pota+potb+potd))/(4*pai*epsi*1.0e-14);}
if (rv == 7) {rhp[rv][5]=(elc*elc*6.241509e18*(pot+pota+potb+potc))/(4*pai*epsi*1.0e-14);}
}
// hen3=distance between C and H nuclei
kro=hen3; // forc=force between C and H nuclei
double forc=(suh*den)/(kro*kro)+(suh*rsi)/(4.0*hen1*hen1);
for (int rv=0; rv <=1; rv++) {
for (int kj=0; kj <=2; kj++) {
mmp[rv+1][kj]=mmp[rv+1][kj]+(forc*(nux[rv*2+1][kj]-nux[0][kj]))/kro;
}}
// nuckan=repulsive potential energy between 4 nuclei
nuckan=(elc*elc*6.241509e18*((4.0*rsi*den)/(3.0*hen1)+3.0/hen1))/(4*pai*epsi*1.0e-14);
toav=toav+nuckan;
ex=(int)(toav*100.0); ggx=ex/100.0;
impho.setText("tV "+Double.toString(ggx)); // show total V to two decimal places
for (int rv=0; rv <=3; rv++) { // show force component of electron 0-3
// CF=force toward rpp[][0-2] = inner product of rhp anf rpp
gx=Math.sqrt(rpp[rv][0]*rpp[rv][0]+rpp[rv][1]*rpp[rv][1]+rpp[rv][2]*rpp[rv][2]);
gy=(rhp[rv][0]*rpp[rv][0]+rhp[rv][1]*rpp[rv][1]+rhp[rv][2]*rpp[rv][2])/gx;
ex=(int)(1000*gy); ww="CF ";
elp[rv][6].setText(ww+Integer.toString(ex));
for (int jou=0; jou <=2; jou++) {
gz=rhp[rv][jou]-(gy*rpp[rv][jou])/gx; // show force component other than CF
ex=(int)(1000*gz);
elp[rv][jou+7].setText(Integer.toString(ex));
}
}
for (int rv=4; rv <=7; rv++) { // show force component of electron 0-3
for (int jou=0; jou <=2; jou++) {
vvh[0][jou]=nux[rv-3][jou]-nux[0][jou]; vvh[1][jou]=hpr[rv][jou]-nux[0][jou];
}
vvh[0][3]=Math.sqrt(vvh[0][0]*vvh[0][0]+vvh[0][1]*vvh[0][1]+vvh[0][2]*vvh[0][2]);
// vvh[2][3] = inner product of vectors vvh[0][] and vvh[1][]
vvh[2][3]=(vvh[0][0]*vvh[1][0]+vvh[0][1]*vvh[1][1]+vvh[0][2]*vvh[1][2])/vvh[0][3];
for (int jou=0; jou <=2; jou++) {
vvh[2][jou]=(vvh[2][3]*vvh[0][jou])/vvh[0][3];
vvh[3][jou]=vvh[2][jou]-vvh[1][jou]; // vvh[3][0-2]= vector from electron 4-7 to C-H line
}
vvh[3][3]=Math.sqrt(vvh[3][0]*vvh[3][0]+vvh[3][1]*vvh[3][1]+vvh[3][2]*vvh[3][2]);
// gy (CF) = force toward C-H line of electron 4-7 = inner product of rhp and vvh[3]
gy=(rhp[rv][0]*vvh[3][0]+rhp[rv][1]*vvh[3][1]+rhp[rv][2]*vvh[3][2])/vvh[3][3];
gx=Math.sqrt(gy*gy); elp[rv][6].setText("CF "+Integer.toString((int)(gx*1000)));
for (int jou=0; jou <=2; jou++) {
ggz=rhp[rv][jou]-(vvh[3][jou]*gy)/vvh[3][3];
ex=(int)(1000*ggz);
// show force component other than CF
elp[rv][jou+7].setText(Integer.toString(ex));
}
}
// show force toward C nucleus
for (int rv=0; rv <=1; rv++) {
mmp[rv+1][3]=-(mmp[rv+1][0]*(nux[rv*2+1][0]-nux[0][0])+
mmp[rv+1][1]*(nux[rv*2+1][1]-nux[0][1])+mmp[rv+1][2]*(nux[rv*2+1][2]-nux[0][2]))/hen3;
}
for (int rv=0; rv <=2; rv++) {
for (int jou=0; jou <=3; jou++) { // show mmpho[0-2][0-3]
ex=(int)(1000*mmp[rv][jou]); ww=" ";
if (rv==0 && jou > 2) {ex=0;}
if (jou==0) {ww="FX=";} if (jou==1) {ww="FY=";}
if (jou==2) {ww="FZ=";} if (jou==3 && rv !=0) {ww="Cn=";}
mmpho[rv][jou].setText(ww+Integer.toString(ex));
}}
double hiwa=0.0;
for (int rv=0; rv <=7; rv++) { hiwa=hiwa+rhp[rv][5]; }
for (int rv=0; rv <=7; rv++) {
// distribute repulsive potential energy between 4 nuclei to each electron
rhp[rv][3]=rhp[rv][3]+(nuckan*rhp[rv][5])/hiwa;
ex=(int)(100*rhp[rv][3]); ggx=ex/100.0;
elp[rv][4].setText("V "+Double.toString(ggx)); // show each V to two decimal places
}
gy=-toav*0.5; // gy=total kinetic energy (eV)
// distribute kinetic energy to each electron based on rhp[][3] (=V)
for (int rv=0; rv <=7; rv++) {
gz=(gy*rhp[rv][3])/toav; rhp[rv][4]=gz;
ex=(int)(100*gz); gz=ex/100.0; elp[rv][5].setText("T "+Double.toString(gz));
}
for (int rv=0; rv <=7; rv++) { // show de Broglie wave of each electron
// gz = force acting on each electron
gz=Math.sqrt(rhp[rv][0]*rhp[rv][0]+rhp[rv][1]*rhp[rv][1]+rhp[rv][2]*rhp[rv][2]);
if (rv < 4 ) { // teqq[0-3][0-2]= force only in carbon atom in electron 0-3
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)
gx=Math.sqrt((2*rhp[rv][4]*1.602177e-19)/me); // gx=velocity (m/s)
if (rv < 4) {gx=Math.sqrt((-teqq[rv][3]*1.602177e-19)/me);} // only in carbon atom
ggx=(me*gx*gx)/gy; // ggx="temporary" radius
ggy=(2*pai*ggx*me*gx)/h; // ggy=number of de Broglie's waves contained in one orbit
ex=(int)(ggy*1000); ggy=ex/1000.0;
elp[rv][10].setText("wn "+Double.toString(ggy));
}
// --------------------- show picture
int nmx[][]=new int[5][3]; int hpk[][]=new int[8][3];
for (int yp=0; yp <=4; 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 <=7; 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] > 349) {hpk[yp][kj]=349;}
if (hpk[yp][kj] < 1) {hpk[yp][kj]=1;}
}}
g.clearRect(9,299,1170,699);
g.setColor(Color.cyan); g.drawLine(375,310,375,660); g.drawLine(735,310,735,660);
g.setColor(Color.yellow);
for (int rv=0; rv <=3; rv++) {
g.drawLine(hpk[rv][0]+20,660-hpk[rv][1],nmx[0][0]+20,660-nmx[0][1]);
g.drawLine(hpk[rv][0]+380,660-hpk[rv][2],nmx[0][0]+380,660-nmx[0][2]);
g.drawLine(hpk[rv][1]+740,660-hpk[rv][2],nmx[0][1]+740,660-nmx[0][2]);
}
g.setColor(Color.white); // show electron 0 (particle)
g.fillOval(hpk[0][0]+13,653-hpk[0][1],14,14);
g.fillOval(hpk[0][0]+373,653-hpk[0][2],14,14);
g.fillOval(hpk[0][1]+733,653-hpk[0][2],14,14);
// show electron 1
g.fillOval(hpk[1][0]+13,653-hpk[1][1],14,14);
g.fillOval(hpk[1][0]+373,653-hpk[1][2],14,14);
g.fillOval(hpk[1][1]+733,653-hpk[1][2],14,14);
g.setColor(Color.red); // show electron 2
g.fillOval(hpk[2][0]+13,653-hpk[2][1],14,14);
g.fillOval(hpk[2][0]+373,653-hpk[2][2],14,14);
g.fillOval(hpk[2][1]+733,653-hpk[2][2],14,14);
// show electron 3
g.fillOval(hpk[3][0]+13,653-hpk[3][1],14,14);
g.fillOval(hpk[3][0]+373,653-hpk[3][2],14,14);
g.fillOval(hpk[3][1]+733,653-hpk[3][2],14,14);
// show electron 4
g.setColor(Color.green);
g.fillOval(hpk[4][0]+13,653-hpk[4][1],14,14);
g.fillOval(hpk[4][0]+373,653-hpk[4][2],14,14);
g.fillOval(hpk[4][1]+733,653-hpk[4][2],14,14);
// show electron 5
g.fillOval(hpk[5][0]+13,653-hpk[5][1],14,14);
g.fillOval(hpk[5][0]+373,653-hpk[5][2],14,14);
g.fillOval(hpk[5][1]+733,653-hpk[5][2],14,14);
// show electron 6
g.setColor(Color.pink);
g.fillOval(hpk[6][0]+13,653-hpk[6][1],14,14);
g.fillOval(hpk[6][0]+373,653-hpk[6][2],14,14);
g.fillOval(hpk[6][1]+733,653-hpk[6][2],14,14);
// show electron 7
g.fillOval(hpk[7][0]+13,653-hpk[7][1],14,14);
g.fillOval(hpk[7][0]+373,653-hpk[7][2],14,14);
g.fillOval(hpk[7][1]+733,653-hpk[7][2],14,14);
g.setColor(Color.lightGray); // show five nuclei
for (int yp=0; yp <=4; yp++) {
g.fillOval(nmx[yp][0]+10,650-nmx[yp][1],20,20);g.fillOval(370+nmx[yp][0],650-nmx[yp][2],20,20);
g.fillOval(730+nmx[yp][1],650-nmx[yp][2],20,20);
}
g.setColor(Color.blue); // show each particle's number
for (int rw=0; rw <=7; rw++) {
g.drawString(Integer.toString(rw),hpk[rw][0]+17,665-hpk[rw][1]);
g.drawString(Integer.toString(rw),hpk[rw][0]+377,665-hpk[rw][2] );
g.drawString(Integer.toString(rw),hpk[rw][1]+737,665-hpk[rw][2] );
}
for (int rw=1; rw <=4; rw++) {
g.drawString("H"+Integer.toString(rw-1),nmx[rw][0]+13,665-nmx[rw][1]);
g.drawString("H"+Integer.toString(rw-1),nmx[rw][0]+373,665-nmx[rw][2] );
g.drawString("H"+Integer.toString(rw-1),nmx[rw][1]+733,665-nmx[rw][2] );
}
}
}