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