Skip to content

Commit

Permalink
support environment temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
heterophyllus committed Oct 7, 2021
1 parent 41efaf7 commit 55bb38c
Show file tree
Hide file tree
Showing 22 changed files with 761 additions and 399 deletions.
1 change: 1 addition & 0 deletions GlassPlotter.pro
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ RESOURCES += \
resource.qrc



10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,18 @@ Note that the catalog files in this repository are not always up to date.
2. CODE V XML
Available on [Synopsys support page](https://www.synopsys.com/optical-solutions/support/support-glass-catalog.html).

## Notes
This application computes refractive index relative to air(relative refractive index). This is because the values in the catalog are relative index values. And the refractive index of optical glasses changes with temperature, the extend of which depending on the glass type and on the wavelength. Read [Schott Technical Information (TIE-19)](https://www.schott.com/products/optical-glass/downloads) for calculation details.


When you find a slight difference between official data and that of this application,
check the environment temperature setting (File->Preference). With the temperature value set to the same as that of the glass manufacturer, the calculated refractive index should be the same value.


## Dependency

All of the followings except Qt itself have been already included in this repository.

|Library|Description|
|---|---|
|[Qt](https://www.qt.io)|GUI library|
Expand All @@ -40,7 +49,6 @@ Note that the catalog files in this repository are not always up to date.
|[pugixml](https://github.com/zeux/pugixml)|Simple XML parser|


All of the aboves except Qt itself have been already included in this repository.

## License
This project is licensed under GPL License - see the [LICENSE](LICENSE.md) for details.
Expand Down
2 changes: 2 additions & 0 deletions sourcefiles.pri
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#############################################################################

SOURCES += \
src/air.cpp \
src/preference_dialog.cpp \
src/catalog_view_form.cpp \
src/catalog_view_setting_dialog.cpp \
Expand All @@ -28,6 +29,7 @@ SOURCES += \


HEADERS += \
src/air.h \
src/preference_dialog.h \
src/catalog_view_form.h \
src/catalog_view_setting_dialog.h \
Expand Down
35 changes: 35 additions & 0 deletions src/air.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "air.h"

#include "math.h"

Air::Air()
{

}

Air::~Air()
{

}

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 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 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);

return nref;
}

18 changes: 18 additions & 0 deletions src/air.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef AIR_H
#define AIR_H


class Air
{
public:
Air();
~Air();

static double refractive_index_abs(double lambdamicron, double T, double P= 101325.0);

private:
static double refractive_index_ref(double lambdamicron);

};

#endif // AIR_H
16 changes: 8 additions & 8 deletions src/catalog_view_form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void CatalogViewForm::setUpTable(QStringList properties, GlassCatalog* catalog,
glass = catalog->glass(i);

// glass name should be at the first column.
addTableItem(i,0,glass->name());
addTableItem(i,0,glass->productName());

// properties
col = 1;
Expand All @@ -220,22 +220,22 @@ void CatalogViewForm::setUpTable(QStringList properties, GlassCatalog* catalog,
addTableItem(row,col,glass->MIL());
}
else if("nd" == properties[j]){
addTableItem(row,col,numToQString(glass->nd(), 'f', digit));
addTableItem(row,col,numToQString(glass->getValue("nd"), 'f', digit));
}
else if("ne" == properties[j]){
addTableItem(row,col,numToQString(glass->ne(), 'f', digit));
addTableItem(row,col,numToQString(glass->getValue("ne"), 'f', digit));
}
else if("vd" == properties[j]){
addTableItem(row,col,numToQString(glass->vd(), 'f', digit));
addTableItem(row,col,numToQString(glass->getValue("vd"), 'f', digit));
}
else if("ve" == properties[j]){
addTableItem(row,col,numToQString(glass->ve(), 'f', digit));
addTableItem(row,col,numToQString(glass->getValue("ve"), 'f', digit));
}
else if("PgF" == properties[j]){
addTableItem(row,col,numToQString(glass->PgF(), 'f', digit));
addTableItem(row,col,numToQString(glass->getValue("PgF"), 'f', digit));
}
else if("PCt_" == properties[j]){
addTableItem(row,col,numToQString(glass->PCt_(), 'f', digit));
addTableItem(row,col,numToQString(glass->getValue("PCt_"), 'f', digit));
}
else if("Dispersion Formula" == properties[j]){
addTableItem(row,col,glass->formulaName());
Expand All @@ -253,7 +253,7 @@ void CatalogViewForm::setUpTable(QStringList properties, GlassCatalog* catalog,
addTableItem(row, ++col, numToQString(glass->E0(),'g',digit));
addTableItem(row, ++col, numToQString(glass->E1(),'g',digit));
addTableItem(row, ++col, numToQString(glass->Ltk(),'g',digit));
addTableItem(row, ++col, numToQString(glass->T0(),'f',digit));
addTableItem(row, ++col, numToQString(glass->Tref(),'f',digit));
}
else if("Low TCE" == properties[j]){
addTableItem(row, col, numToQString(glass->lowTCE(), 'f', digit));
Expand Down
2 changes: 1 addition & 1 deletion src/curve_fitting_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void CurveFittingDialog::addGlassForNewRow()
else{
QString s1 = QString::number(glass->getValue(m_xDataName));
QString s2 = QString::number(glass->getValue(m_yDataName));
QString s3 = glass->name() + "_" + glass->supplyer();
QString s3 = glass->fullName();
addNewRow(s1, s2, s3);
}
glass = nullptr;
Expand Down
6 changes: 3 additions & 3 deletions src/dispersion_formula.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ class DispersionFormula
return ( c[0] + c[1]/lambdamicron + c[2]/pow(lambdamicron,3.5) );
}

static double Nikon_Hikari(double lambdamicron, const QVector<double>& c){
// https://www.hikari-g.co.jp/products/nature/properties_optical_glass/
return sqrt( c[0] + c[1]*pow(lambdamicron,2) + c[2]*pow(lambdamicron,4) + c[3]*pow(lambdamicron,-2) + c[4]*pow(lambdamicron,-6) + c[5]*pow(lambdamicron,-8) + c[6]*pow(lambdamicron,-8) + c[7]*pow(lambdamicron,-10) + c[8]*pow(lambdamicron, -12) );
static double Nikon_Hikari(double lambdamicron, const QVector<double>& c){
// https://www.hikari-g.co.jp/products/nature/properties_optical_glass/
return sqrt( c[0] + c[1]*pow(lambdamicron,2) + c[2]*pow(lambdamicron,4) + c[3]*pow(lambdamicron,-2) + c[4]*pow(lambdamicron,-4) + c[5]*pow(lambdamicron,-6) + c[6]*pow(lambdamicron,-8) + c[7]*pow(lambdamicron,-10) + c[8]*pow(lambdamicron, -12) );
}

static double Laurent(double lambdamicron, const QVector<double>& c){
Expand Down
12 changes: 6 additions & 6 deletions src/dispersion_plot_form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ QVector<double> DispersionPlotForm::computeUserDefinedCurve(const QVector<double
dummyGlass.setDispCoef(i,m_tableCoefs->item(i,0)->text().toDouble());
}

ydata = dummyGlass.index(xdata);
ydata = dummyGlass.refractiveIndex_rel(xdata);
}
else // formula in CODEV format
{
Expand All @@ -290,7 +290,7 @@ QVector<double> DispersionPlotForm::computeUserDefinedCurve(const QVector<double
dummyGlass.setDispCoef(i,m_tableCoefs->item(i,0)->text().toDouble());
}

ydata = dummyGlass.index(xdata);
ydata = dummyGlass.refractiveIndex_rel(xdata);
}

return ydata;
Expand Down Expand Up @@ -364,15 +364,15 @@ void DispersionPlotForm::updateAll()
currentGlass = m_glassList[i];

// graphs
ydata = currentGlass->index(vLambdamicron);
ydata = currentGlass->refractiveIndex_rel(vLambdamicron);
graph = m_customPlot->addGraph();
graph->setName(currentGlass->name() + "_" + currentGlass->supplyer());
graph->setName(currentGlass->fullName());
graph->setData(vLambdamicron, ydata);
graph->setPen( QPen(getColorFromIndex(i, m_maxGraphCount)) );
graph->setVisible(true);

// table
header << currentGlass->name();
header << currentGlass->productName();
for(j = 0; j< rowCount; j++)
{
addTableItem(j, 0, QString::number(vLambdamicron[j], 'f', digit) ); // wavelength
Expand Down Expand Up @@ -414,7 +414,7 @@ void DispersionPlotForm::deleteGraph()

for(int i = 0;i < glassCount; i++)
{
if(m_glassList[i]->name() == glass_supplyer[0] && m_glassList[i]->supplyer() == glass_supplyer[1]){
if(m_glassList[i]->productName() == glass_supplyer[0] && m_glassList[i]->supplyer() == glass_supplyer[1]){
m_glassList.removeAt(i);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/dndt_plot_form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void DnDtPlotForm::setGlass()

clearAll();
m_currentGlass = newGlass;
ui->label_GlassName->setText( m_currentGlass->name() + "_" + m_currentGlass->supplyer() );
ui->label_GlassName->setText( m_currentGlass->fullName() );

// plot for default wavelength
m_wvlList = QList<double>({435.8, 546.1, 587.0, 852.1, 1060.0});
Expand Down
Loading

0 comments on commit 55bb38c

Please sign in to comment.