Sample C language program computing atomic radius ( carbon, oxigen, boron )

Top page (correct Bohr model including helium).
Back to molecular bond page.

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.)
Here we use the new unit of 1 MM = 1 × 10-14 meter.

In this program, first we choose the kind of atoms.
If you compute carbon like atoms (= C, Si ), input the valiue of "0", first.
If you compute oxygen-like (= O, Si ) or boron-like (= B, Al ) atoms input "1" or "2", respectively.

Next input the central charge Z and total ionization energies of all valence electrons.
From these inputted values, this program compute potential energies and force of tetrahedral carbon.
And using Virial theorem ( E = -T = 1/2 V ), this program calculate de Broglie wave in one orbit
On the screen, this de Broglie wave's number (= almost 2.0 ), and the distance (MM) between each valence electron and the central nucleus are shown.



#include <stdio.h>
#include <math.h>

int main(void) 
 {
   int i;
   double fig,Z,E,ke,r,F,nuc,radius,debroglie,a,wave;
   double poten, kinetic,velo;
   double me=9.1093826e-31;
   double pai=3.141592653589793; 
   double epsi=8.85418781787346e-12;
   double h=6.62606896e-34; 
   double ele=1.60217653e-19;  
     
                             /* choose carbon-like = 0, oxygen-like = 1, boron like = 2 */
   
    printf(" First, input 0, 1, or 2 to choose atoms. \n");  
    printf("  Carbon, Si = 0, Oxygen, S = 1, Boron, Al = 2  ? ");  
    scanf("%lf",&fig);
 
                            /* input central positive charge Z  */ 
    printf(" central charge Z ?    ");  
    scanf("%lf",&Z);

                         /* input total ionization energy |E| eV  */
    printf(" total ionization energies |E| eV ? ");  
    scanf("%lf", &E);
    printf("                        \n");

     ke=(ele*ele)/(4.0*pai*epsi);
     poten = -2.0 * E * 1.602177e-19;

    /*  Carbon-like atoms ( C, Si )  */

                          /* length r from potenial V in tetrahedron  */
     r =(ke/poten) * (-(8.0*Z)/sqrt(6.0) + 3.0);
                
                   /* kinetic = total kinetic energy by Virial theorem */        
      kinetic=-0.5*poten;       
      velo=sqrt((kinetic)/(2.0*me));  /* velo = electron's velocity (m/s) */
 
                      /* F = force acting on each electron (N) */
       F = (ke/(r*r))*(Z*2.0/3.0 - sqrt(6.0)/4.0  );

                       /* nuc = distance between electron and nucleus */
       nuc=r*sqrt(6)/2.0;  

       radius=(me*velo*velo)/F; /* rotation radius from centrifugal force */
       debroglie = h/(me*velo);       /* de Broglie wavelength of electron */
       wave=(2.0*pai*radius)/debroglie;  /* wave's number in one orbit */


    /* oxygen-like atoms ( O, S )  */

   if ( fig == 1 ) {
                     /* a = distance between electron and nucleus  */
       a = (ke/poten)*(-6.0*Z + 12.0/sqrt(2)+1.5);

                          /* velo = veclocity of each  electron 0-5 */
     velo=sqrt(kinetic/(3.0*me));

                         /*  F = force acting on each electron (N) */
     F = (ke/(a*a))*(Z-2.0/sqrt(2)-0.25);

     radius=(me*velo*velo)/F; /* rotation radius from centrifugal force */
     debroglie = h/(me*velo);       /* de Broglie wavelength of electron */
     wave=(2.0*pai*radius)/debroglie;  /* wave's number in one orbit */
     nuc = a;
      }

    /* Boron -like atoms ( B, Al ) */ 

   if ( fig == 2 ) {
                             /* r = distance between electron and nucleus */
      r =(ke/poten) * (-(3.0*Z) + sqrt(3));  
                                
                           /* velo = velocity of each electron 0-2 */ 
      velo=sqrt((2.0*kinetic)/(3.0*me)); 
                           /*  F = force acting on each electron  */
    F = (ke/(r*r))*(Z - (1.0/sqrt(3)) );


       radius=(me*velo*velo)/F;  /* rotation radius from centrifugal force */
       debroglie = h/(me*velo);    /* de Broglie wavelength of electron */
       wave=(2.0*pai*radius)/debroglie;  /*  wave's number in one orbit  */

      nuc = r;
      }
  
      nuc = nuc * 1.0e14;  /* change meter to MM */

      printf("de Broglie wave in one orbit : %.3f \n", wave);
      printf("distance between electron and nucleus: %.2f ", nuc);
      printf("                        \n");
                      
   
     return 0;
   }