Canoe
Comprehensive Atmosphere N' Ocean Engine
rt_solver_lambert.cpp
Go to the documentation of this file.
1 // C/C++
2 #include <cmath>
3 #include <iostream>
4 
5 // athena
6 #include <athena/mesh/mesh.hpp>
7 
8 // climath
9 #include <climath/special.h>
10 
11 // application
12 #include <application/application.hpp>
13 #include <application/exceptions.hpp>
14 
15 // harp
16 #include "radiation.hpp"
17 #include "rt_solvers.hpp"
18 
19 void RadiationBand::RTSolverLambert::CalBandFlux(MeshBlock const *pmb, int k,
20  int j, int il, int iu) {
21  throw NotImplementedError("RTSolverLambert::CalBandFlux");
22 }
23 
25  int k, int j) {
26  RadiationBand *pband = pmy_band_;
27 
28  auto &rayOutput = pband->rayOutput_;
29  auto &toa = pband->toa_;
30  auto &tau = pband->tau_;
31  auto &temf = pband->temf_;
32  auto &spec = pband->pgrid_->spec;
33 
34  auto &btoa = pband->btoa;
36  Real alpha = pband->HasPar("alpha") ? pband->GetPar<Real>("alpha") : 0.;
37 
38  Real il = pmb->is;
39  Real iu = pmb->ie + 1;
40 
41  std::vector<Real> taut(iu + 1);
42 
43  // integrate from top to bottom
44  for (int m = 0; m < pband->GetNumOutgoingRays(); ++m) {
45  btoa(m, k, j) = 0.;
46  for (int n = 0; n < pband->GetNumSpecGrids(); ++n) {
47  taut[iu] = 0.;
48  toa(n, m) = 0.;
49  for (int i = iu - 1; i >= il; --i) {
50  taut[i] = taut[i + 1] + tau(n, i) / rayOutput[m].mu;
51  toa(n, m) +=
52  0.5 * (temf[i + 1] * exp(-taut[i + 1]) + temf[i] * exp(-taut[i])) *
53  tau(n, i) / rayOutput[m].mu;
54  }
55  toa(n, m) += temf[il] * exp(-taut[il]);
57  if ((alpha > 0) && (taut[il] < 1000.)) {
58  toa(n, m) += temf[il] * alpha * gammq(alpha, taut[il]) *
59  pow(taut[il], -alpha) * tgamma(alpha);
60  }
61  btoa(m, k, j) += spec[n].wght * toa(n, m);
62  }
63  }
64 }
T GetPar(std::string const &name) const
Get parameter.
bool HasPar(std::string const &name) const
Check if a parameter exists.
void CalBandFlux(MeshBlock const *pmb, int k, int j, int il, int iu) override
void CalBandRadiance(MeshBlock const *pmb, int k, int j) override
std::vector< Real > temf_
temperature at cell boundary (face)
size_t GetNumOutgoingRays()
Get number of outgoing rays.
std::shared_ptr< SpectralGridBase > pgrid_
spectral grid
AthenaArray< Real > toa_
spectral bin top-of-the-atmosphere radiance
AthenaArray< Real > btoa
band top-of-the-atmosphere radiance
AthenaArray< Real > tau_
spectral bin optical depth
size_t GetNumSpecGrids() const
Get number of spectral grids.
std::vector< Direction > rayOutput_
outgoing rays
double gammq(double a, double x)
Definition: gamma.c:82