LandscapeDNDC 1.37.0
mc_canoak.h
1
12#ifndef M1D_MOD_MICROCLIMATE_CANOAK_H
13#define M1D_MOD_MICROCLIMATE_CANOAK_H
14
15#define WCC_FLEX 2
16#define sze Site::MAX_FOLIAGE_LAYER + WCC_FLEX // canopy layers is 40 with flex
17#define sze3 3 * Site::MAX_FOLIAGE_LAYER + WCC_FLEX // 3 times canopy layers is 120 with flex
18#define szeang 18 + 1 // number of sky angle classes is 18 with flex ( [sk] flex suddenly 1?)
19// sk:replaced with soil_layer_cnt() #define soilsze 12 // number of soil layers is 10 [100?] with flex
20
21#include "microclimatemodule.h"
22
23#include "site.h"
24#include "global/global.h"
25
26class LClock;
27
28class InputClassSet;
29class Setup;
30class Site;
31class SiteParameters;
32class SoilLayers;
33class Species;
34
35class State;
36class AirChemistry;
37class Physiology;
38class SoilChemistry;
39class VegStructure;
40class WaterCycle;
41
42namespace ldndc { class config_file_t; }
43
44
45
46class MicroClimateCANOAK : public MicroClimateModuleBase {
47 LDNDC_MODULE_NAME("microclimate:canoak")
48 public:
49 MicroClimateCANOAK(
50 State const &,
51 InputClassSet const &,
52 LClock const &,
53 unsigned int);
54
55 ~MicroClimateCANOAK();
56
57
58 lerr_t configure( ldndc::config_file_t const &) { return LDNDC_ERR_OK; }
59
60 lerr_t initialize();
61
62 lerr_t solve();
63
64 lerr_t finalize() { return LDNDC_ERR_OK; }
65
66
67 private:
68 LClock const & time_;
69
70 Setup const & se_;
71 Site const & si_;
72 SiteParameters const & sipar_;
73 SoilLayers const & sl_;
74 Species const & sp_;
75
76 AirChemistry const & ac_;
77 Physiology const & ph_;
78 SoilChemistry const & sc_;
79 VegStructure const & vs_;
80 WaterCycle const & wc_;
81
82
83 private:
84 /* vapor pressure (Pa) */
85 double * vpd_layer;
86 /* fine root distribution */
87 double * fFrt_sl;
88 /* soil water field capacity */
89 double * watmax;
90 /* soil water wilting point */
91 double * watmin;
92
93 double * dispersion_;
94
95 double WM2_IN_JCM2;
96
97 // structure for input variables
98 struct input_variables {
99 int dayy; // day
100 // rg int hhrr; // hour
101 double hhrr; // hour
102 double ta; // air temperature, C
103 double rglobal; // global radiation, W m-2
104 double parin; // photosynthetically active radiation, micromole m-2 s-1
105 double pardif; // diffuse PAR, micromol m-2 s-1
106 double ea; // vapor pressure, kPa
107 double wnd; // wind speed, m s-1
108 double ppt; // precipitation, mm per hour
109 double co2air; // CO2 concentration, ppm
110 double press_mb; // air pressure, mb
111 double tsoil; // soil temperature in 50 cm, degree C
112 double soilmoisture;// soil moisture in 15 cm, %
113 //rg long int flag; // input coding
114 };
115
116 // structure for time variables
117 struct time_variables {
118 double local_time;
119 long int daytime; // day+hour coding, e.g. 1230830
120 int year; // year
121 int days; // day
122 //rg int jdold; // previous day (only needed for calculating averages in the original code)
123 //rg int fileyear; // year for filenames
124 //rg int filestart; // time for filestart
125 //rg int count; // number of iterations
126 //rg int leafout; // day of leaf out
127 //rg int fulleaf; // date of full leaf
128 double lai; // lai as a function of time
129 };
130
131 // water, carbon and energy exchange
132 struct flux_variables {
133 double photosyn; // photosynthesis, um m-2 s-1
134 double nee; // net ecosystem exchange, umol m-2 s-1
135 double potevap; // potential evaporation, mm m-2 s-1 // rg
136 double transp; // canopy transpiration, mm m-2 s-1
137 double soilevap; // soil evaporation, mm m-2 s-1
138 double canopyevap; // canopy evaporation, mm m-2 s-1
139 double through; // throughfall = water flux into soil, mm m-2 s-1
140 double surfrun; // surface runoff = water flux lateral to surface, mm m-2 s-1
141
142 flux_variables ()
143 {
144 photosyn = 0.0;
145 nee = 0.0;
146 potevap = 0.0;
147 transp = 0.0;
148 soilevap = 0.0;
149 canopyevap = 0.0;
150 through = 0.0;
151 surfrun = 0.0;
152 }
153 };
154
155 // structure for meteorological variables
156 struct meteorology {
157 double ustar; // friction velocity, m s-1
158 double ustarnew; // updated friction velocity with new H, m s-1
159 double rhova_g; // absolute humidity, g m-3
160 double rhova_kg; // absolute humidity, kg m-3
161 double sensible_heat_flux; // sensible heat flux, W M-2
162 //rg double H_old; // old sensible heat flux, W m-2 (replaced with new static variable)
163 double air_density; // air density, kg m-3
164 double T_Kelvin; // absolute air temperature, K
165 double dispersion[sze3][sze]; // Lagrangian dispersion matrix, s m-1
166 double zl; // z over L, height normalized by the Obukhov length
167 double press_kpa; // station pressure, kPa
168 double press_bars; // station pressure, bars
169 double press_Pa; // pressure, Pa
170 double pstat273; // gas constant computations
171 double air_density_mole; // air density, mole m-3
172 double relative_humidity; // relative humidity
173
174 meteorology ()
175 {
176 ustar = 0.0;
177 ustarnew = 0.0;
178 rhova_g = 0.0;
179 rhova_kg = 0.0;
180 sensible_heat_flux = 0.0;
181 air_density = 0.0;
182 T_Kelvin = 0.0;
183 zl = 0.0;
184 press_kpa = 0.0;
185 press_bars = 0.0;
186 press_Pa = 0.0;
187 pstat273 = 0.0;
188 air_density_mole = 0.0;
189 relative_humidity = 0.0;
190 }
191 };
192
193 // structure for surface resistances and conductances
194 struct surface_resistances {
195 double gcut; // cuticle conductances, mol m-2 s-1
196 double kballstr; // drought factor to Ball Berry Coefficient
197 double rcuticle; // cuticle resistance, m2 s mol-1
198 };
199
200 // structure for plant and physical factors
201 struct factors {
202 double latent; // latent heat of vaporization, J kg-1
203 double latent18; // latent heat of vaporization times molecular mass of vapor, 18 g mol-1
204 double heatcoef; // factor for sensible heat flux density
205 double a_filt; // filter coefficients
206 double b_filt; // filter coefficients
207 double co2; // CO2 factor, ma/mc * rhoa (mole m-3)
208 };
209
210 // structure for bole respiration and structure
211 struct bole_respiration_structure {
212 double factor; // base respiration, micromoles m-2 s-1, data from Edwards
213 double respiration_mole; // bole respiration, micromol m-2 s-1
214 double respiration_mg; // bole respiration, mg CO2 m-2 s-1
215 double calc; // calculation factor
216 double layer[sze]; // bole pai per layer
217 };
218
219 // structure for canopy architecture
220 struct canopy_architecture {
221 //rg?? double bdens[soilsze]; // probability density of leaf angle
222 double bdens[10]; // probability density of leaf angle
223 };
224
225 // structure for non dimensional variables
226 struct non_dimensional_variables {
227 // Prandtl Number
228 double pr;
229 double pr33;
230 // Schmidt number for vapor
231 double sc;
232 double sc33;
233 // Schmidt number for CO2
234 double scc;
235 double scc33;
236 // Schmidt number for ozone
237 double sco3;
238 double sco333;
239 // Grasshof number
240 double grasshof;
241 // multiplication factors with leaf length and diffusivity
242 double lfddv;
243 double lfddh;
244 };
245
246 // boundary layer resistances
247 struct boundary_layer_resistances {
248 double vapor; // resistance for water vapor, s/m
249 double heat; // resistance for heat, s/m
250 double co2; // resistance for CO2, s/m
251
252 boundary_layer_resistances ()
253 {
254 vapor = 0.0;
255 heat = 0.0;
256 co2 = 0.0;
257 }
258 };
259
260 struct other_globals {
261 // Parameter are here set on default values (plus for gloabl definition).
262 // Later new parameters are read in from canisotope_param.txt in read_paramter()
263 //rg double parameter[250];// declare parameter array that will be read in from canisotope_param.txt in read_paramter()
264 //rg char parameter_string[5][256];
265 double paraopt[31]; //rg
266
267 // canopy structure variables
268 //rg double ht = 33.0;//changed: Canopy height
269 //rg double lai = 6.4;//changed: original lai=6.0 Leaf area index
270 int jtot;//=40; // number of canopy layers
271 int jktot;//=41; // jtot + 1
272 int jtot3;//=120; // number of layers in the domain, three times canopy height
273 int izref;//=52; // changed: array value of reference ht at 43 m, jtot/ht
274
275 double hm; // canopy height
276 double laiT; // potential leaf area index during the year
277 double pai;// = 1.4; // changed: plant area index
278 double vcopt;// = 66.3; // changed: original: 70, carboxylation rate at optimal temperature, umol m-2 s-1
279 double jmopt;// = 127.5; // changed: original: 170, electron transport rate at optimal temperature, umol m-2 s-1
280 double rd25;// = 0.34; // changed: new: 1.91 original: 0.34, dark respiration at 25 C, rd25= 0.34 umol m-2 s-1
281 double ustar_ref;//=1.00; // reference ustar for Dij
282
283 double delz;// = 0.825; // changed: height of each layer, ht/jtot
284 double zh65;//=0.019697; // changed: 0.65/ht
285
286 // Consts for Photosynthesis model and kinetic equations for Vcmax and Jmax.
287 // Taken from Harley and Baldocchi (1995, PCE)
288 double hkin;// = 200000.0; // enthalpy term
289 double skin;// = 710.0; // entropy term
290 double ejm;// = 55000.0; // activation energy for electron transport
291 double evc;// = 55000.0; // activation energy for carboxylation
292
293 // Enzyme constants & partial pressure of O2 and CO2 Michaelis-Menten K values.
294 // From survey of literature.
295 double kc25;// = 274.6; // kinetic coef for CO2 at 25 C, microbars
296 double ko25;// = 419.8; // kinetic coef for O2 at 25C, millibars
297 double o2;// = 210.0; // oxygen concentration umol mol-1
298
299 /* tau is computed on the basis of the Specificity factor (102.33)
300 times Kco2/Kh2o (28.38) to convert for value in solutiont to that based in air
301 The old value was 2321.1. */
302 double tau25;// = 2904.12; // New value for Quercus robor from Balaguer et al. 1996
303
304 // Arrhenius constants
305 // Eact for Michaelis-Menten const. for KC, KO and dark respiration
306 // These values are from Harley
307 double ekc;// = 80500.0; // Activation energy for K of CO2; J mol-1
308 double eko;// = 14500.0; // Activation energy for K of O2
309 double erd;// = 38000.0; // activation energy for dark respiration, eg Q10=2
310 double ektau;// = -29000.0;
311 double toptvc;// = 311.0; // optimum temperature for maximum carboxylation
312 double toptjm;// = 311.0; // optimum temperature for maximum electron transport
313 double eabole;// = 45162; // activation energy for bole respiration for Q10 = 2.02
314
315 // leaf energy balance
316 double ep;// = 0.98; // emissivity of leaves
317 double epm1;// = 0.02; // 1- ep
318 double epsoil;// = 0.98; // Emissivity of soil
319 double epsigma;// = 5.5566e-8; // ep*sigma
320 double epsigma2;// = 11.1132e-8; // 2.0 * ep * sigma
321 double epsigma4;// = 22.2264e-8; // 4.0 * ep * sigma
322 double epsigma6;// = 33.3396e-8; // 6.0 * ep * sigma
323 double epsigma8;// = 44.448e-8; // 8.0 * ep * sigma
324 double epsigma12;//= 66.6792e-8; // 12.0 * ep * sigma
325 double betfact;// = 1.5; // multiplication factor for aerodynamic sheltering, based on work by Grace and Wilson
326
327 // Ball-Berry stomatal coefficient for stomatal conductance
328 double kball;// = 9.5;
329
330 // intercept of Ball-Berry model, mol m-2 s-1
331 double bprime;// = 0.0175; // intercept for H2O
332 double bprime16;// = bprime/1.577; // 0.0109375; ntercept for CO2, bprime16 = bprime / 1.577;
333
334 // Minimum stomatal resistance, s m-1.
335 double rsm;// = 145.0;
336 double brs;// = 60.0; // curvature coeffient for light response
337
338 // leaf quantum yield, electrons
339 double qalpha;// = 0.22;
340 double qalpha2;// = 0.0484; // qalpha squared, qalpha2 = pow(qalpha, 2.0);
341
342 // leaf clumping factor
343 double markov;// = 0.84;
344
345 // Leaf dimension. geometric mean of length and width (m)
346 double lleaf;// = 0.1; // leaf length, m
347
348 // geografical parameters
349 double latitude;//51.07; // changed 51 degree 04'45,14'' N, latitude
350 double longitude;//10.45; // changed 10 degree 27'07,83'' E, longitude
351 double zone;//-1.0; // changed, minus one hour delay from GMT
352
353 // soil parameters
354 size_t n_soil;// = 10; // number of soil layers
355 double z_litter; // depth of litter layer
356 double density_litter; // bulk density of litter
357 double density_soil;// = 1.33; // bulk density of soil
358
359 // general Parameters
360
361 // physical parameters
362 double PI; // pi
363 double PI180; // pi divided by 180, radians per degree
364 double PI2; // 2 times pi
365 double PI9; // 0.9 times pi
366
367 // Universal constants
368 double rugc; // universal gas constant (J mole-1 K-1)
369 double rgc1000; // gas constant times 1000.
370 double dtk; // degree Kelvin at 0 degree centigrade
371
372 // Constants for leaf energy balance
373 double sigma; // Stefan-Boltzmann constant W M-2 K-4
374 double cp; // specific heat of air, J KG-1 K-1
375 double mass_air; // molecular mass of dry air, g mole-1
376 double mass_CO2; // molecular mass of CO2, g mole-1
377 double mass_13CO2; // molecular mass of 13CO2, g mole-1
378 double fumol; // conversion factor from Watt in umol PAR (Cox et al. 1998: 4.57) // rg
379 double fpar; // conversion factor for global into PA-radiation (Monteith 1965, Meek et al. 1984)
380
381 // Diffusivity values for 273 K and 1013 mb (STP) using values from Massman (1998) Atmos Environment
382 // These values are for diffusion in air. When used these values must be adjusted for
383 // temperature and pressure
384 // nu, Molecular viscosity
385 double nuvisc; // mm2 s-1
386 double nnu; // m2 s-1
387
388 // Diffusivity of CO2
389 double dc; // mm2 s-1
390 double ddc; // m2 s-1
391
392 // Diffusivity of heat
393 double dh; // mm2 s-1
394 double ddh; // m2 s-1
395
396 // Diffusivity of water vapor
397 double dv; // mm2 s-1
398 double ddv; // m2 s-1
399
400 // Diffusivity of ozone
401 double do3; // mm2 s-1
402 double ddo3; // m2 s-1
403
404 // Diffusivity of 13CO2
405 // Isotope ratio of PeeDee Belimdite standard (PDB)
406 // redefined as 13C/(12C+13C) for PDB, Tans et al 93
407 double Rpdb_CO2;
408
409 // Isotope ratio of PeeDee Belimdite standard (PDB)
410 // defined as 13C/12C, from Farquhar
411 double Rpdb_12C;
412
413 // Start and End of model run in year, format dddhhmm
414 /* rg: not needed
415 long start_run = 0000000;//start on doy 000 at 0000 hours
416 long end_run = 3660000;//end on doy 366 at 0000 hours
417 long start_profiles = 1400000;//start model profiles on doy 140 at 0000 hours
418 long end_profiles = 1450000;//end model profiles on doy 145 at 0000 hours
419 */
420
421 other_globals ()
422 {
423 PI = cbm::PI; // pi
424 PI180 = cbm::PI / 180.0; // pi divided by 180, radians per degree
425 PI2 = 2.0 * cbm::PI; // 2 times pi
426 PI9 = 0.9 * cbm::PI; // 0.9 times pi
427
428 // Universal constants
429 rugc = cbm::RGAS; // universal gas constant (J mole-1 K-1)
430 rgc1000 = 1000.0 * cbm::RGAS; // gas constant times 1000.
431 dtk = cbm::D_IN_K; // degree Kelvin at 0 degree centigrade
432
433 // Constants for leaf energy balance
434 sigma = 5.67e-08; // Stefan-Boltzmann constant W M-2 K-4
435 cp = 1005.; // specific heat of air, J KG-1 K-1
436 mass_air = 28.97; // molecular mass of dry air, g mole-1
437 mass_CO2 = 44.; // molecular mass of CO2, g mole-1
438 mass_13CO2 = 45.; // molecular mass of 13CO2, g mole-1
439 fumol = 4.57; // conversion factor from Watt in umol PAR (Cox et al. 1998: 4.57) // rg
440 fpar = 0.45; // conversion factor for global into PA-radiation (Monteith 1965, Meek et al. 1984)
441
442 // Diffusivity values for 273 K and 1013 mb (STP) using values from Massman (1998) Atmos Environment
443 // These values are for diffusion in air. When used these values must be adjusted for
444 // temperature and pressure
445 // nu, Molecular viscosity
446 nuvisc = 13.27; // mm2 s-1
447 nnu = 0.00001327; // m2 s-1
448
449 // Diffusivity of CO2
450 dc = 13.81; // mm2 s-1
451 ddc = 0.00001381; // m2 s-1
452
453 // Diffusivity of heat
454 dh = 18.69; // mm2 s-1
455 ddh = 0.00001869; // m2 s-1
456
457 // Diffusivity of water vapor
458 dv = 21.78; // mm2 s-1
459 ddv = 0.00002178; // m2 s-1
460
461 // Diffusivity of ozone
462 do3 = 14.44; // mm2 s-1
463 ddo3 = 0.00001444; // m2 s-1
464
465 // Diffusivity of 13CO2
466 // Isotope ratio of PeeDee Belimdite standard (PDB)
467 // redefined as 13C/(12C+13C) for PDB, Tans et al 93
468 Rpdb_CO2 = 0.01115;
469
470 // Isotope ratio of PeeDee Belimdite standard (PDB)
471 // defined as 13C/12C, from Farquhar
472 Rpdb_12C = 0.01124;
473 }
474 };
475
476
477 // radiation variables, visible, near infrared and infrared
478 struct solar_radiation_variables {
479 // profiles of the probabilities of sun and shade leaves
480 double prob_beam[sze]; // probability of beam or sunlit fraction
481 double prob_sh[sze]; // probability of shade
482 double ir_dn[sze]; // downward directed infrared radiation, W m-2
483 double ir_up[sze]; // upward directed infrared radiation. W m-2
484 // inputs of near infrared radiation and components, W m-2
485 double nir_beam; // incoming beam component near infrared radiation, W m-2
486 double nir_diffuse; // incoming diffuse component near infrared radiation, W m-2
487 double nir_total; // incoming total near infrared radiaion, W m-2
488 // computed profiles of near infrared radiation, W m-2
489 double nir_dn[sze]; // downward scattered near infrared radiation
490 double nir_up[sze]; // upward scattered near infrared radiation
491 double nir_sun[sze]; // near infrared radiation on sunlit fraction of layer
492 double nir_sh[sze]; // near infrared radiation on shaded fraction of layer
493 double beam_flux_nir[sze]; // flux density of direct near infrared radiation
494 // leaf and soil optical properities of near infrared radiation
495 double nir_reflect; // leaf reflectance in the near infrared
496 double nir_trans; // leaf transmittance in the near infrared
497 double nir_soil_refl; // soil reflectance in the near infrared
498 double nir_absorbed; // leaf absorptance in the near infrared
499 // inputs of visible light, PAR, W m-2
500 double par_diffuse; // diffuse component of incoming PAR, parin
501 double par_beam; // beam component of incoming PAR, parin
502 // computed profiles of visible radiation, PAR, W m-2
503 double par_shade[sze]; // PAR on shaded fraction of layer
504 double par_sun[sze]; // PAR on sunlit fraction of layer, beam and diffuse
505 double beam_flux_par[sze]; // PAR in the beam component
506 double par_down[sze]; // downward scattered PAR
507 double par_up[sze]; // upward scattered PAR
508 // flux densities of visible quanta on sun and shade leaves for photosynthesis calculations, micromoles m-2 s-1
509 double quantum_sun[sze]; // par on sunlit leaves
510 double quantum_sh[sze]; // par on shaded leaves
511 // optical properties of leaves and soil for PAR
512 double par_absorbed; // PAR leaf absorptance
513 double par_reflect; // PAR leaf reflectance
514 double par_trans; // PAR leaf transmittance
515 double par_soil_refl; // PAR soil reflectance
516 // Net radiation profiles, W m-2
517 double rnet_sun[sze]; // net radiation flux density on sunlit fraction of layer
518 double rnet_sh[sze]; // net radiation flux density on shade fraction of layer
519
520 double exxpdir[sze]; // exponential transmittance of diffuse radiation through a layer
521 double beta_rad; // solar elevation angle, radians
522 double sine_beta; // sine of beta
523 double beta_deg; // solar elevation angle, degrees
524 double ratrad; // radiation ratio to detect cloud amount
525 double ratradnoon; // radiation ratio at noon for guestimating cloud amount at night
526
527 solar_radiation_variables ()
528 {
529 nir_beam = 0.0;
530 nir_diffuse = 0.0;
531 nir_total = 0.0;
532 nir_reflect = 0.0;
533 nir_trans = 0.0;
534 nir_soil_refl = 0.0;
535 nir_absorbed = 0.0;
536 par_diffuse = 0.0;
537 par_beam = 0.0;
538 par_absorbed = 0.0;
539 par_reflect = 0.0;
540 par_trans = 0.0;
541 par_soil_refl = 0.0;
542 beta_rad = 0.0;
543 sine_beta = 0.0;
544 beta_deg = 0.0;
545 ratrad = 0.0;
546 ratradnoon = 0.0;
547
548 for (int n1 = 0; n1 <= sze; n1++){
549 prob_beam[n1] = 0.0;
550 prob_sh[n1] = 0.0 ;
551 ir_dn[n1] = 0.0;
552 ir_up[n1] = 0.0;
553 nir_dn[n1] = 0.0;
554 nir_up[n1] = 0.0;
555 nir_sun[n1] = 0.0;
556 nir_sh[n1] = 0.0;
557 beam_flux_nir[n1] = 0.0;
558 par_shade[n1] = 0.0;
559 par_sun[n1] = 0.0;
560 beam_flux_par[n1] = 0.0;
561 par_down[n1] = 0.0;
562 par_up[n1] = 0.0;
563 rnet_sun[n1] = 0.0;
564 rnet_sh[n1] = 0.0;
565 exxpdir[n1] = 0.0;
566 }
567 }
568 };
569
570 // physical properties of soil abd soil energy balance variables
571 struct soil_variables {
572 // soil properties
573 double * z_soil; // depth increments of soil layers
574 double * bulk_density; // bulk density of soil
575 double * T_soilIni; // initial soil temperature
576 double * T_soil; // soil temperature
577 double * k_conductivity_soil; // thermal conductivity of soil *dz
578 double * k_conductivity_soil_norm; // thermal conductivity of soil
579 double * cp_soil; // specific heat of soil layer (J m-2 K-1)
580 double * cp_soil_norm; // specific heat of soil (J m-3 K-1)
581 double T_Kelvin; // soil surface temperature in Kelvin
582 double T_air; // air temperature above soil, C
583 double sfc_temperature; // soil surface temperature in C
584 double Temp_ref; // reference soil temperature, annual mean, C
585 double Temp_amp; // amplitude of soil temperature, C
586 double resistance_h2o; // soil resistance for water vapor
587 //rg double water_content_sfc; // volumetric water content of soil surface
588 double water_content_15cm; // vol water content of 15 cm soil layer
589 double water_content_litter; // vol water content of litter
590 double * water_content;// vol water content of litter
591 double T_base; // base soil temperature
592 double T_15cm; // soil temperature at 15 cm
593 double amplitude; // amplitude of soil temperature cycle
594 double clay_fraction; // clay fraction
595 // soil energy flux densities, W m-2
596 double lout; // longwave efflux from soil
597 double evap; // soil evaporation
598 double heat; // soil sensible heat flux density
599 double rnet; // net radiation budget of the soil
600 double gsoil; // soil heat flux density
601 // soil CO2 respiratory efflux
602 double respiration_mole; // soil respiration, micromol m-2 s-1
603 double respiration_mg; // soil respiration, mg CO2 m-2 s-1
604 double base_respiration; // base rate of soil respiration, micromol m-2 s-1
605 double resp_13; // respiration of 13C micromole m-2 s-1
606 double SR_ref_temp; // refernce temperature for soil respiration, degC
607 double dtsoi; // time step for water balance calculations, s
608 double dtbal; // time step for energy balance calculations, s
609 long int mtime; // number of time steps for energy balance calculatoin per outer time step
610 // from LSM
611 double * swp; //soil water potential (kPa)
612 double * swp_mm; //soil water potential (mm)
613 double * r;
614 double * a;
615 double * b;
616 double * c;
617 double * dwat;
618 double * watmin; //minimum volumetric soil water content // rg
619 double * watsat; //saturated volumetric soil water content (porosity)
620 double * smpsat; //soil matrix potential at saturation (mm)
621 double * bch; //clapp and hornberger "b"
622 double * hksat; //hydraulic conductivity at saturation (mm h2o/s)
623 double * root; //relative root abundance (0 to 1)
624 double * h2osoi; //volumetric soil water content
625 double qdrai; //sub-surface runoff (mm h2o s-1)
626 double qinfl; //infiltration rate, mm h2o s-1
627 double * clay; //clay fraction in each layer
628 double * sand; //sand fraction in each layer
629 double soil_mm; //water content in the soil, mm m-2
630 double qtran; //plant transpiration, mm s-1
631 double * qin; //water input into each layer, mm s-1
632 double * qout; //water output from each layer, mm s-1
633
634 soil_variables( size_t _soil_layer_cnt);
635
636 ~soil_variables();
637 };
638
639 // Structure for Profile information,fluxes and concentrations
640 struct profile {
641 // microclimate profiles
642 double tair[sze3]; // air temp (C)
643 double tair_filter[sze3]; // numerical filter of Tair
644 double u[sze3]; // wind speed (m/s)
645 double rhov_air[sze3]; // water vapor density
646 double rhov_filter[sze3]; // numerical filter of rhov_air
647 double co2_air[sze3]; // co2 concentration (ppm)
648 // canopy structure profiles
649 double dLAIdz[sze]; // leaf area index of layer (m2/m2)
650 double ht[sze]; // layer height (m)
651 double dPAIdz[sze]; // plant area index of layer
652 double Gfunc_solar[sze]; // leaf-sun direction cosine function
653 double Gfunc_sky[sze][szeang]; // leaf-sky sector direction cosine function
654 double tleaf[sze]; // leaf temperature per layer (sun and shade)
655 double isopreneflux[sze]; // isoprene flux per layer (sun and shade)
656 double vcmax[sze]; // vcmax in per layer
657 double jmax[sze]; // jmax per layer
658 double rd[sze]; // rd per layer
659 // variables for 13C isotopes
660 double c13cnc[sze3]; // concentration of 13C
661 double c12cnc[sze3]; // concentration of 12C
662 double sour13co2[sze]; // source/sink strength 13C
663 double d13C[sze3]; // del 13C
664 double D13C[sze]; // photosynthetic weighted discrimination, 13D
665 double D13C_long[sze]; // photosynthetic weighted discrimination, 13D
666 double d13Cair[sze3]; // del 13C of the air
667 double d13Cplant[sze]; // del 13C of the plant
668 double R13_12_air[sze3]; // 13C/12C ratio of the air
669 double Rplant_sun[sze]; // ratio of discriminated 13C in sunlit leaves
670 double Rplant_shd[sze]; // ratio of discriminated 13C in shaded leaves
671 double Rresp[sze]; // discriminated 13C for later respiration, Ps weight
672 double Rresp_sum[sze]; // summing of Ps weighted values for daily ave
673 double Rresp_ave[sze]; // previous days discriminated 13C for later respiration
674 int cnt_Rresp[sze];
675 double recycle[sze3]; // fraction of recycled CO2, after Yakir and Sternberg
676 // source/sink strengths
677 double source_co2[sze]; // source/sink strength of CO2
678 // fluxes for total layer, with sun/shade fractions
679 double dPsdz_mg[sze]; // layer photosynthesis (mg layer-1 s-1)
680 double dPsdz[sze]; // layer photosynthesis (umol layer-1 s-1)
681 double dHdz[sze]; // layer sensible heat flux
682 double dLEdz[sze]; // layer latent heat flux
683 double dRNdz[sze]; // layer net radiation flux
684 double dRESPdz[sze]; // layer respiration
685 double dStomCondz[sze]; // layer stomatal conductance
686 // sun leaf variables
687 double sun_frac[sze]; // sun leaf fraction
688 double sun_tleaf[sze]; // leaf temp (C)
689 double sun_A[sze]; // layer A flux for sun only (umol m-2 s-1)
690 double sun_gs[sze]; // stomatal conductance (m s-1)
691 double sun_rs[sze]; // stomatal resistance to H2O (s/m)
692 double sun_rbh[sze]; // boundary layer resistance to heat (s/m)
693 double sun_rbv[sze]; // boundary layer resistance to H2O (s/m)
694 double sun_rbco2[sze]; // boundary layer resistance to CO2 (s/m)
695 double sun_cs[sze]; // Cs on sun leaves (CO2 mixing ratio on leaf surface
696 double sun_ci[sze]; // Ci on sun leaves
697 double sun_cc[sze]; // Cc (CO2 mixing ratio at site of carboxylation) on sun leaves
698 double sun_D13[sze]; // discrimination 13C
699 double sun_D13_long[sze]; // discrimination 13C
700 double sun_ccca[sze]; // Cc/Ca on sunlit leaves
701 double sun_cica[sze]; // Ci/Ca on sunlit leaves
702 double sun_lai[sze]; // sunlit lai of layer
703 double sun_T_filter[sze]; // filtered sunlit temperature
704 double sun_wj[sze]; // electron transport rate of Ps for sun leaves
705 double sun_wc[sze]; // carboxylatio velocity for sun leaves
706 double sun_resp[sze]; // respiration
707 double sun_isopreneflux[sze];// isoprene flux per layer for sunleaves
708 double iso_sun[sze]; // isoprene flux per leaf area in the sun
709 // shade leaf variables
710 double shd_frac[sze]; // shade leaf fraction
711 double shd_tleaf[sze]; // temperature of shaded leaves
712 double shd_A[sze]; // photosynthesis of shaded leaves
713 double shd_gs[sze]; // stomatal conductance of shade leaves
714 double shd_rs[sze]; // stomatal resistance of shaded leaves
715 double shd_rbh[sze]; // boundary layer resistance for heat on shade leaves
716 double shd_rbv[sze]; // boundary layer resistance for vapor on shade leaves
717 double shd_rbco2[sze]; // boundary layer resistance for CO2 on shade leaves
718 double shd_cs[sze]; // Cs on shade leaves (CO2 mixing ratio on leaf surface
719 double shd_ci[sze]; // Ci on shade leaves
720 double shd_cc[sze]; // Cc (CO2 mixing ratio at site of carboxylation) on sun leaves
721 double shd_D13[sze]; // del 13C on shaded leaves
722 double shd_D13_long[sze]; // discrimination 13C
723 double shd_ccca[sze]; // Cc/Ca ratio on shaded leaves
724 double shd_cica[sze]; // Ci/Ca ratio on shaded leaves
725 double shd_lai[sze]; // shaded lai of layer
726 double shd_T_filter[sze]; // previous temperature
727 double shd_wc[sze]; // carboxylation rate for shade leaves
728 double shd_wj[sze]; // electron transport rate for shade leaves
729 double shd_resp[sze]; // respiration
730 double shd_isopreneflux[sze];// isoprene flux per layer for shade leaves
731 double iso_shd[sze]; // isoprene flux per leaf area in the shade
732
733 profile ()
734 {
735 for (int n0 = 0; n0 <= sze3; n0++){
736 tair[n0] = 0.0;
737 tair_filter[n0] = 0.0 ;
738 u[n0] = 0.0;
739 rhov_air[n0] = 0.0;
740 rhov_filter[n0] = 0.0;
741 co2_air[n0] = 0.0 ;
742 c13cnc[n0] = 0.0;
743 c12cnc[n0] = 0.0;
744 d13C[n0] = 0.0;
745 d13Cair[n0] = 0.0 ;
746 R13_12_air[n0] = 0.0;
747 recycle[n0] = 0.0;
748 }
749
750 for (int n1 = 0; n1 <= sze; n1++){
751 dLAIdz[n1] = 0.0;
752 ht[n1] = 0.0 ;
753 dPAIdz[n1] = 0.0;
754 Gfunc_solar[n1] = 0.0;
755 tleaf[n1] = 0.0;
756 isopreneflux[n1] = 0.0;
757 vcmax[n1] = 0.0;
758 jmax[n1] = 0.0;
759 rd[n1] = 0.0 ;
760 D13C[n1] = 0.0;
761 D13C_long[n1] = 0.0;
762 d13Cplant[n1] = 0.0;
763 Rplant_shd[n1] = 0.0;
764 Rresp[n1] = 0.0;
765 Rresp_ave[n1] = 0.0;
766 source_co2[n1] = 0.0;
767 cnt_Rresp[n1] = 0;
768 dPsdz_mg[n1] = 0.0;
769 dPsdz[n1] = 0.0 ;
770 dHdz[n1] = 0.0;
771 dLEdz[n1] = 0.0;
772 dRNdz[n1] = 0.0;
773 dRESPdz[n1] = 0.0;
774 dStomCondz[n1] = 0.0;
775 sun_frac[n1] = 0.0;
776 sun_tleaf[n1] = 0.0 ;
777 sun_A[n1] = 0.0;
778 sun_gs[n1] = 0.0;
779 sun_rs[n1] = 0.0;
780 sun_rbh[n1] = 0.0;
781 sun_rbco2[n1] = 0.0;
782 sun_cs[n1] = 0.0;
783 sun_ci[n1] = 0.0;
784 sun_cc[n1] = 0.0;
785 sun_D13[n1] = 0.0;
786 sun_D13_long[n1] = 0.0;
787 sun_ccca[n1] = 0.0;
788 sun_cica[n1] = 0.0;
789 sun_lai[n1] = 0.0;
790 sun_T_filter[n1] = 0.0;
791 sun_wc[n1] = 0.0;
792 sun_wj[n1] = 0.0;
793 sun_resp[n1] = 0.0;
794 sun_isopreneflux[n1] = 0.0;
795 iso_sun[n1] = 0.0;
796 shd_frac[n1] = 0.0;
797 shd_tleaf[n1] = 0.0 ;
798 shd_A[n1] = 0.0;
799 shd_gs[n1] = 0.0;
800 shd_rs[n1] = 0.0;
801 shd_rbh[n1] = 0.0;
802 shd_rbco2[n1] = 0.0;
803 shd_cs[n1] = 0.0;
804 shd_ci[n1] = 0.0;
805 shd_cc[n1] = 0.0;
806 shd_D13[n1] = 0.0;
807 shd_D13_long[n1] = 0.0;
808 shd_ccca[n1] = 0.0;
809 shd_cica[n1] = 0.0;
810 shd_lai[n1] = 0.0;
811 shd_T_filter[n1] = 0.0;
812 shd_wc[n1] = 0.0;
813 shd_wj[n1] = 0.0;
814 shd_resp[n1] = 0.0;
815 shd_isopreneflux[n1] = 0.0;
816 iso_shd[n1] = 0.0;
817 }
818 }
819 };
820
821 /*rg
822 struct switch_variable{ //rg: changed from double to int
823 int a;// sets soil respiration reference temperature to (1) input soil temperature or (0) modeled soil temperature at 5 cm
824 int b;//
825 int c;//
826 int d;//
827 int e;//
828 int f;//
829 int g;//
830 int h;//
831 int i;//
832 int j;//
833 } set_switch;
834 */
835
836 struct isotope_variable {
837 double delta_soil; // delta13C of soil respiration
838 double da_m_day; // slope of daytime regression deltaCa*Ca=m*Ca+b
839 double da_b_day; // intercept of daytime regression deltaCa*Ca=m*Ca+b
840 double da_m_night; // slope of nighttime regression deltaCa*Ca=m*Ca+b
841 double da_b_night; // intercept of nighttime regression deltaCa*Ca=m*Ca+b
842 };
843
844 struct input_variables input;
845 struct flux_variables flux;
846 struct time_variables time_var;
847 struct meteorology met;
848 struct surface_resistances sfc_res;
849 struct factors fact;
850 struct bole_respiration_structure bole;
851 struct canopy_architecture canopy;
852 struct non_dimensional_variables non_dim;
853 struct boundary_layer_resistances bound_layer_res;
854 struct solar_radiation_variables solar;
855 struct soil_variables soil;
856 struct profile prof;
857 struct isotope_variable Cisotope;
858 struct other_globals og;
859
860 // VARIABLES and PARAMETERS
861// sk:rm int ts,nd,ndStart,ndEnd,tsStart,tsEnd,tsMax,ny,doy;
862 bool leaf_out,leaf_full,leaf_fall,leaf_fall_complete;
863// double ts_co2_concentration,ts_airtemperature,ts_shortwaveradiance,ts_airpressure,ts_watervaporsaturationdeficit,ts_precipitation,ts_windspeed;
864// double ZONE,LAT,LONG,TAMP,temp_ny;
865 double TAU,RCMIN,VCMAX25,JMAX25,LLEAF,BFACT1,BFACT2,FSTO,
866 RCPAR1,TCPAR1,SRPAR1,RCNIR1,TCNIR1,SRNIR1,
867 RCPAR2,TCPAR2,SRPAR2,RCNIR2,TCNIR2,SRNIR2,
868 RCPAR3,TCPAR3,SRPAR3,RCNIR3,TCNIR3,SRNIR3,
869 RCPAR4,TCPAR4,SRPAR4,RCNIR4,TCNIR4,SRNIR4;
870 double ht,lai,laiPot;
871 double h_litter,clayf,bdens;
872 double fH2O;
873 double wc_sfc,wc_15cm,wc_litter,t_firstmin;
874
875 void CANOAK();
876// double *vpd_layer, double *disper);
877
878 void ROUGH
879 (double HEIGHT,double LAI,double SAI,
880 double &DISP);
881
882 void DISPER(
883 double HH,double DD);
884
885 void INPUT_DATA(
886// sk:rm int doy,int ts,int tsMax,
887 double ts_airtemperature,double ts_shortwaveradiance,double ts_watervaporsaturationdeficit,
888 double ts_windspeed,double ts_precipitation,double ts_co2_concentration,double ts_airpressure
889// double t_firstmin,double wc_15cm,double wc_litter
890 );
891
892 void SOIL_RESPIRATION();
893
894 void BOLE_RESPIRATION();
895// (double BFACT1,double BFACT2);
896
897 void ENERGY_AND_CARBON_FLUXES();
898// (double FSTO,double *vpd_layer);
899
900 void DIFFUSE_DIRECT_RADIATION();
901
902 void RNET();
903
904 void PAR();
905
906 void NIR();
907
908 double SKY_IR
909 (double a);
910
911 void IRFLUX();
912
913 void G_FUNC_DIFFUSE();
914
915 void GFUNC();
916
917 void ANGLE();
918
919 double GAMMAF
920 (double a);
921
922 void LAI_TIME();
923// (double lai);
924
925 void FREQ
926 (double a);
927
928 void STOMATA();
929
930 double TEMP_FUNC
931 (double a,double b,double c,double d, double e);
932
933 double TBOLTZ
934 (double a,double b, double c, double d);
935
936 void BOUNDARY_RESISTANCE( size_t); //(double a, double b);
937
938 void FRICTION_VELOCITY(double &metH_old);
939
940 void CONC(double *ap1, double *ap2, double c, double d, double e);
941
942 void ENERGY_BALANCE
943 (double b,double d,double e,
944 double f,double g,
945 double &apc,double &h,double &i,
946 double &j,double &vpd_leaf);
947
948 double SFC_VPD
949 (double a, double b, double c);
950
951 void SOIL_ENERGY_BALANCE();
952
953 double SOIL_SFC_RESISTANCE
954 (double a);
955
956 void ISOTOPE();
957
958 void SET_PARAMETER(
959// double TAU,double RCMIN,double VCMAX25,double JMAX25,double LLEAF,
960// double RCPAR1,double TCPAR1,double SRPAR1,
961// double RCNIR1,double TCNIR1,double SRNIR1,
962// double RCPAR2,double TCPAR2,double SRPAR2,
963// double RCNIR2,double TCNIR2,double SRNIR2,
964// double RCPAR3,double TCPAR3,double SRPAR3,
965// double RCNIR3,double TCNIR3,double SRNIR3,
966// double RCPAR4,double TCPAR4,double SRPAR4,
967// double RCNIR4,double TCNIR4,double SRNIR4,
968// int ndStart,int ndEnd,int tsStart,int tsEnd,int tsMax,int doy,
969// double LAT,double LONG,double ZONE,double TAMP
970// double temp_ny,double ht,double laiPot,
971// double h_litter,double bdens,double clayf,
972 /*double wc_15cm,double wc_litter*/);
973
974 int SOILH2O
975 (/*int tsMax, double lai*/);
976
977 int TRIDIA
978 (double &checkChange);
979
980 private:
981
982
983 lerr_t run_(
984// sk:rm SitePar &psi, /*unsigned int runWC, unsigned int runPH2,*/
985// sk:rm int ny,int nd,int ndEnd,int ts,int tsEnd,int doy,
986// sk:rm std::string const & SITEname,int ndStart,int tsStart,int tsMax,
987// sk:rm int vtMax,int flMax,int slMax,int slFloor,
988// sk:rm std::string *name_vt,
989// int ZONE, double LONG, double LAT,
990// sk:rm double TAMP,
991 double *wcMax_sl,double *wcMin_sl,double *h_sl,double *h_fl,
992// double *depth_vt,
993 double *hMax_vt,double *hMin_vt,double *clay_sl,
994 double *dens_sl,double *poro_sl,double *stonef_sl,double *fcOrg_sl,
995// double temp_ny, double ts_co2_concentration, double ts_airpressure,
996 double ts_airtemperature,
997 //double ts_shortwaveradiance,
998 double ts_watervaporsaturationdeficit, double ts_windspeed,
999// double ts_precipitation,
1000 double *lai_vt,double *lai_fl,double *dvsFlush_vt,double *dvsMort_vt,
1001 double *f_vt,double *laiPot_vt,double **fFrt_vtsl,
1002 double *ts_co2_concentration_fl,double *fH2O_vt,double *wc_sl,
1003 double &albedo,double &rad_a,double &vpd_a,double *temp_fl,
1004 double *rad_fl,double *vpd_fl,double *win_fl,double *tempOld_fl,
1005 double *tFol_fl,double *ts_sunlitfoliagefraction_fl,double *parshd_fl,double *parsun_fl,
1006 double &temp_a,double &temp_l,double *temp_sl
1007// sk:rm double *disper
1008 );
1009
1010
1011 int Time_sec(); // time routine
1012
1013 void PHOTOSYNTHESIS
1014 (int JJ,double zzz,/*double FSTO,*/double Iphoton,
1015 double cca,double tlk,double leleaf,
1016 double &rstom,double &A_mg,double &rd,double &ci,
1017 double &cs,double &wj,double &wc);
1018
1019 double DW2DZ
1020 (double Z,double HH,double ustar, double sigma_zo);
1021
1022 double RAN0
1023 (long *a);
1024
1025 double SIGMA
1026 (double Z,double HH,double sigma_zo,double sigma_h,double ustar);
1027
1028 double TL
1029 (double Z,double HH,double DD,double sigma_zo,double sigma_h,double ustar);
1030
1031 double RANDGEN
1032 (double low,double delta,
1033 long &seed);
1034
1035 double UZ
1036 (double a);
1037};
1038
1039
1040#endif // M1D_MOD_MICROCLIMATE_CANOAK_H
1041
Spatially explicit groundwater model.
Definition: airchemistryput.h:15