import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.Scanner; public class twoion extends JPanel /* various combination of two atoms */ { public static void main(String arg[]) { JFrame frame = new JFrame("Two-atoms, ioons +4group"); /* 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[8][11]; /* electron text */ JTextField eln[]=new JTextField[8]; JTextField impho=new JTextField(7); /* total V text */ JTextField mmpho[][]=new JTextField[2][4]; /* nucleus text */ /* imppo = distance (= nuc ) between electron and nucleus text */ JTextField imppo=new JTextField(7); JTextField naibua=new JTextField(7); JTextField naibub=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("Atom A"); JButton b8=new JButton("Atom B"); JButton b9=new JButton("internuc"); JButton bb1=new JButton("nuc"); JButton bb2=new JButton("charge Z"); JButton bb3=new JButton("ele No."); JButton bb4=new JButton("+X (MM)"); JButton bb5=new JButton(" A nuc "); JButton bb6=new JButton(" B nuc "); JButton bb7=new JButton(" angle "); String aato[]={"H","Be","B","C","O","N","F","Ne", "Na", "Mg", "Al", "Si","S","P","Cl", "K", "Ca", "Ti", "Se", "Br", "Kr", "Na+","Mg2+","Al3+","K+","Ca2+","Cr","Cr2+","Mn", "Mn2+", "Fe", "Fe2+", "Fe3+","Co","Co+","Ni", "Ni2+", "Cu", "Cu+", "Cu2+", "Zn", "Zn2+"}; String bato[]= {"H","Be","B","C","O","N","F","Ne", "Na", "Mg", "Al", "Si","S","P","Cl", "K", "Ca", "Ti", "Se", "Br", "Kr", "Na+","Mg2+","Al3+","K+","Ca2+","Cr","Cr2+","Mn", "Mn2+", "Fe", "Fe2+", "Fe3+","Co","Co+","Ni", "Ni2+", "Cu", "Cu+", "Cu2+", "Zn", "Zn2+"}; 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; int page[]={0,0,0}; /* kade[0, 1] = number of valence electrons in A and B */ int kade[]={4,4}; int kin[]={3,3}; double rtw=Math.sqrt(2); double rth=Math.sqrt(3); double rsi=Math.sqrt(6); double rfi=Math.sqrt(5); double ele[][][]=new double[2][18][11]; // parameters of atoms 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, 1}, {intnuc, 0, 0, 4.22, 1}}; // te0=initial coodinate of hydrogen double te0[][]={{0, 0, 4500}, {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}}; double henss=4596; double henrr=4596/rtw; // te2=initial coordinate of oxygen double te2[][]={{henrr, henrr, 0}, {henrr, -henrr, 0.0}, {-henrr, henrr, 0}, {-henrr, -henrr, 0}, {0, 0, henss},{0, 0, -henss} }; // te3= initial coodinate of nitrogen double te3[][]={{-2666,4617.6, 0}, {-2666, -4617.6, 0}, {0, 0, 5332}, {5332, 0, 0}, {0, 0, -5332}}; // te4= initial coordinate of fluorine double te4[][]={{2537, -3047, 563}, {2537,3045, 563}, {-2537, 3047, 563}, {-2537, -3047, 563}, {0, 0, 4003}, {-2500, 0, -3127}, {2500, 0, -3127}}; double te5[][]={{10530,0, 0}, {-10530, 0, 0}}; double te6[][]={{8001, 0, 0}, {-4000.51, 6929.06, 0}, {-4000.51, -6929.06, 0}}; double nex=2919.45; double nez=2064.38; double te7[][]={{nex, 0, nez}, {0, nex, nez}, {-nex, 0, nez}, {0, -nex, nez}, {nex, 0, -nez}, {0, nex, -nez}, {-nex, 0, -nez}, {0, -nex, -nez}}; double te8[][]={{8474, 0, 0},{3058.28, -5588.18, -5588.18}, {3058.28, 5588.18, -5588.18}, {3058.28, 5588.18, 5588.18}, {3058.28, -5588.18, 5588.18}, {-5177.54, 0, 6708.33}, {-5177.54, -6708.33, 0}, {-5177.54, 0, -6708.33}, {-5177.54, 6708.33, 0} }; double te10[][]={{7165, 0, 0},{2800.33, 6595.1, 0}, {2800.33, 2037.88, 6272.35}, {2800.33, -5335.57, 3876.46}, {2800.33, -5335.57, -3876.46}, {2800.33, 2037.88, -6272.35}, {-4234.18, -5780.04, 0}, {-4234.18, -1786.01, -5497.18}, {-4234.18, 4676.15, -3397.42}, {-4234.18, 4676.15, 3397.42}, {-4234.18, -1786.12, 5497.14} }; double te11[][]={{5485.06, -3772.22, 0}, {5485.06, 1886.05, -3266.87}, {5485.06, 1886.05, 3266.87}, {590.7, 6630.73, 0}, {590.7, 2048.86, 6306.24}, {590.7, -5364.39, 3897.42}, {590.7, -5364.39, -3897.42}, {590.7, 2048.86, -6306.24}, {-4852.16, 3222.74, 3222.74}, {-4852.16, -3222.74, 3222.74}, {-4852.16, -3222.74, -3222.74}, {-4852.16, 3222.74, -3222.74} }; double te12[][]={ {500, 3000, 0}, {500, 927.051, 2853.17}, {500, -2427.05, 1763.356}, {500, -2427.051, -1763.356}, {500, 927.051, -2853.17}, {0, 3000, 0}, {0, 1500, 2598.07}, {0, -1500, 2598.07}, {0, -3000, 0}, {0, -1500, -2598.07}, {0, 1500, -2598.07}, {-500, -3000, 0}, {-500, -927.051, -2853.17}, {-500, 2427.05, -1763.356}, {-500, 2427.051, 1763.356}, {-500, -927.051, 2853.17} }; double te13[][]={{3000, 0, 0}, {500, 3000, 0}, {500, 927.051, 2853.17}, {500, -2427.05, 1763.356}, {500, -2427.051, -1763.356}, {500, 927.051, -2853.17}, {0, 3000, 0}, {0, 1500, 2598.07}, {0, -1500, 2598.07}, {0, -3000, 0}, {0, -1500, -2598.07}, {0, 1500, -2598.07}, {-500, -3000, 0}, {-500, -927.051, -2853.17}, {-500, 2427.05, -1763.356}, {-500, 2427.051, 1763.356}, {-500, -927.051, 2853.17} }; double te14[][]={{2000, 2000, 0}, {2000, 0, 2000}, {2000, -2000, 0}, {2000, 0, -2000}, {0, 2000, 2000}, {0, -2000, 2000}, {0, -2000, -2000}, {0, 2000, -2000}, {-2000, 2000, 0}, {-2000, 0, 2000}, {-2000, -2000, 0}, {-2000, 0, -2000}, {2000, 0, 0}, {0, 2000, 0}, {0, 0, 2000}, {0, -2000, 0}, {0, 0, -2000}, {-2000,0,0} }; double te9[][]=new double[10][3]; int ten1[]={1, 4, 6, 5, 7, 2, 3, 8, 9, 10, 11, 12, 16, 17, 18 }; /* atom kind, number of valence electrons, te number */ int ten2[][]={{1,0}, {2, 5}, {3,6}, {4,1}, {6,2}, {5,3}, {7,4}, {8,7}, {1,0}, {2,5}, {3,6}, {4,1}, {6,2}, {5,3}, {7,4}, {1,0}, {2,5}, {4,1}, {6,2}, {7,4}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {6,2}, {4,1}, {7,4}, {5,3}, {8,7}, {6,2}, {5,3}, {9,8}, {8,7}, {10,9}, {8,7}, {11,10}, {10,9}, {9,8}, {12,11}, {10,9} }; /* atom kind, total ionization energies */ double ten3[]={ 13.606, 27.5, 71.4215, 148.025, 433.107, 266.948, 658.836, 953.705, 5.112, 22.65, 53.247, 103.132, 276.358, 176.929, 408.88, 4.346, 17.965, 91.105, 254.43, 368.14, 507.773, 1301.87, 1703.71, 2161.438, 769.17, 985.23, 263.468, 240.082, 395.14, 372.00, 559.66, 535.5, 504.77, 764.03 ,756.34, 1012.58 ,986.74, 1306.26 ,1298.55 ,1278.42, 1650.97, 1623.27 }; double tee[][][]=new double[15][18][3]; public J2DPanel() { setBackground(Color.black); JPanel p=new JPanel(); p.setLayout(new GridLayout(13,12)); String vv,zww; int aaa=0; double sx,sy,sz,px,py,pz; /* te9 = 10 electrons */ sx = 4000.0; sy =(sx*2.0)/rsi; sz=(sy*rsi)/6.0; px=sy/rth; py=2.0*px; double te99[][]={{sx, 0.0, 0.0}, {-sz, 0.0, py}, {-sz, -sy, -px}, {-sz, sy, -px}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0} }; for (int el=0; el <=2; el++) { for (int pos=0; pos <=2; pos++) { sx = (te99[0][pos]+te99[el+1][pos])/2.0; te99[4+el][pos]=sx; }} for (int el=1; el <=3; el++) { for (int pos=0; pos <=2; pos++) { int tug=el+1; if (el==3) {tug=1;} sx = (te99[el][pos]+te99[tug][pos])/2.0; te99[6+el][pos]=sx; }} for (int el=0; el <=9; el++) { for (int pos=0; pos <=2; pos++) { te9[el][pos]=te99[el][pos]; }} for (int el=0; el <=14; el++) { for (int pos=0; pos <=17; pos++) { for (int jou=0; jou <=2; jou++) { tee[el][pos][jou]=0.0; }}} sx=0.0; /* transfer "te" coordinates to "tee" */ for (int el=0; el <=14; el++) { for (int pos=0; pos <=ten1[el]-1; pos++) { for (int jou=0; jou <=2; jou++) { if (el==0) { sx= te0[pos][jou]; } if (el==1) { sx= te1[pos][jou]; } if (el==2) { sx= te2[pos][jou]; } if (el==3) { sx= te3[pos][jou]; } if (el==4) { sx= te4[pos][jou]; } if (el==5) { sx= te5[pos][jou]; } if (el==6) { sx= te6[pos][jou]; } if (el==7) { sx= te7[pos][jou]; } if (el==8) { sx= te8[pos][jou]; } if (el==9) { sx= te9[pos][jou]; } if (el==10) { sx= te10[pos][jou]; } if (el==11) { sx= te11[pos][jou]; } if (el==12) { sx= te12[pos][jou]; } if (el==13) { sx= te13[pos][jou]; } if (el==14) { sx= te14[pos][jou]; } tee[el][pos][jou]=sx; }}} for (int el=0; el <=7; el++) { for (int pos=0; pos <=2; pos++) { elp[el][pos]=new JTextField(7); elp[el][pos].addActionListener(this); } eln[el]=new JTextField(7); } for (int el=0; el <=7; el++) { /* other parameters of each electron */ for (int pos=3; pos <=10; pos++) { elp[el][pos]=new JTextField(7); }} for (int kn=0; kn <=1; kn++) { for (int el=0; el <=17; el++) { for (int pos=0; pos <=10; pos++) { ele[kn][el][pos]=0.0; }}} /* mmpho[0-2] = force components acting on nucleus */ for (int el=0; el <=1; el++) { for (int pos=0; pos <=3; 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[]={"+Y (MM)", "+Z (MM)", "nuc (MM)", "V (eV)", "Force", "fx ", "fy", "fz", "direw", "Waves "}; /* 1st line */ p.add(bb3); p.add(bb4); for (int el=0; el <=9; el++) { p.add(new Label(sihy[el])); } /* 2nd - 8th line */ for (int el=0; el <=7; el++) { p.add(eln[el]); for (int pos=0; pos <=10; pos++) { p.add(elp[el][pos]); }} /* 9th line */ p.add(bb5); for (int pos=0; pos <=3; pos++) { p.add(mmpho[0][pos]); } p.add(bb6); for (int pos=0; pos <=3; pos++) { p.add(mmpho[1][pos]); } 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(naibua); p.add(naibub); /* 12th line */ p.add(bb7); 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); bb3.addActionListener(this); bb4.addActionListener(this); bb5.addActionListener(this); bb6.addActionListener(this); bb7.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 <=7; el++) { vv=" "; if ( el < kade[abd] ) { vv="ele "+el;} eln[el].setText(vv); } for (int el=0; el <=7; el++) { double nnuc=0.0; if (el < kade[0] ) { 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++) { double coordi = 0.0; if ( el < kade[0]) { ele[0][el][jou]=te1[el][jou]+nux[0][jou]; ele[1][el][jou]=te1[el][jou]+nux[1][jou]; /* show initial coordinate */ aaa=(int)(100*te1[el][jou]); 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; int per=0; double perr1=0.0; double perr2=0.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++) { ele[1][ba][0] = ele[1][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=Math.sqrt((ele[abd][0][0]-nux[abd][0])*(ele[abd][0][0]-nux[abd][0])+ele[abd][0][1]*ele[abd][0][1]+ele[abd][0][2]*ele[abd][0][2] ); per=(int)(10*diam); perr1=per/10.0; imppo.setText(Double.toString(perr1)); } 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() == bb7 && kade[abd] > 7 ) { mar=15; page[2]=page[2]*-1+1; } /* angle display change */ /* Force acting on nucleus, only in each atom ? */ if (e.getSource() == bb5) { mar=13; if ( nux[0][4] > 0 ) { nux[0][4] = -1; mmpho[0][3].setText(" = A only"); } else { nux[0][4]= 1; mmpho[0][3].setText(" "); } } if (e.getSource() == bb6) { mar=14; if ( nux[1][4] > 0 ) { nux[1][4] = -1; mmpho[1][3].setText(" = B only"); } else { nux[1][4]= 1; mmpho[1][3].setText(" "); } } /* electron text page change */ if (e.getSource() == bb3 ) { mar=11; if ( kade[abd] > 8 ) {page[0]=page[0]*-1 + 1 ;} else { page[0]=0; } } /* electron manipulation change */ if (e.getSource() == bb4 ) { mar=12; if ( page[1] == 1) {page[1]=0;} else { page[1]=1; } } int att=0; int sih=0; if (e.getSource() == b7) { mar=17; /* atom A change */ ss=(String)coom.getSelectedItem(); } if (e.getSource() == b8) { mar=18; /* atom B change */ ss=(String)coomm.getSelectedItem(); } if ( mar==17 || mar==18 ) { if (ss=="H") {saia=1.0; saik=1; diam=4500; per=0; } if (ss=="Be") {saia=2.261; saik=2; diam=10530; per=1; } if (ss=="B") {saia=3.223; saik=3; diam=8001; per=2;} if (ss=="C") {saia=4.22; saik=4; diam=6415; per=3;} if (ss=="O") {saia=6.273; saik=6; diam=4596; per=4;} if (ss=="N") {saia=5.25; saik=5; diam=5332; per=5;} if (ss=="F") {saia=7.327; saik=7; diam=4025; per=6;} if (ss=="Ne") {saia=8.388; saik=8; diam=3575.6; per=7;} if (ss=="Na") {saia=1.839; saik=1; diam=25900; per=8;} if (ss=="Mg") {saia=2.987; saik=2; diam=17400; per=9;} if (ss=="Al") {saia=4.004; saik=3; diam=13900; per=10;} if (ss=="Si") {saia=5.05; saik=4; diam=11500; per=11;} if (ss=="S") {saia=7.18; saik=6; diam=8622; per=12;} if (ss=="P") {saia=6.12; saik=5; diam=9825; per=13;} if (ss=="Cl") {saia=8.26; saik=7; diam=7640; per=14;} if (ss=="K") {saia=2.261; saik=1; diam=37450; per=15;} if (ss=="Ca") {saia=3.5; saik=2; diam=26050; per=16;} if (ss=="Ti") {saia=6.094; saik=4; diam=16360; per=17;} if (ss=="Se") {saia=8.726; saik=6; diam=11990; per=18;} if (ss=="Br") {saia=9.93; saik=7; diam=10765; per=19;} if (ss=="Kr") {saia=11.107; saik=8; diam=9800; per=20;} if (ss=="Na+") {saia=9.384; saik=8; diam=3060; per=21; } if (ss=="Mg2+") {saia=10.38; saik=8; diam=2675; per=22;} if (ss=="Al3+") {saia=11.38; saik=8; diam=2375; per=23;} if (ss=="K+") {saia=10.44; saik=8; diam=5970; per=24;} if (ss=="Ca2+") {saia=11.494; saik=8; diam=5277; per=25;} if (ss=="Cr") {saia=8.85; saik=6; diam=11782; per=26;} if (ss=="Cr2+") {saia=9.32; saik=4; diam=10078; per=27;} if (ss=="Mn") {saia=10.213; saik=7; diam=10390; per=28;} if (ss=="Mn2+") {saia=10.649; saik=5; diam=9052; per=29;} if (ss=="Fe") {saia=11.538; saik=8; diam=9335; per=30;} if (ss=="Fe2+") {saia=11.91; saik=6; diam=8264; per=31;} if (ss=="Fe3+") {saia=12.19; saik=5; diam=7770; per=32;} if (ss=="Co") {saia=12.854; saik=9; diam=8474; per=33;} if (ss=="Co+") {saia=13.012; saik=8; diam=8030; per=34;} if (ss=="Ni") {saia=14.259; saik=10; diam=7759; per=35;} if (ss=="Ni2+") {saia=14.511; saik=8; diam=7030; per=36;} if (ss=="Cu") {saia=15.51; saik=11; diam=7165; per=37;} if (ss=="Cu+") {saia=15.705; saik=10; diam=6852;per=38;} if (ss=="Cu2+") {saia=15.787; saik=9; diam=6551; per=39;} if (ss=="Zn") {saia=16.84; saik=12; diam=6657; per=40;} if (ss=="Zn2+") {saia=17.163; saik=10; diam=6128; per=41;} if (saik < 9 && abd==mar-17) {page[0]=0;} if (saik < 8 && abd==mar-17) {page[2]=0;} kin[mar-17]=per; kade[mar-17]=saik; if (abd==mar-17) { mar=mar-10; 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[][][]=new double[2][18][8]; double rpp[][][]=new double[2][18][8]; double teqq[][][]=new double[2][18][8]; double teqqq[][][]=new double[2][18][8]; for (int yp=0; yp <=1; yp++) { for (int el=0; el <=17; el++) { for (int jou=0; jou <=7; jou++) { rhp[yp][el][jou] = 0.0; rpp[yp][el][jou] = 0.0; teqq[yp][el][jou] = 0.0; teqqq[yp][el][jou] = 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 noxx[][]={{0,0,0,0,0, 0,0,0,0},{0,0,0,0,0, 0,0,0,0}}; if (mar==11 || mar==12 || mar==7 || mar==8 || mar==1 ) { /* electron text page change */ if (page[0] == 0) { for (int yp=0; yp <=7; yp++) { ww=" "; if ( yp < kade[abd] ) { ww="ele " + yp; if (kade[abd]==6 && page[1]==1) { if (yp==1 || yp== 3 || yp==5) { ww = " "+ yp;} } if (kade[abd]==5 && page[1]==1) { if (yp==1) { ww = " "+ yp;} } if (kade[abd]==7 && page[1]==1) { if (yp==1 || yp==3 || yp==6 ) { ww = " "+ yp;} } if (kade[abd]==9 && page[1]==1) { if (yp==2 || yp==3 || yp==4 || yp > 5 ) { ww = " "+ yp;} } if (kade[abd]==11 && page[1]==1) { if (yp==2 || yp==3 || yp==4 || yp == 5 || yp > 6 ) { ww = " "+ yp;} } if (kade[abd]==12 && page[1]==1) { if (yp==1 || yp==2 || yp==4 || yp == 5 || yp ==6 || yp==7 ) { ww = " "+ yp;} } } /* if (yp < kade ) end */ eln[yp].setText(ww); if ( mar > 10 ) { for (int kj=0; kj <=2; kj++) { ggx=0.0; if ( yp < kade[abd] ) { ex=(int)(100*(ele[abd][yp][kj]-nux[abd][kj])); ggx=ex/100.0; } elp[yp][kj].setText(Double.toString(ggx)); } } } } /* if (page=0) end */ if (page[0]==1) { for (int yp=8; yp <=15; yp++) { ww=" "; if ( yp < kade[abd] ) { ww="ele " + yp; if (kade[abd]==9 && page[1]==1) { ww = " "+ yp; } if (kade[abd]==11 && page[1]==1) { ww = " "+ yp; } if (kade[abd]==12 && page[1]==1) { if (yp > 8 ) { ww = " "+ yp;} } } /* if (yp < kade ) end */ eln[yp-8].setText(ww); if (mar > 10 ) { for (int kj=0; kj <=2; kj++) { ggx=0.0; if ( yp < kade[abd] ) { ex=(int)(100*(ele[abd][yp][kj]-nux[abd][kj])); ggx=ex/100.0; } elp[yp-8][kj].setText(Double.toString(ggx)); } } } } /* if (page=1) end */ } /* if ( mar==11 ) end */ if ( mar !=1 ) { /* get electron coordinates from text */ for (int yp=0; yp <=7; yp++) { for (int kj=0; kj <=2; kj++) { if ( page[0]==0 && yp < kade[abd] ) { ww=elp[yp][kj].getText(); /* ele[0,1][0-7][0-2] = electron coorinate */ ele[abd][yp][kj]=Double.parseDouble(ww); ele[abd][yp][kj]=ele[abd][yp][kj]+ nux[abd][kj]; } if (page[0]==1 && yp+8 < kade[abd] ) { ww=elp[yp][kj].getText(); /* ele[][8-][0-2] = electron coorinate */ ele[abd][yp+8][kj]=Double.parseDouble(ww)+nux[abd][kj]; } } /* for (kj = 0) end */ } /* determine other electron coordinate when page[1]=1 */ if (page[1]==1) { if ( kade[abd]==6 && ele[abd][0][0]-nux[abd][0] > 10 && ele[abd][1][0]-nux[abd][0] > 10 ) { for (int kj=0; kj <=2; kj++) { if ( kj < 2) { ele[abd][kj*2+1][0] = ele[abd][kj*2][0]; ele[abd][kj*2+1][2] = ele[abd][kj*2][2]; ele[abd][kj*2+1][1] = -ele[abd][kj*2][1]; } else { ele[abd][5][0] = ele[abd][4][0]; ele[abd][5][1] = ele[abd][4][1]; ele[abd][5][2] = -ele[abd][4][2]; } } } if ( kade[abd]==5 ) { ele[abd][1][0] = ele[abd][0][0]; ele[abd][1][1] = -ele[abd][0][1]; ele[abd][1][2] = ele[abd][0][2]; } if ( kade[abd]==7 && ele[abd][5][0]-nux[abd][0] !=0 && ele[abd][0][0]-nux[abd][0] !=0 ) { for (int kj=0; kj <=2; kj++) { if ( kj < 2) { ele[abd][kj*2+1][0] = ele[abd][kj*2][0]; ele[abd][kj*2+1][2] = ele[abd][kj*2][2]; ele[abd][kj*2+1][1] = -ele[abd][kj*2][1]; } else { ele[abd][6][0] = -(ele[abd][5][0]-nux[abd][0])+nux[abd][0]; ele[abd][6][1] = ele[abd][5][1]; ele[abd][6][2] = ele[abd][5][2]; } } } if ( kade[abd]==9 ) { for (int yp=0; yp <=1; yp++) { ey=yp*4+1; ggz=Math.sqrt(ele[abd][ey][1]*ele[abd][ey][1]+ele[abd][ey][2]*ele[abd][ey][2]); for (int kj=1; kj <=3; kj++) { ele[abd][ey+kj][0] = ele[abd][ey][0]; ggy=Math.sqrt(ele[abd][ey+kj][1]*ele[abd][ey+kj][1]+ele[abd][ey+kj][2]*ele[abd][ey+kj][2]); ele[abd][ey+kj][1]=(ele[abd][ey+kj][1]*ggz)/ggy; ele[abd][ey+kj][2]=(ele[abd][ey+kj][2]*ggz)/ggy; } } } if ( kade[abd]==11 ) { for (int yp=0; yp <=1; yp++) { ey=yp*5+1; ggz=Math.sqrt(ele[abd][ey][1]*ele[abd][ey][1]+ele[abd][ey][2]*ele[abd][ey][2]); for (int kj=1; kj <=4; kj++) { ele[abd][ey+kj][0]=ele[abd][ey][0] ; ggy=Math.sqrt(ele[abd][ey+kj][1]*ele[abd][ey+kj][1]+ele[abd][ey+kj][2]*ele[abd][ey+kj][2]); ele[abd][ey+kj][1]=(ele[abd][ey+kj][1]*ggz)/ggy; ele[abd][ey+kj][2]=(ele[abd][ey+kj][2]*ggz)/ggy; } } } if ( kade[abd]==12 ) { for (int yp=0; yp <=2; yp++) { ey=yp*3; if (yp==2) {ey=8;} ez=2; if (yp==1) {ez=4;} if (yp==2) {ez=3;} ggz=Math.sqrt(ele[abd][ey][1]*ele[abd][ey][1]+ele[abd][ey][2]*ele[abd][ey][2]); for (int kj=1; kj <=ez; kj++) { ele[abd][ey+kj][0]=ele[abd][ey][0] ; ggy=Math.sqrt(ele[abd][ey+kj][1]*ele[abd][ey+kj][1]+ele[abd][ey+kj][2]*ele[abd][ey+kj][2]); ele[abd][ey+kj][1]=(ele[abd][ey+kj][1]*ggz)/ggy; ele[abd][ey+kj][2]=(ele[abd][ey+kj][2]*ggz)/ggy; } } } } /* if (page[1]=1) end */ } /* if (mar != 1) end */ /* "nuc" = distance between nucleus and electron charge */ ww=imppo.getText(); gz=Double.parseDouble(ww); gy=0; if (mar==9) { for (int yp=0; yp <=kade[abd]-1; yp++) { gx=Math.sqrt((ele[abd][yp][0]-nux[abd][0])*(ele[abd][yp][0]-nux[abd][0])+ (ele[abd][yp][1]-nux[abd][1])*(ele[abd][yp][1]-nux[abd][1])+(ele[abd][yp][2]-nux[abd][2])*(ele[abd][yp][2]-nux[abd][2])); if (gx==0) {gx=50;} for (int kj=0; kj <=2; kj++) { ele[abd][yp][kj]=((ele[abd][yp][kj]-nux[abd][kj])*gz)/gx + nux[abd][kj]; }} mar=0; } if (mar==7 || mar==8 || mar==17 || mar==18) { /* atom's kind change */ int nat=0; if (mar==8 || mar==18) {nat=1;} kade[nat]=saik; /* kate[] = number of valence electrons */ nux[nat][3]=saia; /* nux[0][3] = charge of nucleus */ for (int yp=0; yp <=kade[nat]-1; yp++) { for (int kj=0; kj <=2; kj++) { ele[nat][yp][kj]=tee[ten2[kin[nat]][1]][yp][kj]; } ggx=Math.sqrt(ele[nat][yp][0]*ele[nat][yp][0]+ele[nat][yp][1]*ele[nat][yp][1]+ele[nat][yp][2]*ele[nat][yp][2]); for (int kj=0; kj <=2; kj++) { ele[nat][yp][kj]=(ele[nat][yp][kj]*diam)/ggx + nux[nat][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 <=kade[abd]-1; yp++) { gx=ele[abd][yp][0]-nux[abd][0]; gy=ele[abd][yp][1]; ggx=gx*ccos-gy*ssin; ggy=gx*ssin+gy*ccos; ele[abd][yp][0]=ggx+nux[abd][0]; ele[abd][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 <=kade[abd]-1; yp++) { gx=ele[abd][yp][0]-nux[abd][0]; gy=ele[abd][yp][2]; ggx=gx*ccos-gy*ssin; ggy=gx*ssin+gy*ccos; ele[abd][yp][0]=ggx+nux[abd][0]; ele[abd][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 <=kade[abd]-1; yp++) { gx=ele[abd][yp][1]; gy=ele[abd][yp][2]; ggx=gx*ccos-gy*ssin; ggy=gx*ssin+gy*ccos; ele[abd][yp][1]=ggx; ele[abd][yp][2]=ggy; }} /* noxx[0,1][0-2] = center of A,B valence electrons */ for (int nuc=0; nuc <=1; nuc++) { for (int kj=0; kj <=2; kj++) { for (int yp=0; yp <=kade[nuc]-1; yp++) { noxx[nuc][kj]=noxx[nuc][kj] + ele[nuc][yp][kj]; } noxx[nuc][kj]=noxx[nuc][kj]/kade[nuc]; if (kade[nuc]==1) { noxx[nuc][kj] = nux[nuc][kj];} } } for (int yp=0; yp <=7; yp++) { /* show relative coordinates */ for (int kj=0; kj <=2; kj++) { gx=0.0; if ( yp < kade[abd] && page[0]==0 ) { gx=ele[abd][yp][kj]-nux[abd][kj]; } if ( page[0]==1 && yp+8 < kade[abd] ) { gx=ele[abd][yp+8][kj]-nux[abd][kj]; } ex=(int)(100*gx); gx=ex/100.0; elp[yp][kj].setText(Double.toString(gx)); }} /* show bond angle */ int ank=0; if (page[2]==0 ) { if (kade[abd] > 1 ) { int mn=3; if (kade[abd] ==2 ) {mn=1;} if (kade[abd] == 3) { mn=2;} for (int yp=0; yp <=mn; yp++) { for (int kj=0; kj <=mn; kj++) { if ( yp < kj ) { gx=Math.sqrt((ele[abd][yp][0]-nux[abd][0])*(ele[abd][yp][0]-nux[abd][0])+ele[abd][yp][1]*ele[abd][yp][1]+ele[abd][yp][2]*ele[abd][yp][2]); gy=Math.sqrt((ele[abd][kj][0]-nux[abd][0])*(ele[abd][kj][0]-nux[abd][0])+ele[abd][kj][1]*ele[abd][kj][1]+ele[abd][kj][2]*ele[abd][kj][2]); gz=Math.sqrt((ele[abd][yp][0]-ele[abd][kj][0])*(ele[abd][yp][0]-ele[abd][kj][0])+(ele[abd][yp][1]-ele[abd][kj][1] )*(ele[abd][yp][1]-ele[abd][kj][1])+(ele[abd][yp][2]-ele[abd][kj][2])*(ele[abd][yp][2]-ele[abd][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((ele[abd][4][0]-nux[abd][0])*(ele[abd][4][0]-nux[abd][0])+ele[abd][4][1]*ele[abd][4][1]+ele[abd][4][2]*ele[abd][4][2]); for (int yp=0; yp <=2; yp++) { gy=Math.sqrt((ele[abd][yp][0]-nux[abd][0])*(ele[abd][yp][0]-nux[abd][0])+ele[abd][yp][1]*ele[abd][yp][1]+ele[abd][yp][2]*ele[abd][yp][2]); gz=Math.sqrt((ele[abd][yp][0]-ele[abd][4][0])*(ele[abd][yp][0]-ele[abd][4][0])+(ele[abd][yp][1]-ele[abd][4][1] )*(ele[abd][yp][1]-ele[abd][4][1])+(ele[abd][yp][2]-ele[abd][4][2])*(ele[abd][yp][2]-ele[abd][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] > 6 ) { gx=Math.sqrt((ele[abd][yp][0]-nux[abd][0])*(ele[abd][yp][0]-nux[abd][0])+ele[abd][yp][1]*ele[abd][yp][1]+ele[abd][yp][2]*ele[abd][yp][2]); gy=Math.sqrt((ele[abd][yp+1][0]-nux[abd][0])*(ele[abd][yp+1][0]-nux[abd][0])+ele[abd][yp+1][1]*ele[abd][yp+1][1]+ele[abd][yp+1][2]*ele[abd][yp+1][2]); gz=Math.sqrt((ele[abd][yp][0]-ele[abd][yp+1][0])*(ele[abd][yp][0]-ele[abd][yp+1][0])+(ele[abd][yp][1]-ele[abd][yp+1][1] )*(ele[abd][yp][1]-ele[abd][yp+1][1])+(ele[abd][yp][2]-ele[abd][yp+1][2])*(ele[abd][yp][2]-ele[abd][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] < 2 ) {bangle[yp].setText(" 0 ");} if (kade[abd] == 2 && yp > 0 ) {bangle[yp].setText(" 0 ");} if (kade[abd] == 3 && yp > 2 ) {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 ");} } } /* if (page[2]=0) end */ if (page[2]==1 ) { ank=0; gx=Math.sqrt((ele[abd][7][0]-nux[abd][0])*(ele[abd][7][0]-nux[abd][0])+ele[abd][7][1]*ele[abd][7][1]+ele[abd][7][2]*ele[abd][7][2]); for (int yp=0; yp <=2; yp++) { ez=yp*2+2; gy=Math.sqrt((ele[abd][ez][0]-nux[abd][0])*(ele[abd][ez][0]-nux[abd][0])+ele[abd][ez][1]*ele[abd][ez][1]+ele[abd][ez][2]*ele[abd][ez][2]); gz=Math.sqrt((ele[abd][ez][0]-ele[abd][7][0])*(ele[abd][ez][0]-ele[abd][7][0])+(ele[abd][ez][1]-ele[abd][7][1] )*(ele[abd][ez][1]-ele[abd][7][1])+(ele[abd][ez][2]-ele[abd][7][2])*(ele[abd][ez][2]-ele[abd][7][2])); aid=(gx*gx+gy*gy-gz*gz)/(2.0*gx*gy); aid=(Math.acos(aid)*180.0)/pai; wa=Integer.toString(ez); wb=Integer.toString(7); ex=(int)(10*aid); aid=ex/10.0; bangle[yp].setText(wa+"-n-"+wb+" "+Double.toString(aid)); } if ( kade[abd] > 8 ) { gx=Math.sqrt((ele[abd][8][0]-nux[abd][0])*(ele[abd][8][0]-nux[abd][0])+ele[abd][8][1]*ele[abd][8][1]+ele[abd][8][2]*ele[abd][8][2]); for (int yp=0; yp <=2; yp++) { ez=yp*2+3; gy=Math.sqrt((ele[abd][ez][0]-nux[abd][0])*(ele[abd][ez][0]-nux[abd][0])+ele[abd][ez][1]*ele[abd][ez][1]+ele[abd][ez][2]*ele[abd][ez][2]); gz=Math.sqrt((ele[abd][ez][0]-ele[abd][8][0])*(ele[abd][ez][0]-ele[abd][8][0])+(ele[abd][ez][1]-ele[abd][8][1] )*(ele[abd][ez][1]-ele[abd][8][1])+(ele[abd][ez][2]-ele[abd][8][2])*(ele[abd][ez][2]-ele[abd][8][2])); aid=(gx*gx+gy*gy-gz*gz)/(2.0*gx*gy); aid=(Math.acos(aid)*180.0)/pai; wa=Integer.toString(ez); wb=Integer.toString(8); ex=(int)(10*aid); aid=ex/10.0; bangle[yp+3].setText(wa+"-n-"+wb+" "+Double.toString(aid)); } if ( kade[abd] > 9) { gx=Math.sqrt((ele[abd][9][0]-nux[abd][0])*(ele[abd][9][0]-nux[abd][0])+ele[abd][9][1]*ele[abd][9][1]+ele[abd][9][2]*ele[abd][9][2]); for (int yp=0; yp <=1; yp++) { ez=5; if (yp==1) {ez=8;} gy=Math.sqrt((ele[abd][ez][0]-nux[abd][0])*(ele[abd][ez][0]-nux[abd][0])+ele[abd][ez][1]*ele[abd][ez][1]+ele[abd][ez][2]*ele[abd][ez][2]); gz=Math.sqrt((ele[abd][ez][0]-ele[abd][9][0])*(ele[abd][ez][0]-ele[abd][9][0])+(ele[abd][ez][1]-ele[abd][9][1] )*(ele[abd][ez][1]-ele[abd][9][1])+(ele[abd][ez][2]-ele[abd][9][2])*(ele[abd][ez][2]-ele[abd][9][2])); aid=(gx*gx+gy*gy-gz*gz)/(2.0*gx*gy); aid=(Math.acos(aid)*180.0)/pai; wa=Integer.toString(ez); wb=Integer.toString(9); ex=(int)(10*aid); aid=ex/10.0; bangle[yp+6].setText(wa+"-n-"+wb+" "+Double.toString(aid)); } if ( kade[abd] > 10) { gx=Math.sqrt((ele[abd][10][0]-nux[abd][0])*(ele[abd][10][0]-nux[abd][0])+ele[abd][10][1]*ele[abd][10][1]+ele[abd][10][2]*ele[abd][10][2]); for (int yp=0; yp <=1; yp++) { ez=7; if (yp==1) {ez=9;} gy=Math.sqrt((ele[abd][ez][0]-nux[abd][0])*(ele[abd][ez][0]-nux[abd][0])+ele[abd][ez][1]*ele[abd][ez][1]+ele[abd][ez][2]*ele[abd][ez][2]); gz=Math.sqrt((ele[abd][ez][0]-ele[abd][10][0])*(ele[abd][ez][0]-ele[abd][10][0])+(ele[abd][ez][1]-ele[abd][10][1] )*(ele[abd][ez][1]-ele[abd][10][1])+(ele[abd][ez][2]-ele[abd][10][2])*(ele[abd][ez][2]-ele[abd][10][2])); aid=(gx*gx+gy*gy-gz*gz)/(2.0*gx*gy); aid=(Math.acos(aid)*180.0)/pai; wa=Integer.toString(ez); wb=Integer.toString(10); ex=(int)(10*aid); aid=ex/10.0; bangle[yp+8].setText(wa+"-n-"+wb+" "+Double.toString(aid)); } if ( kade[abd] > 11 ) { gx=Math.sqrt((ele[abd][11][0]-nux[abd][0])*(ele[abd][11][0]-nux[abd][0])+ele[abd][11][1]*ele[abd][11][1]+ele[abd][11][2]*ele[abd][11][2]); ez=10; gy=Math.sqrt((ele[abd][ez][0]-nux[abd][0])*(ele[abd][ez][0]-nux[abd][0])+ele[abd][ez][1]*ele[abd][ez][1]+ele[abd][ez][2]*ele[abd][ez][2]); gz=Math.sqrt((ele[abd][ez][0]-ele[abd][11][0])*(ele[abd][ez][0]-ele[abd][11][0])+(ele[abd][ez][1]-ele[abd][11][1] )*(ele[abd][ez][1]-ele[abd][11][1])+(ele[abd][ez][2]-ele[abd][11][2])*(ele[abd][ez][2]-ele[abd][11][2])); aid=(gx*gx+gy*gy-gz*gz)/(2.0*gx*gy); aid=(Math.acos(aid)*180.0)/pai; wa=Integer.toString(ez); wb=Integer.toString(11); ex=(int)(10*aid); aid=ex/10.0; bangle[10].setText(wa+"-n-"+wb+" "+Double.toString(aid)); } /* if (kade[] > 11 ) end */ } /* if (kade[abd] > 10) end */ } /* if (kade[] > 9) end */ } /* if (kade[] > 8 ) end */ } /* angle if (page[2]=1) end */ toav=0.0; /* toav=total potential energy */ double ppot; /* interaction between electrons 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((ele[0][yp][0]-ele[0][kj][0])*(ele[0][yp][0]-ele[0][kj][0])+ (ele[0][yp][1]-ele[0][kj][1])*(ele[0][yp][1]-ele[0][kj][1])+ (ele[0][yp][2]-ele[0][kj][2])*(ele[0][yp][2]-ele[0][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; noxx[0][8]=noxx[0][8]+ppot; /* rhp[0][el][3]= potential energy of each electron */ rhp[0][yp][3]=rhp[0][yp][3]+ppot/2.0; rhp[0][kj][3]=rhp[0][kj][3]+ppot/2.0; /* teqq[0][el][3] = potential energy only in A atom */ teqq[0][yp][3]=teqq[0][yp][3]+ppot/2.0; teqq[0][kj][3]=teqq[0][kj][3]+ppot/2.0; for (int jou=0; jou <=2; jou++) { /* rhp[0][el][0-2]=force component acting on each electron */ ggx=(suh*(ele[0][yp][jou]-ele[0][kj][jou]))/(kro*kro*kro); rhp[0][yp][jou]=rhp[0][yp][jou]+ggx; rhp[0][kj][jou]=rhp[0][kj][jou]-ggx; /* teqq[0][el][0-2] = force component only in A atom */ teqq[0][yp][jou]=teqq[0][yp][jou]+ggx; teqq[0][kj][jou]=teqq[0][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((ele[1][yp][0]-ele[1][kj][0])*(ele[1][yp][0]-ele[1][kj][0])+ (ele[1][yp][1]-ele[1][kj][1])*(ele[1][yp][1]-ele[1][kj][1])+ (ele[1][yp][2]-ele[1][kj][2])*(ele[1][yp][2]-ele[1][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; noxx[1][8]=noxx[1][8]+ppot; /* rhp[1][el][3]= potential energy of each electron (B) */ rhp[1][yp][3]=rhp[1][yp][3]+ppot/2.0; rhp[1][kj][3]=rhp[1][kj][3]+ppot/2.0; /* teqq[1][el][3] = potential energy only in B atom */ teqq[1][yp][3]=teqq[1][yp][3]+ppot/2.0; teqq[1][kj][3]=teqq[1][kj][3]+ppot/2.0; for (int jou=0; jou <=2; jou++) { /* rhp[1][el][0-2]=force component acting on each electron */ ggx=(suh*(ele[1][yp][jou]-ele[1][kj][jou]))/(kro*kro*kro); rhp[1][yp][jou]=rhp[1][yp][jou]+ggx; rhp[1][kj][jou]=rhp[1][kj][jou]-ggx; /* teqq[1][el][0-2] = force component only in B atom */ teqq[1][yp][jou]=teqq[1][yp][jou]+ggx; teqq[1][kj][jou]=teqq[1][kj][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((ele[0][yp][0]-ele[1][kj][0])*(ele[0][yp][0]-ele[1][kj][0])+ (ele[0][yp][1]-ele[1][kj][1])*(ele[0][yp][1]-ele[1][kj][1])+ (ele[0][yp][2]-ele[1][kj][2])*(ele[0][yp][2]-ele[1][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[][el][3]= potential energy of each electron */ rhp[0][yp][3]=rhp[0][yp][3]+ppot/2.0; rhp[1][kj][3]=rhp[1][kj][3]+ppot/2.0; for (int jou=0; jou <=2; jou++) { /* force component */ ggx=(suh*(ele[0][yp][jou]-ele[1][kj][jou]))/(kro*kro*kro); rhp[0][yp][jou]=rhp[0][yp][jou]+ggx; rhp[1][kj][jou]=rhp[1][kj][jou]-ggx; } }} /* ----- interaction between nucleus and electron */ for (int at=0; at <=1; at++) { for (int yp=0; yp <=kade[at]-1; yp++) { for (int rv=0; rv <=1; rv++) { /* kro=distance between nucleus and electron */ kro=Math.sqrt((ele[at][yp][0]-nux[rv][0])*(ele[at][yp][0]-nux[rv][0])+ (ele[at][yp][1]-nux[rv][1])*(ele[at][yp][1]-nux[rv][1])+ (ele[at][yp][2]-nux[rv][2])*(ele[at][yp][2]-nux[rv][2])); if (kro == 0) {kro=5000.0;} ex=(int)(kro*10); double dinu=ex/10.0; if ( at==rv && at==abd ) { /* show distance between nucleus and ele */ if ( yp < 8 && page[0]==0 ) { elp[yp][3].setText("nuc "+Double.toString(dinu)); } if ( yp > 7 && page[0]==1 ) { elp[yp-8][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[at][yp][3]=rhp[at][yp][3]+ppot; if (rv==at) { noxx[at][8]=noxx[at][8]+ppot; } /* rhp[][][6] = potential energy between another nucleus */ if (rv != at ) { rhp[at][yp][6]=rhp[at][yp][6]+ppot;} /* ggx=force component between nucleus and electron */ for (int jou=0; jou <=2; jou++) { ggx=(suh*nux[rv][3]*(ele[at][yp][jou]-nux[rv][jou]))/(kro*kro*kro); rhp[at][yp][jou]=rhp[at][yp][jou]-ggx; /* mmp[][0-2] = force component acting on each nucleus */ mmp[rv][jou]=mmp[rv][jou]+ggx; if (rv==at) { noxx[at][jou+5]=noxx[at][jou+5]+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; /* distribute internuclear V to electron based on rhp[][][6] */ gx=0.0; for (int nc=0; nc <= 1; nc++) { for (int yp=0; yp <= kade[nc]-1; yp++) { gx=gx+rhp[nc][yp][6]; }} for (int rv=0; rv <= 1; rv++) { for (int yp=0; yp <= kade[rv]-1; yp++) { rhp[rv][yp][3]=rhp[rv][yp][3]+(ppot*rhp[rv][yp][6])/gx ; }} /* interaction between electrons and their center nuc */ for (int nc=0; nc <= 1; nc++) { for (int yp=0; yp <= kade[nc]-1; yp++) { kro=Math.sqrt((ele[nc][yp][0]-noxx[nc][0])*(ele[nc][yp][0]-noxx[nc][0])+(ele[nc][yp][1]-noxx[nc][1])*(ele[nc][yp][1]-noxx[nc][1])+ (ele[nc][yp][2]-noxx[nc][2])*(ele[nc][yp][2]-noxx[nc][2])); if (kro == 0) {kro=5000.0;} ppot=-(elc*elc*nux[nc][3]*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14); teqq[nc][yp][3]=teqq[nc][yp][3] + ppot; for (int jou=0; jou <=2; jou++) { ggx=(suh*nux[nc][3]*(ele[nc][yp][jou]-noxx[nc][jou]))/(kro*kro*kro); teqq[nc][yp][jou]=teqq[nc][yp][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 */ free[0]=ten3[kin[0]]; free[1]=ten3[kin[1]]; 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((ele[abd][rv][0]-nux[abd][0])*(ele[abd][rv][0]-nux[abd][0])+ (ele[abd][rv][1]-nux[abd][1])*(ele[abd][rv][1]-nux[abd][1])+(ele[abd][rv][2]-nux[abd][2])*(ele[abd][rv][2]-nux[abd][2])); /* gy=forces toward nucleus (CF) */ gy=-(rhp[abd][rv][0]*(ele[abd][rv][0]-nux[abd][0])+rhp[abd][rv][1]*ele[abd][rv][1]+rhp[abd][rv][2]*ele[abd][rv][2])/gx; ex=(int)(1000*gy); ww="CF "; if ( page[0] == 0 && rv < 8 ) { elp[rv][5].setText(ww+Integer.toString(ex)); } if ( page[0] == 1 && rv > 7 && rv < 16 ) { elp[rv-8][5].setText(ww+Integer.toString(ex)); } /* show forces other than CF */ for (int jou=0; jou <=2; jou++) { gz=rhp[abd][rv][jou]-(gy*(nux[abd][jou]-ele[abd][rv][jou]))/gx; if (kade[abd]==1 && jou==0) { gz=rhp[abd][rv][0]; } ex=(int)(1000*gz); if (page[0]==0 && rv < 8 ) { elp[rv][jou+6].setText(Integer.toString(ex)); } if (page[0]==1 && rv > 7 && rv < 16 ) { elp[rv-8][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 ( nux[rv][4] < 0 ) { ex=(int)(1000*noxx[rv][jou+5]); } 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[abd][rv][3]); ggx=ex/100.0; if (page[0]==0 && rv < 8 ) { elp[rv][4].setText("V "+Double.toString(ggx)); } if (page[0]==1 && rv > 7 && rv < 16 ) { elp[rv-8][4].setText("V "+Double.toString(ggx)); } } /* show de Broglie wave */ double gouk=0.0; double goukk=0.0; double gggx,gggy,gggz, gz2; for (int rv=0; rv <=kade[abd]-1; rv++) { gz=Math.sqrt(rhp[abd][rv][0]*rhp[abd][rv][0]+rhp[abd][rv][1]*rhp[abd][rv][1]+rhp[abd][rv][2]*rhp[abd][rv][2]); gggz=gz; gz =Math.sqrt(teqq[abd][rv][0]*teqq[abd][rv][0]+teqq[abd][rv][1]*teqq[abd][rv][1]+teqq[abd][rv][2]*teqq[abd][rv][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[abd][rv][3]*1.602177e-19)/me); gggx=gx; gx=Math.sqrt((-1.0*teqq[abd][rv][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; if ( kade[abd] > 1) { if (page[0]==0 && rv < 8) { elp[rv][10].setText("wn "+Double.toString(ggz)); } if (page[0]==1 && rv > 7 && rv < 16 ) { elp[rv-8][10].setText("wn "+Double.toString(ggz)); } } else { elp[3][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; if (kade[abd]==1) { rhp[abd][rv][5]=ggy; } ex=(int)(ggy*10000); ggz=ex/10000.0; if (page[0]==0 && rv < 8) { elp[rv][9].setText("di "+Double.toString(ggz)); } if (page[0]==1 && rv > 7 && rv < 16 ) { elp[rv-8][9].setText("di "+Double.toString(ggz)); } if ( kade[abd] == 1) { elp[rv][10].setText("wn "+Double.toString(ggz)); } } gouk=gouk/kade[abd]; ex=(int)(gouk*10000); gouk=ex/10000.0; if (kade[abd] > 1) { avew.setText("ave "+Double.toString(gouk)); } goukk=goukk/kade[abd]; ex=(int)(goukk*10000); goukk=ex/10000.0; if (kade[abd] > 1) { direc.setText("ave "+Double.toString(goukk)); } else { direc.setText(" "); } if (page[0] == 0 ) { for (int yp=2; yp <=7; yp++) { for (int kj=3; kj <=10; kj++) { ez=0; if (kade[abd] <=2) { if (kade[abd]==1 && yp==3 && kj==10) {ez=1;} if (ez==0) { elp[yp][kj].setText(" 0 "); } } if (kade[abd] <=3 && yp > 2 && ez !=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 ");} if (kade[abd] <=7 && yp > 6 ) {elp[yp][kj].setText(" 0 ");} }}} if (page[0] == 1) { for (int yp=0; yp <=7; yp++) { for (int kj=3; kj <=10; kj++) { if (kade[abd] <=9 && yp > 0 ) {elp[yp][kj].setText(" 0 ");} if (kade[abd] <=10 && yp > 1 ) {elp[yp][kj].setText(" 0 ");} if (kade[abd] <=11 && yp > 2 ) {elp[yp][kj].setText(" 0 ");} if (kade[abd] <=12 && yp > 3 ) {elp[yp][kj].setText(" 0 ");} }} } for (int frr=0; frr <=1; frr++) { ex=(int)(1000*noxx[frr][8]); ggx=ex/1000.0; if ( frr==0 ) { naibua.setText("A-tV " + Double.toString(ggx) ); } else { naibub.setText("B-tV " + Double.toString(ggx) ); } } /* hydrogen parameter after moving */ double eee[][][]=new double[2][18][11]; for (int nu=0; nu <=1; nu++) { for (int rv=0; rv <=kade[nu]-1; rv++) { for (int jou=0; jou <=2; jou++) { eee[nu][rv][jou]=ele[nu][rv][jou]; eee[nu][rv][jou]=ele[nu][rv][jou]; if (kade[nu] == 1 && jou==0) { gx=Math.sqrt(rhp[nu][0][1]*rhp[nu][0][1]+rhp[nu][0][2]*rhp[nu][0][2]); gy=Math.sqrt(ele[nu][0][1]*ele[nu][0][1]+ele[nu][0][2]*ele[nu][0][2]); /* hyrogen electron moves in x direction by force */ eee[nu][0][0]=ele[nu][0][0]+(rhp[nu][0][0] * gy*2)/gx; } }}} if ( kade[abd] == 1 ) { toav=0.0; /* toav= total potential energy after moving */ /* interaction between electrons 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((eee[0][yp][0]-eee[0][kj][0])*(eee[0][yp][0]-eee[0][kj][0])+ (eee[0][yp][1]-eee[0][kj][1])*(eee[0][yp][1]-eee[0][kj][1])+ (eee[0][yp][2]-eee[0][kj][2])*(eee[0][yp][2]-eee[0][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[0][el][3]= potential energy of each electron */ rpp[0][yp][3]=rpp[0][yp][3]+ppot/2.0; rpp[0][kj][3]=rpp[0][kj][3]+ppot/2.0; for (int jou=0; jou <=2; jou++) { /* rpp[0][el][0-2]=force component acting on each electron */ ggx=(suh*(eee[0][yp][jou]-eee[0][kj][jou]))/(kro*kro*kro); rpp[0][yp][jou]=rpp[0][yp][jou]+ggx; rpp[0][kj][jou]=rpp[0][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((eee[1][yp][0]-eee[1][kj][0])*(eee[1][yp][0]-eee[1][kj][0])+ (eee[1][yp][1]-eee[1][kj][1])*(eee[1][yp][1]-eee[1][kj][1])+ (eee[1][yp][2]-eee[1][kj][2])*(eee[1][yp][2]-eee[1][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[1][el][3]= potential energy of each electron (B) */ rpp[1][yp][3]=rpp[1][yp][3]+ppot/2.0; rpp[1][kj][3]=rpp[1][kj][3]+ppot/2.0; for (int jou=0; jou <=2; jou++) { /* rpp[1][el][0-2]=force component acting on each electron */ ggx=(suh*(eee[1][yp][jou]-eee[1][kj][jou]))/(kro*kro*kro); rpp[1][yp][jou]=rpp[1][yp][jou]+ggx; rpp[1][kj][jou]=rpp[1][kj][jou]-ggx; } }}} /* 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((eee[0][yp][0]-eee[1][kj][0])*(eee[0][yp][0]-eee[1][kj][0])+ (eee[0][yp][1]-eee[1][kj][1])*(eee[0][yp][1]-eee[1][kj][1])+ (eee[0][yp][2]-eee[1][kj][2])*(eee[0][yp][2]-eee[1][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[][el][3]= potential energy of each electron */ rpp[0][yp][3]=rpp[0][yp][3]+ppot/2.0; rpp[1][kj][3]=rpp[1][kj][3]+ppot/2.0; for (int jou=0; jou <=2; jou++) { /* force component */ ggx=(suh*(eee[0][yp][jou]-eee[1][kj][jou]))/(kro*kro*kro); rpp[0][yp][jou]=rpp[0][yp][jou]+ggx; rpp[1][kj][jou]=rpp[1][kj][jou]-ggx; } }} /* ----- interaction between nucleus and electron */ for (int at=0; at <=1; at++) { for (int yp=0; yp <=kade[at]-1; yp++) { for (int rv=0; rv <=1; rv++) { /* kro=distance between nucleus and electron */ kro=Math.sqrt((eee[at][yp][0]-nux[rv][0])*(eee[at][yp][0]-nux[rv][0])+ (eee[at][yp][1]-nux[rv][1])*(eee[at][yp][1]-nux[rv][1])+ (eee[at][yp][2]-nux[rv][2])*(eee[at][yp][2]-nux[rv][2])); if (kro == 0) {kro=5000.0;} /* 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[at][yp][3]=rpp[at][yp][3]+ppot; /* rpp[][][6] = potential energy between another nucleus */ if (rv != at ) { rpp[at][yp][6]=rpp[at][yp][6]+ppot;} /* ggx=force component between nucleus and electron */ for (int jou=0; jou <=2; jou++) { ggx=(suh*nux[rv][3]*(eee[at][yp][jou]-nux[rv][jou]))/(kro*kro*kro); rpp[at][yp][jou]=rpp[at][yp][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; gx=0.0; /* distribute internuclear potential to electrons */ for (int nc=0; nc <= 1; nc++) { for (int yp=0; yp <= kade[nc]-1; yp++) { gx=gx+rpp[nc][yp][6]; }} for (int rv=0; rv <= 1; rv++) { for (int yp=0; yp <= kade[rv]-1; yp++) { rpp[rv][yp][3]=rpp[rv][yp][3]+(ppot*rpp[rv][yp][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[abd][0][0]*rpp[abd][0][0]+rpp[abd][0][1]*rpp[abd][0][1]+rpp[abd][0][2]*rpp[abd][0][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[abd][0][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[abd][0][5] + ggy)/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=eee[abd][0][kj]-nux[abd][kj]; elp[1][kj].setText(Integer.toString((int)gx)); } for (int kj=3; kj <=8; kj++) { elp[1][kj].setText(" 0 "); } gz=rpp[abd][0][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[2][18][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 nc=0; nc <=1; nc++) { for (int yp=0; yp <=kade[nc]-1; yp++) { for (int kj=0; kj <=2; kj++) { hpk[nc][yp][kj]=(int)(ele[nc][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(0,299,1170,699); g.setColor(Color.black); g.fillRect(0,299,1170,699); g.setColor(Color.cyan); g.drawLine(555,310,555,660); g.drawString("X - Z plane", 257,355); g.drawString("X - Y plane", 810,355); g.setColor(Color.magenta); String aw=" "; String bw=" "; aw= aato[kin[0]]; bw= aato[kin[1]]; g.drawString(aw+" = "+ Integer.toString(kade[0]), 137,355); g.drawString(bw+" = "+ Integer.toString(kade[1]), 418,355); g.drawString(aw+" = "+ Integer.toString(kade[0]), 692,355); g.drawString(bw+" = "+ Integer.toString(kade[1]), 973,355); g.setColor(Color.lightGray); /* show nucleus */ for ( int rv=0; rv <= 1; rv++) { g.fillOval(nmx[rv][0]+med-3,502,20,20); g.fillOval(nmx[rv][0]+medd-3,502,20,20); } for ( int rv=0; rv <= 1; rv++) { g.setColor(Color.white); /* show electron 0 (particle) */ g.fillOval(hpk[rv][0][0]+med, 505-hpk[rv][0][2],14,14); g.fillOval(hpk[rv][0][0]+medd,505-hpk[rv][0][1],14,14); if ( kade[rv] > 1 ) { g.setColor(Color.pink); /* show electron 1 */ g.fillOval(hpk[rv][1][0]+med, 505-hpk[rv][1][2],14,14); g.fillOval(hpk[rv][1][0]+medd,505-hpk[rv][1][1],14,14); } if ( kade[rv] > 2 ) { g.setColor(Color.red); /* show electron 2 */ g.fillOval(hpk[rv][2][0]+med, 505-hpk[rv][2][2],14,14); g.fillOval(hpk[rv][2][0]+medd,505-hpk[rv][2][1],14,14); } if ( kade[rv] > 3 ) { g.setColor(Color.green); /* show electron 3 */ g.fillOval(hpk[rv][3][0]+med, 505-hpk[rv][3][2],14,14); g.fillOval(hpk[rv][3][0]+medd,505-hpk[rv][3][1],14,14); } if ( kade[rv] > 4 ) { /* N last electron */ g.setColor(Color.magenta); g.fillOval(hpk[rv][4][0]+med, 505-hpk[rv][4][2],14,14); g.fillOval(hpk[rv][4][0]+medd,505-hpk[rv][4][1],14,14); } if ( kade[rv] > 5 ) { /* O last electron */ g.setColor(Color.white); g.fillOval(hpk[rv][5][0]+med, 505-hpk[rv][5][2],14,14); g.fillOval(hpk[rv][5][0]+medd,505-hpk[rv][5][1],14,14); } if ( kade[rv] > 6 ) { /* F last electron */ g.setColor(Color.pink); g.fillOval(hpk[rv][6][0]+med, 505-hpk[rv][6][2],14,14); g.fillOval(hpk[rv][6][0]+medd,505-hpk[rv][6][1],14,14); } if ( kade[rv] > 7 ) { /* Ne */ g.setColor(Color.red); g.fillOval(hpk[rv][7][0]+med, 505-hpk[rv][7][2],14,14); g.fillOval(hpk[rv][7][0]+medd,505-hpk[rv][7][1],14,14); } if ( kade[rv] > 8 ) { g.setColor(Color.green); /* nine electron */ g.fillOval(hpk[rv][8][0]+med, 505-hpk[rv][8][2],14,14); g.fillOval(hpk[rv][8][0]+medd,505-hpk[rv][8][1],14,14); } if ( kade[rv] > 9 ) { /* 10 electrons */ g.setColor(Color.magenta); g.fillOval(hpk[rv][9][0]+med, 505-hpk[rv][9][2],14,14); g.fillOval(hpk[rv][9][0]+medd,505-hpk[rv][9][1],14,14); } if ( kade[rv] > 10 ) { /* 11 electrons */ g.setColor(Color.white); g.fillOval(hpk[rv][10][0]+med, 505-hpk[rv][10][2],14,14); g.fillOval(hpk[rv][10][0]+medd,505-hpk[rv][10][1],14,14); } if ( kade[rv] > 11 ) { /* 12 electrons */ g.setColor(Color.pink); g.fillOval(hpk[rv][11][0]+med, 505-hpk[rv][11][2],14,14); g.fillOval(hpk[rv][11][0]+medd,505-hpk[rv][11][1],14,14); } for (int rw=0; rw <=kade[rv]-1; rw++) { g.setColor(Color.blue); if ( rw < 10 ) { g.drawString(Integer.toString(rw),hpk[rv][rw][0]+med+4, 517-hpk[rv][rw][2]); g.drawString(Integer.toString(rw),hpk[rv][rw][0]+medd+4, 517-hpk[rv][rw][1] ); } else { g.drawString(Integer.toString(rw),hpk[rv][rw][0]+med+1, 517-hpk[rv][rw][2]); g.drawString(Integer.toString(rw),hpk[rv][rw][0]+medd+1, 517-hpk[rv][rw][1] ); } } } } }