adding support for spectroscopy

This commit is contained in:
Dave Goodwin 2007-12-15 17:18:20 +00:00
parent c438d5846f
commit 9d38835054
3 changed files with 195 additions and 0 deletions

View file

@ -0,0 +1,84 @@
#/bin/sh
###############################################################
# $Author$
# $Date$
# $Revision$
#
# Copyright 2007 California Institute of Technology
#
###############################################################
.SUFFIXES :
.SUFFIXES : .cpp .d .o .h
INCDIR = ../../../build/include/cantera/kernel
INSTALL_TSC = ../../../bin/install_tsc
do_ranlib = @DO_RANLIB@
debug_mode = @CANTERA_DEBUG_MODE@
ifeq ($(debug_mode), 1)
DEBUG_FLAG=-DDEBUG_MODE
else
DEBUG_FLAG=
endif
PIC_FLAG=@PIC@
CXX_FLAGS = @CXXFLAGS@ $(LOCAL_DEFS) $(CXX_OPT) $(PIC_FLAG) $(DEBUG_FLAG)
SPECTRA_OBJ = rotor.o
SPECTRA_H = rotor.h
CXX_INCLUDES = -I. @CXX_INCLUDES@ -I../base
LIB = @buildlib@/libctspectra.a
DEPENDS = $(SPECTRA_OBJ:.o=.d)
all: $(LIB) .depends
@(@INSTALL@ -d $(INCDIR))
@(for lh in $(SPECTRA_H) ; do \
$(INSTALL_TSC) "$${lh}" $(INCDIR) ; \
done)
%.d:
@CXX_DEPENDS@ $(CXX_INCLUDES) $*.cpp > $*.d
.cpp.o:
@CXX@ -c $< $(CXX_FLAGS) $(CXX_INCLUDES)
$(LIB): $(SPECTRA_OBJ) $(SPECTRA_H)
@ARCHIVE@ $(LIB) $(SPECTRA_OBJ) > /dev/null
ifeq ($(do_ranlib),1)
@RANLIB@ $(LIB)
endif
clean:
@(for lh in dummy.h $(SPECTRA_H) ; do \
th=$(INCDIR)/"$${lh}" ; \
if test -f "$${th}" ; then \
$(RM) "$${th}" ; \
echo "$(RM) $${th}" ; \
fi \
done)
@(if test -f $(LIB) ; then \
$(RM) $(LIB) ; \
echo "$(RM) $(LIB)" ; \
fi)
$(RM) *.o *~ .depends *.d
(if test -d SunWS_cache ; then \
$(RM) -rf SunWS_cache ; \
fi )
depends:
@MAKE@ .depends
.depends: $(DEPENDS)
cat $(DEPENDS) > .depends
TAGS:
etags *.h *.cpp
ifeq ($(wildcard .depends), .depends)
include .depends
endif

View file

@ -0,0 +1,51 @@
#ifdef WIN32
#pragma warning(disable:4786)
#pragma warning(disable:4503)
#endif
#include "ct_defs.h"
#include "rotor.h"
namespace Cantera {
/*
* @param mu reduced mass in kg
* @param re bond length in meters
* @dipoleMoment permanent dipole moment in ...
*/
Rotor::Rotor(doublereal Bv, doublereal dipoleMoment,
doublereal Dv, doublereal Hv ) : m_Bv(Bv),
m_Dv(Dv),
m_Hv(Hv),
m_dipole(dipoleMoment) {}
// energy in wavenumbers
doublereal Rotor::energy_w(int J) {
int jjp1 = J*(J + 1);
return jjp1*(m_Bv + jjp1*(m_Hv*jjp1 - m_Dv));
}
doublereal Rotor::degeneracy(int J) {
return 2*J + 1;
}
doublereal Rotor::partitionFunction(doublereal T, int cutoff) {
int j = 0;
if (cutoff < 0) cutoff = 100;
doublereal dsum = 0.0, sum = 0.0;
for (j = 0; j < cutoff; j++) {
dsum = degeneracy(j)*exp(-Planck*energy_w(j)/(Boltzmann * T));
sum += dsum;
}
return sum;
}
doublereal Rotor::frequency(int J_lower, int J_upper) {
return (energy_w(J_upper) - energy_w(J_lower));
}
}

View file

@ -0,0 +1,60 @@
#ifndef CT_ROTOR
#define CT_ROTOR
#include "ct_defs.h"
namespace Cantera {
class Rotor {
public:
Rotor() {}
virtual ~Rotor() {}
/*
*/
Rotor(doublereal Bv, doublereal dipoleMoment = 0.0,
doublereal Dv = 0.0, doublereal Hv = 0.0);
// energy in wavenumbers
doublereal energy_w(int J);
doublereal degeneracy(int J);
doublereal partitionFunction(doublereal T, int cutoff=-1);
doublereal frequency(int J_lower, int J_upper);
protected:
doublereal m_Bv;
doublereal m_Dv;
doublereal m_Hv;
doublereal m_dipole;
};
/** convert from Hz to wavenmbers */
inline doublereal hz_to_wnum(doublereal freq) {
return freq/(100.0*lightSpeed);
}
inline doublereal wnum_to_J(doublereal w) {
return Planck * w * 100.0 * lightSpeed;
}
inline doublereal J_to_wnum(doublereal e) {
return e /(Planck * 100.0 * lightSpeed);
}
inline doublereal wnum_to_eV(doublereal w) {
return Planck * w * 100.0 * lightSpeed / ElectronCharge;
}
inline doublereal eV_to_wnum(doublereal e) {
return e * ElectronCharge / (Planck * 100.0 * lightSpeed);
}
}
#endif