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