|
SCATMECH > Example Programs
Example Programs
The following provides examples of how the SCATMECH library
can be used in a variety of types of calculations. Since
each example has its own main(), each is expected to
be linked separately.
- BRDFProg -- Polarized light
scattering model evaluator
- RCWProg -- Reflection or
transmission from a grating
- ReflectProg -- Thin film
reflectance
- MieProg -- Mie
scattering
The following example (found in brdfprog.cpp) asks the
user for an incident angle, a range of incident polar and
azimuthal angles, and a BRDF model. The program writes out
to the standard output the principal angle of the
polarization, the various degrees of polarizations, and the
intensity. This example can be used to investigate the
behavior of models presented in papers by the author.
#include "brdf.h"
using namespace std;
using namespace SCATMECH; // Use the SCATMECH library
void main(int argv,char** argc)
{
// Query user for scattering angles and ranges...
double thetai = AskUser("Incident Angle ",45.)*deg;
double thetas_1 = AskUser("Initial Scattering Angle ",45.)*deg;
double thetas_2 = AskUser("Final Scattering Angle ",45.)*deg;
double thetas_3 = AskUser("Step Scattering Angle ",1.)*deg;
double phis_1 = AskUser("Initial Azimuthal Angle ",0.)*deg;
double phis_2 = AskUser("Final Azimuthal Angle ",180.)*deg;
double phis_3 = AskUser("Step Azimuthal Angle ",2.)*deg;
// Get an instance of BRDF_Model...
BRDF_Model_Ptr model = Get_Model_Ptr();
// Query user for model parameters...
model->AskUser();
// Loop through scattering geometries...
for (double thetas=thetas_1;thetas<=thetas_2;thetas+=thetas_3) {
for (double phis=phis_1;phis<=phis_2;phis+=phis_3) {
// Get the Mueller matrix for scattering...
MuellerMatrix m=model->Mueller(thetai,thetas,phis,0.);
// Calculate the Stokes vector for p-polarized incident light...
StokesVector s=m*StokesVectorUnitP();
// Print out various light scattering parameters...
cout << thetas/deg << tab // Scattering angle (theta)
<< phis/deg << tab // Scattering angle (phi)
<< s.eta()/deg << tab // Principal angle of polarization
<< s.DOLP() << tab // Degree of linear polarization
<< s.DOCP() << tab // Degree of circular polarization
<< s.DOP() << tab // Degree of polarization
<< s.I() << endl; // The intensity (BRDF)
}
}
}
Top of Page
The following program (found in rcwprog.cpp)
demonstrates how one can use the rigorous coupled-wave
(RCW) solution for diffraction from a grating. In this
case, it calculates ellipsometric parameters for the normal
(specular) reflection or transmission from the grating as a
function of wavelength and writes the results to the
standard output.
#include "rcw.h"
using namespace std;
using namespace SCATMECH;
int main()
{
// Create object...
RCW_Model RCW;
// Query user for parameters...
RCW.AskUser();
// This keeps RCW from being verbose...
RCW.set_quiet(1);
// Output file header...
cout << "lambda" << tab << "alpha" << tab << "beta" << endl;
// Scan wavelengths...
for (double lambda = 0.200;lambda <= 0.800; lambda += 0.005) {
// Set the wavelength...
RCW.set_lambda(lambda);
// Get the Mueller matrix intensity of
//the specular (0 order) reflection...
MuellerMatrix M = RCW.GetIntensity(0);
// Get the Stokes vector for 45 deg polarized incident light...
StokesVector S = M*StokesVectorUnitLinear(45.*deg);
// Output the normalized Stokes parameters
// measured by a rotating analyzer ellipsometer...
cout << lambda << tab << S[1]/S[0] << tab << S[2]/S[0] << endl;
}
return 0;
}
Top of Page
The following program (found in reflectprog.cpp)
demonstrates how one can use the thin film classes to
characterize the reflection from a stack of dielectric
films.
#include "filmtran.h"
using namespace std;
using namespace SCATMECH;
int main(int argv,char** argc)
{
// Query user for wavelength...
double lambda = AskUser("Wavelength",0.633);
// Query user for substrate...
dielectric_function substrate =
dielectric_function::AskUser("Substrate",optical_constant(1.5,0));
// Query user for films...
dielectric_stack stack = dielectric_stack::AskUser("Stack","");
// Loop through angles...
for (double theta=0;theta<90;theta+=1) {
// Print out s- and p-polarized reflectances...
cout << theta << tab
<< norm(stack.rp12(theta*deg,lambda,vacuum,substrate)) << tab
<< norm(stack.rs12(theta*deg,lambda,vacuum,substrate)) << endl;
}
return 0;
}
Top of Page
The following program (found in mieprog.cpp) is a
simple Mie scattering program, demonstrating the use of the
MieScatterer class.
#include "miescat.h"
using namespace std; // Use unqualified names for Standard C++ library
using namespace SCATMECH; // Use unqualified names for the SCATMECH library
int main(int argv,char** argc)
{
// Query user for angle and wavelength...
double dtheta = AskUser("Step angle",1.)*deg;
// Create a Mie scatterer...
MieScatterer mie;
// Query user for parameters...
mie.AskUser();
// Output scattering efficiencies...
cout << "Qsca = " << mie.Qsca(lambda)
<< " Qext = " << mie.Qext(lambda)
<< " Qback = " << mie.Qback(lambda) << endl;
// Output column header...
cout << endl
<< "Angle" << tab
<< "S11" << tab
<< "Pol" << tab
<< "S33" << tab
<< "S34" << endl;
// Get normalization factor at zero angle...
double m00= MuellerMatrix(mie.s(0.0))[0][0];
// Loop through angles...
for (double theta=0.;theta<=180.*deg;theta+=dtheta) {
// Evaluate scattering matrix...
MuellerMatrix m = mie.s(theta);
// Output unique elements of normalized Mueller matrix...
cout << theta/deg << tab
<< m[0][0]/m00 << tab
<< m[0][1]/m[0][0] << tab
<< m[2][2]/m[0][0] << tab
<< m[2][3]/m[0][0] << endl;
}
return 0;
}
Top of Page
For More Information
SCATMECH Technical Information and Questions
Optical Technology Division (OTD) Home Page
OTD Technical Inquiries
OTD Website Comments
Current SCATMECH version: 6.00 (February 2008)
This page first online: Version 3.00 (December 2001)
This page last modified: Version 6.00 (February 2008)
|