Skip to content

Commit

Permalink
fix computation of delta_n_abs
Browse files Browse the repository at this point in the history
  • Loading branch information
heterophyllus committed Aug 28, 2022
1 parent 5902277 commit abb6f61
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 20 deletions.
Binary file modified data/Schott.xlsx
Binary file not shown.
6 changes: 3 additions & 3 deletions src/air.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ double Air::refractive_index_abs(double lambdamicron, double T, double P)
{
constexpr double P0 = 101325.0;
constexpr double Tref = 15;
double nref = refractive_index_ref(lambdamicron);
double nref = refractive_index_15degC_1atm(lambdamicron);
double num = nref - 1.0;
double denom = 1.0 + (T-Tref)*(3.4785*pow(10,-3));

return ( 1.0 + (num/denom)*(P/P0) );
}

double Air::refractive_index_ref(double lambdamicron)
double Air::refractive_index_15degC_1atm(double lambdamicron)
{
double term1 = 6432.8;
constexpr double term1 = 6432.8;
double term2 = 2949810.0*pow(lambdamicron, 2)/( 146.0*pow(lambdamicron,2) - 1.0 );
double term3 = 25540.0*pow(lambdamicron,2)/( 41.0*pow(lambdamicron,2) - 1.0 );
double nref = 1.0 + (term1 + term2 + term3)*pow(10, -8);
Expand Down
2 changes: 1 addition & 1 deletion src/air.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Air
static double refractive_index_abs(double lambdamicron, double T, double P= 101325.0);

/** Computes refractive index at the reference temperature */
static double refractive_index_ref(double lambdamicron);
static double refractive_index_15degC_1atm(double lambdamicron);
};

#endif // AIR_H
37 changes: 24 additions & 13 deletions src/glass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ double Glass::Pxy_(const QString& x, const QString& y) const

double Glass::refractiveIndex(double lambdamicron) const
{
return refractiveIndex_rel(lambdamicron);
return refractiveIndex_rel(lambdamicron, T_);
}

double Glass::refractiveIndex(const QString& spectral) const
Expand All @@ -145,7 +145,7 @@ double Glass::refractiveIndex(const QString& spectral) const

QVector<double> Glass::refractiveIndex(const QVector<double> &vLambdamicron) const
{
return refractiveIndex_rel(vLambdamicron);
return refractiveIndex_rel(vLambdamicron, T_);
}

double Glass::refractiveIndex_rel_Tref(double lambdamicron) const
Expand All @@ -167,12 +167,11 @@ double Glass::refractiveIndex_abs_Tref(double lambdamicron) const
return n_abs_T0;
}

double Glass::refractiveIndex_abs(double lambdamicron) const
double Glass::refractiveIndex_abs(double lambdamicron, double T) const
{
double dn = 0.0;
if(hasThermalData_){
double dn_dt = dn_dt_abs(T_, lambdamicron);
dn = (T_-Tref_)*dn_dt;
dn = delta_n_abs(T, lambdamicron);
}

double n_abs_T0 = refractiveIndex_abs_Tref(lambdamicron);
Expand All @@ -181,10 +180,10 @@ double Glass::refractiveIndex_abs(double lambdamicron) const
return n_abs;
}

double Glass::refractiveIndex_rel(double lambdamicron) const
double Glass::refractiveIndex_rel(double lambdamicron, double T) const
{
double n_abs = refractiveIndex_abs(lambdamicron);
double n_air = Air::refractive_index_abs(lambdamicron, T_);
double n_abs = refractiveIndex_abs(lambdamicron, T);
double n_air = Air::refractive_index_abs(lambdamicron, T);
double n_rel = n_abs/n_air;

return n_rel;
Expand All @@ -204,13 +203,13 @@ QVector<double> Glass::refractiveIndex_rel_Tref(const QVector<double>& vLambdami
}


QVector<double> Glass::refractiveIndex_rel(const QVector<double> &vLambdamicron) const
QVector<double> Glass::refractiveIndex_rel(const QVector<double> &vLambdamicron, double T) const
{
const int dataCount = vLambdamicron.size();
QVector<double> n_rel_v(dataCount);

for(int i = 0; i < dataCount; i++){
n_rel_v[i] = refractiveIndex_rel(vLambdamicron[i]);
n_rel_v[i] = refractiveIndex_rel(vLambdamicron[i], T);
}

return n_rel_v;
Expand Down Expand Up @@ -452,11 +451,9 @@ void Glass::appendTransmittanceData(double lambdamicron, double trans, double th
double Glass::dn_dt_abs(double T, double lambdamicron) const
{
double dT = T - Tref_;
double Stk = (Ltk() > 0.0) - (Ltk() < 0.0);
double n = refractiveIndex_abs_Tref(lambdamicron);

//return (n*n-1)/(2*n) * ( D0() + 2*D1()*dT + 3*D2()*dT*dT + (E0() + 2*E1()*dT)/(lambdamicron*lambdamicron - Ltk()*Ltk()) );
return (n*n-1)/(2*n) * ( D0() + 2*D1()*dT + 3*D2()*dT*dT + (E0() + 2*E1()*dT)/(lambdamicron*lambdamicron - Stk*Ltk()*Ltk()) );
return (n*n-1)/(2*n) * ( D0() + 2*D1()*dT + 3*D2()*dT*dT + (E0() + 2*E1()*dT)/(lambdamicron*lambdamicron - Ltk()*Ltk()) );
}

QVector<double> Glass::dn_dt_abs(const QVector<double>& vT, double lambdamicron) const
Expand All @@ -471,6 +468,20 @@ QVector<double> Glass::dn_dt_abs(const QVector<double>& vT, double lambdamicron)
return vDndt;
}


double Glass::delta_n_abs(double T, double lambdamicron) const
{
double dT = T - Tref_;
double Stk = (Ltk() > 0.0) - (Ltk() < 0.0);
double n = refractiveIndex_rel_Tref(lambdamicron);

// Schott technical document
return (n*n-1)/(2*n) * ( D0()*dT+ D1()*dT*dT + D2()*dT*dT*dT + (E0()*dT + E1()*dT*dT)/(lambdamicron*lambdamicron - Ltk()*Ltk()) );

// Zemax manual
//return (n*n-1)/(2*n) * ( D0()*dT+ D1()*dT*dT + D2()*dT*dT*dT + (E0()*dT + E1()*dT*dT)/(lambdamicron*lambdamicron - Stk*Ltk()*Ltk()) );
}

void Glass::setThermalData(int n, double val)
{
Q_ASSERT( thermal_data_size_ == thermal_data_.size() );
Expand Down
8 changes: 5 additions & 3 deletions src/glass.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ class Glass
double dn_dt_abs(double T, double lambdamicron) const;
QVector<double> dn_dt_abs(const QVector<double>& vT, double lambdamicron) const;

double delta_n_abs(double T, double lambdamicron) const;

inline void setHasThermalData(bool state);
void setThermalData(int n, double val);

Expand Down Expand Up @@ -135,10 +137,10 @@ class Glass
private:
double refractiveIndex_abs_Tref(double lambdamicron) const;
double refractiveIndex_rel_Tref(double lambdamicron) const;
double refractiveIndex_abs(double lambdamicron) const;
double refractiveIndex_rel(double lambdamicron) const;
double refractiveIndex_abs(double lambdamicron, double T) const;
double refractiveIndex_rel(double lambdamicron, double T) const;
QVector<double> refractiveIndex_rel_Tref(const QVector<double>& vLambdamicron) const;
QVector<double> refractiveIndex_rel(const QVector<double>& vLambdamicron) const;
QVector<double> refractiveIndex_rel(const QVector<double>& vLambdamicron, double T) const;

/** current temperature */
static double T_;
Expand Down

0 comments on commit abb6f61

Please sign in to comment.