Skip to content

Commit

Permalink
Revise MuellerMatrix::valid() after finding error
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-germer committed Mar 23, 2020
1 parent 3f897e8 commit 82c2795
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 20 deletions.
5 changes: 4 additions & 1 deletion code/allrough.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ namespace SCATMECH {
vector<double> a(N);
vector<double> PSDint(N);
for (int i=0; i<N; ++i) {
double argument = fourpisqr*nu*qpow*stack->get_t()[i];
// The following was changed 2/27/2019...
// double argument = fourpisqr*nu*qpow*stack->get_t()[i];
double argument = nu*qpow*stack->get_t()[i];

// The replication factor between the layers...
a[i] = exp(-argument);
// The intrinsic roughness of the layer...
Expand Down
2 changes: 1 addition & 1 deletion code/axifree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ namespace SCATMECH {
JonesMatrix rotatein = GetJonesRotator(bi,ai,si,pi).transpose();
JonesMatrix rotateout = GetJonesRotator(br,ar,sr,pr);

return rotateout*scatter*rotatein;
return rotateout*scatter*rotatein;
}

//
Expand Down
9 changes: 3 additions & 6 deletions code/filmtran.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,14 +611,11 @@ namespace SCATMECH {
ModelParameterSet(dielectric_stack& variable,const string& parameter,const string& value)
{
if (parameter.empty()) {
if (value.empty()) {
variable.wash();
return;
}
istringstream iss(value);
variable.wash();
istringstream iss(value);
string material;
iss >> material;
if (iss.fail()) throw SCATMECH_exception("Invalid parameter for dielectric_stack");
if (iss.fail()) return;
double thickness;
iss >> thickness;
if (iss.fail()) {
Expand Down
11 changes: 6 additions & 5 deletions code/inherit.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace SCATMECH {
template <class _Model> _Model* _Get_Model();

typedef std::deque<const Inheritance*> InheritanceList;
typedef std::auto_ptr<ModelParameterBase> ModelParameterBasePtr;
typedef std::unique_ptr<ModelParameterBase> ModelParameterBasePtr;
typedef std::deque<const ModelParameterBase*> ModelParameterList;
typedef std::deque<STRING> StringList;

Expand Down Expand Up @@ -423,6 +423,7 @@ namespace SCATMECH {
}
}


private:
friend class ModelParameterBase;

Expand Down Expand Up @@ -470,7 +471,7 @@ namespace SCATMECH {

/// The following contains a pointers to the class that contain the
/// maker and the registrars for this Model class...
std::auto_ptr<Model_Maker_Base> maker;
std::unique_ptr<Model_Maker_Base> maker;

//
// Functions that returns a list of inherited classes and their
Expand All @@ -482,14 +483,14 @@ namespace SCATMECH {
void get_model_inheritance_list(InheritanceList& result,int option=1) const;
Model* get_model(bool top) const;
Model* get_named_model(const STRING& name,bool nothrow) const;
void get_parameters(ModelParameterList& result,bool top) const;
friend void display_descriptions(const Inheritance* inherit,
void get_parameters(ModelParameterList& result, bool top) const;
friend void display_descriptions(const Inheritance* inherit,
const InheritanceList& ilist);
};

/// @brief Smart pointer to a Model
///
/// The template class Model_Ptr<_Model> works similarly to std::auto_ptr<T>,
/// The template class Model_Ptr<_Model> works similarly to std::unique_ptr<T>,
/// except that it makes cloned copies rather than transferring ownership of
/// a pointer. It also adds some functions which make use of the SCATMECH
/// Inheritance and Model classes.
Expand Down
14 changes: 12 additions & 2 deletions code/mueller.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//********ei**********************************************************************
//******************************************************************************
//** SCATMECH: Polarized Light Scattering C++ Class Library
//**
//** File: mueller.cpp
Expand Down Expand Up @@ -492,7 +492,17 @@ namespace SCATMECH {
imax = i;
}
}
if (sqr(real(W(imax,1)))<sqr(real(W(imax,2)))+sqr(real(W(imax,3)))+sqr(real(W(imax,4)))) return false;
// Check that the vector with the largest eigenvalue is a valid Stokes vector.
// After normalizing to the 1st element, the others must be real and the
// sum-of-squares must be less than 1.
COMPLEX W1 = W(1, imax);
COMPLEX W2 = W(2, imax) / W1;
COMPLEX W3 = W(3, imax) / W1;
COMPLEX W4 = W(4, imax) / W1;
if (fabs(imag(W2)) > small) return false;
if (fabs(imag(W3)) > small) return false;
if (fabs(imag(W4)) > small) return false;
if (1. < sqr(real(W2)) + sqr(real(W3)) + sqr(real(W4))) return false;
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions code/mueller.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ namespace SCATMECH {
j[0]=pp;
j[1]=ss;
j[2]=ps,
j[3]=sp;
j[3]=sp;
}

///
Expand Down Expand Up @@ -1101,7 +1101,7 @@ namespace SCATMECH {
//
MuellerMatrix MuellerDiagonal(double m00,double m11, double m22, double m33);
///
/// Returns a partiall linear polarizer
/// Returns a partial linear polarizer
///
MuellerMatrix MuellerPartialLinearPolarizer(
double tmax, ///< The maximum transmittance
Expand Down
4 changes: 1 addition & 3 deletions code/rough.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,7 @@ namespace SCATMECH {

DEFINE_MODEL(ABC_PSD_Function,PSD_Function,
"PSD = A/pow(1+sqr(B*f),C/2)");
DEFINE_PARAMETER(ABC_PSD_Function,double,A,"Program assumes power spectrum S2(f) = "
"A/(1+(B*f)^2)^(C/2)\n"
"Power Spectrum A Parameter [um^4]","0.01",0xFF);
DEFINE_PARAMETER(ABC_PSD_Function,double,A,"Power Spectrum A Parameter [um^4]","0.01",0xFF);
DEFINE_PARAMETER(ABC_PSD_Function,double,B,"Power Spectrum B Parameter [um]","362",0xFF);
DEFINE_PARAMETER(ABC_PSD_Function,double,C,"Power Spectrum C Parameter","2.5",0xFF);

Expand Down

0 comments on commit 82c2795

Please sign in to comment.