|
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
Notice that all four examples contain a try/catch block, so that any errors
are handled and messages written to the standard error stream (cerr).
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
to the standard output the principal angle of the
polarization, the various degrees of polarizations, and the
intensity.
#include "brdf.h"
using namespace std; // Use unqualified names for Standard C++ library
using namespace SCATMECH; // Use unqualified names for SCATMECH library
int main(int argv,char** argc)
{
try {
// 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)
}
}
} catch (exception& e) {
cerr << e.what() << endl;
}
return 0;
}
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()
{
try {
// Create object...
RCW_Model RCW;
// Query user for parameters...
RCW.AskUser();
// This keeps RCW from being verbose...
RCW.set_quiet(1);
// Display all of the available parameters...
cerr << endl << "Available parameters:" << endl << endl;
RCW.print_parameters(cerr);
cerr << endl;
// Get parameter to vary, its limits, and its range...
string parameter=AskUser("Parameter to vary",string("lambda"));
double begin=AskUser("Initial value",0.200);
double end=AskUser("Final value",0.800);
double step=AskUser("Step value",0.005);
// Output file header...
cout << parameter << tab << "alpha" << tab << "beta" << endl;
// Scan parameter...
for (double value = begin; value <= end; value += step) {
// Set the parameter...
RCW.set_parameter(parameter,value);
// 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 << value << tab << S[1]/S[0] << tab << S[2]/S[0] << endl;
}
} catch (exception& e) {
cerr << e.what() << 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; // Use unqualified names for Standard C++ library
using namespace SCATMECH;
int main()
{
try {
// 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;
}
} catch (exception& e) {
cerr << e.what() << 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)
{
try {
// 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()
<< " Qext = " << mie.Qext()
<< " Qback = " << mie.Qback() << 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;
}
} catch (exception& e) {
cerr << e.what() << endl;
}
return 0;
}
Top of Page
For More Information
SCATMECH Technical Information and Questions
Sensor Science Division Home Page
Sensor Science Division Inquiries
Website Comments
Current SCATMECH version: 7.22 (April 2021)
|