40 HITRAN::HITRAN(
const std::string & data_file,
const std::string & partition_function_file,
41 libMesh::Real T_min, libMesh::Real T_max, libMesh::Real T_step)
48 if ( (T_min<0.0) || (T_min>=T_max) || (T_step<=0.0) || (T_min>
_T0) || (T_max<
_T0) )
51 ss <<
"Invalid specification of temperature range:" <<std::endl;
52 ss <<
"T_min: " <<T_min <<std::endl;
53 ss <<
"T_max: " <<T_max <<std::endl;
54 ss <<
"T_step: " <<T_step <<std::endl;
55 libmesh_error_msg(ss.str());
59 std::ifstream hitran_file;
60 hitran_file.open(data_file);
61 if (!hitran_file.is_open())
64 ss <<
"Unable to open provided hitran_file: " <<data_file <<std::endl;
65 libmesh_error_msg(ss.str());
68 while(!hitran_file.eof())
71 getline(hitran_file,line);
76 std::vector<libMesh::Real> vals;
80 libmesh_assert_equal_to(vals.size(),8);
84 _isotop.push_back(static_cast<unsigned int>(vals[0]-1));
86 _nu.push_back(vals[1]);
87 _sw.push_back(vals[2]);
91 _n.push_back(vals[6]);
96 libmesh_assert_equal_to(
_isotop.size(),
_nu.size() );
97 libmesh_assert_equal_to(
_nu.size(),
_sw.size() );
101 libmesh_assert_equal_to(
_elower.size(),
_n.size() );
102 libmesh_assert_equal_to(
_n.size(),
_delta_air.size() );
109 std::ifstream qT_file;
110 qT_file.open(partition_function_file);
111 if (!qT_file.is_open())
113 std::stringstream ss;
114 ss <<
"Unable to open provided partition_function_file: " <<partition_function_file <<std::endl;
115 libmesh_error_msg(ss.str());
119 unsigned int num_T = (T_max-T_min)/T_step + 1;
122 unsigned int counter = 0;
124 while(!qT_file.eof())
127 getline(qT_file,line);
132 _qT.push_back(std::vector<libMesh::Real>());
137 libmesh_assert_equal_to(num_T,
_qT[counter].size());
147 for(
unsigned int i=0; i<
_qT.size(); i++)
148 _qT0.push_back(this->get_partition_function_value(
_T0,i));
160 libMesh::Real deriv = -1.0;
161 if (std::abs(T-
_Tmin)<libMesh::TOLERANCE)
168 else if (std::abs(T-
_Tmax)<libMesh::TOLERANCE)
180 deriv = (QT1-QT0)/(2.0*
_Tstep);
188 libmesh_assert_less(index,
_isotop.size());
194 libmesh_assert_less(index,
_nu.size());
200 libmesh_assert_less(index,
_sw.size());
218 libmesh_assert_less(index,
_elower.size());
224 libmesh_assert_less(index,
_n.size());
248 libMesh::Real retval = -1.0;
256 std::stringstream ss;
257 ss <<
"Error: Temperature " <<T <<
"K does not exist in the given partition sum data" <<std::endl;
258 libmesh_error_msg(ss.str());
267 index = std::max(index,(
unsigned int)1);
275 std::stringstream ss;
276 ss <<
"Error, temperature T=" <<T_star <<
" is outside the specified range of provided partition function values" <<std::endl;
277 libmesh_error_msg(ss.str());
281 return y[index_r-1] + ( (T_star-(T-
_Tstep))*(y[index_r]-y[index_r-1]) )/(T-(T-
_Tstep));
libMesh::Real interpolate_values(int index_r, libMesh::Real T_star, const std::vector< libMesh::Real > &y) const
Linear interpolation helper function.
std::vector< libMesh::Real > _nu
libMesh::Real elower(unsigned int index)
Lower state energy of transition [ ].
unsigned int get_data_size()
Return the data size.
libMesh::Real partition_function(libMesh::Real T, unsigned int iso)
int _data_size
Size of spectroscopic data.
libMesh::Real nu0(unsigned int index)
Linecenter wavenumber [ ].
std::vector< libMesh::Real > _sw
unsigned int isotopologue(unsigned int index)
Isotopologue ID.
std::vector< libMesh::Real > _gamma_air
std::vector< libMesh::Real > _gamma_self
libMesh::Real partition_function_derivative(libMesh::Real T, unsigned int iso)
Finite difference derivative for partition function.
void split_string_real(const std::string &input, const std::string &delimiter, std::vector< libMesh::Real > &results)
std::vector< libMesh::Real > _n
libMesh::Real delta_air(unsigned int index)
Air pressure-induced line shift [ ].
libMesh::Real get_partition_function_value(libMesh::Real T, unsigned int iso)
Search through the partition function data to get value for given temperature.
libMesh::Real n_air(unsigned int index)
Temperature coefficient [].
HITRAN()
User should not call empty constructor.
libMesh::Real _T0
Reference temperature (296K)
libMesh::Real gamma_self(unsigned int index)
Self-broadening half-wdith [ ].
std::vector< libMesh::Real > _delta_air
std::vector< unsigned int > _isotop
int _q_size
Size of partition function data.
std::vector< std::vector< libMesh::Real > > _qT
Vector for partition function values for all isotopologues.
int T_index(libMesh::Real T)
Find the index into _T corresponding to the given temperature.
libMesh::Real sw(unsigned int index)
Linestrength [ ].
std::vector< libMesh::Real > _elower
libMesh::Real gamma_air(unsigned int index)
Air-broadening half-width [ ].
std::vector< libMesh::Real > _qT0