/* emprical 3d- 4d- 5d- tramsition metal pseudopotential */ /* real space DFT-LDA */ /* coded by Ikeuchi Mitsuru */ /* ver 0.0.1 2004.10.02 */ import java.awt.*; import java.awt.event.*; import java.applet.*; public class transitionMetalEPP extends Applet implements MouseListener, MouseMotionListener, ItemListener, ActionListener, AdjustmentListener, Runnable { /* -------------------------------------- set global ------ */ Choice cvw, ch_md, ch_noe; Button bt_reset, bt_start, bt_stop; Scrollbar spx,spy,spz; Thread th = null; Dimension dim; Image imgOff; Graphics gOff; int sleepTime = 30; int dispMode = 1; int dispObj = 0; double px0 = 0.0; double py0 = 0.0; double pz0 = 0.0; int started = 1; double NOE = 3.0; double Znuc = 3.0; double Rcore = 2.278138; int dgX, dgY, dgXb,dgYb; double viewTheta = -15.0*3.14/180.0; double viewFai = -72.0*3.14/180.0; double dtheta = 0.0*3.14/180.0; double pai = 3.1415926536; double cosTh = Math.cos(viewTheta); double sinTh = Math.sin(viewTheta); double cosFi = Math.cos(viewFai); double sinFi = Math.sin(viewFai); double t = 0.0; double dx = 1.0/4.0; double dy = 1.0/4.0; double dz = 1.0/4.0; double dt = 1.0*(dx*dx); int NNx = 64+1; int NNy = 64+1; int NNz = 64+1; int NN = NNx+1; /* max(NNx,NNy,NNz)+1 */ double vv[][][] = new double[NNx][NNy][NNz]; double vvext[][][] = new double[NNx][NNy][NNz]; double vvh[][][] = new double[NNx][NNy][NNz]; double vvx[][][] = new double[NNx][NNy][NNz]; double vvc[][][] = new double[NNx][NNy][NNz]; double rho[][][] = new double[NNx][NNy][NNz]; double sdEnergy[] = new double[20]; double sdState[][][][] = new double[20][NNx][NNy][NNz]; double occ[] = new double[20]; /* d- transition metal pseudopotential */ /* J.K. Baria, P.N. Gajjar and A.R. Jani; FIZIKA B 12 (2003) 1, 23-40 */ double BGJpp[][] = { /* Zv , rc , Z , M , Zs , Zd */ /* Sc */ { 3.0, 2.278138, 21.0, 44.96, 2.0, 1.0 }, /* Ti */ { 4.0, 2.182266, 22.0, 47.9 , 2.0, 2.0 }, /* V */ { 5.0, 2.086584, 23.0, 50.94, 2.0, 3.0 }, /* Cr */ { 6.0, 1.967013, 24.0, 52.0 , 1.0, 5.0 }, /* Mn */ { 7.0, 1.870366, 25.0, 54.94, 2.0, 5.0 }, /* Fe */ { 8.0, 1.702500, 26.0, 55.84, 1.0, 7.0 }, /* Co */ { 9.0, 1.485970, 27.0, 58.93, 1.0, 8.0 }, /* Ni */ { 10.0, 1.269247, 28.0, 58.7 , 2.0, 8.0 }, /* Cu */ { 11.0, 1.081773, 29.0, 63.54, 1.0,10.0 }, /* Y */ { 3.0, 2.613985, 39.0, 88.91, 2.0, 1.0 }, /* Zr */ { 4.0, 2.543297, 40.0, 91.22, 2.0, 2.0 }, /* Nb */ { 5.0, 2.423815, 41.0, 92.91, 1.0, 4.0 }, /* Mo */ { 6.0, 2.382264, 42.0, 95.94, 1.0, 5.0 }, /* Tc */ { 7.0, 2.014131, 43.0, 98.0 , 2.0, 5.0 }, /* Ru */ { 8.0, 1.726644, 44.0, 101.0 , 1.0, 7.0 }, /* Rh */ { 9.0, 1.485504, 45.0, 102.91, 1.0, 8.0 }, /* Pd */ { 10.0, 1.204740, 46.0, 106.4 , 0.0,10.0 }, /* Ag */ { 11.0, 1.075202, 47.0, 107.87, 1.0,10.0 }, /* Lu */ { 3.0, 2.542542, 71.0, 88.91, 2.0, 1.0 }, /* Hf */ { 4.0, 2.519295, 72.0, 91.22, 2.0, 2.0 }, /* Ta */ { 5.0, 2.538271, 73.0, 92.91, 2.0, 3.0 }, /* W */ { 6.0, 2.371332, 74.0, 95.94, 2.0, 4.0 }, /* Re */ { 7.0, 1.894193, 75.0, 98.0 , 2.0, 5.0 }, /* Os */ { 8.0, 1.580087, 76.0, 101.0 , 2.0, 6.0 }, /* Ir */ { 9.0, 1.221598, 77.0, 102.91, 2.0, 7.0 }, /* Pt */ { 10.0, 0.787344, 78.0, 106.4 , 1.0, 9.0 }, /* Au */ { 11.0, 0.954561, 79.0, 107.87, 1.0,10.0 } }; int pxBox[] = new int[8]; int pyBox[] = new int[8]; int boxp[][] = { {0,1},{0,2},{0,4},{1,3},{1,5},{2,3},{2,6},{4,5},{4,6},{3,7},{5,7},{6,7} }; int xpts[] = new int[NN]; int ypts[] = new int[NN]; /* ----------------------------- applet control ------ */ public void init() { resize(630,320); setBackground(Color.white); dim = getSize(); imgOff = createImage(dim.width,dim.height); gOff = imgOff.getGraphics(); cvw = new Choice(); cvw.addItem("ph-0");cvw.addItem("ph-1");cvw.addItem("ph-2"); cvw.addItem("ph-3");cvw.addItem("ph-4");cvw.addItem("ph-5"); cvw.addItem("ph-6");cvw.addItem("ph-7"); cvw.addItemListener(this); cvw.select("ph-0"); ch_md = new Choice(); ch_md.addItem("density");ch_md.addItem("phase");ch_md.addItem("ph-grid"); ch_md.addItem("Vext"); ch_md.addItem("VH"); ch_md.addItem("Vx"); ch_md.addItem("Vc"); ch_md.addItem("Veff"); ch_md.addItem("rho"); ch_md.addItemListener(this); ch_md.select("phase"); ch_noe = new Choice(); ch_noe.addItem("n=3(Sc)"); ch_noe.addItem("n=4(Ti)"); ch_noe.addItem("n=5(V)"); ch_noe.addItem("n=6(Cr)"); ch_noe.addItem("n=7(Mn)"); ch_noe.addItem("n=8(Fe)"); ch_noe.addItem("n=9(Co)"); ch_noe.addItem("n=10(Ni)"); ch_noe.addItem("n=11(Cu)"); ch_noe.addItem("n=3(Y)"); ch_noe.addItem("n=4(Zr)"); ch_noe.addItem("n=5(Nb)"); ch_noe.addItem("n=6(Mo)"); ch_noe.addItem("n=7(Tc)"); ch_noe.addItem("n=8(Ru)"); ch_noe.addItem("n=9(Rh)"); ch_noe.addItem("n=10(Pd)"); ch_noe.addItem("n=11(Ag)"); ch_noe.addItem("n=3(Lu)"); ch_noe.addItem("n=4(Hf)"); ch_noe.addItem("n=5(Ta)"); ch_noe.addItem("n=6(W)"); ch_noe.addItem("n=7(Re)"); ch_noe.addItem("n=8(Os)"); ch_noe.addItem("n=9(Ir)"); ch_noe.addItem("n=10(Pt)"); ch_noe.addItem("n=11(Au)"); ch_noe.addItemListener(this); ch_noe.select("n=3(Al)"); bt_reset= new Button("reset"); bt_reset.addActionListener(this); bt_start= new Button("start"); bt_start.addActionListener(this); bt_stop = new Button("stop"); bt_stop.addActionListener(this); spx= new Scrollbar(Scrollbar.HORIZONTAL,50,10,0,110); spx.addAdjustmentListener(this); spy= new Scrollbar(Scrollbar.HORIZONTAL,0,10,0,110); spy.addAdjustmentListener(this); spz= new Scrollbar(Scrollbar.HORIZONTAL,0,10,0,110); spz.addAdjustmentListener(this); addMouseListener(this); addMouseMotionListener(this); setLayout(new BorderLayout()); Panel pnl = new Panel(); pnl.setLayout(new GridLayout(1,6,5,0)); pnl.add(bt_reset); pnl.add(bt_start); pnl.add(bt_stop); pnl.add(ch_noe); pnl.add(cvw); pnl.add(ch_md); add(pnl,"North"); setInitialCondition(); } public void start() { if (th == null) { th = new Thread(this); th.start(); } } public void stop() { if (th != null) { th.stop(); th = null; } } public void itemStateChanged(ItemEvent ev){ int ic; if (ev.getSource() == cvw){ dispObj = cvw.getSelectedIndex(); } else if (ev.getSource() == ch_md){ dispMode = ch_md.getSelectedIndex(); } else if (ev.getSource() == ch_noe){ ic = ch_noe.getSelectedIndex(); Znuc = BGJpp[ic][0]; NOE = Znuc; Rcore = BGJpp[ic][1]; setPotential(); } } public void actionPerformed(ActionEvent ev){ if(ev.getSource() == bt_reset){ started = -1; } else if(ev.getSource() == bt_start){ started = 1; } else if(ev.getSource() == bt_stop){ started = 0; } } public void adjustmentValueChanged(AdjustmentEvent ev){ if (ev.getSource() == spx) { px0 = 0.1*(double)(spx.getValue()); } else if (ev.getSource() == spy) { py0 = 0.1*(double)(spy.getValue()); } else if (ev.getSource() == spz) { pz0 = 0.1*(double)(spz.getValue()); } } public void mousePressed(MouseEvent ev){ } public void mouseReleased(MouseEvent ev){ dgXb = 0; dgYb = 0; dgX = 0; dgY = 0; } public void mouseClicked(MouseEvent ev){ } public void mouseEntered(MouseEvent ev){ } public void mouseExited (MouseEvent ev){ } public void mouseMoved (MouseEvent ev){ } public void mouseDragged(MouseEvent ev){ dgXb = dgX; dgYb = dgY; dgX=ev.getX(); dgY=ev.getY(); if (dgXb==0 && dgYb==0) { dgXb = dgX; dgYb = dgY; } viewTheta += 0.5*3.14/180.0*(dgX-dgXb); viewFai += 0.5*3.14/180.0*(dgY-dgYb); cosTh = Math.cos(viewTheta); sinTh = Math.sin(viewTheta); cosFi = Math.cos(viewFai); sinFi = Math.sin(viewFai); } public void run() { while (th != null) { try { timeEvolution(); offPaint(); repaint(); Thread.sleep(sleepTime); } catch (InterruptedException e) { } } } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { g.drawImage(imgOff,0,0,this); } /* ----------------------------- offPaint -------------------- */ void offPaint() { int i,gb; double ev,ek; double g0,g1; double dens; gOff.setColor(Color.white); gOff.fillRect(0,0,dim.width,dim.height); g0 = 0.0; g1 = 0.0; if (NOE<=2.0) { g0= NOE; g1 = 0.0; } else if (NOE>2.0) { g0= 2.0; g1 = (NOE-2.0)/3.0; } dens = 500.0; if (dispMode==0 || dispMode==1) { boxPlot(); dens3DPlotSD(dens,dispMode,dispObj); boxPlot2(); } else if (dispMode==2) { gridFnPlot(sdState[dispObj], NNz/2, 50.0); } else if (dispMode==3) { gridFnPlot(vvext, NNz/2, 5.0); } else if (dispMode==4) { gridFnPlot(vvh, NNz/2, 5.0); } else if (dispMode==5) { gridFnPlot(vvx, NNz/2, 5.0); } else if (dispMode==6) { gridFnPlot(vvc, NNz/2, 5.0); } else if (dispMode==7) { gridFnPlot(vv, NNz/2, 5.0); } else if (dispMode==8) { gridFnPlot(rho, NNz/2, 200.0); } gOff.setColor(Color.black); gOff.drawString("transition metal perudopotential",30,40); gOff.drawString("ne(atom)",630/6*3+10,40); gOff.drawString("object",630/6*4+10,40); gOff.drawString("view",630/6*5+10,40); gb = 360; gOff.setColor(Color.black); gOff.drawString("box="+(int)(NNx*dx)+"x"+ +(int)(NNy*dy)+"x"+(int)(NNz*dz)+" au",gb,60); gOff.drawString("dx="+(int)(dx*100.0)/100.0+" au",gb,80); gOff.drawString("W(r)=-Zv/r (r>=Rc)",gb,100); gOff.drawString(" = -Zv*r/Rc^2 *{2-exp(1-r/Rc)} (r0.0) { gOff.setColor(Color.red); gOff.drawString("g["+i+"]="+(float)(occ[i])+"",gb,200+12*i); } else { gOff.setColor(Color.blue); } gOff.drawString("E["+i+"]="+(float)(sdEnergy[i])+"",gb+100,200+12*i); } } /*------------------------------- plot methods ------------*/ void dens3DPlotSD(double weight,int mode, int istate) { int i,j,k,ix,iy,ir; int gbx,gby; double cxx,cyy,czz; double z,ppx,ppy,ppz; double mag,dens,col; gbx = 60; gby = 80; mag = 3.0; cxx = mag*(NNx/2.0); cyy = mag*(NNy/2.0); czz = mag*(NNz/2.0); for (i=1; i0) { if (ir>10) { ir = 10; } z = k*mag; ppy = cosFi*(j*mag-cyy)+sinFi*(z-czz) + cyy; ppz = -sinFi*(j*mag-cyy)+cosFi*(z-czz) + czz; ppx = cosTh*(i*mag-cxx)+sinTh*(ppz-czz) + cxx; ppz = -sinTh*(i*mag-cxx)+cosTh*(ppz-czz) + czz; ix = (int)(ppx)+gbx; iy = (int)(ppy)+gby; col = 0.0; if (mode==0) { col = 0.66 -0.05*dens; if (col<0.0) { col = 0.0; } } else if (mode==1) { if (sdState[istate][i][j][k]>=0) { col = 0.33; } else { col = 0.01; } } gOff.setColor(Color.getHSBColor((float)col, (float)(0.19+0.4*occ[istate]),0.9f)); gOff.fillOval(ix-ir/2,iy-ir/2,ir,ir); } } } } } void gridFnPlot(double fn[][][], int zPos, double weight) { int i,j,k,gbx,gby; int cx,cy,cz; double z,px,py,pz,sc; double ph2; cx = NNx/2; cy = NNy/2; cz = 0; sc = 4.0; gbx = 30+(int)(cx/sc); gby = 20+(int)(cy/sc); k = zPos; for(j=0; jsdEnergy[ist+1]+0.001) { for (i=1;i2.0) { occ[i] = 2.0; s = s-2.0; } else { occ[i] = s; s = 0.0; } } } void setRho() { int i,j,k,ie; double ne,g0,g1; for (i=1; i=1.0) { ec = -0.1423/(1.0+1.0529*Math.sqrt(r)+0.3334*r); } else { ec = -0.0480-0.0116*r+(0.0311+0.0020*r)*Math.log(r); } return ( ec ); } /* ----------------- Gram-Schmidt --------- */ void GramSchmidt(int stateMax) { int i,j,k,ist,istate; double s; normalize(sdState[0]); for (istate=1; istate