From c3d2eb31dff71e37fa7f47283592633f9a162f7c Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Tue, 25 Dec 2007 09:35:42 +0000 Subject: [PATCH] *** empty log message *** --- Cantera/src/base/ctexceptions.h | 2 +- Cantera/src/kinetics/GasKinetics.h | 2 ++ Cantera/src/spectra/LineBroadener.cpp | 28 +++++++++++++++++----- Cantera/src/spectra/LineBroadener.h | 2 ++ test_problems/spectroscopy/spectratest.cpp | 24 +++++++------------ 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/Cantera/src/base/ctexceptions.h b/Cantera/src/base/ctexceptions.h index ddc06fccb..2a9338ee7 100755 --- a/Cantera/src/base/ctexceptions.h +++ b/Cantera/src/base/ctexceptions.h @@ -42,7 +42,7 @@ namespace Cantera { * * \include edemo.cpp * - * The function showErrors() will print out the fatal error condition to standard output. + * The function showErrors() will p//rint out the fatal error condition to standard output. * * A group of defines may be used during debugging to assert conditions which should * be true. These are named AssertTrace(), AssertThrow(), and AssertThrowMsg(). diff --git a/Cantera/src/kinetics/GasKinetics.h b/Cantera/src/kinetics/GasKinetics.h index 0d954dafb..777f48921 100755 --- a/Cantera/src/kinetics/GasKinetics.h +++ b/Cantera/src/kinetics/GasKinetics.h @@ -1,6 +1,8 @@ /** * @file GasKinetics.h * + * @ingroup chemkinetics + * * $Author$ * $Revision$ * $Date$ diff --git a/Cantera/src/spectra/LineBroadener.cpp b/Cantera/src/spectra/LineBroadener.cpp index bfa952de1..2795cbe07 100644 --- a/Cantera/src/spectra/LineBroadener.cpp +++ b/Cantera/src/spectra/LineBroadener.cpp @@ -70,9 +70,17 @@ namespace CanteraSpectra { m_gamma_lor = gamma; m_sigsqrt2 = SqrtTwo*m_sigma; m_gamma = gamma/m_sigsqrt2; - m_eps = 1.0e-9; + m_eps = 1.0e-20; } + void Voigt::testv() { + m_gamma = 1.0e1; + cout << F(1.0) << endl; + m_gamma = 0.5; + cout << F(1.0) << endl; + m_gamma = 0.0001; + cout << F(10.0) << endl; + } /** * This method evaluates the function * \f[ @@ -90,14 +98,18 @@ namespace CanteraSpectra { double b = (tau + x)/y; double t = b*y; double f1, f2, f3; - double c0 = 2.0/(Pi*m_eps); + double c0 = 2.0/(Pi*m_eps); // eps or e? const double c1 = 1.0/SqrtTwo; const double c2 = 2.0/SqrtPi; if (y > c0/m_eps) { - throw CanteraError("Voigt::F", - "condition that y < c0/epsion violated"); + //cout << "returning 0.0 since y > c0/m_eps" << endl; + return 0.0; } + //{ + // throw CanteraError("Voigt::F", + // "condition that y < c0/epsilon violated"); + //} while (1 > 0) { f1 = c2*y*exp(-Pi*Pi/(t*t)); f2 = fabs(y*y - Pi*Pi/(t*t)); @@ -107,7 +119,7 @@ namespace CanteraSpectra { if ((f1/(f2*f3)) < 0.5*m_eps) break; } double h = t/y; - int N = int(0.5*b/h); + int N = int(0.5 + b/h); double S = 0.0; double u = h/2; for (int i = 0; i < N; i++) { @@ -120,17 +132,21 @@ namespace CanteraSpectra { C = 2.0*exp(y*y - x*x)*cos(2*x*y)/(1.0 + exp(2*Pi/h)); } else { + //cout << "returning 0, since y2 > Pi/h" << endl; return 0.0; } + //cout << "for x = " << x << ", y = " << y << endl; + //cout << "V(x,y) = " << Q+C << endl; return Q + C; } /** * Voigt profile. * + * Not sure that constant is right. */ doublereal Voigt::profile(doublereal deltaFreq) { - const double ff = m_gamma_lor*m_gamma_lor/(2.0*Pi*m_sigma*m_sigma); + const double ff = 1.0/(m_sigsqrt2*SqrtPi); return ff*F(deltaFreq/m_sigsqrt2); } diff --git a/Cantera/src/spectra/LineBroadener.h b/Cantera/src/spectra/LineBroadener.h index 501512449..30560d19d 100644 --- a/Cantera/src/spectra/LineBroadener.h +++ b/Cantera/src/spectra/LineBroadener.h @@ -123,6 +123,8 @@ namespace CanteraSpectra { //virtual doublereal cumulative(doublereal deltaFreq) //virtual doublereal width() + void testv(); + protected: doublereal F(doublereal x); diff --git a/test_problems/spectroscopy/spectratest.cpp b/test_problems/spectroscopy/spectratest.cpp index f72244bc9..8c15baad2 100644 --- a/test_problems/spectroscopy/spectratest.cpp +++ b/test_problems/spectroscopy/spectratest.cpp @@ -3,7 +3,7 @@ #include "spectra.h" #include using namespace std; -using namespace Cantera; +using namespace CanteraSpectra; int main() { // double B; @@ -24,31 +24,25 @@ int main() { // } // test line broading classes - double gam = 2.0; - double sigma = 10.0; + double gam = 2.0e0; + double sigma = 5.0; LineBroadener* lor = new Lorentzian(gam); LineBroadener* gaus = new Gaussian(sigma); - LineBroadener* voig = new Voigt(sigma, gam); + Voigt* voig = new Voigt(sigma, gam); + //voig->testv(); - double nu0 = 1000.0; - double dnu = 0.2; + double dnu = 0.1; double nu; - double gw = gaus->width(); double sum = 0.0, sumg = 0.0, sumlor = 0.0; - for (int n = -1000; n < 1000; n++) { + for (int n = -2000; n < 2000; n++) { //cout << n << endl; nu = n*dnu; sumg += gaus->profile(nu)*dnu; sum += voig->profile(nu)*dnu; sumlor += lor->profile(nu)*dnu; - try { - cout << nu << ", " << (*lor)(nu) << ", " << (*gaus)(nu) - << ", " << (*voig)(nu) << endl; - } - catch (CanteraError) { - showErrors(); - } + cout << nu << ", " << (*lor)(nu) << ", " << (*gaus)(nu) + << ", " << (*voig)(nu) << endl; } cout << "Voigt area = " << sum << endl; cout << "Gaussian area = " << sumg << endl;