Athena++/Atmosphere
Planetary Atmosphere Simulator
radiation.hpp
Go to the documentation of this file.
1 #ifndef RADIATION_HPP
2 #define RADIATION_HPP
3 
4 // C/C++ headers
5 #include <string>
6 #include <vector>
7 
8 // Athena++ headers
9 #include "../athena.hpp"
10 #include "../astronomy/celestrial_body.hpp"
11 
12 class MeshBlock;
13 class ParameterInput;
14 class Absorber;
15 class Radiation;
16 
17 #ifdef RT_DISORT
18 #undef SQR
19 extern "C" {
21 }
22 #endif
23 
24 struct Spectrum {
26 };
27 
28 struct Direction {
30 };
31 
32 namespace RadiationFlags {
33  const uint64_t None = 0LL;
34  const uint64_t Dynamic = 1LL << 0;
35  const uint64_t LineByLine = 1LL << 1;
36  const uint64_t CorrelatedK = 1LL << 2;
37  const uint64_t Planck = 1LL << 3;
38  const uint64_t Star = 1LL << 4;
39  const uint64_t Sphere = 1LL << 5;
40  const uint64_t FluxOnly = 1LL << 6;
41 }
42 
44 public:
45  // data
46  std::string myname;
47  int num_bins;
48  uint64_t bflags;
52 
53  // spectra
54  std::vector<Spectrum> spec;
56 
57  // band radiation results
62 
63  // outgoing rays
64  std::vector<Direction> rayOutput;
65 
66  // functions
67  RadiationBand(Radiation *prad); // delayed initialization
68  RadiationBand(Radiation *prad, std::string name, ParameterInput *pin);
70 
71  void addAbsorber(std::string name, std::string file, ParameterInput *pin);
72  void addAbsorber(Absorber *pab);
73  void setSpectralProperties(AthenaArray<Real> const& w, int k, int j, int il, int iu);
74  void calculateRadiativeFlux(Direction rayInput, Real dist_au, int k, int j, int il, int iu);
75  void calculateRadiance(Direction rayInput, Real dist_au, int k, int j, int il, int iu);
76 
77 #ifdef RT_DISORT
78  void init_disort(ParameterInput *pin);
79  void free_disort();
80  disort_state ds;
81  disort_output ds_out;
82 #endif
83 
84 protected:
85  Real **tau_, **ssa_, ***pmom_, *tem_, *temf_;
88  Real alpha_; // T ~ Ts*(\tau/\tau_s)^\alpha at lower boundary
89 };
90 
91 class Radiation {
92 public:
93  // constants
94  static Real const hPlanck;
95  static Real const hPlanck_cgs;
96  static Real const cLight;
97  static Real const cLight_cgs;
98  static Real const stefanBoltzmann;
99 
100  // data
103  uint64_t rflags;
105  CelestrialBody *planet;
106  std::string radiance_units;
107 
108  // incomming rays and outgoing radiance
109  std::vector<Direction> rayInput;
111 
112  // functions
113  Radiation(MeshBlock *pmb); // delayed initialization
114  Radiation(MeshBlock *pmb, ParameterInput *pin);
115  ~Radiation();
116  RadiationBand* getBand(int n);
117  int getNumBands();
118  void calculateRadiativeFluxes(AthenaArray<Real> const& w, Real time,
119  int k, int j, int il, int iu);
120  void calculateRadiances(AthenaArray<Real> const& w, Real time,
121  int k, int j, int il, int iu);
123  int k, int j, int il, int iu);
124  void readRadiationBands(ParameterInput *pin, int &b);
126  //std::vector<Direction> getIncomingRays();
127 
128  // restart functions
129  size_t getRestartDataSizeInBytes();
130  size_t dumpRestartData(char *pdst);
131  size_t loadRestartData(char *psrc);
132 
133 protected:
135 };
136 
137 #endif
double Real
Definition: athena.hpp:29
#define LL(iq, lc)
Definition: cdisort.h:293
Real ** flxdn_
Definition: radiation.hpp:86
std::vector< Direction > rayOutput
Definition: radiation.hpp:64
Radiation * pmy_rad
Definition: radiation.hpp:49
AthenaArray< Real > bpmom
Definition: radiation.hpp:58
RadiationBand * prev
Definition: radiation.hpp:50
Absorber * pabs
Definition: radiation.hpp:51
void calculateRadiance(Direction rayInput, Real dist_au, int k, int j, int il, int iu)
Real * temf_
Definition: radiation.hpp:85
AthenaArray< Real > btau
Definition: radiation.hpp:58
AthenaArray< Real > bflxup
Definition: radiation.hpp:59
Real ** flxup_
Definition: radiation.hpp:86
void calculateRadiativeFlux(Direction rayInput, Real dist_au, int k, int j, int il, int iu)
Real ** toa_
Definition: radiation.hpp:87
Real ** ssa_
Definition: radiation.hpp:85
AthenaArray< Real > btoa
btoa is a reference to radiance in Radiation
Definition: radiation.hpp:61
Real ** tau_
Definition: radiation.hpp:85
RadiationBand(Radiation *prad)
void setSpectralProperties(AthenaArray< Real > const &w, int k, int j, int il, int iu)
Real *** pmom_
Definition: radiation.hpp:85
RadiationBand * next
Definition: radiation.hpp:50
AthenaArray< Real > bflxdn
Definition: radiation.hpp:59
uint64_t bflags
Definition: radiation.hpp:48
std::string myname
Definition: radiation.hpp:46
void addAbsorber(std::string name, std::string file, ParameterInput *pin)
std::vector< Spectrum > spec
Definition: radiation.hpp:54
AthenaArray< Real > bssa
Definition: radiation.hpp:58
static Real const cLight_cgs
Definition: radiation.hpp:97
void calculateRadiances(AthenaArray< Real > const &w, Real time, int k, int j, int il, int iu)
Definition: radiation.cpp:137
uint64_t rflags
Definition: radiation.hpp:103
MeshBlock * pmy_block
Definition: radiation.hpp:101
Real cooldown
Definition: radiation.hpp:104
static Real const hPlanck
Definition: radiation.hpp:94
size_t dumpRestartData(char *pdst)
Definition: radiation.cpp:262
Radiation(MeshBlock *pmb)
Definition: radiation.cpp:23
size_t loadRestartData(char *psrc)
Definition: radiation.cpp:277
Real stellarDistance_au_
Definition: radiation.hpp:134
void calculateRadiativeFluxes(AthenaArray< Real > const &w, Real time, int k, int j, int il, int iu)
Definition: radiation.cpp:110
static Real const hPlanck_cgs
Definition: radiation.hpp:95
int getNumBands()
Definition: radiation.cpp:100
static Real const stefanBoltzmann
Definition: radiation.hpp:98
std::string radiance_units
Definition: radiation.hpp:106
CelestrialBody * planet
Definition: radiation.hpp:105
RadiationBand * getBand(int n)
Definition: radiation.cpp:89
std::vector< Direction > rayInput
Definition: radiation.hpp:109
int getTotalNumberOutgoingRays()
Definition: radiation.cpp:239
size_t getRestartDataSizeInBytes()
Definition: radiation.cpp:249
void addRadiativeFluxes(AthenaArray< Real > &x1flux, int k, int j, int il, int iu)
Definition: radiation.cpp:162
void readRadiationBands(ParameterInput *pin, int &b)
Definition: radiation.cpp:182
RadiationBand * pband
Definition: radiation.hpp:102
Real current
Definition: radiation.hpp:104
static Real const cLight
Definition: radiation.hpp:96
AthenaArray< Real > radiance
Definition: radiation.hpp:110
const uint64_t None
Definition: radiation.hpp:33
const uint64_t Sphere
Definition: radiation.hpp:39
const uint64_t Dynamic
Definition: radiation.hpp:34
const uint64_t Star
Definition: radiation.hpp:38
const uint64_t LineByLine
Definition: radiation.hpp:35
const uint64_t FluxOnly
Definition: radiation.hpp:40
const uint64_t Planck
Definition: radiation.hpp:37
const uint64_t CorrelatedK
Definition: radiation.hpp:36
Real phi
Definition: radiation.hpp:29
Real wav2
Definition: radiation.hpp:25
Real wav1
Definition: radiation.hpp:25
Real rad
Definition: radiation.hpp:25
Real wght
Definition: radiation.hpp:25