import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.Scanner; import java.io.*; public class sdfd2 extends JPanel /* multiple atomic molecues */ { public static void main(String arg[]) { JFrame frame = new JFrame("multiple-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 { /* ------------------------------------------------------------- */ /* -------You need to change saving folder or file-name ------------- */ /* ------------------------------------------------------------- */ String fil="c:\\sdff\\nitric-acid.txt"; /* ----------------------------------------------------------- */ /* ------------------------- end ------------------------------ */ /* ----------------------------------------------------------- */ int maxa = 300; /* maxa = total number of atoms, ex. CH4 -- maxa=5 */ int gen=maxa; double model[][]=new double[gen][9]; int model2[][]=new int[gen][9]; int doko[]=new int[gen]; int maxx=0; int yoko=0; int ue=0; int joug=0; 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][12]; /* text */ JTextField impho=new JTextField(7); /* total V text */ JTextField mmpho[][]=new JTextField[2][12]; /* nucleus text */ /* imppo = distance (= nuc ) between electron and nucleus text */ JTextField imppo=new JTextField(7); JTextField charge=new JTextField(7); /* charge Z text */ JTextField avew=new JTextField(7); /* average de Broglie wave */ JTextField direc=new JTextField(7); /* directt de Broglie wave */ JTextField atom[]=new JTextField[6]; /* atomic number on the screen */ JTextField kait[]=new JTextField[7]; /* angle, moving */ JTextField blan[]=new JTextField[11]; /* blank text */ JTextField bangle[]=new JTextField[11]; /* bond angle text */ JTextField over[]=new JTextField[2]; /* atom moving text */ JButton b1=new JButton("x-y ang"); JButton b2=new JButton("x-z ang"); JButton b3=new JButton("y-z ang"); JButton b4=new JButton("nucleus"); JButton b5=new JButton("electron"); JButton b6=new JButton("top nucl"); JButton b7=new JButton("A atom"); JButton b8=new JButton("hydrogen"); JButton b9=new JButton("move"); JButton bb1=new JButton("nuc"); JButton bb2=new JButton("charge Z"); JButton bb3=new JButton("inversion"); JButton bb4=new JButton("direction"); JButton bb5=new JButton("overall ?"); String aato[]={"H","C","O","N","F","Si","S","P","Cl"}; JComboBox coom=new JComboBox(aato); int mar=0; int abd=0; /* mar = mark used when you click some button */ /* abd = atomic number, which is chosen and showed on screen now */ double saia=4.22; int saik=4; double diam=6415.0; double cent[]={0, 0, 0}; /* cent[0-2] = screen center coorinate */ double ska[][]=new double[10][8];double erot[][]=new double[10][8]; int overa=0; /* overa=0 -- overall molecule move, overa=1 -- each atom move */ int muke=1; /* some neighboring atomic number, in which direction, electrons are turned */ int muk=1; /* some neighboring atomic number, in which direction, atoms are turned */ int sho=1; /* sho=1 -- all atoms' initialization */ int gamm = 0; /* gamm=0 overall molecule is showed on screen */ /* gamm=1 some atom and their neighboring atoms are shown on screen */ /* gamm=2 some atom and their valence electrons are shown on screen */ int gy=maxa; double att[][]=new double[gy][13]; /* att[atom][0-2]=each atom x,y,z absolute coordinate (MM) */ /* att[atom][3]=each atom's central charge */ /* att[atom][4]= each atom's valence electron radius (MM) */ int ato[][]=new int[gy][13]; /* ato[atom][4]=number of valence electrons of each atom */ /* ato[atom][5-10] = neighboring atomic number */ /* ato[atom][12] = hydrogen-atom type (= 0, 1, 2, or 4 ) */ int marki[]=new int[gy]; /* marki = initialization mark of atom, marki=1 -- initialize */ double rtw=Math.sqrt(2); double rth=Math.sqrt(3); double rsi=Math.sqrt(6); double rfi=Math.sqrt(5); double ele[][][]=new double[gy][7][12]; /* each eletron parameters */ int genn[]=new int[gy]; /* 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,563, -3045}, {-2537, 563, 3047}, {2537, 563, 3047}, {2537, 563, -3047}, {0, 4003, 0}, {2500, -3127, 0}, {-2500, -3127, 0 }}; /* met[0-3][] = hydrogen type dependent (0-3) initial vector, length = 10000 */ double met[][]={{0.0, 0.0, -10000.0}, {4714.0, 8660.3, 1666.7}, {4714.0,-5773.5,6666.7}, {-9428.1,-2886.8,1666.7}}; double hen3=10900.0; double henrrr=(hen3*2.0)/rsi; double hen1=(henrrr*rsi)/6.0; double hen2=henrrr/rth; double hen4=2.0*hen2; double nux[][]={{hen3, 0, 0, 1}, {-hen1, 0, hen4, 1}, {-hen1, -henrrr, -hen2, 1},{-hen1, henrrr, -hen2,1}}; double mett[][]=new double[8][4]; public J2DPanel() { setBackground(Color.black); JPanel p=new JPanel(); p.setLayout(new GridLayout(13,12)); String vv,zww; int aaa=0; for (int el=0; el <=maxa-1; el++) { for (int pos=0; pos <=8; pos++) { model[el][pos]=0; model2[el][pos]=-1; if (pos==8) { model2[el][pos]=0; } } doko[el]=1; } try { FileReader fr=new FileReader(fil); StreamTokenizer st=new StreamTokenizer(fr); int tk=st.nextToken(); if ( tk !=StreamTokenizer.TT_EOF ) { do { if ( tk !=StreamTokenizer.TT_WORD) { model[maxx][yoko]=st.nval; yoko++; } for (int el=0; el <=1; el++) { tk=st.nextToken(); if ( tk !=StreamTokenizer.TT_WORD) { model[maxx][yoko]=st.nval; yoko++; } } tk=st.nextToken(); if ( tk !=StreamTokenizer.TT_WORD) { ue=1; joug=maxx; } else { saia=4.22; saik=4; diam=6415; if (st.sval.equals("H")) {saia=1.0; saik=1; diam=4500;} if (st.sval.equals("O")) {saia=6.273; saik=6; diam=4596;} if (st.sval.equals("N")) {saia=5.25; saik=5; diam=5332;} if (st.sval.equals("F")) {saia=7.3; saik=7; diam=4003;} if (st.sval.equals("Si")) {saia=5.05; saik=4; diam=11500;} if (st.sval.equals("S")) {saia=7.18; saik=6; diam=8622;} if (st.sval.equals("P")) {saia=6.12; saik=5; diam=9825;} if (st.sval.equals("Cl")) {saia=8.26; saik=7; diam=7640;} model2[maxx][0] = saik; model[maxx][3] = saia; model[maxx][4] = diam; for (int el=0; el <=11; el++) { tk=st.nextToken(); } } if (ue==0) { maxx=maxx+1; yoko=0; tk=st.nextToken(); } } while (ue < 1 ) ; } /* if ( tk !=StreamTokenizer.TT_EOF ) end */ int kazu=(int)(model[maxx][1]); model2[0][1]=kazu-1; doko[0]=doko[0]+1; model2[kazu-1][1]=0; doko[kazu-1]=doko[kazu-1]+1; for (int el=0; el <=2; el++) { tk=st.nextToken(); } tk=st.nextToken(); while ( tk !=StreamTokenizer.TT_EOF ) { if ( tk !=StreamTokenizer.TT_WORD ) { int ato=(int)(st.nval-1); tk=st.nextToken(); int ait=(int)(st.nval-1); model2[ato][doko[ato]] = ait; doko[ato]=doko[ato]+1; model2[ait][doko[ait]] = ato; doko[ait]=doko[ait]+1; for (int el=0; el <=4; el++) { tk=st.nextToken(); } } tk=st.nextToken(); } maxa=joug; for (int el=0; el <=joug-1; el++) { for (int pos=0; pos <=2; pos++) { model[el][pos]= model[el][pos]*10000; } } fr.close(); } /* try end */ catch(Exception e) { System.out.println(e); } /* met, mett = hydrogen electron 0-3 vector */ double tx,ty,tz,tkk; for (int el=0; el <=3; el++) { tx = met[el][1]*nux[el][2]-met[el][2]*nux[el][1]; ty = met[el][2]*nux[el][0]-met[el][0]*nux[el][2]; tz = met[el][0]*nux[el][1]-met[el][1]*nux[el][0]; tkk = Math.sqrt(tx*tx+ty*ty+tz*tz); mett[el][0] = (tx*10000.0)/tkk; mett[el][1] = (ty*10000.0)/tkk; mett[el][2] = (tz*10000.0)/tkk; } for (int err=0; err <=9; err++) { for (int era=0; era <=7; era++) { erot[err][era]=0.0; ska[err][era]=0.0; }} for (int era=0; era <=maxa-1; era++) { marki[era]=1;; } double ini1=0; int ini2=0; for (int el=0; el <=maxa-1; el++) { for (int pos=0; pos <=4; pos++) { att[el][pos] = model[el][pos]; /* att[][]= each atom coordinate and nuclear charge */ }} for (int el=0; el <=maxa-1; el++) { for (int pos=0; pos <=12; pos++) { if (pos < 4 ) { ato[el][pos] = 0; } else { ato[el][pos] = model2[el][pos-4]; /* ato[][4-12]= each atom informations */ } }} saia=att[abd][3]; diam=att[abd][4]; muk=ato[abd][5]; muke=ato[abd][5]; /* direction of which surrounding atom */ for (int el=0; el <=6; el++) { for (int pos=0; pos <=11; pos++) { elp[el][pos]=new JTextField(7); if (pos > 0 && pos < 4) { elp[el][pos].addActionListener(this); } }} over[0]=new JTextField(7); over[1]=new JTextField(7); for (int el=0; el <=1; el++) { for (int pos=0; pos <=11; pos++) { mmpho[el][pos]=new JTextField(7); }} for (int pos=0; pos <= 5; pos++) { kait[pos]=new JTextField(7); } for (int pos=0; pos <=10; pos++) { bangle[pos]=new JTextField(7); blan[pos]=new JTextField(7); } for (int pos=0; pos <= 5; pos++) { atom[pos]=new JTextField(7); } /* layout */ String sihy[]={"eNo. ", "+X (MM)", "+Y (MM)", "+Z (MM)", "nuc (MM)", "V (eV) or FX", "Force or FY", "direw or FZ", "Waves ", "-"}; /* 1st line */ for (int el=0; el <=9; el++) { p.add(new Label(sihy[el])); } p.add(b4); p.add(atom[0]); for (int pos=0; pos <=9; pos++) { /* 2nd */ p.add(elp[0][pos]); } p.add(b5); p.add(atom[1]); for (int pos=0; pos <=9; pos++) { /* 3rd */ p.add(elp[1][pos]); } p.add(b6); p.add(atom[2]); for (int pos=0; pos <=9; pos++) { /* 4th */ p.add(elp[2][pos]); } p.add(b8); p.add(atom[3]); for (int pos=0; pos <=9; pos++) { /* 5th */ p.add(elp[3][pos]);} p.add(bb5); p.add(over[0]); for (int pos=0; pos <=10; pos++) { /* 6th */ p.add(elp[4][pos]);} p.add(over[1]); /* 7th line */ for (int pos=0; pos <=11; pos++) { p.add(elp[5][pos]);} for (int pos=0; pos <=9; pos++) { /* 8th */ p.add(elp[6][pos]);} p.add(direc); p.add(avew); for (int el=0; el <=1; el++) { /* 9, 10 lines */ for (int pos=0; pos <=11; pos++) { p.add(mmpho[el][pos]); }} p.add(bb4); p.add(atom[4]); /* 11th line */ 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); /* 12th */ p.add(b7); p.add(coom); p.add(impho); p.add(b9); p.add(kait[3]); p.add(kait[4]); p.add(kait[5]); p.add(bb3); p.add(blan[0]); p.add(blan[1]); p.add(blan[2]); p.add(blan[3]); /* 13th line */ p.add(new Label(" angle ")); for (int pos=0; pos <=10; pos++) { p.add(bangle[pos]); } coom.setSelectedItem("C"); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); b4.addActionListener(this); b5.addActionListener(this); b6.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); add(p,"South"); imppo.setText(Double.toString(att[abd][4])); charge.setText(Double.toString(att[abd][3])); over[0].setText("overall"); over[1].setText(Integer.toString(0)); for (int el=0; el <=5; el++) { kait[el].setText(Integer.toString(0)); } for (int el=0; el <=4; el++) { atom[el].setText(Integer.toString(0)); } } /* public J2DPanel() end */ /* when button click or text change */ public void actionPerformed(ActionEvent e) { String ss; ss=" "; double Rf1=0.0; mar=0; double kazu; int tei; /* sho=1 all initialization */ if (e.getSource() == bb2 && gamm !=0 && sho !=1 ) { /* charge Z change */ ss=charge.getText(); att[abd][3]=Double.parseDouble(ss); } /* abd = atom A (= 0) or B (= 1) on screen */ if (e.getSource() == b9 && sho !=1 ) { if (gamm==0 && overa==0) { /* all molecule move */ for (int ba=0; ba <= 2; ba++) { ss=kait[ba+3].getText(); cent[ba]=cent[ba]-Double.parseDouble(ss); /* cent = center coordinate */ } mar = 9; } if ( gamm == 0 && overa==1 ) { /* each atom move */ ss=over[1].getText(); int dore=Integer.parseInt(ss); /* dore=atomic number */ if ( dore >= 0 && dore < maxa ) { for (int ba=0; ba <= 2; ba++) { ss=kait[ba+3].getText(); double ido= Double.parseDouble(ss); att[dore][ba]=att[dore][ba]+ido; for (int rz=0; rz <= ato[dore][4]-1; rz++) { ele[dore][rz][ba] = ele[dore][rz][ba]+ ido; } } mar=6;} } } if (e.getSource() == b1 && sho !=1 ) { mar=1; } /* x-y rotation */ if (e.getSource() == b2 && sho !=1 ) { mar=2; } /* x-z rotation */ if (e.getSource() == b3 && sho !=1 ) { mar=3; } /* y-z rotation */ if (e.getSource() == b4 && sho !=1 ) { /* show each atom screen */ ss=atom[0].getText(); tei=Integer.parseInt(ss); if ( tei >=0 && tei < maxa) { mar=4; gamm = 1; abd=tei; /* gamm=1 each atom screen */ imppo.setText(Double.toString(att[abd][4])); charge.setText(Double.toString(att[abd][3])); if (ato[abd][4]==1) { atom[3].setText(Integer.toString(ato[abd][12])); } else { atom[3].setText(Integer.toString(0)); } } } /* abd= atomic number chosen */ /* show each atomic electron screen */ if (e.getSource() == b5 && sho !=1 ) { ss=atom[1].getText(); tei=Integer.parseInt(ss); if ( tei >=0 && tei < maxa ) { mar=5; muke=ato[tei][5]; /* muke = first atomic number around it */ gamm = 2; abd=tei; imppo.setText(Double.toString(att[abd][4])); charge.setText(Double.toString(att[abd][3])); if (ato[abd][4]==1) { atom[3].setText(Integer.toString(ato[abd][12])); } else { atom[3].setText(Integer.toString(0)); } kazu=att[abd][3]; ss="H"; if (kazu==4.22) {ss="C";} if (kazu==5.25) {ss="N";} if (kazu==6.273) {ss="O";} if (kazu==7.3) {ss="F";} if (kazu==5.05) {ss="Si";} if (kazu==6.12) {ss="P";} if (kazu==7.18) {ss="S";} if (kazu==8.26) {ss="Cl";} coom.setSelectedItem(ss); } } /* gamm=2 each atomic electron screen */ /* show overall molecule screen */ if (e.getSource() == b6 && sho !=1 ) { ss=atom[2].getText(); tei=Integer.parseInt(ss); if ( tei >=0 && tei < maxa ) { mar=6; gamm = 0; abd=tei; /* abd = atomic number chosen */ imppo.setText(Double.toString(att[abd][4])); charge.setText(Double.toString(att[abd][3])); for (int kj=0; kj <=2; kj++) { cent[kj] = att[abd][kj]; /* cent[0-2] = center coordinate of screen */ } } } /* atom kind change */ if (e.getSource() == b7 && sho !=1 && gamm==2 ) { mar=5; 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;} att[abd][3] = saia; ato[abd][4] = saik; att[abd][4]=diam; charge.setText(Double.toString(saia)); imppo.setText(Double.toString(diam)); ato[abd][12]=0; atom[3].setText(Integer.toString(ato[abd][12])); marki[abd]=1; /* marki[]= initialization of atom */ } /* hydrogen atom's type change ( 0-3 ) */ if (e.getSource() == b8 && sho !=1 && gamm==2 ) { if (ato[abd][4]==1 ) { mar=8; ss=atom[3].getText(); tei=Integer.parseInt(ss); if ( tei >= 0 && tei < 4 ) { ato[abd][12]=tei; marki[abd]=1; } }} /* nuc (= distance between electron and nucleus ) change */ if (e.getSource() == bb1 && sho !=1 && gamm==2 ) { mar=10; } /* inversion of valence electrons */ if (e.getSource() == bb3 && sho !=1 && gamm==2 ) { mar=11; } if (e.getSource() == bb4 && sho !=1 ) { if (gamm==1) {mar=12; /* turn present atom to which surrounding atom */ ss=atom[4].getText(); muk=Integer.parseInt(ss); if (muk==abd || muk >= maxa || muk < 0 ) {muk=ato[abd][5];} } if (gamm==2) { ss=atom[4].getText(); tei=Integer.parseInt(ss); int dorr=0; for (int yb=0; yb <=5; yb++) { if (tei==ato[abd][5+yb] && tei >= 0 && tei < maxa) { dorr=1; } } if ( dorr==1 ) { mar=17; muke=tei; } } } if (e.getSource() == bb5 && sho !=1 ) { /* overall or each atom move ? */ mar=16; if (overa==0) {overa=1; over[0].setText("each at");} else { overa=0; over[0].setText("overall"); }} 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, ppot; kro=0.0; krr=0.0;gx=0.0;gy=0.0;gz=0.0;ggx=0.0; ggy=0.0; ggz=0.0; int ex,ey,ez,cx,cy,cz,ce; String ww, wa, wb; ww="0"; ez=0; ey=0; int ha=0; int hb=0; ex=maxa; double potn=0.0; double debroglie=0; double gouk=0; double rhp[][][]= new double[ex][7][7]; /* rhp = each electron parameter */ double rpp[][][]= new double[ex][7][7]; /* rhp[atom][electron][coordinate, V] */ for (int yp=0; yp <=maxa-1; yp++) { for (int kj=0; kj <=6; kj++) { for (int jou=0; jou <=6; jou++) { rhp[yp][kj][jou]=0.0; rpp[yp][kj][jou]=0.0; }}} ex=maxa; double ell[][]=new double[ex][7]; ex = maxa; double mmp[][]=new double[ex][7]; double mpp[][]=new double[ex][7]; for (int yp=0; yp <=maxa-1; yp++) { for (int kj=0; kj <=6; kj++) { mmp[yp][kj]=0.0; mpp[yp][kj]=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}; double kakz=0.0; double kakt=0.0; int ssi=0; double vx,vy,vz; double hzx, hzy, hzz,kakf; double zx,zy,zz, sux,suy,suz; hzx=0; hzy=0; hzz=0; /* rot = calculation tool */ double rot[][]=new double[14][8]; double rort[][]=new double[14][8]; for (int rz=0; rz <=13; rz++) { for (int kj=0; kj <=7; kj++) { rot[rz][kj]=0.0; rort[rz][kj]=0.0; }} double rcos=0; double rsin=0; double cosr=0; double sinr=0; double bcos=0; double bsin=0; ex=maxa; int jun[][]=new int[ex][7]; for (int rz=0; rz <=maxa-1; rz++) { for (int jou=0; jou <=6; jou++) { jun[rz][jou]=0; }} for (int yp=0; yp <=maxa-1; yp++) { /* each atom initialization */ if (marki[yp] == 1) { marki[yp]=0; if ( sho==1 ) {mar=6; } /* sho=1 all atom initialization */ else if (gamm==2) { mar=5; } if (ato[yp][4] < 2 ) { /* velence electron ato[yp][4]=1 hydrogen */ ex= ato[yp][5]; /* ex = first atomic number around hydrogen */ ez=ato[ex][5]; int sta=0; int kai=0; int kaii=0; for (int hhd=0; hhd <=5; hhd++) { cx=ato[ex][5+hhd]; int betu=0; /* cx= surrounding atomic number around ex */ if ( cx > -1 ) { if ( ato[cx][4]==1 && sta==0 && jun[ex][hhd] ==0 && ato[cx][12]==0 ) { /* if cx is first hydrogen */ ey = cx; sta=1; betu=1; jun[ex][hhd]=1; /* jun, betu = marking */ /* rot[0][0-2] = ex-ey(= cx ) vector */ rot[0][0] = att[ey][0]-att[ex][0]; rot[0][1] = att[ey][1]-att[ex][1]; rot[0][2] = att[ey][2]-att[ex][2]; rot[0][3] = Math.sqrt(rot[0][0]*rot[0][0]+rot[0][1]*rot[0][1]+rot[0][2]*rot[0][2]); /* rot[0][3] = vector length */ /* rot[1][0-2] = x axis unit vector */ rot[1][0]= 1; rot[1][1] = 0; rot[1][2]=0; rot[1][3]=1; /* projection of rot[0] on x axis */ gx = (rot[0][0]*rot[1][0]+rot[0][1]*rot[1][1]+rot[0][2]*rot[1][2])/rot[1][3]; for (int kj=0; kj <=2; kj++) { // rot[2] = vector perpendicular to x axis rot[2][kj] = rot[0][kj]- gx*rot[1][kj]; } rot[2][3]=Math.sqrt(rot[2][0]*rot[2][0]+rot[2][1]*rot[2][1]+rot[2][2]*rot[2][2]); if ( rot[2][3]==0 ) { /* if rot[0] is parallel to x axis */ rot[2][0]=0; rot[2][1]=1.0; rot[2][2] = 0; rot[2][3]=1; } rcos=gx/rot[0][3]; /* rcos = first rotation cosine */ gy = (rot[0][0]*rot[2][0]+rot[0][1]*rot[2][1]+rot[0][2]*rot[2][2])/rot[2][3]; rsin=gy/rot[0][3]; /* rsin = forst rotation sine */ /* rot[3][0-2] = perpendicular to rot[1] and rot[2] */ rot[3][0]=rot[1][1]*rot[2][2]-rot[1][2]*rot[2][1]; rot[3][1]=rot[1][2]*rot[2][0]-rot[1][0]*rot[2][2]; rot[3][2]=rot[1][0]*rot[2][1]-rot[1][1]*rot[2][0]; rot[3][3]=Math.sqrt(rot[3][0]*rot[3][0]+rot[3][1]*rot[3][1]+rot[3][2]*rot[3][2]); /* (gx, gy, gz) = (0,0,1) projection onto rot[1], rot[2], rot[3] */ gz=rot[3][2]/rot[3][3]; gx=rot[1][2]/rot[1][3]; gy=rot[2][2]/rot[2][3]; ggx=rcos*gx-rsin*gy; ggy = rsin*gx+rcos*gy; /* rot[6] = vector after first rotating unit vector (0,0,1) */ for (int jou=0; jou <=2; jou++) { rot[6][jou]= (ggx*rot[1][jou])/rot[1][3] + (ggy*rot[2][jou])/rot[2][3]+(gz*rot[3][jou])/rot[3][3]; } rot[6][3]=Math.sqrt(rot[6][0]*rot[6][0]+rot[6][1]*rot[6][1]+rot[6][2]*rot[6][2]); /* rot[4][0-2] = vector perpendicular to rot[6] and rot[0] */ rot[4][0]=rot[6][1]*rot[0][2]-rot[6][2]*rot[0][1]; rot[4][1]=rot[6][2]*rot[0][0]-rot[6][0]*rot[0][2]; rot[4][2]=rot[6][0]*rot[0][1]-rot[6][1]*rot[0][0]; rot[4][3]=Math.sqrt(rot[4][0]*rot[4][0]+rot[4][1]*rot[4][1]+rot[4][2]*rot[4][2]); /* (gx,gy,gz) = projection of (0, 0, -4500) onto rot[1], rot[2], rot[3] */ gz=(rot[3][2]*-4500)/rot[3][3]; gy= (rot[2][2] * -4500)/rot[2][3]; gx= (rot[1][2] * -4500)/rot[1][3]; ggx=rcos*gx - rsin*gy; ggy=rsin*gx+rcos*gy; /* (hzx, hzy, hzz) = vector after first rotating ( 0, 0, -4500 ) */ hzx=ggx+ ggy*rot[2][0]/rot[2][3] + gz*rot[3][0]/rot[3][3]; hzy=ggy*rot[2][1]/rot[2][3] + gz*rot[3][1]/rot[3][3]; hzz=ggy*rot[2][2]/rot[2][3] + gz*rot[3][2]/rot[3][3]; /* ele[atom][ ele 0 ][0-2] = absolute coordinate of hydrogen electron */ ele[ey][0][0] = att[ey][0]+ hzx ; ele[ey][0][1] = att[ey][1]+ hzy ; ele[ey][0][2] = att[ey][2]+ hzz ; /* ele[atom][ ele 0 ][6-7] = vector after rotating ( 0, 0, -4500 ) */ ele[ey][0][6] = hzx; ele[ey][0][7] = hzy; ele[ey][0][8] = hzz; } /* if sta=0 end */ /* when second hydrogen is found around ex atom */ if ( ato[cx][4]==1 && sta ==1 && betu == 0 && jun[ex][hhd] ==0 && ato[cx][12] == 1 ) { /* ato[cx][12] = hydrogen type number ( 0-3 ) */ jun[ex][hhd]=1; sta=2; ez=cx; /* ez=cx -- this hydrogen atomic number */ /* rot[5] = ex to ez vector */ rot[5][0] = att[ez][0]-att[ex][0]; rot[5][1] = att[ez][1]-att[ex][1]; rot[5][2] = att[ez][2]-att[ex][2]; rot[5][3]=Math.sqrt(rot[5][0]*rot[5][0]+rot[5][1]*rot[5][1]+rot[5][2]*rot[5][2]); /* gx, gy = projection of rot[5] to rot[4] and rot[6] */ gx=(rot[5][0]*rot[4][0]+rot[5][1]*rot[4][1]+rot[5][2]*rot[4][2])/rot[4][3]; gy=(rot[5][0]*rot[6][0]+rot[5][1]*rot[6][1]+rot[5][2]*rot[6][2])/rot[6][3]; ggx= Math.sqrt(gx*gx+gy*gy); if ( ggx==0 ) { cosr=1.0; sinr=0.0; } else { cosr= gy/ggx; sinr=gx/ggx; } /* second rotation cosine sine */ /* second rotation of ( hzx, hzy, hzy) */ gz=(hzx*rot[0][0]+ hzy*rot[0][1] + hzz*rot[0][2])/rot[0][3]; gy=(hzx*rot[6][0]+ hzy*rot[6][1] + hzz*rot[6][2])/rot[6][3]; gx=(hzx*rot[4][0]+ hzy*rot[4][1] + hzz*rot[4][2])/rot[4][3]; ggx= cosr*gx+sinr*gy; ggy=-sinr*gx+cosr*gy; hzx=(ggx*rot[4][0])/rot[4][3] + (ggy*rot[6][0])/rot[6][3] + (gz*rot[0][0])/rot[0][3]; hzy=(ggx*rot[4][1])/rot[4][3] + (ggy*rot[6][1])/rot[6][3] + (gz*rot[0][1])/rot[0][3]; hzz=(ggx*rot[4][2])/rot[4][3] + (ggy*rot[6][2])/rot[6][3] + (gz*rot[0][2])/rot[0][3]; ele[ey][0][6] = hzx; ele[ey][0][7] = hzy; ele[ey][0][8] = hzz; ele[ey][0][0] = att[ey][0]+ hzx ; ele[ey][0][1] = att[ey][1]+ hzy ; ele[ey][0][2] = att[ey][2]+ hzz ; } /* if sta == 1 end */ /* when hydrogen atom (type1-3) is found */ if ( ato[cx][4]==1 && ato[cx][12] > 1 && jun[ex][hhd]==0 ) { jun[ex][hhd]=1; } if ( ato[cx][4]==1 && ato[cx][12] == 1 && sta==2 && jun[ex][hhd]==0 ) { jun[ex][hhd]=1; } if ( ato[cx][4]==1 && ato[cx][12] ==0 && jun[ex][hhd] != 1 ) { jun[ex][hhd]=2; /* when other type 0 hydrogen is found */ for (int kj=0; kj <=2; kj++) { rot[9][kj]=att[cx][kj]-att[ato[cx][5]][kj]; } rot[9][3]=Math.sqrt(rot[9][0]*rot[9][0]+rot[9][1]*rot[9][1]+rot[9][2]*rot[9][2]); rot[10][0]=rot[9][1]*1.0; rot[10][1]=-rot[9][0]*1.0; rot[10][2]=0.0; rot[10][3]=Math.sqrt(rot[10][0]*rot[10][0]+rot[10][1]*rot[10][1]+rot[10][2]*rot[10][2]); if ( rot[10][3] ==0 ) { rot[10][0]=0; rot[10][1]=1; rot[10][2]=0; rot[10][3]=1; } rot[11][0] = rot[10][1]*rot[9][2]-rot[10][2]*rot[9][1]; rot[11][1] = rot[10][2]*rot[9][0]-rot[10][0]*rot[9][2]; rot[11][2] = rot[10][0]*rot[9][1]-rot[10][1]*rot[9][0]; rot[11][3]=Math.sqrt(rot[11][0]*rot[11][0]+rot[11][1]*rot[11][1]+rot[11][2]*rot[11][2]); for (int kj=0; kj <=2; kj++) { ele[cx][0][6+kj]=(4500.0*rot[11][kj])/rot[11][3]; ele[cx][0][kj] = ele[cx][0][6+kj] + att[cx][kj]; } } } } /* for hhd = 5 end */ int banum=0; for (int hte=0; hte <=5; hte++) { /* two rotations of hydrogen electron */ double tx,ty,tz ,ttx, tty, ttz; int ee; if ( jun[ex][hte]==1 ) { cx=ato[ex][5+hte]; if ( cx > -1 ) { ee = ato[cx][12] ; /* ato[][12]= hydrogen atom type ( 0, 1, 2, or 3 ) */ banum=1; ez=cx; if ( ato[cx][12] == 0 && jun[ex][hte] == 1 ) { banum=0; } if ( banum !=0 ) { /* projection hydrogen vector met[][] onto rot[1], rot[2], rot[3] */ gx=(met[ee][0]*rot[1][0]+ met[ee][1]*rot[1][1] + met[ee][2]*rot[1][2])/rot[1][3]; gy=(met[ee][0]*rot[2][0]+ met[ee][1]*rot[2][1] + met[ee][2]*rot[2][2])/rot[2][3]; gz=(met[ee][0]*rot[3][0]+ met[ee][1]*rot[3][1] + met[ee][2]*rot[3][2])/rot[3][3]; ggx=rcos*gx-rsin*gy; ggy=rsin*gx+rcos*gy; for (int jou=0; jou <=2; jou++) { /* rot[7][0-2] = after first rotation */ rot[7][jou]= (ggx*rot[1][jou])/rot[1][3]+(ggy*rot[2][jou])/rot[2][3] + (gz*rot[3][jou])/rot[3][3]; } jun[ex][hte] = 2; if (sta==2) { /* projection of rot[7] to rot[4], rot[6], rot[0] */ gx=(rot[7][0]*rot[4][0]+ rot[7][1]*rot[4][1] + rot[7][2]*rot[4][2])/rot[4][3]; gy=(rot[7][0]*rot[6][0]+ rot[7][1]*rot[6][1] + rot[7][2]*rot[6][2])/rot[6][3]; gz=(rot[7][0]*rot[0][0]+ rot[7][1]*rot[0][1] + rot[7][2]*rot[0][2])/rot[0][3]; ggx=cosr*gx+sinr*gy; ggy=-sinr*gx+cosr*gy; for (int jou=0; jou <=2; jou++) { /* after second rotation */ rot[7][jou]= (ggx*rot[4][jou])/rot[4][3]+(ggy*rot[6][jou])/rot[6][3] + (gz*rot[0][jou])/rot[0][3]; } } for (int kj=0; kj <=2; kj++) { /* ele[atom][ele0][6-7] = after two rotations of hydrogen vector met */ ele[cx][0][6+kj] = (rot[7][kj]*4500.0)/10000.0; /* ele[atom][ele0][0-2] = initial absolute coordinate of hydrogen electron */ ele[cx][0][kj] = ele[cx][0][6+kj] + att[cx][kj]; } } }} /* if ( jun=1 ) end */ }} /* if hydrogen end */ if ( ato[yp][4] > 1) { /* valence electron ato[][4] > 1 -- other atoms */ ex = ato[yp][5]; /* ex = first around atom */ rort[0][0] = att[ex][0]-att[yp][0]; /* rort[0][0-2] = vector yp to ex */ rort[0][1] = att[ex][1]-att[yp][1]; rort[0][2] = att[ex][2]-att[yp][2]; rort[0][3] = Math.sqrt(rort[0][0]*rort[0][0]+rort[0][1]*rort[0][1]+rort[0][2]*rort[0][2]); for (int kj=0; kj <=2; kj++) { /* rort[1][0-2] = each atom's electron vector */ if ( ato[yp][4] == 4 ) { rort[1][kj] = te1[0][kj]; } if ( ato[yp][4] == 6 ) { rort[1][kj] = te2[0][kj]; } if ( ato[yp][4] == 5 ) { rort[1][kj] = te3[3][kj]; } if ( ato[yp][4] == 7 ) { rort[1][kj] = te4[4][kj]; } } rort[1][3]=Math.sqrt(rort[1][0]*rort[1][0]+rort[1][1]*rort[1][1]+rort[1][2]*rort[1][2]); gy=rort[1][3]; diam=att[yp][4]; /* diam = each atom's diameter (= nuc ) */ for (int kj=0; kj <=3; kj++) { rort[1][kj]=(rort[1][kj]*diam)/rort[1][3]; } /* gx = projection of rot[1] on rot[0] */ gx=(rort[1][0]*rort[0][0]+rort[1][1]*rort[0][1]+rort[1][2]*rort[0][2])/rort[0][3]; rort[0][4]=gx; for (int kj=0; kj <=2; kj++) { /* rort[2] = perpendicular to rot[0] */ rort[2][kj] = rort[1][kj]-(rort[0][kj]*gx)/rort[0][3] ; } rort[2][3]=Math.sqrt(rort[2][0]*rort[2][0]+rort[2][1]*rort[2][1]+rort[2][2]*rort[2][2]); if ( rort[2][3] == 0 ) { /* when rort[1] is parallel to rort[0] */ rort[2][0]=0; rort[2][1]=1; rort[2][2]=0; rort[2][3]=1; if ( ato[yp][4]==6 ) { rort[2][0]=1; rort[2][1]=1; rort[2][2]=0; rort[2][3]=Math.sqrt(2); } if ( ato[yp][4]==7 ) { rort[2][0]=1; rort[2][1]=0; rort[2][2]=0; rort[2][3]=1; } } /* rort[3][0-2] = perpendicular to rot[0] and rot[2] */ rort[3][0] = rort[0][1]*rort[2][2] - rort[0][2]*rort[2][1]; rort[3][1] = rort[0][2]*rort[2][0] - rort[0][0]*rort[2][2]; rort[3][2] = rort[0][0]*rort[2][1] - rort[0][1]*rort[2][0]; rort[3][3]=Math.sqrt(rort[3][0]*rort[3][0]+rort[3][1]*rort[3][1]+rort[3][2]*rort[3][2]); /* ggx = projection of rort[1] to rort[2] */ ggx= (rort[1][0]*rort[2][0]+rort[1][1]*rort[2][1]+rort[1][2]*rort[2][2])/rort[2][3]; bcos = rort[0][4]/rort[1][3]; bsin = ggx/rort[1][3]; /* rotation cosine, sine */ if (ato[yp][4]==4 && sho==1 ) { ato[yp][12]=0; for (int shu=0; shu <=5; shu++) { int atn=ato[yp][5+shu]; if ( atn > -1 && atn < yp ) { if ( ato[atn][4]==4 ) { if (ato[atn][12]==0) { ato[yp][12]=1; } } } } } for (int rz=0; rz <=ato[yp][4]-1; rz++) { for (int kj=0; kj <=2; kj++) { /* rot[4][0-2] = each electron vector */ if ( ato[yp][4] == 4 ) { rort[4][kj] = te1[rz][kj]; } if ( ato[yp][4] == 6 ) { rort[4][kj] = te2[rz][kj]; } if ( ato[yp][4] == 5 ) { rort[4][kj] = te3[rz][kj]; } if ( ato[yp][4] == 7 ) { rort[4][kj] = te4[rz][kj]; } } rort[4][3]=Math.sqrt(rort[4][0]*rort[4][0]+rort[4][1]*rort[4][1]+rort[4][2]*rort[4][2]); for (int kj=0; kj <=3; kj++) { rort[4][kj]=(rort[4][kj]*diam)/rort[4][3]; } /* rort[5][0-2] = projection of rort[4] to rort[0], rort[2], rort[3] */ rort[5][2] = (rort[4][0]*rort[3][0]+rort[4][1]*rort[3][1]+rort[4][2]*rort[3][2])/rort[3][3]; rort[5][0] = (rort[4][0]*rort[0][0]+rort[4][1]*rort[0][1]+rort[4][2]*rort[0][2])/rort[0][3]; rort[5][1] = (rort[4][0]*rort[2][0]+rort[4][1]*rort[2][1]+rort[4][2]*rort[2][2])/rort[2][3]; gx= bcos*rort[5][0] + bsin*rort[5][1]; /* rotation on rort[0] - rort[2] plane */ gy= -bsin*rort[5][0] + bcos*rort[5][1]; for (int kj=0; kj <=2; kj++) { /* ele[yp][rz][3-5] = relative electron coordinate */ ele[yp][rz][kj+3] = (gx*rort[0][kj])/rort[0][3] + (gy*rort[2][kj])/rort[2][3] + (rort[5][2]*rort[3][kj])/rort[3][3] ; /* ele[atom][ele][0-2] = absolute electron coordinate */ if (ato[yp][4]==4 && ato[yp][12]==1 && sho==1 ) { ele[yp][rz][kj+3]= -ele[yp][rz][kj+3]; } ele[yp][rz][kj] = ele[yp][rz][kj+3] + att[yp][kj]; } } } /* other atoms end */ } /* if marki == 1 end */ } /* for loop initialization end */ if (mar == 6 || mar == 4 ) { /* each atom or overall molecule screen */ sho=0; for (int yp=0; yp <=6; yp++) { ww = " "; if ( abd+yp < maxa && mar==6 ) { ww = "atom " + Integer.toString(abd+yp);} if ( yp == 0) { ww = "atom " + Integer.toString(abd); } if ( ato[abd][4+yp] > -1 && mar==4 && yp !=0 ) { ww = "atom " + Integer.toString(ato[abd][4+yp]);} if ( abd+yp >= maxa && mar==6 && abd !=0 && abd+yp-maxa < abd ){ ww = "atom "+ Integer.toString( abd+yp-maxa); } elp[yp][0].setText(ww); /* show atomic number on screen */ for (int kj=0; kj <=2; kj++) { ww = Double.toString(0); if ( abd+yp < maxa && mar==6 ) { /* show each atom absolute coordinate */ ex=(int)(100*att[abd+yp][kj]); ggx=ex/100.0; ww = Double.toString(ggx); } if ( yp == 0 && mar==4 ) { /* show each atom's relative coordinate */ ggx=0; ww = Double.toString(ggx); } if ( ato[abd][4+yp] > -1 && mar==4 && yp !=0 ) { ex=(int)(100*(att[ato[abd][4+yp]][kj]-att[abd][kj])); ggx=ex/100.0; ww = Double.toString(ggx); } if ( abd+yp >= maxa && mar==6 && abd !=0 && abd+yp-maxa < abd ){ ex=(int)(100*att[abd+yp-maxa][kj]); ggx=ex/100.0; ww = Double.toString(ggx); } elp[yp][kj+1].setText(ww); } ex=0; /* show distance between atoms */ if ( abd+yp < maxa && yp !=0 && mar==6 ) { kro=Math.sqrt((att[abd+yp][0]-att[abd][0])*(att[abd+yp][0]-att[abd][0])+ (att[abd+yp][1]-att[abd][1])*(att[abd+yp][1]-att[abd][1])+ (att[abd+yp][2]-att[abd][2])*(att[abd+yp][2]-att[abd][2])); if (kro == 0) {kro=5000.0;} ex=(int)(kro); } if ( ato[abd][4+yp] > -1 && mar==4 && yp != 0 ) { ez=ato[abd][4+yp]; kro=Math.sqrt((att[ez][0]-att[abd][0])*(att[ez][0]-att[abd][0])+ (att[ez][1]-att[abd][1])*(att[ez][1]-att[abd][1])+ (att[ez][2]-att[abd][2])*(att[ez][2]-att[abd][2])); if (kro == 0) {kro=5000.0;} ex=(int)(kro); } for (int kj=5; kj <=9; kj++) { elp[yp][kj].setText(Integer.toString(0)); } } } /* each atom of overall molecule click end */ if ( mar == 5 || mar==17 ) { /* show each atomic electron on screen */ ex = muke; /* muke = direction in which each electron is turned */ rot[0][0] = att[ex][0]-att[abd][0]; // rot[0][0-2] = abd-ex vector rot[0][1] = att[ex][1]-att[abd][1]; rot[0][2] = att[ex][2]-att[abd][2]; rot[0][3] = Math.sqrt(rot[0][0]*rot[0][0]+rot[0][1]*rot[0][1]+rot[0][2]*rot[0][2]); /* rot[1][0-2] = y axis init vector */ rot[1][0] = 0 ; rot[1][1] = 1; rot[1][2] = 0; rot[1][3] = 1; /* rot[2][0-2] = perpendicular to y axis */ rot[2][0]= rot[0][0]; rot[2][1] = 0; rot[2][2] = rot[0][2]; rot[2][3] = Math.sqrt(rot[2][0]*rot[2][0]+rot[2][2]*rot[2][2]); if ( rot[2][3]==0 ) { rot[2][0]= 1; rot[2][1] = 0; rot[2][2] = 0; rot[2][3] = 1; } if ( rot[2][3] < 0.00001 && rot[2][3] > -0.00001 ) { for (int jou=0; jou <=3; jou++) { rot[2][jou]=rot[2][jou]*1.0e9; } } /* ggx = projection of rot[0] on y axis */ ggx=(rot[0][0]*rot[1][0]+rot[0][1]*rot[1][1]+rot[0][2]*rot[1][2])/rot[1][3]; rcos=ggx/rot[0][3] ; erot[4][0]=rcos; /* gx = projection of rot[0] on rot[2] */ gx = (rot[0][0]*rot[2][0]+rot[0][1]*rot[2][1]+rot[0][2]*rot[2][2])/rot[2][3]; rsin= gx/rot[0][3]; erot[4][1]=rsin; /* rot[3][0-2] = vector perpendicular to rot[1] and rot[2] */ rot[3][0]=rot[1][1]*rot[2][2]-rot[1][2]*rot[2][1]; rot[3][1]=rot[1][2]*rot[2][0]-rot[1][0]*rot[2][2]; rot[3][2]=rot[1][0]*rot[2][1]-rot[1][1]*rot[2][0]; rot[3][3] = Math.sqrt(rot[3][0]*rot[3][0]+rot[3][1]*rot[3][1]+rot[3][2]*rot[3][2]); for (int tr=0; tr <=3; tr++) { for (int jou=0; jou <=3; jou++) { erot[tr][jou]=rot[tr][jou]; }} for (int yp=0; yp <=6; yp++) { if ( yp < ato[abd][4] ) { ww = "ele " + Integer.toString(yp);} else { ww = " "; } elp[yp][0].setText(ww); /* show electron number on screen */ if ( yp < ato[abd][4] ) { /* rot[4] = each electron relative coordinate */ for (int kj=0; kj <=2; kj++) { rot[4][kj]=ele[abd][yp][kj] - att[abd][kj]; } rot[4][3] = Math.sqrt(rot[4][0]*rot[4][0]+rot[4][1]*rot[4][1]+rot[4][2]*rot[4][2]); /* rot[5][0-2] = projection of rot[4] onto rot[1], rot[2], rot[3] */ rot[5][2]=(rot[4][0]*rot[3][0]+rot[4][1]*rot[3][1]+rot[4][2]*rot[3][2])/rot[3][3]; rot[5][1]=(rot[4][0]*rot[2][0]+rot[4][1]*rot[2][1]+rot[4][2]*rot[2][2])/rot[2][3]; rot[5][0]=rot[4][1]; gx=rcos*rot[5][0] + rsin*rot[5][1]; /* rotation */ gy=-rsin*rot[5][0] + rcos*rot[5][1]; } for (int kj=0; kj <=2; kj++) { ww=Integer.toString(0); if ( yp < ato[abd][4] ) { /* ele[atom][ele][3-5] = relative cordinate after rotation */ ele[abd][yp][kj+3] = (gy*rot[2][kj])/rot[2][3]+(gx*rot[1][kj])/rot[1][3] + (rot[5][2]*rot[3][kj])/rot[3][3]; /* show relative coordinate of valence electrons */ ex=(int)(100*ele[abd][yp][kj+3]); ggx=ex/100.0; ww = Double.toString(ggx); } elp[yp][kj+1].setText(ww); } /* show distance between electron and nucleus */ if ( yp < ato[abd][4] ) { kro=Math.sqrt(ele[abd][yp][3]*ele[abd][yp][3]+ele[abd][yp][4]*ele[abd][yp][4]+ele[abd][yp][5]*ele[abd][yp][5]); if (kro == 0) {kro=5000.0;} ex=(int)(kro); ww=Integer.toString(ex); } elp[yp][4].setText("nuc "+ ww ); } /* for (int yp=0; yp <=6; yp++) end */ /* surronding atom rotation */ for (int yp=0; yp <=5; yp++) { if ( ato[abd][yp+5] > -1 ) { ez=ato[abd][yp+5]; /* surronding atom's number */ for (int kj=0; kj <=2; kj++) { rot[4][kj]=att[ez][kj] - att[abd][kj]; } rot[4][3] = Math.sqrt(rot[4][0]*rot[4][0]+rot[4][1]*rot[4][1]+rot[4][2]*rot[4][2]); rot[5][2]=(rot[4][0]*rot[3][0]+rot[4][1]*rot[3][1]+rot[4][2]*rot[3][2])/rot[3][3]; rot[5][1]=(rot[4][0]*rot[2][0]+rot[4][1]*rot[2][1]+rot[4][2]*rot[2][2])/rot[2][3]; rot[5][0]=rot[4][1]; gx=rcos*rot[5][0] + rsin*rot[5][1]; gy=-rsin*rot[5][0] + rcos*rot[5][1]; for (int kj=0; kj <=2; kj++) { ska[yp][kj] = (gy*rot[2][kj])/rot[2][3]+(gx*rot[1][kj])/rot[1][3] + (rot[5][2]*rot[3][kj])/rot[3][3]; /* ska[yp][0-2] = vector after rotating surrounding atoms */ } ska[yp][3]=ato[abd][yp+5]; } } /* for (int yp=0; yp <=5; yp++) end */ } /* show electron on screen end */ int hma=0; if ( gamm == 2 ) { /* get valence electron's coordinate from text */ if ( ato[abd][4] == 1 && ato[abd][12] > 0 ) { hma=1;} /* excluding type 1-3 hydrogen */ if ( hma == 0) { for (int yp=0; yp <=6; yp++) { for (int kj=0; kj <=2; kj++) { if ( yp < ato[abd][4] ) { ww=elp[yp][kj+1].getText(); ele[abd][yp][kj+3]=Double.parseDouble(ww); } }} if (mar == 11 && hma !=1 ){ /* inversion of electron's coordinate */ for (int yp=0; yp < ato[abd][4]; yp++) { for (int kj=0; kj <=2; kj++) { ele[abd][yp][kj+3] = -ele[abd][yp][kj+3]; }} } if ( mar == 10 && hma !=1 ) { /* nuc = distance change */ ww=imppo.getText(); gx=Double.parseDouble(ww); for (int yp=0; yp < ato[abd][4]; yp++) { gy=Math.sqrt(ele[abd][yp][3]*ele[abd][yp][3]+ele[abd][yp][4]*ele[abd][yp][4]+ele[abd][yp][5]*ele[abd][yp][5]); for (int kj=0; kj <=2; kj++) { ele[abd][yp][kj+3]=(ele[abd][yp][kj+3]*gx)/gy; } } } if ( mar > 0 && mar < 4 && hma !=1 ) { /* all rotation of electrons */ ww=kait[mar-1].getText(); gx=Double.parseDouble(ww); /* gx = rotation angle, degree */ rcos=Math.cos((gx*pai)/180.0); rsin=Math.sin((gx*pai)/180.0); if (mar==1) { ha=0; hb=1; } /* rotation on x-y plane */ if (mar==2) { ha=0; hb=2; } /* rotation on x-z plane */ if (mar==3) { ha=1; hb=2; } /* rotation on y-z plane */ for (int yp=0; yp < ato[abd][4]; yp++) { gx = rcos*ele[abd][yp][ha+3] - rsin*ele[abd][yp][hb+3]; gy = rsin*ele[abd][yp][ha+3] + rcos*ele[abd][yp][hb+3]; ele[abd][yp][ha+3]=gx; ele[abd][yp][hb+3]=gy; } } /* reshow each electron's coordinate */ for (int yp=0; yp <=6; yp++) { if ( yp < ato[abd][4] ) { ww = "ele " + Integer.toString(yp);} else { ww = " "; } elp[yp][0].setText(ww); for (int kj=0; kj <=2; kj++) { ww=Integer.toString(0); if ( yp < ato[abd][4] ) { ex=(int)(100*ele[abd][yp][kj+3]); ggx=ex/100.0; ww = Double.toString(ggx); } elp[yp][kj+1].setText(ww); } if ( yp < ato[abd][4] ) { /* kro = distance */ kro=Math.sqrt(ele[abd][yp][3]*ele[abd][yp][3]+ele[abd][yp][4]*ele[abd][yp][4]+ele[abd][yp][5]*ele[abd][yp][5]); if (kro == 0) {kro=5000.0;} ex=(int)(kro); ww=Integer.toString(ex); } elp[yp][4].setText("nuc "+ ww ); } } /* if ( hma != 0 ) end */ /* return to absolute coordinate from relative ones */ if ( hma !=1 ) { rot[0][0]=0; rot[0][1]=1; rot[0][2]=0; rot[0][3]=1 ; for (int kj=0; kj <=2; kj++) { rot[1][kj]= att[muke][kj]-att[abd][kj]; } rot[1][3]=Math.sqrt(rot[1][0]*rot[1][0]+rot[1][1]*rot[1][1]+rot[1][2]*rot[1][2]); gx= (rot[1][0]*rot[0][0]+rot[1][1]*rot[0][1]+rot[1][2]*rot[0][2])/rot[0][3]; rcos=gx/rot[1][3]; for (int kj=0; kj <=2; kj++) { rot[2][kj]= rot[1][kj]-rot[0][kj]*gx; } rot[2][3]=Math.sqrt(rot[2][0]*rot[2][0]+rot[2][1]*rot[2][1]+rot[2][2]*rot[2][2]); if ( rot[2][3]==0 ) { rot[2][0]=1; rot[2][1]=0; rot[2][2]=0; rot[2][3]=1; } if ( rot[2][3] < 0.000001 && rot[2][3] > -0.000001 ) { for (int kj=0; kj <=3; kj++) { rot[2][kj]= rot[2][kj]*1.0e10; } } gy=(rot[1][0]*rot[2][0]+rot[1][1]*rot[2][1]+rot[1][2]*rot[2][2])/rot[2][3]; rsin=gy/rot[1][3]; rot[3][0] = rot[2][1]*rot[0][2]- rot[2][2]*rot[0][1]; rot[3][1] = rot[2][2]*rot[0][0]- rot[2][0]*rot[0][2]; rot[3][2] = rot[2][0]*rot[0][1]- rot[2][1]*rot[0][0]; rot[3][3]=Math.sqrt(rot[3][0]*rot[3][0]+rot[3][1]*rot[3][1]+rot[3][2]*rot[3][2]); for (int yp=0; yp < ato[abd][4]; yp++) { gx=ele[abd][yp][4]; /* projection of relative coodinate on y axis */ gz= (ele[abd][yp][3]*rot[3][0]+ele[abd][yp][4]*rot[3][1]+ele[abd][yp][5]*rot[3][2])/rot[3][3]; /* projection onto rot 3 */ gy= (ele[abd][yp][3]*rot[2][0]+ele[abd][yp][4]*rot[2][1]+ele[abd][yp][5]*rot[2][2])/rot[2][3]; /* projection onto rot 2 */ ggx=rcos*gx - rsin*gy; ggy=rsin*gx+rcos*gy; for (int kj=0; kj <=2; kj++) { ele[abd][yp][kj] = ggx*rot[0][kj] + (ggy*rot[2][kj])/rot[2][3] + (gz*rot[3][kj])/rot[3][3]; ele[abd][yp][kj]=ele[abd][yp][kj]+att[abd][kj]; /* absolute coordinate */ } } } if (ato[abd][4]==1 && ato[abd][12]==0) { /* hydrogen type-0 */ ex=ato[abd][5]; /* first surrounding atom's number */ for (int kj=0; kj <=2; kj++) { /* rot[6] = ex-abd vector */ rot[6][kj]=att[abd][kj]-att[ex][kj]; rot[7][kj]=ele[abd][0][kj+6]; /* met vector */ rot[9][kj]=ele[abd][0][kj]-att[abd][kj]; /* abd - each ele vector */ } rot[6][3]=Math.sqrt(rot[6][0]*rot[6][0]+rot[6][1]*rot[6][1]+rot[6][2]*rot[6][2]); rot[7][3]=Math.sqrt(rot[7][0]*rot[7][0]+rot[7][1]*rot[7][1]+rot[7][2]*rot[7][2]); rot[9][3]=Math.sqrt(rot[9][0]*rot[9][0]+rot[9][1]*rot[9][1]+rot[9][2]*rot[9][2]); /* rot[8] = outer product of rot6 and 7 */ rot[8][0] = rot[6][1]*rot[7][2]-rot[6][2]*rot[7][1]; rot[8][1] = rot[6][2]*rot[7][0]-rot[6][0]*rot[7][2]; rot[8][2] = rot[6][0]*rot[7][1]-rot[6][1]*rot[7][0]; rot[8][3]=Math.sqrt(rot[8][0]*rot[8][0]+rot[8][1]*rot[8][1]+rot[8][2]*rot[8][2]); /* projection of rot[9] onto rot7, 6 and 8 */ ggx=(rot[9][0]*rot[7][0]+rot[9][1]*rot[7][1]+rot[9][2]*rot[7][2])/rot[7][3]; ggy=(rot[9][0]*rot[6][0]+rot[9][1]*rot[6][1]+rot[9][2]*rot[6][2])/rot[6][3]; ggz=(rot[9][0]*rot[8][0]+rot[9][1]*rot[8][1]+rot[9][2]*rot[8][2])/rot[8][3]; for (int yp=0; yp <=5; yp++) { if (ato[ex][5+yp] > -1 ) { ey=ato[ex][5+yp]; if (ato[ey][4]==1 && ato[ey][12] > 0) { /* other-types hydrogen */ for (int kj=0; kj <=2; kj++) { rot[0][kj]=att[ey][kj]-att[ex][kj]; rot[1][kj]=ele[ey][0][kj+6]; } rot[0][3]=Math.sqrt(rot[0][0]*rot[0][0]+rot[0][1]*rot[0][1]+rot[0][2]*rot[0][2]); rot[1][3]=Math.sqrt(rot[1][0]*rot[1][0]+rot[1][1]*rot[1][1]+rot[1][2]*rot[1][2]); rot[2][0] = rot[0][1]*rot[1][2]-rot[0][2]*rot[1][1]; rot[2][1] = rot[0][2]*rot[1][0]-rot[0][0]*rot[1][2]; rot[2][2] = rot[0][0]*rot[1][1]-rot[0][1]*rot[1][0]; rot[2][3]=Math.sqrt(rot[2][0]*rot[2][0]+rot[2][1]*rot[2][1]+rot[2][2]*rot[2][2]); /* determine other-type hydrogen electron's position based on hydrogen 0 */ for (int kj=0; kj <=2; kj++) { ele[ey][0][kj]=(ggx * rot[1][kj])/rot[1][3] + (ggz * rot[2][kj])/rot[2][3] + (ggy* rot[0][kj])/rot[0][3]; ele[ey][0][kj]=ele[ey][0][kj]+att[ey][kj] ; } } }} } /* hydrogen 0 end */ } /* if (gamm==2) end */ if ( gamm ==1 ) { /* get each atom's coordinate from text */ for (int yp=1; yp <=6; yp++) { for (int kj=0; kj <=2; kj++) { ez=ato[abd][4+yp]; /* atomic number */ if (ez > 0 ) { ww=elp[yp][kj+1].getText(); ggx=att[ez][kj]; /* change atom and its electron's coordinate */ att[ez][kj]=Double.parseDouble(ww)+att[abd][kj]; for (int kde=0; kde <=ato[ez][4]-1; kde++) { ele[ez][kde][kj] = ele[ez][kde][kj]-ggx+att[ez][kj]; } } }}} if ( mar > 0 && mar < 4 && gamm < 2 ) { /* all rotation gamm=0,1 */ ww=kait[mar-1].getText(); gx=Double.parseDouble(ww); /* gx = rotation angle */ rcos=Math.cos((gx*pai)/180.0); rsin=Math.sin((gx*pai)/180.0); if (mar==1) { ha=0; hb=1; } if (mar==2) { ha=0; hb=2; } if (mar==3) { ha=1; hb=2; } for (int yp=0; yp <= maxa-1; yp++) { /* rotation around abd (= present ) atom */ if ( yp != abd ) { ggx=att[yp][ha]-att[abd][ha]; ggy=att[yp][hb]-att[abd][hb]; gx = rcos*ggx - rsin*ggy; gy = rsin*ggx + rcos*ggy; att[yp][ha]=gx+att[abd][ha]; att[yp][hb]=gy+att[abd][hb]; } for (int ft=0; ft <= ato[yp][4]-1; ft++) { ggx=ele[yp][ft][ha]-att[abd][ha]; ggy=ele[yp][ft][hb]-att[abd][hb]; gx = rcos*ggx - rsin*ggy; gy = rsin*ggx + rcos*ggy; ele[yp][ft][ha]=gx+att[abd][ha]; ele[yp][ft][hb]=gy+att[abd][hb]; } if ( ato[yp][4]==1 ) { /* rotation hydrogen met vector */ ggx=ele[yp][0][ha+6]; ggy=ele[yp][0][hb+6]; gx = rcos*ggx - rsin*ggy; gy = rsin*ggx + rcos*ggy; ele[yp][0][ha+6]=gx; ele[yp][0][hb+6]=gy; } } } if (mar==12){ /* gamm=1 (atom) screen, turn muk atom to y direction */ ex = muk; /* rot[0] = abd to ex vector */ rot[0][0] = att[ex][0]-att[abd][0]; rot[0][1] = att[ex][1]-att[abd][1]; rot[0][2] = att[ex][2]-att[abd][2]; rot[0][3] = Math.sqrt(rot[0][0]*rot[0][0]+rot[0][1]*rot[0][1]+rot[0][2]*rot[0][2]); rot[1][0] = 0; rot[1][1] = 1; rot[1][2] = 0; rot[1][3] = 1; /* y axis */ /* ggx = projection of rot[0] on y axis */ ggx = (rot[0][0]*rot[1][0]+rot[0][1]*rot[1][1]+rot[0][2]*rot[1][2])/rot[1][3]; for (int kj=0; kj <=2; kj++) { rot[2][kj] = rot[0][kj] - (ggx*rot[1][kj])/rot[1][3]; } rot[2][3] = Math.sqrt(rot[2][0]*rot[2][0]+rot[2][1]*rot[2][1]+rot[2][2]*rot[2][2]); rcos=ggx/rot[0][3] ; /* rotation cosine */ if ( rot[2][3]==0 ) { rot[2][0] = 1 ; rot[2][1] = 0; rot[2][2] = 0; rot[2][3] = 1; } gx = (rot[0][0]*rot[2][0]+rot[0][1]*rot[2][1]+rot[0][2]*rot[2][2])/rot[2][3]; rsin= gx/rot[0][3]; /* rotation sine */ rot[3][0]=-rot[2][2]*1.0; rot[3][1]=0; /* outer product of rot 2 x 1 */ rot[3][2]= rot[2][0]*1.0; rot[3][3] = Math.sqrt(rot[3][0]*rot[3][0]+rot[3][1]*rot[3][1]+rot[3][2]*rot[3][2]); for (int yp=0; yp <=maxa-1; yp++) { if (yp != abd ) { for (int kj=0; kj <=2; kj++) { rot[4][kj]= att[yp][kj]-att[abd][kj]; /* abd-yp atoms vector */ } rot[4][3] = Math.sqrt(rot[4][0]*rot[4][0]+rot[4][1]*rot[4][1]+rot[4][2]*rot[4][2]); /* rot[5][0-2] = projection of rot[4] onto rot 1,3,2 */ rot[5][0]=rot[4][1]; rot[5][2] =(rot[4][0]*rot[3][0]+rot[4][1]*rot[3][1]+rot[4][2]*rot[3][2])/rot[3][3]; rot[5][1] =(rot[4][0]*rot[2][0]+rot[4][1]*rot[2][1]+rot[4][2]*rot[2][2])/rot[2][3]; gx=rcos*rot[5][0]+rsin*rot[5][1]; /* rotation on rot 1,2 plane */ gy=-rsin*rot[5][0] + rcos*rot[5][1]; for (int kj=0; kj <=2; kj++) { /* coordinate after rotation */ att[yp][kj] = att[abd][kj] + (gx*rot[1][kj])/rot[1][3] + (gy*rot[2][kj])/rot[2][3] + (rot[5][2]*rot[3][kj])/rot[3][3]; } } for (int ft=0; ft <= ato[yp][4]-1; ft++) { for (int kj=0; kj <=2; kj++) { rot[4][kj]= ele[yp][ft][kj]-att[abd][kj]; /* abd atom - all ele vector */ } rot[4][3] = Math.sqrt(rot[4][0]*rot[4][0]+rot[4][1]*rot[4][1]+rot[4][2]*rot[4][2]); rot[5][0]=rot[4][1]; rot[5][2] =(rot[4][0]*rot[3][0]+rot[4][1]*rot[3][1]+rot[4][2]*rot[3][2])/rot[3][3]; rot[5][1] =(rot[4][0]*rot[2][0]+rot[4][1]*rot[2][1]+rot[4][2]*rot[2][2])/rot[2][3]; gx=rcos*rot[5][0]+rsin*rot[5][1]; /* rotation of all electrons */ gy=-rsin*rot[5][0] + rcos*rot[5][1]; for (int kj=0; kj <=2; kj++) { ele[yp][ft][kj] = att[abd][kj] + (gx*rot[1][kj])/rot[1][3] + (gy*rot[2][kj])/rot[2][3] + (rot[5][2]*rot[3][kj])/rot[3][3]; } } if ( ato[yp][4]==1 ) { /* hydrogen met vector rotation */ rot[5][0]=ele[yp][0][7]; rot[5][2] =(ele[yp][0][6]*rot[3][0]+ele[yp][0][7]*rot[3][1]+ele[yp][0][8]*rot[3][2])/rot[3][3]; rot[5][1] =(ele[yp][0][6]*rot[2][0]+ele[yp][0][7]*rot[2][1]+ele[yp][0][8]*rot[2][2])/rot[2][3]; gx=rcos*rot[5][0]+rsin*rot[5][1]; gy=-rsin*rot[5][0] + rcos*rot[5][1]; for (int kj=0; kj <=2; kj++) { ele[yp][0][6+kj] = (gx*rot[1][kj])/rot[1][3] + (gy*rot[2][kj])/rot[2][3] + (rot[5][2]*rot[3][kj])/rot[3][3]; } } } } /* if (mar==12) end */ // reshow text when gamm = 0 (= overall molecule ) or 1 (= atom ) if ( gamm==0 || gamm==1 ) { for (int yp=0; yp <=6; yp++) { ww = " "; if ( abd+yp < maxa && gamm==0 ) { ww = "atom " + Integer.toString(abd+yp);} if ( yp == 0) { ww = "atom " + Integer.toString(abd); } if ( yp !=0 && ato[abd][4+yp] > -1 && gamm==1 ) { ww = "atom " + Integer.toString(ato[abd][4+yp]);} if ( abd+yp >= maxa && gamm==0 && abd !=0 && abd+yp-maxa < abd ){ ww = "atom "+ Integer.toString(abd+yp-maxa); } elp[yp][0].setText(ww); /* show atomic number on text */ for (int kj=0; kj <=2; kj++) { ww = Integer.toString(0); if ( abd+yp < maxa && gamm==0 ) { /* show absolute coordinate ( gamm=0 ) */ ex=(int)(100*att[abd+yp][kj]); ggx=ex/100.0; ww = Double.toString(ggx); } if ( yp == 0 && gamm==1 ) { /* show relative atomic coordinate ( gamm=1 ) */ ggx=0; ww = Double.toString(ggx); } if ( ato[abd][4+yp] > -1 && gamm==1 && yp !=0 ) { ex=(int)(100*(att[ato[abd][4+yp]][kj]-att[abd][kj])); ggx=ex/100.0; ww = Double.toString(ggx); } if ( abd+yp >= maxa && gamm==0 && abd !=0 && abd+yp-maxa < abd ){ ex=(int)(100*att[abd+yp-maxa][kj]); ggx=ex/100.0; ww = Double.toString(ggx); } elp[yp][kj+1].setText(ww); } ex=0; if ( abd+yp < maxa && yp !=0 && gamm==0 ) { /* show nuc (= distance ) */ kro=Math.sqrt((att[abd+yp][0]-att[abd][0])*(att[abd+yp][0]-att[abd][0])+ (att[abd+yp][1]-att[abd][1])*(att[abd+yp][1]-att[abd][1])+ (att[abd+yp][2]-att[abd][2])*(att[abd+yp][2]-att[abd][2])); ex=(int)(kro); } if ( abd+yp >= maxa && gamm==0 && abd !=0 && abd+yp-maxa < abd ){ kro=Math.sqrt((att[abd+yp-maxa][0]-att[abd][0])*(att[abd+yp-maxa][0]-att[abd][0])+ (att[abd+yp-maxa][1]-att[abd][1])*(att[abd+yp-maxa][1]-att[abd][1])+(att[abd+yp-maxa][2]-att[abd][2])*(att[abd+yp-maxa][2]-att[abd][2])); ex=(int)(kro); } if ( ato[abd][4+yp] > -1 && gamm==1 && yp != 0 ) { ez=ato[abd][4+yp]; kro=Math.sqrt((att[ez][0]-att[abd][0])*(att[ez][0]-att[abd][0])+ (att[ez][1]-att[abd][1])*(att[ez][1]-att[abd][1])+ (att[ez][2]-att[abd][2])*(att[ez][2]-att[abd][2])); if (kro == 0) {kro=5000.0;} ex=(int)(kro); } elp[yp][4].setText("nuc "+Integer.toString(ex)); } } /* show overall molecule or each atom click end */ if (gamm==2) { /* show bond angle gamm=2 */ int ank=0; if (ato[abd][4] != 1 ) { for (int yp=0; yp <=3; yp++) { for (int kj=0; kj <=3; kj++) { if ( yp < kj ) { gx=Math.sqrt(ele[abd][yp][3]*ele[abd][yp][3]+ele[abd][yp][4]*ele[abd][yp][4]+ele[abd][yp][5]*ele[abd][yp][5]); gy=Math.sqrt(ele[abd][kj][3]*ele[abd][kj][3]+ele[abd][kj][4]*ele[abd][kj][4]+ele[abd][kj][5]*ele[abd][kj][5]); gz=Math.sqrt((ele[abd][yp][3]-ele[abd][kj][3])*(ele[abd][yp][3]-ele[abd][kj][3])+(ele[abd][yp][4]-ele[abd][kj][4] )*(ele[abd][yp][4]-ele[abd][kj][4])+(ele[abd][yp][5]-ele[abd][kj][5])*(ele[abd][yp][5]-ele[abd][kj][5])); aid=(gx*gx+gy*gy-gz*gz)/(2.0*gx*gy); aid=(Math.acos(aid)*180.0)/pai; cx=(int)(10*aid); aid=cx/10.0; wa=Integer.toString(yp); wb=Integer.toString(kj); bangle[ank].setText(wa+"-n-"+wb+" "+ Double.toString(aid)); ank=ank+1; }}} if ( ato[abd][4] !=4 ) { gx=Math.sqrt(ele[abd][4][3]*ele[abd][4][3]+ele[abd][4][4]*ele[abd][4][4]+ele[abd][4][5]*ele[abd][4][5]); for (int yp=0; yp <=2; yp++) { gy=Math.sqrt(ele[abd][yp][3]*ele[abd][yp][3]+ele[abd][yp][4]*ele[abd][yp][4]+ele[abd][yp][5]*ele[abd][yp][5]); gz=Math.sqrt((ele[abd][yp][3]-ele[abd][4][3])*(ele[abd][yp][3]-ele[abd][4][3])+(ele[abd][yp][4]-ele[abd][4][4] )*(ele[abd][yp][4]-ele[abd][4][4])+(ele[abd][yp][5]-ele[abd][4][5])*(ele[abd][yp][5]-ele[abd][4][5])); aid=(gx*gx+gy*gy-gz*gz)/(2.0*gx*gy); aid=(Math.acos(aid)*180.0)/pai; cx=(int)(10*aid); aid=cx/10.0; wa=Integer.toString(yp); wb=Integer.toString(4); bangle[yp+6].setText(wa+"-n-"+wb+" "+Double.toString(aid)); } if (ato[abd][4] !=5) { for (int yp=4; yp <=5; yp++) { if ( yp==4 || ato[abd][4]==7 ) { gx=Math.sqrt(ele[abd][yp][3]*ele[abd][yp][3]+ele[abd][yp][4]*ele[abd][yp][4]+ele[abd][yp][5]*ele[abd][yp][5]); gy=Math.sqrt(ele[abd][yp+1][3]*ele[abd][yp+1][3]+ele[abd][yp+1][4]*ele[abd][yp+1][4]+ele[abd][yp+1][5]*ele[abd][yp+1][5]); gz=Math.sqrt((ele[abd][yp][3]-ele[abd][yp+1][3])*(ele[abd][yp][3]-ele[abd][yp+1][3])+(ele[abd][yp][4]-ele[abd][yp+1][4] )*(ele[abd][yp][4]-ele[abd][yp+1][4])+(ele[abd][yp][5]-ele[abd][yp+1][5])*(ele[abd][yp][5]-ele[abd][yp+1][5])); aid=(gx*gx+gy*gy-gz*gz)/(2.0*gx*gy); aid=(Math.acos(aid)*180.0)/pai; cx=(int)(10*aid); aid=cx/10.0; wa=Integer.toString(yp); wb=Integer.toString(yp+1); bangle[yp+5].setText(wa+"-n-"+wb+" "+ Double.toString(aid)); }}} } } for (int yp=0; yp <=10; yp++) { if ( ato[abd][4] ==1 ) {bangle[yp].setText(" 0 ");} if ( ato[abd][4] <=4 && yp > 5 ) {bangle[yp].setText(" 0 ");} if ( ato[abd][4] <=5 && yp > 8 ) {bangle[yp].setText(" 0 ");} if ( ato[abd][4] <=6 && yp > 9 ) {bangle[yp].setText(" 0 ");} } } if (gamm < 2 ) { /* show bond angles when gamm=0,1 */ ez=0; for (int yp=0; yp <=5; yp++) { for (int kj=0; kj <=5; kj++) { ex=ato[abd][yp+5]; ey=ato[abd][kj+5]; if (ato[abd][yp+5] > -1 && ato[abd][kj+5] > -1 ) { if ( yp < kj ) { gx=Math.sqrt((att[ex][0]-att[abd][0])*(att[ex][0]-att[abd][0])+(att[ex][1]-att[abd][1])*(att[ex][1]-att[abd][1])+(att[ex][2]-att[abd][2])*(att[ex][2]-att[abd][2])); gy=Math.sqrt((att[ey][0]-att[abd][0])*(att[ey][0]-att[abd][0])+(att[ey][1]-att[abd][1])*(att[ey][1]-att[abd][1])+(att[ey][2]-att[abd][2])*(att[ey][2]-att[abd][2])); gz=Math.sqrt((att[ex][0]-att[ey][0])*(att[ex][0]-att[ey][0])+(att[ex][1]-att[ey][1])*(att[ex][1]-att[ey][1])+(att[ex][2]-att[ey][2])*(att[ex][2]-att[ey][2])); aid=(gx*gx+gy*gy-gz*gz)/(2.0*gx*gy); aid=(Math.acos(aid)*180.0)/pai; cx=(int)(10*aid); aid=cx/10.0; wa=Integer.toString(ex); wb=Integer.toString(ey); bangle[ez].setText(wa+"-n-"+wb+" "+ Double.toString(aid)); ez=ez+1; } }}} if ( ez < 11 ) { for (int ann=ez; ann <=10; ann++) { bangle[ann].setText(" "); } } } /* bond angle end */ /* noxx[0-2] = center of valence electrons */ if ( ato[abd][4] != 1 && gamm==2 ) { for (int kj=0; kj <=2; kj++) { for (int yp=0; yp <=ato[abd][4]-1; yp++) { noxx[kj]=noxx[kj] + ele[abd][yp][kj]; } noxx[kj]=noxx[kj]/ato[abd][4]; } } /* symmetric position of hydrogen electron wrt. ex-H line */ for (int yp=0; yp <=maxa-1; yp++) { if ( ato[yp][4]==1 ) { ex=ato[yp][5]; for (int kj=0; kj <=2; kj++) { rot[0][kj]=att[yp][kj]-att[ex][kj]; rot[1][kj]=ele[yp][0][kj]-att[ex][kj]; } rot[0][3] = Math.sqrt(rot[0][0]*rot[0][0]+rot[0][1]*rot[0][1]+rot[0][2]*rot[0][2]); ggx = (rot[0][0]*rot[1][0]+rot[0][1]*rot[1][1]+rot[0][2]*rot[1][2])/rot[0][3]; for (int kj=0; kj <=2; kj++) { rot[2][kj]=(rot[0][kj]*ggx)/rot[0][3]-rot[1][kj]; ell[yp][kj]=rot[1][kj]+2.0*rot[2][kj]+att[ex][kj]; } } } toav=0.0; /* toav=total potential energy */ /* interaction among all electrons */ int gtr=0; double vv[]={0, 0, 0, 0, 0, 0, 0, 0, 0}; /* potential between 2 atoms */ for (int ra=0; ra <=maxa-1; ra++) { for (int ya=0; ya <=ato[ra][4]-1; ya++) { for (int rb=0; rb <=maxa-1; rb++) { for (int yb=0; yb <=ato[rb][4]-1; yb++) { gtr=0; if (ra < rb) {gtr=1; } if ( ra==rb && ya < yb ) {gtr=1; } if (gtr > 0 ) { /* kro = distance between electrons */ kro=Math.sqrt((ele[ra][ya][0]-ele[rb][yb][0])*(ele[ra][ya][0]-ele[rb][yb][0])+ (ele[ra][ya][1]-ele[rb][yb][1])*(ele[ra][ya][1]-ele[rb][yb][1])+ (ele[ra][ya][2]-ele[rb][yb][2])*(ele[ra][ya][2]-ele[rb][yb][2])); if (kro==0) {kro=5000.0;} /* ppot=repulsive potential energy (eV) between electrons */ ppot=(elc*elc*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14); toav=toav+ppot; /* rhp[atom][ele][3] = each electron's V (eV) */ rhp[ra][ya][3]=rhp[ra][ya][3]+ppot/2.0; rhp[rb][yb][3]=rhp[rb][yb][3]+ppot/2.0; /* teqq[][3] = potential energy only in abd atom */ if ( ra== abd && rb == abd && ato[abd][4] !=1 ) { teqq[ya][3]=teqq[ya][3]+ppot/2.0; teqq[yb][3]=teqq[yb][3]+ppot/2.0; } ez = 0; ey = 0; ex=0; /* potential between neighboring atoms */ if ( ra == abd ) { ex=ra; ey =rb; ez=1; } if ( rb == abd ) { ex=rb; ey=ra; ez=1; } if ( ez == 1 ) { for ( int kd=0; kd <=5; kd++) { if ( ato[abd][5+kd] == ey ) { vv[kd] = vv[kd] + ppot; } } } if ( ra==rb ){ for ( int kd=0; kd <=5; kd++) { if ( ato[abd][5+kd] == ra ) { vv[kd] = vv[kd] + ppot; } } } if ( ra==abd && rb==abd ){ for ( int kd=0; kd <=5; kd++) { vv[kd] = vv[kd] + ppot; } } /* calculating Coulomb force acting on each electron */ for (int jou=0; jou <=2; jou++) { /* rhp[][0-2]=force component acting on each electron */ ggx=(suh*(ele[ra][ya][jou]-ele[rb][yb][jou]))/(kro*kro*kro); rhp[ra][ya][jou]=rhp[ra][ya][jou]+ggx; rhp[rb][yb][jou]=rhp[rb][yb][jou]-ggx; /* teqq[][0-2] = force component only in abd (= present ) atom */ if ( ra==abd && rb==abd && ato[abd][4] !=1 ) { teqq[ya][jou]=teqq[ya][jou]+ggx; teqq[yb][jou]=teqq[yb][jou]-ggx; } }} }}}} /* ele-ele interaction end */ /* interaction between nucleus and electrons */ for (int ra=0; ra <=maxa-1; ra++) { for (int ya=0; ya <=ato[ra][4]-1; ya++) { for (int nu=0; nu <=maxa-1; nu++) { /* kro = each distance between electron and nucleus */ kro=Math.sqrt((ele[ra][ya][0]-att[nu][0])*(ele[ra][ya][0]-att[nu][0])+ (ele[ra][ya][1]-att[nu][1])*(ele[ra][ya][1]-att[nu][1])+ (ele[ra][ya][2]-att[nu][2])*(ele[ra][ya][2]-att[nu][2])); if (kro == 0) {kro=5000.0;} if ( ato[ra][4] == 1) { /* krr = distance between nucleus and symmetric hydrogen electron */ krr=Math.sqrt((ell[ra][0]-att[nu][0])*(ell[ra][0]-att[nu][0])+ (ell[ra][1]-att[nu][1])*(ell[ra][1]-att[nu][1])+ (ell[ra][2]-att[nu][2])*(ell[ra][2]-att[nu][2])); } /* ppot= each potential energy (eV) */ /* att[atom][3] = nuclear central charge */ ppot=-(elc*elc*att[nu][3]*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14); toav=toav+ppot; /* rhp[atom][ele][3] = each electron's potential V */ rhp[ra][ya][3]=rhp[ra][ya][3]+ppot; if ( ra != nu ) { /* rhp[atom][ele][6] = each electron's V with other nuclei */ rhp[ra][ya][6]=rhp[ra][ya][6]+ppot; } ez = 0; ey = 0; ex=0; if ( ra == abd ) {ex=ra; ey = nu; ez=1;} if ( nu == abd ) {ex=nu; ey=ra; ez=1;} if ( ez == 1 ) { /* vv[] = potential V with a neighboring atom */ for ( int kd=0; kd <=5; kd++) { if ( ato[abd][5+kd] == ey ) { vv[kd] = vv[kd] + ppot; } } } if ( ra==nu ){ for ( int kd=0; kd <=5; kd++) { if ( ato[abd][5+kd] == ra ) { vv[kd] = vv[kd] + ppot; } } } if ( ra==abd && nu==abd ){ for ( int kd=0; kd <=5; kd++) { vv[kd] = vv[kd] + ppot; } } for (int jou=0; jou <=2; jou++) { /* rhp[atom][ele][0-2]=force component acting on each electron */ ggx=(suh*att[nu][3]*(ele[ra][ya][jou]-att[nu][jou]))/(kro*kro*kro); ggy=ggx; if ( ato[ra][4] == 1 ) { /* hydrogen symmetric position */ ggy=(suh*att[nu][3]*(ell[ra][jou]-att[nu][jou]))/(krr*krr*krr); } rhp[ra][ya][jou]=rhp[ra][ya][jou]-ggx; mmp[nu][jou]=mmp[nu][jou]+ggx*0.5+ggy*0.5; /* mmp[atom][0-2] = force component acting on each atom */ } }}} /* electron -nucleus interaction end */ /* nucleus - nucleus interaction */ for (int ga=0; ga <=maxa-1; ga++) { for (int gb=0; gb <=maxa-1; gb++) { if (ga < gb) { /* kro= internuclear distance */ kro=Math.sqrt((att[ga][0]-att[gb][0])*(att[ga][0]-att[gb][0])+ (att[ga][1]-att[gb][1])*(att[ga][1]-att[gb][1])+(att[ga][2]-att[gb][2])*(att[ga][2]-att[gb][2])); if (kro == 0) {kro=5000.0;} ppot=(elc*elc*att[ga][3]*att[gb][3] *6.241509e18)/(4.0*pai*epsi*kro*1.0e-14); toav=toav+ppot; potn=potn+ppot; ez = 0; ey = 0; ex=0; /* potential V with a neiboring atom */ if ( ga == abd ) {ex=ga; ey=gb; ez=1;} if ( gb == abd ) {ex=gb; ey=ga; ez=1;} if ( ez == 1 ) { for ( int kd=0; kd <=5; kd++) { if ( ato[abd][5+kd] == ey ) { vv[kd] = vv[kd] + ppot; } } } /* force component between two nuclei */ for (int jou=0; jou <=2; jou++) { ggx=(suh*att[ga][3]*att[gb][3] *(att[ga][jou]-att[gb][jou]))/(kro*kro*kro); mmp[ga][jou]=mmp[ga][jou]+ggx; mmp[gb][jou]=mmp[gb][jou]-ggx; } } }} /* internuclear interaction end */ /* distribute internuclear repulsive V to each electron based on rhp[][][6] */ gx=0.0; for (int ra=0; ra <=maxa-1; ra++) { for (int ya=0; ya <=ato[ra][4]-1; ya++) { gx=gx+rhp[ra][ya][6]; }} for (int ra=0; ra <=maxa-1; ra++) { for (int ya=0; ya <=ato[ra][4]-1; ya++) { rhp[ra][ya][3]=rhp[ra][ya][3] + (potn*rhp[ra][ya][6])/gx; }} /* interaction between abd electrons and their center nucleus (= noxx[] ) */ if ( ato[abd][4] != 1 ) { for (int yp=0; yp <= ato[abd][4]-1; yp++) { kro=Math.sqrt((ele[abd][yp][0]-noxx[0])*(ele[abd][yp][0]-noxx[0])+ (ele[abd][yp][1]-noxx[1])*(ele[abd][yp][1]-noxx[1])+ (ele[abd][yp][2]-noxx[2])*(ele[abd][yp][2]-noxx[2])); if (kro == 0) {kro=5000.0;} /* teqq[ele][3] = each potential V only inside abd (= present ) atom */ ppot=-(elc*elc*att[abd][3]*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14); teqq[yp][3]=teqq[yp][3] + ppot; /* teqq[ele][0-2] = force component only inside abd atom */ for (int jou=0; jou <=2; jou++) { ggx=(suh*att[abd][3]*(ele[abd][yp][jou]-noxx[jou]))/(kro*kro*kro); teqq[yp][jou]=teqq[yp][jou]-ggx; } } } ex=(int)(100*toav); ggx=ex/100.0; impho.setText("tV "+Double.toString(ggx)); /* show total V (eV) */ double goukk=0.0; if (gamm==2) { for (int rv=0; rv <=6; rv++) { gy=0.0; if ( rv < ato[abd][4] ) { for (int jou=0; jou <=2; jou++) { rot[0][jou] = att[abd][jou]-ele[abd][rv][jou]; rot[3][jou]=att[abd][jou]-att[ato[abd][5]][jou]; } gx=Math.sqrt(rot[0][0]*rot[0][0]+rot[0][1]*rot[0][1]+rot[0][2]*rot[0][2]); /* gy=forces toward nucleus (CF) */ gy=(rhp[abd][rv][0]*rot[0][0]+rhp[abd][rv][1]*rot[0][1]+rhp[abd][rv][2]*rot[0][2])/gx; if ( ato[abd][4]==1) { /* hydrogen, force toward its neighboring atom */ gx=Math.sqrt(rot[3][0]*rot[3][0]+rot[3][1]*rot[3][1]+rot[3][2]*rot[3][2]); gy=-(rhp[abd][0][0]*rot[3][0]+rhp[abd][0][1]*rot[3][1]+rhp[abd][0][2]*rot[3][2])/gx; } } ex=(int)(1000*gy); ww="CF "; if ( ato[abd][4]==1 ) { ww="at ";} elp[rv][6].setText(ww+Integer.toString(ex)); /* show force CF on text */ ggx=0; /* show each electron V on text */ if ( rv < ato[abd][4]) { ex=(int)(100*rhp[abd][rv][3]); ggx=ex/100.0; } elp[rv][5].setText("V "+Double.toString(ggx)); /* show each de Broglie wave */ double gggx,gggy,gggz; ggy = 0; double gagy=0; if ( rv < ato[abd][4]) { /* gz=total force acting on each electron */ 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; if ( ato[abd][4] != 1 ) { /* gz= force only inside abd atom in not-hydrogen atom */ gz=Math.sqrt(teqq[rv][0]*teqq[rv][0]+teqq[rv][1]*teqq[rv][1]+teqq[rv][2]*teqq[rv][2]); } /* gy = change gz to 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 using Virial theorem */ gx=Math.sqrt((-1.0*rhp[abd][rv][3]*1.602177e-19)/me); gggx=gx; if ( ato[abd][4] != 1 ) { /* only inside abd atom in not-hydrogen atom */ gx=Math.sqrt((-1.0*teqq[rv][3]*1.602177e-19)/me); } ggx=(me*gx*gx)/gy; /* ggx= electron's rotating radius based on centrifugal force */ debroglie = h/(me*gx); /* debroglie = de Broglie wavelength ( meter ) */ ggy=(2.0*pai*ggx)/debroglie; /* ggy = number of de Broglie waves in one orbit */ gouk=gouk+ggy; ggx=(me*gggx*gggx)/gggy; debroglie = h/(me*gggx); gagy=(2*pai*ggx)/debroglie; /* gagy = de Broglie wave's number based on direct force */ goukk=goukk+gagy; } ex=(int)(ggy*10000); ggz=ex/10000.0; rhp[abd][rv][5]=ggz; elp[rv][8].setText("wn "+Double.toString(ggz)); /* show de Broglie waves */ ex=(int)(gagy*10000); ggz=ex/10000.0; elp[rv][7].setText("di "+Double.toString(ggz)); } /* for ( --- rv <= 6 ) end */ gouk=gouk/ato[abd][4]; ex=(int)(gouk*10000); gouk=ex/10000.0; avew.setText("ave "+Double.toString(gouk)); /* show average de Broglie waves */ goukk=goukk/ato[abd][4]; ex=(int)(goukk*10000); goukk=ex/10000.0; direc.setText("dia "+Double.toString(goukk)); } /* if gamm==2 end */ for (int ka=0; ka <=4; ka++) { /* show force acting on nucleus in texts below */ ww=" "; ez=0; int mx=0; int my=1; if ( ka==0 ) { ww="now " +Integer.toString(abd); mx=0; my=1; } if (ka !=0 ) { if ( ka < 3 ) { mx=0; my = 5 +4*(ka-1);} if ( ka > 2 ) { mx=1; my = 1 +4*(ka-3);} if ( ato[abd][4+ka] > -1 ) { ww = "nuc "+ Integer.toString(ato[abd][4+ka]); } } mmpho[mx][my-1].setText(ww); /* rotation of force component only in gamm=2 */ double mmf[][]=new double[5][5]; int hht=0; if ( ka ==0 ) { ey=abd; hht=1; } if ( ka !=0 && ato[abd][4+ka] > -1 && gamm==2 ) { ey=ato[abd][4+ka]; hht=1; } if ( hht ==1 ) { for (int kj=0; kj <=2; kj++) { rot[4][kj]=mmp[ey][kj]; } rot[4][3] = Math.sqrt(rot[4][0]*rot[4][0]+rot[4][1]*rot[4][1]+rot[4][2]*rot[4][2]); rot[5][2]=(rot[4][0]*erot[3][0]+rot[4][1]*erot[3][1]+rot[4][2]*erot[3][2])/erot[3][3]; rot[5][1]=(rot[4][0]*erot[2][0]+rot[4][1]*erot[2][1]+rot[4][2]*erot[2][2])/erot[2][3]; rot[5][0]=rot[4][1]; gx=rcos*rot[5][0] + rsin*rot[5][1]; gy=-rsin*rot[5][0] + rcos*rot[5][1]; for (int kj=0; kj <=2; kj++) { mmf[ka][kj] = (gy*erot[2][kj])/erot[2][3]+(gx*erot[1][kj])/erot[1][3] + (rot[5][2]*erot[3][kj])/erot[3][3] ; } } for (int jou=0; jou <=2; jou++) { ex=0; /* show force component acting on each nucleus below */ if ( ka ==0 && gamm < 2 ) {ex=(int)(1000*mmp[abd][jou]);} if ( ka !=0 && ato[abd][4+ka] > -1 && gamm < 2 ) {ex=(int)(1000*mmp[ato[abd][4+ka]][jou]);} if ( ka ==0 && gamm == 2 ) {ex=(int)(1000*mmf[ka][jou]);} if ( ka != 0 && ato[abd][4+ka] > -1 && gamm == 2 ) { ex=(int)(1000*mmf[ka][jou]); } ww=" "; if (jou==0) {ww="FX=";} if (jou==1) {ww="FY=";} if (jou==2) {ww="FZ=";} mmpho[mx][my+jou].setText(ww+Integer.toString(ex)); } if ( ka > 0) { ggx=0; ey=0; ww=" "; if ( ato[abd][4+ka] > -1 ) { ex=(int)(100*vv[ka-1]); ggx=ex/100.0; ww = Integer.toString(ato[abd][4+ka]); } mmpho[1][7+ka].setText("V-"+ww+" "+Double.toString(ggx)); } /* for ( -- ka <= 4 ) end */ /* show force acting on nucleus in upper texts when gamm= 0,1 */ if ( gamm < 2 ) { for (int na=0; na <=6; na++) { for (int jou=0; jou <=3; jou++) { ex=0; ey=0; if ( na==0 && jou < 3 ) { ex=(int)(1000*mmp[abd][jou]); ey=0; } if ( na !=0 && ato[abd][4+na] > -1 && gamm==1 ){ ez=ato[abd][4+na]; for (int kj=0; kj <=3; kj++) { rot[0][kj]= att[abd][kj]-att[ez][kj]; } rot[0][3] = Math.sqrt(rot[0][0]*rot[0][0]+rot[0][1]*rot[0][1]+rot[0][2]*rot[0][2]); ey=(int)(1000*((mmp[ez][0]*rot[0][0]+mmp[ez][1]*rot[0][1]+mmp[ez][2]*rot[0][2])/rot[0][3])); if (jou < 3 ) { ex=(int)(1000*mmp[ato[abd][4+na]][jou]);} } if ( na !=0 && gamm==0 && abd+na < maxa && jou < 3 ) { ex=(int)(1000*mmp[abd+na][jou]); } if ( na !=0 && gamm==0 && abd+na >= maxa ) { if ( na- maxa+abd < abd && jou < 3 ) { ez=na-maxa+abd; ex=(int)(1000*mmp[ez][jou]); }} if (jou==0) {ww="FX=";} if (jou==1) {ww="FY=";} if (jou==2) {ww="FZ=";}if (jou==3) {ww="cf=";} if ( jou < 3 ) { elp[na][5+jou].setText(ww+Integer.toString(ex));} if (jou==3) { elp[na][8].setText(ww+Integer.toString(ey));} } } } /* for ( -- na <= 6 ) end */ } /* if ( gamm < 2 ) end */ ex=maxa; /* epp[][][] = electron after moving by the forces */ double epp[][][]=new double[ex][7][11]; if (ato[abd][4] == 1 && gamm==2 ) { /* when present atom is hydrogen, and gamm=2 */ for (int na=0; na <=maxa-1; na++) { for (int kj=0; kj <=ato[na][4]-1; kj++) { if (ato[na][4] != 1 ) { for (int jou=0; jou <=2; jou++) { epp[na][kj][jou] = ele[na][kj][jou]; }} if ( ato[na][4] == 1 ) { /* hydrogen electron after moving by force */ ez=ato[na][5]; for (int jou=0; jou <=2; jou++) { rot[0][jou]=att[na][jou]-att[ez][jou]; rot[3][jou]=ele[na][0][jou]-att[ez][jou]; } rot[0][3] = Math.sqrt(rot[0][0]*rot[0][0]+rot[0][1]*rot[0][1]+rot[0][2]*rot[0][2]); gx=(rot[3][0]*rot[0][0]+rot[3][1]*rot[0][1]+rot[3][2]*rot[0][2])/rot[0][3]; for (int jou=0; jou <=2; jou++) { rot[2][jou]= (rot[0][jou]* gx)/rot[0][3]-rot[3][jou]; } rot[2][3] = Math.sqrt(rot[2][0]*rot[2][0]+rot[2][1]*rot[2][1]+rot[2][2]*rot[2][2]); gx=(rhp[na][0][0]*rot[2][0]+rhp[na][0][1]*rot[2][1]+rhp[na][0][2]*rot[2][2])/rot[2][3]; gy=-(rhp[na][0][0]*rot[0][0]+rhp[na][0][1]*rot[0][1]+rhp[na][0][2]*rot[0][2])/rot[0][3]; for (int jou=0; jou <=2; jou++) { epp[na][0][jou]=ele[na][0][jou] - (2.0*rot[2][3]*gy*rot[0][jou])/(gx*rot[0][3]); } } /* if (ato[][4]=1) end */ }} /* for (int na=0; na <=maxa-1; na++) end */ /* -------------- potential caluclation after moving by force */ toav=0.0; /* toav=total potential energy */ /* interaction between all electrons */ for (int ra=0; ra <=maxa-1; ra++) { for (int ya=0; ya <=ato[ra][4]-1; ya++) { for (int rb=0; rb <=maxa-1; rb++) { for (int yb=0; yb <=ato[rb][4]-1; yb++) { ex=0; if (ra < rb) {ex=1; } if ( ra==rb && ya < yb ) {ex=1; } if (ex > 0 ) { /* kro = distance between two electrons */ kro=Math.sqrt((epp[ra][ya][0]-epp[rb][yb][0])*(epp[ra][ya][0]-epp[rb][yb][0])+ (epp[ra][ya][1]-epp[rb][yb][1])*(epp[ra][ya][1]-epp[rb][yb][1])+ (epp[ra][ya][2]-epp[rb][yb][2])*(epp[ra][ya][2]-epp[rb][yb][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[ra][ya][3]=rpp[ra][ya][3]+ppot/2.0; rpp[rb][yb][3]=rpp[rb][yb][3]+ppot/2.0; for (int jou=0; jou <=2; jou++) { /* rpp[][0-2]=force component acting on each electron after moving */ ggx=(suh*(epp[ra][ya][jou]-epp[rb][yb][jou]))/(kro*kro*kro); rpp[ra][ya][jou]=rpp[ra][ya][jou]+ggx; rpp[rb][yb][jou]=rpp[rb][yb][jou]-ggx; } } }}}} /* ele-ele interaction end */ /* interaction between nucleus and electrons */ for (int ra=0; ra <=maxa-1; ra++) { for (int ya=0; ya <=ato[ra][4]-1; ya++) { for (int nu=0; nu <=maxa-1; nu++) { kro=Math.sqrt((epp[ra][ya][0]-att[nu][0])*(epp[ra][ya][0]-att[nu][0])+ (epp[ra][ya][1]-att[nu][1])*(epp[ra][ya][1]-att[nu][1])+ (epp[ra][ya][2]-att[nu][2])*(epp[ra][ya][2]-att[nu][2])); if (kro == 0) {kro=5000.0;} ppot=-(elc*elc*att[nu][3]*6.241509e18)/(4.0*pai*epsi*kro*1.0e-14); toav=toav+ppot; rpp[ra][ya][3]=rpp[ra][ya][3]+ppot; if ( ra != nu ) { /* with other nuclei */ rpp[ra][ya][6]=rpp[ra][ya][6]+ppot; } for (int jou=0; jou <=2; jou++) { /* rpp[][0-2]=force component acting on each electron after moving */ ggx=(suh*att[nu][3]*(epp[ra][ya][jou]-att[nu][jou]))/(kro*kro*kro); rpp[ra][ya][jou]=rpp[ra][ya][jou]-ggx; } }}} /* ele-nuc interaction end */ toav=toav+potn; /* potn = internuclear repulsive potential computed above */ gx=0.0; for (int ra=0; ra <=maxa-1; ra++) { /* distribute V by rpp[][6] */ for (int ya=0; ya <=ato[ra][4]-1; ya++) { gx=gx+rpp[ra][ya][6]; }} for (int ra=0; ra <=maxa-1; ra++) { for (int ya=0; ya <=ato[ra][4]-1; ya++) { rpp[ra][ya][3]=rpp[ra][ya][3] + (potn*rpp[ra][ya][6])/gx; }} /* show forces acting on electrons, gamm=2 */ gy=0.0; for (int jou=0; jou <=2; jou++) { rot[0][jou] = att[abd][jou]-att[ato[abd][5]][jou]; } gx=Math.sqrt(rot[0][0]*rot[0][0]+rot[0][1]*rot[0][1]+rot[0][2]*rot[0][2]); /* gy=forces toward another atom */ gy=-(rpp[abd][0][0]*rot[0][0]+rpp[abd][0][1]*rot[0][1]+rpp[abd][0][2]*rot[0][2])/gx; ex=(int)(1000*gy); ww="at "; elp[1][6].setText(ww+Integer.toString(ex)); /* show de Broglie wave */ ggy = 0; double gagyy=0; 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; /* ggy=number of de Broglie's wave in one orbit */ debroglie = h/(me*gx); ggy=(2.0*pai*ggx)/debroglie; ex=(int)(ggy*10000); ggz=ex/10000.0; elp[1][8].setText("wn "+Double.toString(ggz)); elp[1][7].setText("di "+Double.toString(ggz)); gouk= (ggz+rhp[abd][0][5])/2.0; /* average de Broglie wave of before and after moving */ ex=(int)(gouk*10000); gouk=ex/10000.0; avew.setText("ave "+Double.toString(gouk)); direc.setText("dia "+Double.toString(gouk)); } /* if ( att[][4]==1 & gamm=2 ) end */ /* ------------- show particle's picture ----------- */ int hpk[][][]=new int[3][50][4]; double hpk2[][][]=new double[3][50][4]; int hpkk[]=new int[4]; int hpkkk[]=new int[4]; int nk[]={0,0,0}; g.clearRect(0,299,1170,699); if (gamm==0) { /* when gamm=0 (= overall molecule screen ) */ g.setColor(Color.cyan); g.drawLine(555,310,555,660); g.drawString("X - Z plane", 257,355); g.drawString("X - Y plane", 810,355); for (int yp=0; yp <=maxa-1; yp++) { for (int kj=0; kj <=2; kj++) { rot[0][kj]=att[yp][kj]-cent[kj]; rot[0][kj]=rot[0][kj]/142.856; /* change each position into pixel */ } if ( rot[0][0] > -275 && rot[0][0] < 275 ) { if ( rot[0][2] > -150 && rot[0][2] < 150 ) { hpk2[0][nk[0]][0] = rot[0][0]+276; hpk[0][nk[0]][0] = (int)(rot[0][0]+276); hpk2[0][nk[0]][1] = -rot[0][2]+505; hpk[0][nk[0]][1] = (int)(-rot[0][2]+505); hpk[0][nk[0]][3] = yp; nk[0]=nk[0]+1; } if ( rot[0][1] > -150 && rot[0][1] < 150 ) { hpk2[1][nk[1]][0] = rot[0][0]+833; hpk[1][nk[1]][0] = (int)(rot[0][0]+833); hpk2[1][nk[1]][1] = -rot[0][1]+505; hpk[1][nk[1]][1] = (int)(-rot[0][1]+505); hpk[1][nk[1]][3] = yp; nk[1]=nk[1]+1; } } } g.setColor(Color.gray); for (int na=0; na <=nk[0]-1; na++) { ex=hpk[0][na][3]; for (int yp=0; yp <=5; yp++) { ez=ato[ex][5+yp]; if ( ez > -1 ) { /* show internuclear lines */ gx=((att[ez][0] - cent[0])/142.856) +276 ; gy=-((att[ez][2] - cent[2])/142.856) +505; ggx=gx - hpk2[0][na][0]; ggy=gy - hpk2[0][na][1]; if ( gx < 1 ) { ggy=((1 - hpk2[0][na][0] ) * ggy)/ggx; ggx=1- hpk2[0][na][0]; } if ( gx > 555 ) { ggy=( ( 555 - hpk2[0][na][0])*ggy)/ggx; ggx=555-hpk2[0][na][0];} if ( ggy+hpk2[0][na][1] < 355 ) { ggx=((355-hpk2[0][na][1])*ggx)/ggy; ggy=355-hpk2[0][na][1];} if ( ggy+hpk2[0][na][1] > 655 ) { ggx=((655-hpk2[0][na][1])*ggx)/ggy; ggy=655-hpk2[0][na][1]; } cx=(int)(ggx + hpk2[0][na][0]); cy=(int)(ggy + hpk2[0][na][1]); g.drawLine(hpk[0][na][0],hpk[0][na][1],cx,cy); } }} for (int na=0; na <=nk[1]-1; na++) { ex=hpk[1][na][3]; for (int yp=0; yp <=5; yp++) { ez=ato[ex][5+yp]; if ( ez > -1 ) { gx=((att[ez][0] - cent[0])/142.856) +833 ; gy=-((att[ez][1] - cent[1])/142.856) +505; ggx=gx - hpk2[1][na][0]; ggy=gy - hpk2[1][na][1]; if ( gx < 555 ) { ggy=((555 - hpk2[1][na][0] ) * ggy)/ggx; ggx=555- hpk2[1][na][0]; } if ( gx > 1110 ) { ggy=( ( 1110 - hpk2[1][na][0])*ggy)/ggx; ggx=1110-hpk2[1][na][0];} if ( ggy+hpk2[1][na][1] < 355 ) { ggx=((355-hpk2[1][na][1])*ggx)/ggy; ggy=355-hpk2[1][na][1];} if ( ggy+hpk2[1][na][1] > 655 ) { ggx=((655-hpk2[1][na][1])*ggx)/ggy; ggy=655-hpk2[1][na][1]; } cx=(int)(ggx + hpk2[1][na][0]); cy=(int)(ggy + hpk2[1][na][1]); g.drawLine(hpk[1][na][0],hpk[1][na][1],cx,cy); } }} } /* if (gamm=0) end */ if ( gamm==1 || gamm==2) { /* screen when gamm=1 or gamm=2 */ g.setColor(Color.cyan); g.drawLine(390,310,390,660); g.drawLine(770,310,770,660); g.drawString("X - Y plane", 175,355); g.drawString("X - Z plane", 535,355); g.drawString("Y - Z plane", 940,355); } if ( gamm==1 ) { /* when gamm=1 (= some atom and its neighbor ) */ nk[0]=0; nk[1]=0; nk[2]=0; for (int yp=0; yp <=5; yp++) { ez=ato[abd][yp+5]; if ( ez > -1 ) { nk[0]=nk[0]+1; for (int kj=0; kj <=2; kj++) { rot[0][kj]=att[ez][kj]-att[abd][kj]; rot[0][kj]=rot[0][kj]/142.856; } hpk[0][yp][0] = (int)(rot[0][0]+195); hpk[0][yp][1] = (int)(-rot[0][1]+505); hpk[0][yp][3] = ez; if (rot[0][0] < -195 || rot[0][0] > 195 ) { hpk[0][yp][3] = -1; } if (rot[0][1] < -150 || rot[0][1] > 150 ) { hpk[0][yp][3] = -1; } hpk[1][yp][0] = (int)(rot[0][0]+555); hpk[1][yp][1] = (int)(-rot[0][2]+505); hpk[1][yp][3] = ez; if (rot[0][0] < -165 || rot[0][0] > 195 ) { hpk[1][yp][3] = -1; } if (rot[0][2] < -150 || rot[0][2] > 150 ) { hpk[1][yp][3] = -1; } hpk[2][yp][0] = (int)(rot[0][1]+965); hpk[2][yp][1] = (int)(-rot[0][2]+505); hpk[2][yp][3] = ez; if (rot[0][1] < -195 || rot[0][1] > 195 ) { hpk[2][yp][3] = -1; } if (rot[0][2] < -150 || rot[0][2] > 150 ) { hpk[2][yp][3] = -1; } } nk[1]=nk[0]; nk[2]=nk[0]; } g.setColor(Color.lightGray); /* show central nucleus */ g.fillOval(185,495,20,20); g.fillOval(545,495,20,20); g.fillOval(955,495,20,20); for (int jj=0; jj <=ato[abd][4]-1; jj++) { for (int jou=0; jou <=2; jou++) { hpkk[jou]=(int)((ele[abd][jj][jou]-att[abd][jou])/142.856); } /* show small electrons */ g.fillOval(193+hpkk[0],503-hpkk[1],4,4); g.fillOval(553+hpkk[0],503-hpkk[2],4,4); g.fillOval(963+hpkk[1],503-hpkk[2],4,4); } g.setColor(Color.blue); /* show atomic number */ g.drawString(Integer.toString(abd),192, 510); g.drawString(Integer.toString(abd),552, 510); g.drawString(Integer.toString(abd),962, 510); } /* gamm==1 end */ if ( gamm==2 ) { /* screen of some atom and its valence electrons */ nk[0]=ato[abd][4]; nk[1]=nk[0]; nk[2]=nk[0]; for (int yp=0; yp <=5; yp++) { if (ato[abd][5+yp] > -1){ gx=ska[yp][0]/142.856; gy=ska[yp][1]/142.856; gz=ska[yp][2]/142.856; ggy=gy; ggz=gz; ggx=gx; double gxa,gxb, gya, gza; gxa=gx; gxb=gx; gya=gy; gza=gz; if ( gy < -195 ) { gza=(-195.0*gz)/gy; gya=-195;} if ( gy > 195 ) { gza=( 195.0*gz)/gy; gya=195;} if ( gza < -150 ) { gya=(-150.0*gya)/gza; gza=-150;} if ( gza > 150 ) { gya=(150.0*gya)/gza; gza=150;} if ( gx < -195 ) { gy=(-195.0*gy)/gx; gz=(-195.0*gz)/gx; gxa=-195; gxb=-195; } if ( gx > 195 ) { gy=( 195.0*gy)/gx; gz=( 195.0*gz)/gx; gxa=195; gxb=195; } if ( gy < -150 ) { gxa=(-150.0*gxa)/gy; gy=-150; } if ( gy > 150 ) { gxa=(150.0*gxa)/gy; gy =150;} if ( gz < -150 ) { gxb=(-150.0*gxb)/gy; gz=-150;} if ( gz > 150 ) { gxb=(150.0*gxb)/gy; gz=150;} cx=(int)(gxa + 195); cy=(int)(-gy + 505); g.setColor(Color.gray); g.drawLine(195,505,cx,cy); /* show line connected with other atoms */ g.setColor(Color.blue); g.drawString(Integer.toString(ato[abd][5+yp]),cx-3, cy+5); if ( gxb < -165 ) { gz=(gz*-165.0)/gxb; gxb=-165; } cx=(int)(gxb + 555); cy=(int)(-gz + 505); g.setColor(Color.gray); g.drawLine(555,505,cx,cy); g.setColor(Color.blue); g.drawString(Integer.toString(ato[abd][5+yp]),cx-3, cy+5); cx=(int)(gya + 965); cy=(int)(-gza + 505); g.setColor(Color.gray); g.drawLine(965,505,cx,cy); g.setColor(Color.blue); g.drawString(Integer.toString(ato[abd][5+yp]),cx-3, cy+5); }} int yyt=ato[abd][4]; double rott[][]=new double[yyt][4]; for (int yp=0; yp <=ato[abd][4]-1; yp++) { for (int kj=0; kj <=2; kj++) { rott[yp][kj]=ele[abd][yp][3+kj]; rott[yp][kj]=rott[yp][kj]/142.856; } hpk[0][yp][0] = (int)(rott[yp][0]+195); hpk[0][yp][1] = (int)(-rott[yp][1]+505); hpk[0][yp][3] = yp; if (rott[0][0] < -195 || rott[0][0] > 195 ) { hpk[0][yp][3] = -1; } if (rott[0][1] < -150 || rott[0][1] > 150 ) { hpk[0][yp][3] = -1; } hpk[1][yp][0] = (int)(rott[yp][0]+555); hpk[1][yp][1] = (int)(-rott[yp][2]+505); hpk[1][yp][3] = yp; if (rott[0][0] < -195 || rott[0][0] > 195 ) { hpk[1][yp][3] = -1; } if (rott[0][2] < -150 || rott[0][2] > 150 ) { hpk[1][yp][3] = -1; } hpk[2][yp][0] = (int)(rott[yp][1]+965); hpk[2][yp][1] = (int)(-rott[yp][2]+505); hpk[2][yp][3] = yp; if (rott[0][1] < -195 || rott[0][1] > 195 ) { hpk[2][yp][3] = -1; } if (rott[0][2] < -150 || rott[0][2] > 150 ) { hpk[2][yp][3] = -1; } } g.setColor(Color.lightGray); /* show nucleus */ g.fillOval(185,495,20,20); g.fillOval(545,495,20,20); g.fillOval(955,495,20,20); g.setColor(Color.blue); g.drawString(Integer.toString(abd),192, 510); g.drawString(Integer.toString(abd),552, 510); g.drawString(Integer.toString(abd),962, 510); } /* gamm==2 end */ for ( int rv=0; rv <= 2; rv++) { /* show nucleui or electrons' picture */ if (nk[rv] != 0 ) { for ( int na=0; na <= nk[rv]-1; na++) { if ( hpk[rv][na][3] > -1 ) { if ( gamm==2 ) { if ( na==0 || na==5) { g.setColor(Color.white); } if ( na == 1 || na==6 ) { g.setColor(Color.pink); } if ( na==2) { g.setColor(Color.red); } if ( na == 3) { g.setColor(Color.green);} if ( na == 4 ) {g.setColor(Color.magenta);} } if ( gamm < 2 ) { ex=ato[hpk[rv][na][3]][4]; g.setColor(Color.white); if ( ex== 4 ) { g.setColor(Color.white); } if ( ex == 6 ) { g.setColor(Color.pink); } if ( ex == 5 ) { g.setColor(Color.red); } if ( ex == 1 ) { g.setColor(Color.green);} if ( ex == 7 ) {g.setColor(Color.magenta);} } g.fillOval(hpk[rv][na][0]-7, hpk[rv][na][1]-7,14,14); } }}} if ( gamm==1 ) { /* show small electron's picture when gamm=1 */ for ( int na=0; na <=6; na++) { if ( ato[abd][5+na] > -1 ) { ey=ato[abd][na+5]; ex=ato[ey][4]; g.setColor(Color.white); if ( ex== 4 ) { g.setColor(Color.white); } if ( ex == 6 ) { g.setColor(Color.pink); } if ( ex == 5 ) { g.setColor(Color.red); } if ( ex == 1 ) { g.setColor(Color.green);} if ( ex == 7 ) {g.setColor(Color.magenta);} for (int jj=0; jj <=ato[ey][4]-1; jj++) { for (int jou=0; jou <=2; jou++) { hpkk[jou]=(int)((ele[ey][jj][jou]-att[ey][jou])/142.856); hpkkk[jou]=(int)((ele[ey][jj][jou]-att[abd][jou])/142.856); } if ( hpkkk[0] > -195 && hpkkk[0] < 195 ) { if ( hpkkk[1] > -150 && hpkkk[1] < 150 ) { g.fillOval(hpkk[0]+hpk[0][na][0]-2, -hpkk[1]+hpk[0][na][1]-2,4,4); } if ( hpkkk[2] > -150 && hpkkk[2] < 150 ) { if ( hpkkk[0] > -165 ) { g.fillOval(hpkk[0]+hpk[1][na][0]-2,-hpkk[2]+hpk[1][na][1]-2,4,4); } }} if ( hpkkk[1] > -195 && hpkkk[1] < 195 ) { if ( hpkkk[2] > -150 && hpkkk[2] < 150 ) { g.fillOval(hpkk[1]+hpk[2][na][0]-2, -hpkk[2]+hpk[2][na][1]-2,4,4); }} } }} } /* show atomic number */ for ( int rv=0; rv <= 2; rv++) { if (nk[rv] != 0 ) { for ( int na=0; na <= nk[rv]-1; na++) { if ( hpk[rv][na][3] > -1 ) { g.setColor(Color.blue); if ( hpk[rv][na][3] < 10 ) { g.drawString(Integer.toString(hpk[rv][na][3]),hpk[rv][na][0]-3, 5+hpk[rv][na][1]); } else { g.drawString(Integer.toString(hpk[rv][na][3]),hpk[rv][na][0]-6, 5+hpk[rv][na][1]); } } }}} } }