サンプルJAVAコンピュータープログラム(ヘリウム軌道計算)

top page


import java.util.Scanner;
class MathMethod {
 public static void main(String[] args) {
 
 Scanner stdIn=new Scanner(System.in);     // input r1 and |E|
 System.out.println("r1 between nucleus and electron 1 (MM) ?");  
 double r=stdIn.nextDouble();
 System.out.println("total energy |E| in the herium (eV) ? ");  
 double E=stdIn.nextDouble();
 
 double me=9.1093826e-31; double mp=1.67262171e-27;
 double mn=1.67492728e-27;double nucle=2*mp+2*mn;
 double rm=(2*me*nucle)/(2*(2*me+nucle));
 
 double pai=3.141592653589793; double epsi=8.85418781787346e-12;
 double h=6.62606896e-34; double ele=1.60217653e-19;

 for (int i=1;i<100;i++) {      // repeat until r1=initial r1+100
                                
                             // calculation of initial VY from E and r1    
double poten=-(2*ele*ele*2)/(4*pai*epsi*r)+(ele*ele)/(4*pai*epsi*2*r);
                             
                             //vya= total E-potential energy  
double vya=-(E*1.60217646e-19)-poten*1.0e14; 
 if (vya>0) {
                               // vyb=velocity from kinetic energy
 double vyb=Math.sqrt(vya/me); 
 double VY=vyb*1.0e-8;         // change m/sec to MM/SS
 
 double prexx=r; double VX=0.0; double WN=0.0; double preyy=0.0; 
 double xx,yy,vk,preVY,preWN,midWN;
  
 do {
    xx=prexx+VX; yy=preyy+VY;        //electron 1 position after 1SS
    preVY=VY;preWN=WN ;
    vk=VX*VX+VY*VY;                  //calculation of WN from VX,VY 
                                     // WN=WN+Eq(7)
    WN=WN+(rm*vk*1.0e-6)/h;                        
                                   //calculation of VX,VY from Coulomb force
    double ra=Math.sqrt(prexx*prexx+preyy*preyy);       
    double rb=Math.sqrt(4.0*prexx*prexx+2.0*preyy*preyy);
    ra=ra*1.0e-14; rb=rb*1.0e-14; 
    prexx=prexx*1.0e-14; preyy=preyy*1.0e-14;
    double ac=(2*ele*ele)/(4*pai*epsi*rm);
                                          // VX=VX+Eq(5-1)*10^(-30)
    VX=VX+1.0e-30*ac*prexx*(-1.0/(ra*ra*ra)+1.0/(rb*rb*rb));   
                                          // VY=VY+Eq(5-2)*10^(-30)
    VY=VY+1.0e-30*ac*preyy*(-1.0/(ra*ra*ra)+0.5/(rb*rb*rb));
    prexx=xx;preyy=yy;
  
   } while (xx>0);              //repeat above until electron 1 arive at y axis 
   if (VY>-0.0001 && VY<0.0001) {    // last VY condition           
  System.out.print("r1: "+r+"   ");
  System.out.printf("VX:%.5f   ", VX);
  System.out.printf("VY:%.5f   ", VY);
  System.out.printf("preVY:%.5f  ", preVY);
  midWN=(preWN+WN)/2; System.out.printf("midWN:%.5f  \n", midWN);
    }
   }  r=r+1;
   }}}