From 2f197f0dc07aa60e01b194da3866bc2d23894fe4 Mon Sep 17 00:00:00 2001 From: Nicholas Malaya Date: Tue, 7 Feb 2012 17:45:05 +0000 Subject: [PATCH] [cantera]: adding and updating spectra tests --- Cantera/cxx/include/spectra.h | 4 +- configure.ac | 1 + test_problems/Makefile.am | 1 + test_problems/spectroscopy/Makefile.am | 23 ++++++++++ test_problems/spectroscopy/spectratest.cpp | 52 ++++++++++++++++++++-- 5 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 test_problems/spectroscopy/Makefile.am diff --git a/Cantera/cxx/include/spectra.h b/Cantera/cxx/include/spectra.h index 58ccdac61..fa5adaab7 100644 --- a/Cantera/cxx/include/spectra.h +++ b/Cantera/cxx/include/spectra.h @@ -1,8 +1,8 @@ #ifndef CT_SPECTRA_H_INCL #define CT_SECTRA_H_INCL -#include "kernel/LineBroadener.h" -#include "kernel/rotor.h" +#include "LineBroadener.h" +#include "rotor.h" //#include "kernel/AbsorptionLine.h" #endif diff --git a/configure.ac b/configure.ac index 86a196d57..663ceb582 100644 --- a/configure.ac +++ b/configure.ac @@ -106,6 +106,7 @@ AC_OUTPUT(Makefile \ test_problems/printUtilUnitTest/Makefile \ test_problems/pureFluidTest/Makefile \ test_problems/silane_equil/Makefile \ + test_problems/spectroscopy/Makefile \ test_problems/cathermo/Makefile \ test_problems/cathermo/DH_graph_1/Makefile \ test_problems/cathermo/DH_graph_acommon/Makefile \ diff --git a/test_problems/Makefile.am b/test_problems/Makefile.am index 408d9ad5d..557d589ae 100644 --- a/test_problems/Makefile.am +++ b/test_problems/Makefile.am @@ -6,6 +6,7 @@ SUBDIRS = cathermo mixGasTransport ChemEquil_gri_matrix ChemEquil_gri_pairs SUBDIRS += ChemEquil_ionizedGas ChemEquil_red1 CpJump cxx_ex diamondSurf SUBDIRS += diamondSurf_dupl fracCoeff multiGasTransport NASA9poly_test SUBDIRS += negATest printUtilUnitTest pureFluidTest silane_equil +SUBDIRS += spectroscopy # skipped: diff --git a/test_problems/spectroscopy/Makefile.am b/test_problems/spectroscopy/Makefile.am new file mode 100644 index 000000000..e6e24fc42 --- /dev/null +++ b/test_problems/spectroscopy/Makefile.am @@ -0,0 +1,23 @@ +cc_sources = spectratest.cpp + +INC = -I. -I$(top_builddir)/build/include/ +AM_CPPFLAGS = $(INC) +AM_CXXFLAGS = $(AM_CPPFLAGS) + +LINK = -luser -loneD -lzeroD -lequil -lkinetics -ltransport -lthermo +LINK += -lctnumerics -lctmath -ltpx -lctspectra -lconverters -lctbase -lcvode +LINK += -lctlapack -lctblas -lctf2c -lctcxx -lm -lctf2c -lstdc++ +AM_LDFLAGS = -L$(top_builddir)/build/lib/ +LIBS = $(LINK) + +bin_PROGRAMS = spectroscopy +library_includedir = $(INC) + +#----------------------- +# Cantera DH graph test +#----------------------- + +spectroscopy_SOURCES = $(cc_sources) + +TESTS_ENVIRONMENT = +TESTS = spectroscopy diff --git a/test_problems/spectroscopy/spectratest.cpp b/test_problems/spectroscopy/spectratest.cpp index 35790f660..9c453f43d 100644 --- a/test_problems/spectroscopy/spectratest.cpp +++ b/test_problems/spectroscopy/spectratest.cpp @@ -1,7 +1,16 @@ +/** + * @file spectratest.cpp + * + * $Author: $ + * $Date: 2007/05/04 15:18:45 $ + * $Revision: 1.3 $ + * + * nick adding more useful on 2/7/12 + */ #include "Cantera.h" #include "spectra.h" -#include "kernel/Nuclei.h" +#include "Nuclei.h" #include using namespace std; using namespace CanteraSpectra; @@ -13,6 +22,11 @@ int main() { if (*a == *b) { cout << "a and b and indistinguishable" << endl; } + else + { + cout << "\nwhy are a and b not indistinguishable?\n"; + return 1; + } // test line broading classes double gam = 2.0e0; @@ -32,10 +46,42 @@ int main() { sumg += gaus->profile(nu)*dnu; sum += voig->profile(nu)*dnu; sumlor += lor->profile(nu)*dnu; - cout << nu << ", " << (*lor)(nu) << ", " << (*gaus)(nu) - << ", " << (*voig)(nu) << endl; + //cout << nu << ", " << (*lor)(nu) << ", " << (*gaus)(nu) + // << ", " << (*voig)(nu) << endl; } + + /* old output cout << "Voigt area = " << sum << endl; cout << "Gaussian area = " << sumg << endl; cout << "Lorentzian area = " << sumlor << endl; + */ + + // 'blessed' output: + // Voigt area = 0.99363 + // Gaussian area = 1 + // Lorentzian area = 0.993634 + + // guessing a sane tolerance + double TOL = .0001; + + if(abs(sum-.99363) > TOL) + { + cout << "\nVOIGT AREA REGRESSION TEST FAILURE\n"; + return 1; + } + + if(abs(sumg-1.0) > TOL) + { + cout << "\nGAUSSIAN AREA REGRESSION TEST FAILURE\n"; + return 1; + } + if(abs(sumlor-.993634) > TOL) + { + cout << "\nLORENTZIAN AREA REGRESSION TEST FAILURE\n"; + return 1; + } + + // steady as she goes + return 0; + }