Sample JAVA program to compute the electron's orbit of Hydrogen atom 1S of Bohr model.

Back to Planck page
Top page ( correct Bohr model including the two electron atom )

If you copy and paste the program source code below into a text editor, you can easily compile and run this.
(This class file name is Hyatom, so save this text editor as "Hyatom.java", and compile it.)
In this program, we first input the initial x-coordinate r1 (in MM) of electron 1 and the absolute value of the total energy E ( in eV ) of the hydrogen atom 1S orbit.
Here we use the new units, ( 1 MM = 10-14 meter, 1 SS = 10-22 second, 1 MM/SS = 108 m/s ).
From the inputted values, this program outputs the last velocity ( VX,VY in MM/SS ) and number of the de Broglie's waves ( midWN ) contained in one quarter of the orbit.


import java.util.Scanner;
class Hyatom {
 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 1S hydrogen atom (eV) ? ");  
 double E=stdIn.nextDouble();
 
 double me=9.1093826e-31; double mp=1.67262171e-27;
 double rm=(me*mp)/(me+mp);            // rm = reduced mass of electron in H atom
 
 double pai=3.141592653589793; double epsi=8.85418781787346e-12;
 double h=6.62606889e-34; double ele=1.60217653e-19;

                                   // Bor = theoretical value of Bohr radius (MM) (of reduced mass)
                                   // Ene = theoretical value of total energy |E| (eV) in 1S hydrogen
 double Bor=(epsi*h*h*1.0e14)/(pai*ele*ele*rm);   
 double Ene=(ele*ele*ele*ele*rm*6.241509e18)/(8.0*epsi*epsi*h*h); 
 double Exe=13.59844;               // Exe = experimental value of ionization energy (eV) of H atom.
  System.out.printf("theoretical value of Bohr radius (MM):%.5f  \n ", Bor);
  System.out.printf("theoretical value of |E| (eV) in H atom :%.5f  \n ", Ene);
  System.out.printf("experimental value of ionization energy (eV) in H atom :%.5f  \n ", Exe);

 for (int i=1;i < 30;i++) {      // repeat until r1=initial r1+30
                                
                             // calculation of initial VY from E and r1    
 double poten=-(ele*ele)/(4.0*pai*epsi*r);
                                                     //vya (J) = 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((2.0*vya)/rm); 
 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+ number of de Broglie wave contained in short segment
    WN=WN+(rm*vk*1.0e-6)/h;                        
                                   //calculation of VX,VY from Coulomb force
    double ra=Math.sqrt(prexx*prexx+preyy*preyy);       
    ra=ra*1.0e-14;                                 // change MM to meter
    prexx=prexx*1.0e-14; preyy=preyy*1.0e-14;
    double ac=(ele*ele)/(4.0*pai*epsi*rm);
                                          
                                // change velocity components VX (MM/SS) and VY from Coulomb force
    VX=VX+1.0e-30*ac*prexx*(-1.0/(ra*ra*ra));   
    VY=VY+1.0e-30*ac*preyy*(-1.0/(ra*ra*ra));
    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=(WN+preWN)/2.0; System.out.printf("midWN:%.5f  \n", midWN);
    }
   }  r=r+1;
   }}}