ReFRACtor
absco.h
Go to the documentation of this file.
1 #ifndef ABSCO_H
2 #define ABSCO_H
3 #include "gas_absorption.h"
4 #include "array_ad_with_unit.h"
5 #include "array_with_unit.h"
6 #include "null_deleter.h"
7 #include <boost/any.hpp>
8 #include <vector>
9 
10 namespace FullPhysics {
11 class Absco;
12 
13 /****************************************************************/
20 class AbscoInterpolator : public Printable<AbscoInterpolator> {
21 public:
23  const ArrayWithUnit<double, 1>& Press,
24  const ArrayAdWithUnit<double, 1>& Temp,
25  const ArrayAdWithUnit<double, 1>& Broadener_vmr);
26  virtual ~AbscoInterpolator() {}
27  virtual void print(std::ostream& Os) const {Os << "AbscoInterpolator";}
28 
29  blitz::Array<double, 1> absorption_cross_section_noderiv(double wn) const;
31 private:
32  double interpol(double X, const std::vector<double>& Xv,
33  int& i, double& df_dx) const;
34  template<class T> blitz::Array<double, 1>
35  absorption_cross_section_noderiv_calc(double wn) const;
36  template<class T> ArrayAd<double, 1>
37  absorption_cross_section_deriv_calc(double wn) const;
39  blitz::Array<double, 1> p; // This is in Pascals
40  ArrayAd<double, 1> t; // This is in K
41  ArrayAd<double, 1> b; // This is dimensionless
42  blitz::Array<double, 2> t_jac; // t.jacobian(), in C order and contiguous
43  blitz::Array<double, 2> b_jac; // b.jacobian(), in C order and contiguous
44  // Various indexes used in the interpolation
45  blitz::Array<int, 1> ip, itp1, itp2, ib, ib2;
46  blitz::Array<double, 1> dftp1_dt, dftp2_dt, dfb_db,
47  fp, fb, ftp1, ftp2;
48  mutable ArrayAd<double, 1> res; // We return the same results array
49  // each time, so we don't need to keep
50  // creating and destroying this.
51 };
52 
53 /****************************************************************/
56 class Absco: public GasAbsorption {
57 public:
58  virtual ~Absco() {}
59 
60  virtual std::string broadener_name() const = 0;
61 
62 //-----------------------------------------------------------------------
68 //-----------------------------------------------------------------------
69 
70  virtual double table_scale(double wn) const = 0;
71 
72 //-----------------------------------------------------------------------
75 //-----------------------------------------------------------------------
76 
77  virtual int number_broadener_vmr() const
78  { return broadener_vmr_grid().rows(); }
79 
80 //-----------------------------------------------------------------------
82 //-----------------------------------------------------------------------
83 
84  virtual int number_layer() const
85  {return pressure_grid().rows(); }
86 
87 //-----------------------------------------------------------------------
89 //-----------------------------------------------------------------------
90 
91  virtual int number_temperature() const
92  {return temperature_grid().cols(); }
93 
94 //-----------------------------------------------------------------------
99 //-----------------------------------------------------------------------
100 
101  virtual blitz::Array<double, 1> broadener_vmr_grid() const = 0;
102 
103 //-----------------------------------------------------------------------
108 //-----------------------------------------------------------------------
109 
110  virtual blitz::Array<double, 1> pressure_grid() const = 0;
111 
112 //-----------------------------------------------------------------------
117 //-----------------------------------------------------------------------
118 
119  virtual blitz::Array<double, 2> temperature_grid() const = 0;
120 
121 
122  virtual DoubleWithUnit absorption_cross_section
123  (double Wn, const DoubleWithUnit& Press, const DoubleWithUnit& Temp,
124  const DoubleWithUnit& Broadener_vmr) const;
126  absorption_cross_section(double wn,
127  const DoubleWithUnit& press,
128  const AutoDerivativeWithUnit<double>& temp,
129  const AutoDerivativeWithUnit<double>& broadener_vmr) const;
130 
131 //-----------------------------------------------------------------------
136 //-----------------------------------------------------------------------
137 
138  virtual bool is_float() const = 0;
139 
140 //-----------------------------------------------------------------------
156 //-----------------------------------------------------------------------
157  template <class T> blitz::Array<T, 3> read(double wn) const;
158  friend class AbscoInterpolator;
159 protected:
160 
161 //-----------------------------------------------------------------------
164 //-----------------------------------------------------------------------
165 
166  virtual blitz::Array<double, 3> read_double(double wn) const = 0;
167  virtual blitz::Array<float, 3> read_float(double wn) const = 0;
168 private:
169  double interpol(double X, const std::vector<double>& Xv,
170  int& i, double& df_dx) const;
171  mutable std::vector<double> pgrid;
172  mutable std::vector<std::vector<double> > tgrid;
173  mutable std::vector<double> bgrid;
174  void fill_pgrid_tgrid_and_bgrid() const;
175 };
176 
177 template <> inline blitz::Array<double, 3> Absco::read<double>(double wn) const
178 {
179  return read_double(wn);
180 }
181 
182 template <> inline blitz::Array<float, 3> Absco::read<float>(double wn) const
183 {
184  return read_float(wn);
185 }
186 
187 }
188 
189 #endif
190 
This class is used to read the absco tables.
Definition: absco.h:56
virtual int number_layer() const
Number of pressure layers in absco file.
Definition: absco.h:84
AbscoInterpolator(const boost::shared_ptr< Absco > &A, const ArrayWithUnit< double, 1 > &Press, const ArrayAdWithUnit< double, 1 > &Temp, const ArrayAdWithUnit< double, 1 > &Broadener_vmr)
Set up a AbscoInterpolator for the given set up pressure, temperature, and broadner VMR...
Definition: absco.cc:136
This is a AutoDerivative that also has units associated with it.
ArrayAd< double, 1 > absorption_cross_section_deriv(double wn) const
Return absorption cross section, with derivatives.
Definition: absco.cc:286
virtual ~Absco()
Definition: absco.h:58
This is a Mixin for classes that can be printed.
Definition: printable.h:24
const Unit A("A", 1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0)
virtual ~AbscoInterpolator()
Definition: absco.h:26
This is a helper class that calculates the absorption cross section for a fixed set of Pressure...
Definition: absco.h:20
virtual int number_broadener_vmr() const
Number of broadener VMR values in absco file.
Definition: absco.h:77
We frequently have a double with units associated with it.
virtual void print(std::ostream &Os) const
Definition: absco.h:27
This class determine the gaseous absorption coefficient for a given wave number, temperature and pres...
blitz::Array< double, 1 > absorption_cross_section_noderiv(double wn) const
Return absorption cross section, without derivatives.
Definition: absco.cc:209
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
virtual int number_temperature() const
Number of temperature values in absco file.
Definition: absco.h:91

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:08