Skip to content

Commit b71fcde

Browse files
committed
Fixed multiple warning issues
1 parent 7c3882f commit b71fcde

9 files changed

Lines changed: 308 additions & 327 deletions

‎src/app/calc/miesimulation.cpp‎

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -11,90 +11,90 @@
1111

1212
namespace
1313
{
14-
//Shared implementation of the Mie coefficient (an, bn) and qSca/qExt/qBack
15-
//computation.
16-
template <typename RefIndexType>
17-
void ComputeCoefficientsImpl(MieCoefficients &coeff, double xPara, RefIndexType relRef)
14+
//Shared implementation of the Mie coefficient (an, bn) and qSca/qExt/qBack
15+
//computation.
16+
template <typename RefIndexType>
17+
void ComputeCoefficientsImpl(MieCoefficients &coeff, double xPara, RefIndexType relRef)
18+
{
19+
Utilities util;
20+
21+
//use conventional symbols
22+
double x = xPara;
23+
RefIndexType m = relRef;
24+
RefIndexType mx = m * x;
25+
double xStop = x + 4.05 * (pow(x,(1.0 / 3.0))) + 2.0;
26+
27+
unsigned int nStop = static_cast<unsigned int>(ceil(xStop));
28+
unsigned int yMod = static_cast<unsigned int>(ceil(std::abs(mx)));
29+
unsigned int nMx = static_cast<unsigned int>(MAX(xStop, yMod) + 15);
30+
unsigned int arraySize = nStop + 1;
31+
double x2 = x * x;
32+
33+
std::vector<RefIndexType> dnMx(nMx);
34+
dnMx[nMx-1] = 0;
35+
36+
for (unsigned int n = nMx - 1; n>0; n--)
1837
{
19-
Utilities util;
20-
21-
//use conventional symbols
22-
double x = xPara;
23-
RefIndexType m = relRef;
24-
RefIndexType mx = m * x;
25-
double xStop = x + 4.05 * (pow(x,(1.0 / 3.0))) + 2.0;
26-
27-
unsigned int nStop = static_cast<unsigned int>(ceil(xStop));
28-
unsigned int yMod = static_cast<unsigned int>(ceil(std::abs(mx)));
29-
unsigned int nMx = static_cast<unsigned int>(MAX(xStop, yMod) + 15);
30-
unsigned int arraySize = nStop + 1;
31-
double x2 = x * x;
32-
33-
std::vector<RefIndexType> dnMx(nMx);
34-
dnMx[nMx-1] = 0;
35-
36-
for (unsigned int n = nMx - 1; n>0; n--)
37-
{
38-
dnMx[n-1] = (double(n)/mx)-(1.0/(dnMx[n]+double(n)/mx));
39-
}
40-
41-
// at the sphere boundary
42-
double jX0 = cos(x); // phi(-1)
43-
double yX0 = -sin(x); // kai(-1)
44-
double jX1 = sin(x); // phi(0)
45-
double yX1 = cos(x); // kai(0)
46-
47-
std::vector<double> jX(arraySize);
48-
std::vector<double> yX(arraySize);
49-
std::vector<std::complex<double>> xi_x(arraySize);
50-
jX[0] = jX1;
51-
yX[0] = yX1;
52-
xi_x[0]=std::complex<double> (jX1,-yX1); // xi(1)
53-
54-
//Initialize temp holders
55-
std::complex<double> tempQback = 0.0;
56-
double tempQsca = 0.0;
57-
double tempQext = 0.0;
58-
double sign = -1.0; // tracks (-1)^(n-1), toggled each iteration instead of calling pow()
59-
60-
coeff.an.assign(arraySize, std::complex<double>(0.0, 0.0));
61-
coeff.bn.assign(arraySize, std::complex<double>(0.0, 0.0));
62-
63-
for (unsigned int n = 1; n <= nStop; n++)
64-
{
65-
double fac2 = 2.0 * double(n) + 1.0; // 2n+1
66-
double fac3 = fac2 - 2.0; // 2n-1
67-
68-
//Update riccati Bessel functions for x (Array indices = n+1)
69-
jX[n] = fac3 * jX1 / x - jX0; // phi recurrence
70-
yX[n] = fac3 * yX1 / x - yX0; // kai recurrence
71-
xi_x[n] = std::complex<double> (jX[n], -yX[n]);
72-
73-
jX0 = jX1;
74-
jX1 = jX[n];
75-
yX0 = yX1;
76-
yX1 = yX[n];
77-
78-
// Calculate an and bn (According to Bohren and Huffman book)
79-
// Remark: GouGouesbet uses size parameter as "ka" instead of "kx"
80-
RefIndexType dervDn1 = (dnMx[n]/m) + (double(n) / x);
81-
RefIndexType dervDn2 = (m*dnMx[n]) + (double(n) / x);
82-
83-
std::complex<double> an = (dervDn1*jX[n] - jX[n-1])/ (dervDn1*xi_x[n] - xi_x[n-1]);
84-
std::complex<double> bn = (dervDn2*jX[n] - jX[n-1])/ (dervDn2*xi_x[n] - xi_x[n-1]);
85-
coeff.an[n-1] = an;
86-
coeff.bn[n-1] = bn;
87-
88-
sign = -sign; // (-1)^(n-1)
89-
tempQback += fac2 * sign * (an-bn);
90-
tempQsca += fac2 * (util.ComplexAbs(an) * util.ComplexAbs(an) + util.ComplexAbs(bn) * util.ComplexAbs(bn));
91-
tempQext += fac2 * (an + bn).real();
92-
}
93-
coeff.nStop = nStop;
94-
coeff.qBack = util.ComplexAbsSquared(tempQback)/x2; //back scattering efficiency
95-
coeff.qSca = 2.0 * tempQsca / x2; //scattering efficiency
96-
coeff.qExt = 2.0 * tempQext / x2; //extinction efficiency
38+
dnMx[n-1] = (double(n)/mx)-(1.0/(dnMx[n]+double(n)/mx));
9739
}
40+
41+
// at the sphere boundary
42+
double jX0 = cos(x); // phi(-1)
43+
double yX0 = -sin(x); // kai(-1)
44+
double jX1 = sin(x); // phi(0)
45+
double yX1 = cos(x); // kai(0)
46+
47+
std::vector<double> jX(arraySize);
48+
std::vector<double> yX(arraySize);
49+
std::vector<std::complex<double>> xi_x(arraySize);
50+
jX[0] = jX1;
51+
yX[0] = yX1;
52+
xi_x[0]=std::complex<double> (jX1,-yX1); // xi(1)
53+
54+
//Initialize temp holders
55+
std::complex<double> tempQback = 0.0;
56+
double tempQsca = 0.0;
57+
double tempQext = 0.0;
58+
double sign = -1.0; // tracks (-1)^(n-1), toggled each iteration instead of calling pow()
59+
60+
coeff.an.assign(arraySize, std::complex<double>(0.0, 0.0));
61+
coeff.bn.assign(arraySize, std::complex<double>(0.0, 0.0));
62+
63+
for (unsigned int n = 1; n <= nStop; n++)
64+
{
65+
double fac2 = 2.0 * double(n) + 1.0; // 2n+1
66+
double fac3 = fac2 - 2.0; // 2n-1
67+
68+
//Update riccati Bessel functions for x (Array indices = n+1)
69+
jX[n] = fac3 * jX1 / x - jX0; // phi recurrence
70+
yX[n] = fac3 * yX1 / x - yX0; // kai recurrence
71+
xi_x[n] = std::complex<double> (jX[n], -yX[n]);
72+
73+
jX0 = jX1;
74+
jX1 = jX[n];
75+
yX0 = yX1;
76+
yX1 = yX[n];
77+
78+
// Calculate an and bn (According to Bohren and Huffman book)
79+
// Remark: GouGouesbet uses size parameter as "ka" instead of "kx"
80+
RefIndexType dervDn1 = (dnMx[n]/m) + (double(n) / x);
81+
RefIndexType dervDn2 = (m*dnMx[n]) + (double(n) / x);
82+
83+
std::complex<double> an = (dervDn1*jX[n] - jX[n-1])/ (dervDn1*xi_x[n] - xi_x[n-1]);
84+
std::complex<double> bn = (dervDn2*jX[n] - jX[n-1])/ (dervDn2*xi_x[n] - xi_x[n-1]);
85+
coeff.an[n-1] = an;
86+
coeff.bn[n-1] = bn;
87+
88+
sign = -sign; // (-1)^(n-1)
89+
tempQback += fac2 * sign * (an-bn);
90+
tempQsca += fac2 * (util.ComplexAbs(an) * util.ComplexAbs(an) + util.ComplexAbs(bn) * util.ComplexAbs(bn));
91+
tempQext += fac2 * (an + bn).real();
92+
}
93+
coeff.nStop = nStop;
94+
coeff.qBack = util.ComplexAbsSquared(tempQback)/x2; //back scattering efficiency
95+
coeff.qSca = 2.0 * tempQsca / x2; //scattering efficiency
96+
coeff.qExt = 2.0 * tempQext / x2; //extinction efficiency
97+
}
9898
}
9999

100100
//Computes the Mie coefficients (an, bn) for a real relative refractive index.

‎src/app/dialog/displaydialog.cpp‎

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,17 @@
77
#include "ui_displaydialog.h"
88

99
DisplayDialog::DisplayDialog(QWidget *parent) :
10-
QDialog(parent),
11-
ui(new Ui::DisplayDialog)
10+
QDialog(parent),
11+
ui(std::make_unique<Ui::DisplayDialog>())
1212
{
13-
ui->setupUi(this);
13+
ui->setupUi(this);
1414
}
1515

16-
DisplayDialog::~DisplayDialog()
17-
{
18-
delete ui;
19-
}
16+
DisplayDialog::~DisplayDialog() = default;
2017

2118
void DisplayDialog::on_pushButton_Close_clicked()
2219
{
23-
this->close();
20+
this->close();
2421
}
2522

2623
void DisplayDialog::DisplayData(QRadioButton *radioButton_MonoDisperse,
@@ -37,84 +34,84 @@ void DisplayDialog::DisplayData(QRadioButton *radioButton_MonoDisperse,
3734
{
3835
double margin = (1.0 + slider_ConcPercentChange->value() / 200.0);
3936

40-
//Simulation parameters
37+
//Simulation parameters
4138
ui->textBrowser_Display->setText("Simulation parameters:\n");
4239

4340
if (radioButton_MonoDisperse->isChecked())
44-
{
41+
{
4542
ui->textBrowser_Display->append("Distribution: Mono Disperse");
46-
ui->textBrowser_Display->append("Diameter of spheres: " + QString::number(2.0*para->meanRadius) + " um");
43+
ui->textBrowser_Display->append("Diameter of spheres: " + QString::number(2.0*para->meanRadius) + " um");
4744

4845
if (radioButton_NumDen->isChecked())
4946
{
50-
ui->textBrowser_Display->append("Concentration (Spheres in a volume of 1mm^3): "
51-
+ QString::number(para->sphNumDensity * margin));
47+
ui->textBrowser_Display->append("Concentration (Spheres in a volume of 1mm^3): "
48+
+ QString::number(para->sphNumDensity * margin));
5249
}
5350

5451
if (radioButton_VolFrac->isChecked())
5552
{
56-
ui->textBrowser_Display->append("Volume Fraction (Total sphere volume / 1mm^3): "
57-
+ QString::number(para->volFraction * margin));
53+
ui->textBrowser_Display->append("Volume Fraction (Total sphere volume / 1mm^3): "
54+
+ QString::number(para->volFraction * margin));
5855
}
59-
}
56+
}
6057

6158
if (radioButton_PolyDisperse->isChecked())
62-
{
59+
{
6360
int currentIndex = comboBox_Distribution->currentIndex();
6461
if (currentIndex == para->LogNormal) //Log normal distribution
6562
{
66-
ui->textBrowser_Display->append("Distribution: Poly Disperse - Log Normal");
63+
ui->textBrowser_Display->append("Distribution: Poly Disperse - Log Normal");
6764
}
6865

6966
if (currentIndex == para->Gaussian) //Gaussian distribution
7067
{
71-
ui->textBrowser_Display->append("Distribution: Poly Disperse - Gaussian");
68+
ui->textBrowser_Display->append("Distribution: Poly Disperse - Gaussian");
7269
}
7370

7471
if (currentIndex == para->Custom) //Custom distribution
7572
{
76-
ui->textBrowser_Display->append("Distribution: Poly Disperse - Custom");
73+
ui->textBrowser_Display->append("Distribution: Poly Disperse - Custom");
7774
}
7875

79-
ui->textBrowser_Display->append("Number of discrete sphere sizes: "
80-
+ QString::number(para->nRadius));
76+
ui->textBrowser_Display->append("Number of discrete sphere sizes: "
77+
+ QString::number(para->nRadius));
8178

8279
if (currentIndex != para->Custom)
83-
{
84-
ui->textBrowser_Display->append("Mean diameter of spheres: "
85-
+ QString::number(2.0*para->meanRadius) + " um");
86-
ui->textBrowser_Display->append("Std. deviation: " + QString::number(para->stdDev) + " um\n");
80+
{
81+
ui->textBrowser_Display->append("Mean diameter of spheres: "
82+
+ QString::number(2.0*para->meanRadius) + " um");
83+
ui->textBrowser_Display->append("Std. deviation: " + QString::number(para->stdDev) + " um\n");
8784

8885
if (radioButton_NumDen->isChecked())
8986
{
90-
ui->textBrowser_Display->append("Total Concentration (Spheres in a volume of 1mm^3): "
91-
+ QString::number(para->sphNumDensity * margin));
87+
ui->textBrowser_Display->append("Total Concentration (Spheres in a volume of 1mm^3): "
88+
+ QString::number(para->sphNumDensity * margin));
9289
}
9390

9491
if (radioButton_VolFrac->isChecked())
9592
{
96-
ui->textBrowser_Display->append("Volume Fraction (Total sphere volume / 1mm^3): "
97-
+ QString::number(para->volFraction * margin));
93+
ui->textBrowser_Display->append("Volume Fraction (Total sphere volume / 1mm^3): "
94+
+ QString::number(para->volFraction * margin));
9895
}
99-
}
100-
}
96+
}
97+
}
10198
ui->textBrowser_Display->append("Wavelength Range: " + QString::number(para->startWavel) + "nm to "
102-
+ QString::number(para->endWavel) + "nm in "+ QString::number(para->stepWavel) + "nm steps\n");
99+
+ QString::number(para->endWavel) + "nm in "+ QString::number(para->stepWavel) + "nm steps\n");
103100

104-
ui->textBrowser_Display->append("\nSphere Data:");
101+
ui->textBrowser_Display->append("\nSphere Data:");
105102
ui->textBrowser_Display->append("Dia.(um)\tNum. Den.(in a vol. of 1mm^3)\tRef."
106103
" index of sphere (real | imag)\t Ref. index of medium");
107104

108105
for (unsigned int i = 0; i<para->nRadius; i++)
109106
{
110-
ui->textBrowser_Display->append(QString::number(2.0 * para->radArray[i]) + "\t"
111-
+ QString::number(para->numDensityArray[i] * margin) + "\t"
112-
+ QString::number(para->scatRefRealArray[i]) + "\t"
113-
+ QString::number(para->scatRefImagArray[i]) + "\t"
114-
+ QString::number(para->medRefArray[i]));
107+
ui->textBrowser_Display->append(QString::number(2.0 * para->radArray[i]) + "\t"
108+
+ QString::number(para->numDensityArray[i] * margin) + "\t"
109+
+ QString::number(para->scatRefRealArray[i]) + "\t"
110+
+ QString::number(para->scatRefImagArray[i]) + "\t"
111+
+ QString::number(para->medRefArray[i]));
115112
}
116113

117-
ui->textBrowser_Display->append("\n\nOutput:");
114+
ui->textBrowser_Display->append("\n\nOutput:");
118115

119116
if (radioButton_MonoDisperse->isChecked())
120117
{
@@ -151,7 +148,7 @@ void DisplayDialog::DisplayData(QRadioButton *radioButton_MonoDisperse,
151148
}
152149

153150
ui->textBrowser_Display->append("\nForward and Backward Scattering percentages:");
154-
ui->textBrowser_Display->append("WL(nm)\tForward %\tBackward %");
151+
ui->textBrowser_Display->append("WL(nm)\tForward %\tBackward %");
155152

156153
for (unsigned int i = 0; i<para->nWavel; i++)
157154
{
@@ -161,7 +158,7 @@ void DisplayDialog::DisplayData(QRadioButton *radioButton_MonoDisperse,
161158
}
162159

163160
int indexWL = slider_WL_PFPolar->value();
164-
double currentWL = para->startWavel + indexWL*para->stepWavel;
161+
double currentWL = para->startWavel + indexWL*para->stepWavel;
165162

166163
ui->textBrowser_Display->append("\nPhase Function @ Wavelength of " + QString::number(currentWL) + " nm:");
167164

@@ -195,4 +192,4 @@ void DisplayDialog::DisplayData(QRadioButton *radioButton_MonoDisperse,
195192
QString::number(para->phaseFunctionPerp[indexWL][i]));
196193
}
197194
}
198-
}
195+
}

‎src/app/dialog/displaydialog.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef DISPLAYDIALOG_H
22
#define DISPLAYDIALOG_H
33

4+
#include <memory>
45
#include <QDialog>
56
#include <QRadioButton>
67
#include <QComboBox>
@@ -29,11 +30,11 @@ class DisplayDialog : public QDialog
2930
QCheckBox *checkBox_PhasePolarAve,
3031
QCheckBox *checkBox_PhasePolarPara,
3132
QCheckBox *checkBox_PhasePolarPerp, Parameters *);
32-
Ui::DisplayDialog *ui;
33+
std::unique_ptr<Ui::DisplayDialog> ui;
3334

3435
private slots:
3536
void on_pushButton_Close_clicked();
3637

3738
};
3839

39-
#endif // DISPLAYDIALOG_H
40+
#endif // DISPLAYDIALOG_H

0 commit comments

Comments
 (0)