Thesis Data
Chris Harris
21 Dec 1999


Introduction


The ‘Problem Statement’ section originates from my master’s thesis: Real Time Reflectometry of Ga–based Compound Semiconductor Films on Silicon during Plasma Enhanced Molecular Beam Epitaxy, 1999. In the spirit of engineering style, reflect.c crunches the numbers from the Fresnel equation, which has imaginary components. Once values are known over a temperature range of interest, bola.c fits the data to a parabola template. Finally, plot.py emerges to graph the Fresnel curve, revealing a standard deviation envelope at a 95 % confidence level.


Problem Statement

page1 page2 page3 page4

C++ Code


reflect.c:

#include <iostream>
#include <fstream>
#include <cmath>
#include <complex>
using namespace std;

int main(){
  int     w,i;
  double  phi, T, Re, Im, R;
  complex<double> epsilon, a, b, r;

  phi=75*M_PI/180;

  cout << " Data stored in 'reflect.Si' file!!!\n";
  fstream sink("reflect.Si", ios::out);
  sink << "T\t";
  sink << "R\n";

  for(i=0; i<1010; i=i+10){
    T=double(i);

    Re=15+2.1e-3*T+1.5e-6*T*T;
    Im=.132*exp(2.5e-3*T);
    epsilon=complex<double>(Re,Im);

    a=epsilon*sqrt(1-sin(phi)*sin(phi));
    b=sqrt(epsilon-sin(phi)*sin(phi));

    r=(a-b)/(a+b);
    R=real(r*conj(r));

    sink << T << "\t";
    sink << R << endl;
  }
  sink.close();

  return 0;
}


C++ Code


bola.c:

#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;

const int j=200;

class array{
  public:
     double x, y;
     array(){}
};
int main(){
  char   ch;
  int    i, m;
  double var1, var2, s1, s2, s3, s4, sumy, sumxy, sumx2y,
         det, p0, p1, p2, sumr2, ycalc, r, sigma;
  array  *a[j];

  fstream source("reflect.Si", ios::in);
  source >> ch >> ch;
  for(m=0; source >> var1 >> var2; m=m+1){
     a[m] = new array;
     a[m]->x = var1;
     a[m]->y = var2;
  }
  source.close();

  s1     =0;
  s2     =0;
  s3     =0;
  s4     =0;
  sumy   =0;
  sumxy  =0;
  sumx2y =0;

  for(i=0; i<m; i=i+1){
    s1     =s1     + a[i]->x;
    s2     =s2     + pow(a[i]->x,2);
    s3     =s3     + pow(a[i]->x,3);
    s4     =s4     + pow(a[i]->x,4);
    sumy   =sumy   + a[i]->y;
    sumxy  =sumxy  + a[i]->x*a[i]->y;
    sumx2y =sumx2y + a[i]->x*a[i]->x*a[i]->y;
  }
  det=m*(s2*s4-s3*s3)+s1*(s2*s3-s1*s4)+s2*(s1*s3-s2*s2);
  p0 =((s2*s4-s3*s3)*sumy+(s2*s3-s1*s4)*sumxy+(s1*s3-s2*s2)*sumx2y)/det;
  p1 =((s2*s3-s1*s4)*sumy+( m*s4-s2*s2)*sumxy+(s1*s2- m*s3)*sumx2y)/det;
  p2 =((s1*s3-s2*s2)*sumy+(s1*s2- m*s3)*sumxy+( m*s2-s1*s1)*sumx2y)/det;

  sumr2=0;
  for(i=0; i<m; i=i+1){
    ycalc=p0+p1*a[i]->x+p2*a[i]->x*a[i]->x;
    r=a[i]->y-ycalc;
    sumr2=sumr2+r*r;
  }
  sigma=sqrt(sumr2/(m-2));

  ofstream sink("parameter.Si", ios::out);
  cout << " Parameters stored in 'parameter.Si' file: "
       << m  << " data points counted!!!\n";
  sink << "p0    = " << p0    << endl
       << "p1    = " << p1    << endl
       << "p2    = " << p2    << endl
       << "sigma = " << sigma << endl;
  sink.close();

  return 0;
}


Python Code


plot.py:

import math
import matplotlib as mpl
import matplotlib.pyplot as plt

class reflect:

    def __new__(self):

        matrix = self.extract()
        self.plot(matrix)

    def extract():

        data   = open("reflect.Si",'r')
        stream = data.read()
        data.close()

        field  = 2
        entry  = ""
        val    = []
        matrix = []

        for ch in stream:
            entry = entry + ch
            if ch=='\s' or ch=='\t' or ch=='\n':
                if len(entry)>1:
                    val.append(entry[:-1])
                entry = ""
            if len(val)>=field:
                matrix.append(val)
                val = []

        return matrix[1:]

    def plot(matrix):

        mpl.rc('text', color='#C8A078')
        mpl.rc('figure', facecolor='black', edgecolor='black')
        mpl.rc('axes', edgecolor='#C6BDBA', labelcolor='#C8A078', facecolor='black', linewidth=2)
        mpl.rc('xtick', color='#C8A078')
        mpl.rc('ytick', color='#C8A078')
        plt.tick_params(bottom=False, top=False, left=False, right=False)

        plt.figure(1)
        T  = []
        R  = []
        Rc = []
        Rl = []
        Rh = []
        col   = ['#C8A078','#640064','#004040']
        p     = [0.000411231, -1.09148e-07, 4.67455e-09]
        sigma =  4.96852e-05
        print("\n\tT\tR\n")
        for i in matrix:
            t  = float(i[0])
            r  = float(i[1])
            rc = p[0] + p[1]*t + p[2]*t**2
            T.append(t)
            R.append(r)
            Rc.append(rc)
            Rl.append(rc - 2.*sigma)
            Rh.append(rc + 2.*sigma)
            print("\t%s\t%s" %(i[0], i[1]))
        print("\nmatrix size = %i" %len(matrix))
        line = plt.plot(T, Rc, color=col[0], linewidth=2)
        plt.setp(line, linestyle='dotted')
        plt.plot(T, Rl, color=col[1], linewidth=2)
        plt.plot(T, Rh, color=col[1], linewidth=2)
        plt.plot(T, R,  color=col[2], linewidth=3)
        plt.title('Fresnel Curve', fontsize=25)
        plt.xlabel('Temperature, C', fontsize=25)
        plt.ylabel('Reflectance', fontsize=25)
        plt.xticks(fontsize=20)
        plt.yticks(fontsize=20)
        plt.show()

def main():

    r = reflect()

main()


Results


$ c++ reflect.c -o reflect
$ ./reflect

Data stored in 'reflect.Si' file!!!

$ c++ bola.c -o bola
$ ./bola

Parameters stored in 'parameter.Si' file: 101 data points counted!!!

$ cat parameter.Si

p0    = 0.000411231
p1    = -1.09148e-07
p2    = 4.67455e-09
sigma = 4.96852e-05

$ python plot.py

        T       R

        0       0.000302161
        10      0.000313839
        20      0.000325896
        30      0.00033834
        40      0.000351179
        50      0.000364422
        60      0.000378077
        70      0.000392154
        80      0.00040666
        90      0.000421605
        100     0.000436998
            ...
        900     0.00409985
        910     0.00419299
        920     0.00428794
        930     0.00438477
        940     0.00448351
        950     0.0045842
        960     0.00468689
        970     0.00479164
        980     0.00489849
        990     0.00500748
        1000    0.00511869

matrix size = 101



Figure 1: Silicon Fresnel Curve


figure1


blue: pseudo–Brewster angle = 75 degrees, wavelength = 632.8 nm
gold: parabolic fit with purple boundaries at 2 standard deviations