Sample JAVA program to compute the electron's orbit of the carbon ion (C3+) of Bohr model.

Back to the carbon 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 MathMethod, so save this text editor as "", 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 carbon ion (C3+).
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 MathMethod {
 public static void main(String[] args) {
 Scanner stdIn=new Scanner(;     // input r1 and |E|
 System.out.println("r1 between nucleus and electron 1 (MM)? ");  
 double r=stdIn.nextDouble(); 
 System.out.println("total energy |E| of the C3+(eV) ? ");  
 double E=stdIn.nextDouble();
 double me=9.1093826e-31; 
 double pai=3.141592653589793; double epsi=8.85418781787346e-12;
 double h=6.62606896e-34; double ele=1.60217653e-19;
 double ab=(ele*ele)/(4*pai*epsi); double ac=ab/me;

 double Eb=-(16*ele*ele*ele*ele*me)/(32*epsi*epsi*h*h); // Eb=2S energy of C3+
 double Rb=(4*epsi*h*h)/(4*pai*ele*ele*me);           // Rb=2S radius of C3+
 double Rbb=Rb*1.0e14;
 double Rbc=Rbb/(Math.sqrt(2));
 System.out.printf("Bohr radius in 2S electron of C3+ :%.2f\n", Rbb);
 for (int i=1;i < 100;i++) {      // repeat until r1=initial r1+100
 double rr=r*1.0e-14;  // change r(MM) into rr(meter)
                             // disb=distance between e1S and e2S 
 double disb=Math.sqrt(rr*rr+Rb*Rb); 

 double poten=-(2*6*ab)/rr+ab/(2*rr)+(2*ab)/disb-(6*ab)/(Rb);
                            //vya= total E - potential energy - 2S kinetic energy(-Eb)  
 double vya=-(E*1.60217646e-19)-poten+Eb; 

 if (vya > 0) {
                               // vyb=initial 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; xx=0.0;
 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=number of de Broglie's waves
                                   //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);
                                   // rc=distance between e1 and 2Se
    double rc=Math.sqrt(prexx*prexx+(preyy+Rbc)*(preyy+Rbc)+(Rbb*Rbb)/2);
                                   // change MM to meter
    ra=ra*1.0e-14; rb=rb*1.0e-14; rc=rc*1.0e-14;
    prexx=prexx*1.0e-14; preyy=preyy*1.0e-14;
                                   // change velocity (VX,VY)
   } while (xx >= 0);              //electron has moved a half of an orbit? 
   if (VY > -0.001 && VY < 0.001) {    // last VY condition           
  System.out.print("r1: "+r+"   ");
  System.out.printf("VX:%.5f", VX);
  System.out.printf("preVY:%.5f", preVY);
  System.out.printf("VY:%.5f", VY);
  midWN=(preWN+WN)/2; System.out.printf("midWN:%.5f\n", midWN);
   }}  r=r+1;