One-electron hydrogen atomic energy

Simple C program to calculate hydrogen (= H ) atom and helium ion (= He+ ).

Home page

Copy & paste sample program of H atom.

If you copy and paste the program source code below into a text editor, you can easily compile and run this.
(This program is simple c language, so save this text editor as "filename.c", and compile it.)

Choose H or He+ atom, reduced mass or not.

In this program, first we input the atomic number Z ( 1 = hydrogen H atom, 2 = helium He+ ion ) and whether you use reduced mass (= 0 ) or the original electron mass without reduced mass

Display theoretical hydrogen energy, radius

From these values, it outputs theoretical values (= hydrogen solution of Bohr model or Schrodinger equation ) of total energy and (Bohr) radius of the hydrogen-like atoms.

Input hydrogen's energy.

Input the initial electron's x-coordinate (= r ) and total energy of H (or He+ ) atom.

Then we input the initial x-coordinate r1 (in MM = 1.0 × 10-14 meter ) of electron (= electron starts from x-axis to y-axis ), and the absolute value of the total energy E (in eV) of H or He+ atom.

Output de Broglie wavelength of 1/4 orbit.

From the input H or He+'s total energy and initial electron's x-coordinate, this program outputs de Broglie wavelength of 1/4 orbit, after the electron moves from x-axis to y-axis.

From these inputted values of total energy of H or He+ atoms, this program outputs de Broglie wavelength (= WN ) of 1/4 orbit, x,y-components of the last velocity (= VX, VY ) of the electron after the electron has moved its 1/4 orbit from x-axis to y-axis.

↑ When the orbit is symmetrically circular, this last velocity's y-component (= VY ) becomes zero = the electron crosses y-axis perpendicularly after moving its 1/4 orbit.

Unit

Here we use new convenient unit of time = 1 SS = 1 × 10-23 second,  length = 1 MM = 1 × 10-14 meter,   velocity = 1MM/SS = 1×109 m/s,  acceleration = 1MM/SS^2 = 1 × 1032 m/s^2.

The initial x-coordinate r of the electron is automatically increased per calculation of 1/4 orbit until +100.
This method is the same as neutral helium program.

Theoretical H or He+'s energy and radius

Theoretical values of energy and radius based on Bohr model or Schrodinger equation are:
In hydrogen atom (H), total energy = -13.60569 eV, and Bohr radius = 5291.77 MM.
Using reduced mass, total energy = -13.59829 eV, and radius = 5294.65 MM.
In helium ion (He+), total energy = -54.42277 eV, and radius = 2645.89 MM.
Using reduced mass, total energy = -54.41531 eV, and radius = 2646.25 MM.
In these values, one-orbit is just 1 × de Broglie wavelength, and last VY is just zero (= meaning this orbit becomes just symmetrically circular like the theoretical Bohr's hydrogen ).

↑ For example, after starting this program, when we input Z = 1 (= H atom ), reduced mass (= 0 ), initial r1 = 5294.65 (MM), total energy |E| of H atom = 13.59829 (eV), this program outputs the total de Broglie wavelength of 1/4 orbit equal to just 0.250000, and (last)VY velocity equal to just zero (= 0.000000 ), last-y-coordinate equal to the initial r1 (= meaning a symmetrical circular orbit ).

 


#include <stdio.h>
#include <math.h>
                           
/* One-electron hydrogen, helium-ion */

int main(void) 
 {
   int i;
   double Z,whi,toenergy,radius,rm,r,E;  
   double vya,vyb,poten,VX,VY,prexx,preyy,WN,ra;
   double xx,yy,vk,leng,wav,ac;

/* me = electron mass kg,  pai = pi,
   epsi = electric constant,  h = Planck constant,
  ele = electron charge
*/

   double me=9.1093826e-31;
   double pai=3.141592653589793; 
   double epsi=8.85418781787346e-12;
   double h=6.62606896e-34; 
   double ele=1.60217653e-19;  

/* mp = proton mass kg,  alpha = helium nuclear mass */

   double mp=1.67262171e-27;       
   double alph = 6.64465650e-27;    
                  
/*  input Z = atomic number */
 
   printf("Atomic number Z ( H = 1, He+ = 2 )? ");  
   scanf("%lf",&Z);

/* choose reduced mass or usual electron mass */

   printf("You use reduced mass (= 0 ) or usual electron mass (= 1 ) ?");  
   scanf("%lf", &whi);

/* rm = reduced mass */

   rm=me;                 
    if (Z < 1.5) { rm=(me*mp)/(me+mp); }      
    if (Z > 1.5 ) { rm=(me*alph)/(me+alph);}   
    if (whi > 0.5 ) { rm=me; }

 /* toenergy = theoretical total energy of H atom or He+ ion */

    toenergy = -(Z*Z*rm*ele*ele*ele*ele)/(8.0*epsi*epsi*h*h); 

/* radius = thoretical radius of H atom or He+ ion  */

    radius = (epsi*h*h)/(pai*rm*Z*ele*ele);

/*  change unit from J into eV */

    toenergy = toenergy * 6.241509e18;  

/* change unit from meter into MM (= 10^-14 meter ) */    

    radius = radius * 1.0e14;           

    printf("Theory-total-energy: %.5f ", toenergy);
    printf("Theory-radius: %.2f \n", radius);
  
  printf(" \n");

/* input electron-1's initial xc-coordinate r1 */
                                         
    printf("r1 between nucleus and electron 1 (MM)? ");  
    scanf("%lf",&r);

/* input absolute value of total energy |E| of H atom or He+ ion */

    printf("absolute value of total energy |E| of H atom or He+ ion (eV) ? ");  
    scanf("%lf", &E);
 
   for (i=1; i < 100 ;i++) {     

/* repeat until r1 increases to r1+100 */
                                
/* poten = initial Coulomb potential energy (J) */

    poten=-(Z*ele*ele)/(4.0*pai*epsi*r*1.0e-14);
                             
/* vya= total E - potential energy (J) */  

     vya=-(E*1.60217646e-19)-poten; 
    if (vya > 0) {
 
 /* vyb=electron initial velocity (m/sec) */ 

     vyb=sqrt((2*vya)/rm);

/* VX,VY = electron's x,y-velocity (= MM/SS = 10^9 m/s ) */
 
     VY=vyb*1.0e-9;    VX=0.0;  

/* prexx, preyy = electron-1's x,y-coordinate */
      
     prexx=r;  preyy=0.0;

/* WN = sum of de Broglie wavelength */

 WN=0.0;
   
  do {

/* xx,yy= electron's position after 1SS */

    xx=prexx+VX; yy=preyy+VY;        

    vk=VX*VX+VY*VY;  

/* leng = electron's moving length (= meter ) for 1SS */
                
    leng=sqrt(vk)*1.0e-14;  

/* wav = de Broglie wavelength (= meter ) */   

     wav=h/(rm*sqrt(vk)*1.0e9);  

/* WN = sum of de Broglie wavelength */

    WN=WN+leng/wav;                
                               
/* ra = distance between nucleus and electron */

    ra=sqrt(prexx*prexx+preyy*preyy);  

/* change unit of length from MM into meter */
                                   
    ra=ra*1.0e-14;    
    prexx=prexx*1.0e-14; preyy=preyy*1.0e-14;


    ac=(ele*ele)/(4.0*pai*epsi*rm);
                                    
/* calculating acceleration (= MM/SS^2 = 10^32 m/s^2  ) from Coulomb force  */

/* update electron's x,y-velocity = VX,VY from Coulomb force   */

    VX=VX+1.0e-32*ac*prexx*(-Z/(ra*ra*ra));   
    VY=VY+1.0e-32*ac*preyy*(-Z/(ra*ra*ra));

    prexx=xx;preyy=yy;
  
   } while (xx >= 0);             

 /* until electron has moved 1/4 orbit to reach y-axis */
     
/* display electron's initial x-coordinate r1 */     
  printf("r1= %.2f ", r );

/* display electron's last velocity VX, VY */

  printf("VX= %.6f ", VX);
  printf("VY= %.6f ", VY);

/* display electron's last y-coordinate */

  printf("last y = %.2f ", yy);

/* display total de Broglie wavelength WN of 1/4 orbit */

  printf("WN= %.6f\n", WN);
    
   }  r=r+1;
   }  return 0;
   }