Canoe
Comprehensive Atmosphere N' Ocean Engine
absorber.hpp
Go to the documentation of this file.
1 #ifndef SRC_OPACITY_ABSORBER_HPP_
2 #define SRC_OPACITY_ABSORBER_HPP_
3 
4 // C/C++
5 #include <map>
6 #include <memory>
7 #include <string>
8 #include <vector>
9 
10 // external
11 #include <yaml-cpp/yaml.h>
12 
13 // athena
14 #include <athena/athena.hpp>
15 
16 // canoe
17 #include <virtual_groups.hpp>
18 
19 class AirParcel;
20 
22 class Absorber : public NamedGroup,
23  public ParameterGroup,
24  public SpeciesIndexGroup,
25  public CheckGroup {
26  public: // constructor and destructor
27  Absorber(std::string name);
28  virtual ~Absorber();
29 
30  public: // member functions
32  void SetModel(std::string name) { model_name_ = name; }
33 
35  void LoadOpacityFromFile(std::string filename);
36 
38  void SetOpacityFile(std::string filename);
39 
41  void LoadOpacity();
42 
44  virtual void LoadCoefficient(std::string fname, size_t bid) {}
45 
47  virtual Real GetAttenuation(Real wave1, Real wave2,
48  AirParcel const& var) const {
49  return 0.;
50  }
51 
53  virtual Real GetSingleScatteringAlbedo(Real wave1, Real wave2,
54  AirParcel const& var) const {
55  return 0.;
56  }
57 
59  virtual void GetPhaseMomentum(Real* pp, Real wave1, Real wave2,
60  AirParcel const& var, int np) const {}
61 
62  protected:
64  std::string model_name_;
65 
67  std::string opacity_filename_;
68 };
69 
70 using AbsorberPtr = std::shared_ptr<Absorber>;
71 using AbsorberContainer = std::vector<AbsorberPtr>;
72 
74  public:
77  std::string search_path;
78 
83  static AbsorberPtr CreateFrom(YAML::Node const& my, std::string band_name);
84 
90  static AbsorberContainer CreateFrom(std::vector<std::string> const& names,
91  std::string band_name,
92  YAML::Node const& rad);
93 
94  protected:
99  static AbsorberPtr createAbsorberPartial(std::string name, std::string type);
100 };
101 
102 #endif // SRC_OPACITY_ABSORBER_HPP_
std::shared_ptr< Absorber > AbsorberPtr
Definition: absorber.hpp:70
std::vector< AbsorberPtr > AbsorberContainer
Definition: absorber.hpp:71
std::string search_path
Definition: absorber.hpp:77
static AbsorberPtr createAbsorberPartial(std::string name, std::string type)
Only create an absorber based on its name and class.
static AbsorberPtr CreateFrom(YAML::Node const &my, std::string band_name)
Create an absorber from YAML node.
base class of all absorbers
Definition: absorber.hpp:25
virtual Real GetAttenuation(Real wave1, Real wave2, AirParcel const &var) const
Get attenuation coefficient [1/m].
Definition: absorber.hpp:47
std::string model_name_
absorption model model
Definition: absorber.hpp:64
void LoadOpacity()
Load opacity from internal variable.
Definition: absorber.cpp:30
virtual void GetPhaseMomentum(Real *pp, Real wave1, Real wave2, AirParcel const &var, int np) const
Get phase function [1].
Definition: absorber.hpp:59
std::string opacity_filename_
opacity filename
Definition: absorber.hpp:67
Absorber(std::string name)
Definition: absorber.cpp:11
void SetModel(std::string name)
Set absorption model.
Definition: absorber.hpp:32
virtual Real GetSingleScatteringAlbedo(Real wave1, Real wave2, AirParcel const &var) const
Get single scattering albedo [1].
Definition: absorber.hpp:53
virtual void LoadCoefficient(std::string fname, size_t bid)
Load absorption coefficient from file.
Definition: absorber.hpp:44
virtual ~Absorber()
Definition: absorber.cpp:16
void SetOpacityFile(std::string filename)
Set opacity filename to internal variable, does not load opacity.
Definition: absorber.cpp:26
void LoadOpacityFromFile(std::string filename)
Combines SetOpacityFile() and LoadOpacity()
Definition: absorber.cpp:21