RadLib
Loading...
Searching...
No Matches
rad_wsgg.cc
Go to the documentation of this file.
1
3
4#include <vector>
5#include <iostream>
6#include <cstdlib>
7#include <cmath>
8#include "rad_wsgg.h"
9
10using namespace std;
11
13
14const double rad_wsgg::cCoefs[100]={7.412956e-001, -5.244441e-001, 5.822860e-001, -2.096994e-001, 2.420312e-002,
15 -9.412652e-001, 2.799577e-001, -7.672319e-001, 3.204027e-001, -3.910174e-002,
16 8.531866e-001, 8.230754e-002, 5.289430e-001, -2.468463e-001, 3.109396e-002,
17 -3.342806e-001, 1.474987e-001, -4.160689e-001, 1.697627e-001, -2.040660e-002,
18 4.314362e-002, -6.886217e-002, 1.109773e-001, -4.208608e-002, 4.918817e-003,
19 1.552073e-001, -4.862117e-001, 3.668088e-001, -1.055508e-001, 1.058568e-002,
20 6.755648e-001, 1.409271e+000, -1.383449e+000, 4.575210e-001, -5.019760e-002,
21 -1.125394e+000, -5.913199e-001, 9.085441e-001, -3.334201e-001, 3.842361e-002,
22 6.040543e-001, -5.533854e-002, -1.733014e-001, 7.916083e-002, -9.893357e-003,
23 -1.105453e-001, 4.646634e-002, -1.612982e-003, -3.539835e-003, 6.121277e-004,
24 2.550242e-001, 3.805403e-001, -4.249709e-001, 1.429446e-001, -1.574075e-002,
25 -6.065428e-001, 3.494024e-001, 1.853509e-001, -1.013694e-001, 1.302441e-002,
26 8.123855e-001, -1.102009e+000, 4.046178e-001, -8.118223e-002, 6.298101e-003,
27 -4.532290e-001, 6.784475e-001, -3.432603e-001, 8.830883e-002, -8.415221e-003,
28 8.693093e-002, -1.306996e-001, 7.414464e-002, -2.029294e-002, 2.010969e-003,
29 -3.451994e-002, 2.656726e-001, -1.225365e-001, 3.001508e-002, -2.820525e-003,
30 4.112046e-001, -5.728350e-001, 2.924490e-001, -7.980766e-002, 7.996603e-003,
31 -5.055995e-001, 4.579559e-001, -2.616436e-001, 7.648413e-002, -7.908356e-003,
32 2.317509e-001, -1.656759e-001, 1.052608e-001, -3.219347e-002, 3.386965e-003,
33 -3.754908e-002, 2.295193e-002, -1.600472e-002, 5.046318e-003, -5.364326e-004};
34
35const double rad_wsgg::dCoefs[20]={3.404288e-002, 6.523048e-002, -4.636852e-002, 1.386835e-002, -1.444993e-003,
36 3.509457e-001, 7.465138e-001, -5.293090e-001, 1.594423e-001, -1.663261e-002,
37 4.570740e+000, 2.168067e+000, -1.498901e+000, 4.917165e-001, -5.429990e-002,
38 1.098169e+002, -5.092359e+001, 2.343236e+001, -5.163892e+000, 4.393889e-001};
39
40
41
42const double rad_wsgg::bco2[20]={ 8.425766e-001, -1.442229e+000, 1.286974e+000, -5.202712e-001, 7.581559e-002,
43 -3.023864e-002, 5.264245e-001, -6.209696e-001, 2.704755e-001, -4.090690e-002,
44 1.070243e-001, -1.989596e-001, 3.101602e-001, -1.737230e-001, 3.081180e-002,
45 3.108972e-002, 1.981489e-001, -2.543676e-001, 1.061331e-001, -1.498231e-002 };
46
47const double rad_wsgg::bh2o[20]={ 7.129509e-001, -1.378353e+000, 1.555028e+000, -6.636291e-001, 9.773674e-002,
48 1.589917e-001, 5.635578e-002, 2.666874e-001, -2.040335e-001, 3.742408e-002,
49 -1.196373e-001, 1.349665e+000, -1.544797e+000, 6.397595e-001, -9.153650e-002,
50 3.078250e-001, -6.003555e-001, 4.441261e-001, -1.468813e-001, 1.824702e-002 };
51
52const double rad_wsgg::kco2[5]={0.000000e+000, 3.388079e-002, 4.544269e-001, 4.680226e+000, 1.038439e+002};
53
54const double rad_wsgg::kh2o[5]={0.000000e+000, 7.703541e-002, 8.242941e-001, 6.854761e+000, 6.593653e+001};
55
92
93void rad_wsgg::get_k_a_oneband(double &kabs,
94 double &awts,
95 const int iband,
96 const double T_dmb,
97 const double P,
98 const double fvsoot,
99 const double xH2O,
100 const double xCO2,
101 const double xCO_not_used,
102 const double xCH4_not_used){
103
104 if(iband < 0 || iband >= nGGa) {
105 cerr << "\n\n***** rad_wsgg::get_k_a_oneband: iband out of range *****\n" << endl;
106 exit(0);
107 }
108
109 //------------------------
110
111 double Mr = xH2O/(xCO2+1E-10);
112 double MrOrig = Mr;
113 if(Mr < 0.01) Mr = 0.01;
114 if(Mr > 4.0) Mr = 4.0;
115 if(MrOrig > 1E8) MrOrig = 1E8;
116
117 double T = T_dmb;
118 //if(T<500) T = 500; // 500 is in the 2014 paper, but 300 is used in Fig. 2 of the 2020 paper.kjk0
119 if(T<300) T = 300;
120 if(T>2400) T = 2400;
121
122 double Tr = T/1200;
123
124 //--------------
125
126 const int ni = 4;
127 const int nj = 5;
128 const int nk = 5;
129
130 int off; // index offset
131
132 //------------- kabs
133
134 if(iband==0)
135 kabs = 0.0;
136 else{
137 off = (iband-1)*nk;
138 kabs = dCoefs[off+0] + Mr*(dCoefs[off+1] + Mr*(dCoefs[off+2] + Mr*(dCoefs[off+3] + Mr*(dCoefs[off+4]))));
139 kabs *= (P/101325)*(xH2O+xCO2);
140 }
141
142 //------------- awts
143
144 int njnk = nj*nk;
145 int injnk;
146 if(iband==0){
147 awts = 1.0;
148 vector<double> b(nj,0.0);
149 for(int i=0; i<ni; i++) {
150 injnk = i*njnk;
151 for(int j=0; j<nj; j++){
152 off = injnk + j*nk;
153 b[j] = cCoefs[off+0] + Mr*(cCoefs[off+1] + Mr*(cCoefs[off+2] + Mr*(cCoefs[off+3] + Mr*(cCoefs[off+4])))); // notationally, cCoefs terms are like cCoefs[i][j][k] where k is +0,+1,etc.
154 }
155 awts -= b[0] + Tr*(b[1] + Tr*(b[2] + Tr*(b[3] + Tr*(b[4]))));
156 }
157 }
158 else{
159 injnk = (iband-1)*njnk;
160 vector<double> b(nj,0.0);
161 for(int j=0; j<nj; j++){
162 off = injnk + j*nk;
163 b[j] = cCoefs[off+0] + Mr*(cCoefs[off+1] + Mr*(cCoefs[off+2] + Mr*(cCoefs[off+3] + Mr*(cCoefs[off+4])))); // notationally, cCoefs terms are like cCoefs[i][j][k] where k is +0,+1,etc.
164 }
165 awts = b[0] + Tr*(b[1] + Tr*(b[2] + Tr*(b[3] + Tr*(b[4]))));
166 }
167
168 //------------- if Mr < 0.01 linear interp k, a between those bounds and the pure component
169
170 if(MrOrig < 0.01){ // High CO2 low H2O
171
172 double f = (0.01-MrOrig)/0.01; // convenience variable
173 double pfac = P/101325*xCO2;
174
175 //---------- kabs
176
177 kabs = kco2[iband]*pfac*(f) + kabs*(1.0-f);
178
179 //---------- awts
180
181 double aco2;
182 if(iband==0){
183 aco2 = 1.0;
184 for(int i=1; i<nGGa; i++){
185 off = nj*(i-1);
186 aco2 -= bco2[off+0] + Tr*(bco2[off+1] + Tr*(bco2[off+2] + Tr*(bco2[off+3] + Tr*(bco2[off+4]))));
187 }
188 }
189 else{
190 off = nj*(iband-1);
191 aco2 = bco2[off+0] + Tr*(bco2[off+1] + Tr*(bco2[off+2] + Tr*(bco2[off+3] + Tr*(bco2[off+4]))));
192 }
193 awts = aco2*(f) + awts*(1.0-f);
194 }
195
196 //------------- if Mr > 0.4, linear interp k, a between those bounds and the pure component
197
198 if(MrOrig > 4.0){ // High H2O low CO2
199
200 double f = (1E8-MrOrig)/(1E8-4.0); // convenience variable
201 double pfac = P/101325*xH2O;
202
203 //---------- kabs
204
205 kabs = kabs*(f) + kh2o[iband]*pfac*(1.0-f);
206
207 //---------- awts
208
209 double ah2o;
210 if(iband==0){
211 ah2o = 1.0;
212 for(int i=1; i<nGGa; i++){
213 off = nj*(i-1);
214 ah2o -= bh2o[off+0] + Tr*(bh2o[off+1] + Tr*(bh2o[off+2] + Tr*(bh2o[off+3] + Tr*(bh2o[off+4]))));
215 }
216 }
217 else{
218 off = nj*(iband-1);
219 ah2o = bh2o[off+0] + Tr*(bh2o[off+1] + Tr*(bh2o[off+2] + Tr*(bh2o[off+3] + Tr*(bh2o[off+4]))));
220 }
221 awts = awts*(f) + ah2o*(1.0-f);
222 }
223
224 //--------------------- soot contribution: add ksoot to all gases including the clear gas
225
226 if(fvsoot > 0.0){
227 double ksoot= 1817 * fvsoot*T; // 1817 = 3.72*csoot/C2.
228 kabs += ksoot;
229 }
230
231 return;
232}
233
269
270void rad_wsgg::get_k_a(vector<double> &kabs,
271 vector<double> &awts,
272 const double T_dmb,
273 const double P,
274 const double fvsoot,
275 const double xH2O,
276 const double xCO2,
277 const double xCO_not_used,
278 const double xCH4_not_used){
279
280 //------------------------
281
282
283 kabs.resize(nGGa);
284 awts.resize(nGGa);
285
286 double k, a;
287 for(int i=0; i<nGGa; i++){
288 get_k_a_oneband(k, a, i, T_dmb, P, fvsoot, xH2O, xCO2, xCO_not_used, xCH4_not_used);
289 kabs[i] = k;
290 awts[i] = a;
291 }
292
293 return;
294}
static const double dCoefs[]
Definition rad_wsgg.h:35
void get_k_a(std::vector< double > &kabs, std::vector< double > &awts, const double T_dmb, const double P, const double fvsoot, const double xH2O, const double xCO2, const double xCO_not_used, const double xCH4_not_used)
‍absorption coefficients for pure h2o (size 5 = nGGa)
Definition rad_wsgg.cc:270
static const double bh2o[]
‍map to [i,j] of size ni,nj = 4,5
Definition rad_wsgg.h:47
void get_k_a_oneband(double &kabs, double &awts, const int iband, const double T, const double P, const double fvsoot, const double xH2O, const double xCO2, const double xCO_not_used, const double xCH4_not_used)
Definition rad_wsgg.cc:93
static const double kco2[]
‍map to [i,j] of size ni,nj = 4,5
Definition rad_wsgg.h:52
static const double cCoefs[]
map to [i,j,k] of size ni,nj,nk = 4,5,5
Definition rad_wsgg.h:14
static const double bco2[]
‍map to [i,k] of size ni,nk = 4,5
Definition rad_wsgg.h:42
static const double kh2o[]
‍absorption coefficients for pure co2 (size 5 = nGGa)
Definition rad_wsgg.h:54
int nGGa
number of grey gases including the clear gas
Definition rad.h:32
Header file for child class rad_wsgg.